Testura/Testura.Code

Compile to (Memory)Stream

Opened this issue · 1 comments

Hi,

As a developer that writes dynamic code, I need to compile code which I have to use at runtime immediately. Saving it to first to file and then load the assembly file could be a solution, but this will not work on Blazor (.NET running on WebAssembly in the webbrowser).

I would like to be able to write the assembly to a MemoryStream which I can then load using the Assembly.Load(byte[] rawAssembly) overload.

Currently adding save to Stream functionality to Compiler.cs. If you think this might be useful too I can submit a PR so you can take a look at the code.

Sounds like a good idea. We have CompileSourceInMemoryAsync in Compiler.cs but it will only return success or failure (with errors). Maybe you can create a new method or improve on that one so you get the actual assembly too?