https://github.com/kulikov-dev/blanklineassignmentsanalyzer
The custom Roslyn analyzer provides warning messages for blocks of code with variable assignments, which doesn't have blank lines before and after itself.
https://github.com/kulikov-dev/blanklineassignmentsanalyzer
code-analysis-tool code-fix diagnostic-analyzer plugin roslyn roslyn-analyzer vs-2022
Last synced: 6 months ago
JSON representation
The custom Roslyn analyzer provides warning messages for blocks of code with variable assignments, which doesn't have blank lines before and after itself.
- Host: GitHub
- URL: https://github.com/kulikov-dev/blanklineassignmentsanalyzer
- Owner: kulikov-dev
- License: mit
- Created: 2022-08-24T12:55:10.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-25T12:48:01.000Z (about 3 years ago)
- Last Synced: 2025-04-01T14:22:10.548Z (6 months ago)
- Topics: code-analysis-tool, code-fix, diagnostic-analyzer, plugin, roslyn, roslyn-analyzer, vs-2022
- Language: C#
- Homepage:
- Size: 45.9 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### 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:
``` csharp
//// Wrong
CallFirstFunc();
var a = "a";
var b = 2;
CallSomeFunc();
```
``` csharp
//// Correct
CallFirstFunc();var a = "a";
var b = 2;
CallSomeFunc();
```