TWT
TWT

Reputation: 2571

Roslyn - CSharpCompilation to CSharpCompilation reference

I want to include an already existing CSharpCompilation object into a new CSharpCompilation object. Similar to project-to-project references in c#. My current solution is to include the syntax trees of the first compilation in the new compilation, but that gives problems when I need to compare Symbols in both compilations (they are not the same). MetadataReference.CreateFrom...(), doesn't contain an overload for Compilation. Is this possible somehow?

Upvotes: 3

Views: 695

Answers (2)

SLaks
SLaks

Reputation: 887469

You need to put both Compilations' Projects in the same Solution, then add a ProjectReference.

Upvotes: 0

svick
svick

Reputation: 244837

I believe you're looking for the CompilationReference type, which can be created by calling CSharpCompilation.ToMetadataReference().

Upvotes: 3

Related Questions