I am trying to change the syntax tree and then update the semantic model. Here is what I still have:
var tree = Roslyn.Compilers.CSharp.SyntaxTree.ParseCompilationUnit(code); var compilation = Roslyn.Compilers.CSharp.Compilation.Create( "MyCompilation", syntaxTrees: new[] { tree }, references: new[] { mscorlib }); var semanticModel = compilation.GetSemanticModel(tree); ... var oldStatementNode = (parent as ExpressionStatementSyntax);
If I try to call semanticModel = compilation.GetSemanticModel(tree); or even make a new compilation with tree before calling GetTypeInfo() - the same exception.
So how do I get the SemanticModel update? (Of course, I could get a modified source and do everything from the very beginning, but I think there is a more efficient way).
I'm missing something obvious here, I'm sure maybe a new syntax tree has appeared somewhere?
ren
source share