in my current project, we have a couple of code generator routines to help us through some mindless tasks. Everything works fine from the technical point of view, so that might be more a curiosity than a real issue: when I open a newly generated piece of code, it is (of course) not properly indented (although syntactically correct).
Now, the question: is there an API somewhere that can be used to indent a piece of c# code? Much like what happens when I use the shortcut Ctrl+E,D in VS2010.
Thanks!
Just to clarify, I am looking for a function like that:
string GetProperlyFormattedCode(string notFormattedCode);
where notFormattedCode
is a piece of valid c# source code, and the output of the function is the same code after application of formatting rules. In other words, I am looking for the function that lies behind the "Edit -> Advanced -> Format selection" command of Visual Studio.