Skip to content

The custom Roslyn analyzer provides warning messages for blocks of code with variable assignments, which doesn't have blank lines before and after itself.

License

Notifications You must be signed in to change notification settings

kulikov-dev/BlankLineAssignmentsAnalyzer

Repository files navigation

BlankLineAssignmentsAnalizer

I ran into a problem that the organization introduced a rule to separate variable assignment blocks with blank lines. It's a nightmare to fix it by hand, so after short analysis I found out:

  • ReSharper does not contain such kind of a rule and it is not possible to create it;
  • StyleCop allows to write your own analyzer, but it is not supported in VisualStudio 2022.

As a solution, I wrote a small plug-in for Visual Studio 2022 that implements the check of this rule via built-in Roslyn analyzer (.NET Compiler Platofrm). The plugin highlights sections of code that don't match the rule and allows to auto-fix them (CodeFix).

Example:

//// Wrong
CallFirstFunc();
var a = "a";
var b = 2;
CallSomeFunc();
//// Correct
CallFirstFunc();

var a = "a";
var b = 2;

CallSomeFunc();

About

The custom Roslyn analyzer provides warning messages for blocks of code with variable assignments, which doesn't have blank lines before and after itself.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published