Last active
October 19, 2015 17:52
-
-
Save JoshVarty/52a7699f4d4ce4099c2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tree = CSharpSyntaxTree.ParseText(@" | |
public class MyClass | |
{ | |
int MyMethod() { return 0; } | |
}"); | |
var Mscorlib = MetadataReference.CreateFromFile(typeof(object).Assembly.Location); | |
var compilation = CSharpCompilation.Create("MyCompilation", | |
syntaxTrees: new[] { tree }, references: new[] { Mscorlib }); | |
//Note that we must specify the tree for which we want the model. | |
//Each tree has its own semantic model | |
var model = compilation.GetSemanticModel(tree); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment