AssemblyNameReference class does not exist, what is the replacement?

I test the Roslyn API using the Getting Started: Semantic Analysis walkthrough. There is a part that tries to add a compilation link:

var compilation = Compilation.Create("HelloWorld") .AddReferences(new AssemblyNameReference("mscorlib")) .AddSyntaxTrees(tree); 

But it looks like the API has changed and "AssemblyNameReference" no longer exists. Or it may be the wrong document, because the name "AddReferences" says that it needs some kind of IEnumerable.

By the way, I'm looking for the right implementation to check it out!

+4
source share
1 answer

The Semantic Analysis (CSharp) prospectus, published in September 2012, contains this code:

 var compilation = Compilation.Create("HelloWorld") .AddReferences(MetadataReference.CreateAssemblyReference("mscorlib")) .AddSyntaxTrees(tree); 

You are probably viewing the walkthrough version from an earlier CTP. Try using static factory methods in the MetadataReference.

+5
source

Source: https://habr.com/ru/post/1447418/


All Articles