mehrandvd
mehrandvd

Reputation: 9116

AssemblyNameReference class does not exist, what is the replacement?

I'm checking the Roslyn API using 'Getting Started: Semantic Analysis' walkthrough. There's a part in it which tries to add a reference to the compilation:

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

But it seems the API is changed and the 'AssemblyNameReference' does not exist anymore. Or may the document is wrong, because naming of 'AddReferences' tells that it needs some sort of IEnumerable.

BTW, I'm looking for the correct implementation so I could test it!

Upvotes: 3

Views: 448

Answers (1)

Kirill Osenkov
Kirill Osenkov

Reputation: 8986

The September 2012 version of the Semantic Analysis (CSharp) walkthrough contains this code:

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

You are probably looking at a version of the walkthrough from an earlier CTP. Try using static factory methods on MetadataReference.

Upvotes: 5

Related Questions