Jump to content

Roslynator Command Line

Posted on:November 20, 2018 at 01:00 AM

In one of my previous posts i’ve introduced Roslynator

Today I will show you how to automatically fix code issues with Roslynator. There is a NuGet package

First, ensure that following NuGet packages are installed in your solution.

Then download Roslynator.CommandLine NuGet package and extract the content of tools\net461\ in to a separate location. I have just created a subfolder called Roslynator in the source directory.

The sample code looks like following. It is a standard Program.cs file automatically generated by Visual Studio (from the predefined template).

Magic

Here is where the magic happens. The result of the command is displayed below.


Roslynator.exe fix ..\Gmtl.Research.Roslynator.sln 

As we can see Rosylnator has found and fixed 3 issues in total.

The fixed class (Program.cs) now looks like so:

Summary

The command line extension for Roslynator makes it even more powerful. Including that in CI/CD pipeline will definitely improve code quality.