C# - Identify variable usage in source code
<p>I'm currently looking for a library that can find parts of code where variables are used and replace them with some other code.</p>

<p>For example in this code:</p>

<pre><code>int foo = 0;
int a = foo * 5;
</code></pre>

<p>the library could identify foo so that I could replace it with this:</p>

<pre><code>int foo = 0;
int a = DoSomething(foo) * 5;
</code></pre>

<p>Does anything similar exist?</p>

<p>Thank you in advance.</p>

<p>EDIT: I forgot to say that I don't know the name of these variables. I have to identify them as such and then replace the code. For example, I need to find out if <em>foo</em> is a variable and not a method/comment/anything else and then replace it.</p>