5

From many examples of compiling a Roslyn SyntaxTree, I have seen code such as:

[... create tree and compilation ...]
var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("foo"), AssemblyBuilderAccess.RunAndCollect);
var module = assembly.DefineDynamicModule("foo");

var result = compilation.Emit(module);

But when I try to do this in the current Roslyn released with Visual Studio 2015 RC, I see no Emit() which takes a module. I need to write to a stream and load it into a regular AppDomain-locked Assembly.

I then see this answer from Tomas Matousek: https://stackoverflow.com/a/22977158

Where he says that this has been removed because it was "problematic".

I am having difficulty finding any other information about this on the Internet. Does anyone know if:

  • There is another way in Roslyn to compile into an assembly that can be garbage collected?
  • Or this will be supported in the final release of VS / Roslyn?
  • Where I should direct this question if nobody here knows (had trouble finding an official, active Roslyn forum)?
Community
  • 1
  • 1
Stmated
  • 477
  • 5
  • 17
  • 2
    The official, active Roslyn site [is on github](https://github.com/dotnet/roslyn). If you want to start a discussion about something, create an issue. – svick May 09 '15 at 17:26
  • 1
    It's not possible within Roslyn until the CLR supports collectible assemblies. You can vote for them here: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6120992-support-for-collectible-assemblies On GitHub: https://github.com/dotnet/coreclr/issues/552 – JoshVarty May 10 '15 at 06:17

1 Answers1

0

As svick and JoshVarty said in the comments, this is currently not possible. I also created an issue (https://github.com/dotnet/roslyn/issues/2621) for this that might or might not end up with some more information from the Microsoft team.

Stmated
  • 477
  • 5
  • 17