VS2010 extension for formatting C# code
I want to create a Visual Studio Extension. That extension, whenever ran by the user will primarily format/indent C# code in a defined manner. For example
private void Method(int a, int b)
{
}
will be converted to something like
private void Method
(
int a,
int b
)
{
}
At this point I have no experience or idea about the APIs that I can use for this kind of task. I would like to kn开发者_运维知识库ow if there are any APIs that MS provides for parsing C# code in a .cs file or any third party APIs? or any general APIs that can help me in achieving this kind of thing.
You could use the CodeElement interface (have a look at this example: HOWTO: Navigate the code elements of a file from a Visual Studio .NET macro or add-in). With that you will be able to get information about methods, for example, but I do not know if that allows you to go beyond that level.
If that's not enough for you, Irony comes with a C# grammar in the examples.
精彩评论