Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider saving DLLs with Mono.Cecil #25

Open
michaelkruglos opened this issue Aug 22, 2020 · 3 comments
Open

Consider saving DLLs with Mono.Cecil #25

michaelkruglos opened this issue Aug 22, 2020 · 3 comments

Comments

@michaelkruglos
Copy link

Have you considered Mono.Cecil for assembly generation? It can write DLLs, which can later be used with .net core. If you copy the <appname>.runtimeconfig.json from any existing .net core app as <dllname>.runtimeconfig.json, you can run that dll with dotnet <dllname>.dll. There's no point in waiting for Microsoft to implement it. They mentioned it not being a must have for NET 5. In the mean-time Mono.Cecil does an excellent job and comes with the ability to optimize methods.

Examples:

@RyanLamansky
Copy link
Owner

I won't personally do it but I'm planning to add extension points to the compilation process to enable this scenario. There's definitely interest, and I suspect someone might take this on.

My most pressing concern right now is to be able to compile complex real-world WASMs--being able to write DLLs is of no help to anyone if they don't work.

@kekekeks
Copy link

Note that Mono.Cecil has several huge API differences, especially when it comes to resolving .NET Types. In XamlX compiler we have some kind of an abstraction for SRE and Mono.Cecil APIs that allows to access .NET type system and emit MSIL in a unified way, a full example that a emits a class can be found here.

It also comes with a sanity checking IL emitter proxy that checks basic things like stack balance at label instructions, unmarked labels, etc.

It's possible to extract said abstraction to a separate library if that would help.

@yself
Copy link

yself commented Nov 6, 2020

I have done some experiments with saving the generated assembly using Lokad.ILPack which does some magic to save the System.Reflection.Emit assemblies even on .NET Core, where the feature is directly missing. Should be as simple as follwing, but definitely needs more testing.

var gen = new Lokad.ILPack.AssemblyGenerator();
gen.GenerateAssembly(module.Assembly, "generated.dll");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants