I'm currently designing a CLR-compatible programming language. I wrote the parser in ANTLR and would now like to build a .NET assembly out of the code. Currently I use AssemblyBuilder
and co. to generate classes, methods and the assembly itself. Now I want to output the method body (statements, loops, conditionals,...). Is directly emitting IL using ILGenerator
the best/only way, or are there better or easier alternatives?
Also, I first wanted to use .NET 5 for the project, but the AssemblyBuilder.Save
method is not supported in .NET Core yet. Because of that, I had to restart with .NET Framwework 4.8, which does not support the latest language features. Furthermore, I'd like for the output assembly to be .NET 5/6 too. Is there another way, do save a dynamic assembly to the disk in .NET 5?