'.NET Core: Generating debuggable assembly from text files in runtime
Using the TickSpec project (https://github.com/fsprojects/TickSpec), it is possible to execute tests written in gherkin. The gherkin is written in a text file and during runtime the file is loaded and individual rows are mapped to method calls. Using .NET framework the project supports placing breakpoints in the gherkin file. It is implemented using System.Reflection.Emit where the ability for the breakpoints (and to have steps in callstack) are added using MarkSequencePoint method.
In .NET core the System.Reflection.Emit is limited and several methods are missing. I have found that for example the MarkSequencePoint method is available in the compiler services. However, I have not found a way how it can be used to emit a dynamic method.
What is the proper way to do such task in netstandard library? I do not necessarily need to emit everything, I need any way how to enable the breakpoints and to have the steps visible in the callstack.
Solution 1:[1]
MarkSequencePoint for System.Reflection.Emit is still not implemented in .NET 6.0. F# fsi is facing the same issue, they have the ticket https://github.com/dotnet/fsharp/issues/5457. Nevertheless, they found a way how to solve the issue, see the pull request https://github.com/dotnet/fsharp/pull/12722, the same solution uses C# Interactive.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Michal Ková? |
