Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

How to update resolver's context?

$
0
0

I need to add variable declaration to using statement. Example:

using (new StringWriter())  --->  using (StringWriter s = new StringWriter())

I writed next code:

AstType type = new SimpleType("StringWriter");
VariableDeclarationStatement variable =
    new VariableDeclarationStatement(type, "s", usingStatement.ResourceAcquisition.Clone() as Expression);
usingStatement.ResourceAcquisition.ReplaceWith(variable);

But I can't resolve new node, because I got assertion in this line:

ResolveVisitor.cs:244

Debug.Assert(oldResolver.LocalVariables.SequenceEqual(resolver.LocalVariables));

Code to resolve:

ResolveResult result = Context.mResolver.Resolve(variable);

What can I do?


Viewing all articles
Browse latest Browse all 1764

Trending Articles