Roslyn: Using Code fixes outside of Visual Studio using CodeFixProvider

Created on 8 Aug 2016  路  2Comments  路  Source: dotnet/roslyn

Question:
Hi guys!
Is there way to use code fixes on cs files using for example StyleCop analyzers
for fixing list of cs files in console application with provided path and extension of file(.cs | .vb) ?
Thanks for answer.

Area-IDE Question Resolution-Answered

All 2 comments

You can find the best example by creating a new solution with the analyzer + code fix template and looking at the test project. This contains all this stuff to apply analyzers and code fixes to a given source text, you just have to extract it a bit to your own console app.

I have written a small summary in this answer on SO: http://stackoverflow.com/questions/30384868/how-can-i-unit-test-roslyn-diagnostics

You can also find a small example here (which is restricted to analyzing but can be easily extended with code fixes): https://github.com/VSDiagnostics/VSDiagnostics/blob/8ee489b7e80b68f23864924cd369c0e10e05754a/VSDiagnostics/VSDiagnostics.Console/Program.cs

Thanks @Vannevelj!

@Artur2 - let us know if you have further questions.

Was this page helpful?
0 / 5 - 0 ratings