I use the CSharpCompilation class to compile SyntaxTree , where the root is the class declaration. I pass the constructor a CSharpCompilationOptions object that contains my using statements.
My understanding is that the syntax tree will be compiled using the context of any use of the statements that I pass. However, when I try to access the class that is defined in one of the "applications", I go to the options object, I get an error message that does not exist in the current context.
I am clearly doing something wrong. Does anyone know what a message list is for when it moved to the CSharpCompilationOptions class?
This is the code:
public static void TestMethod() { string source = @"public class Test { public static void TestMethod() { string str = Directory.GetCurrentDirectory(); } }"; SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(source); List<string> usings = new List<string>() { "System.IO", "System" }; List<MetadataFileReference> references = new List<MetadataFileReference>() { new MetadataFileReference(typeof(object).Assembly.Location), };
c # roslyn
user2697817
source share