VS2010 extension for C # code formatting

I want to create a Visual Studio extension. This extension, when it is launched by the user, will basically format / indent C # code in a certain way. for instance

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 API that I can use for this kind of task. I would like to know if there are any APIs that MS provides for parsing C # code in a .cs file or any third-party APIs? or any common APIs that can help me achieve this kind of thing.

+4
source share
1 answer

You can use the CodeElement interface (look at this example: HOWTO: moving file code elements from a Visual Studio.NET macro or add-in ). With this, you can get information about methods, for example, but I don’t know if it allows you to go beyond this level.

If this is not enough for you, Irony contains C # grammar in the examples.

+2
source

Source: https://habr.com/ru/post/1344465/


All Articles