简体   繁体   中英

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?

我相信您正在寻找CompilationReference类型,它可以通过调用CSharpCompilation.ToMetadataReference()创建。

您需要将两个CompilationProject放在同一个Solution ,然后添加一个ProjectReference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM