Quantcast
Channel: Microsoft "Roslyn" CTP forum
Viewing all articles
Browse latest Browse all 504

How does ReplaceNodes work?

$
0
0

How does ReplaceNodes() method stores results of replacements? That is, I have two nested block statements:

// block #1
{
    // block #2
    {

    }
}

I store them in variables block1 and block2. Now I execute ReplaceNodes method:

root = root.ReplaceNodes(new SyntaxNode[] { block1, block2 },
(n, ne) =>
{
    return Syntax.Block();
});

How is it possible, that even that block2 (the nested one) gets visited and is replaced, and then its parent node (untouched!!) is visited and is replaced as well, only the second replacement really takes effect on new root node? If the statements were not nested one in each other, then both changes would take effect. I am wondering where is the first replacement stored and how is it lost? I know I am overriding the block1 with empty block (so the block2 is out), but what happens with the temporary tree with block2 replaced?


Viewing all articles
Browse latest Browse all 504

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>