Yes, this is achievable, but this is quite a big work. Reflection won't help much, because it works with compiled assemblies or assemblies created during runtime, but refactoring has to work with source code.
Is there available classes? It actually depends on available compilers. There are some provisions, but they are not implemented in any of the compilers I knew so far. Here is the idea: the abstract class
System.CodeDom.Compiler.CodeDomProvider
has the method
Parse
which could generate a CodeDOM tree instead of compilation. Please see:
http://msdn.microsoft.com/en-us/library/system.codedom.compiler.codedomprovider.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.codedom.compiler.codedomprovider.parse.aspx[
^].
It would be a great help. Unfortunately, in all the implementations I knew so far, this method is not supported (throws "not implemented" exception). So, it looks like you don't have anything close from .NET FCL.
Of course, you can try to find some 3
rd-party products, but this is a different story.
—SA