Skip to content

Custom Roslyn Analyzers which NIX team uses to enforce coding standards

License

Notifications You must be signed in to change notification settings

nixsolutions/nix-net-analyzers

Repository files navigation

🔍 NIX .NET Analyzers · image image image image

Custom Roslyn Analyzers which NIX team uses to enforce coding standards

📚 Description

By default - NIX Team uses StyleCop Analyzers for code quality and code style checks. The goal is to define standard approach which all projects will use.

Decision to changes those rules is up to project Tech Lead.

Applicable for: .NET 5 and higher. Partially can work for .NET 3.1.

NIX Team StyleCops comes with NuGet Package:
image
The package has a dependency on StyleCop.Analyzers (1.1.118) so it will be automatically installed.

✅ Installation

  • Install NuGet Package to every project in solution
  • If you don't have .editorconfig yet, the installation will automatically add the .editorconfig template file to the .sln folder. Or you can do it manually: you can find file in the repository by this path nuget/NIX.Analyzers/assets/config/.editorconfig
    Now your project is using the rules described in the file. All warnings from .Net Analyzers (CAxxxx, CSxxxx) except CA1058, CA1062 marked as Messages.
    You can find more information about StyleCop (SAxxxx/SXxxxx) rules here.

⚙ Settings

NIX Team has few custom code rules to ensure better software quality and following clean code practices.

Custom rules:

  1. Line must not be longer than 200 characters;
  2. Method must not be larger than 50 lines;
  3. File must not be larger than 1000 lines;
  4. Method must not have more than 5 parameters;
  5. Constructor must not have more than 5 parameters;

To override these rules you must use .editorconfig and specify which rule you want to override: dotnet_diagnostic.Nix01.max_line_length = 200
dotnet_diagnostic.Nix02.max_method_lines = 50
dotnet_diagnostic.Nix03.max_file_lines = 1000
dotnet_diagnostic.Nix04.max_params_in_method = 5
dotnet_diagnostic.Nix05.max_params_in_ctor = 5

P.S. Unfortunately, Rider doesn't support PowerShell scripts on NuGet installation, so you should add .editorconfig manually.
You can find the file in the repository by this path nuget/NIX.Analyzers/assets/config/.editorconfig

About

Custom Roslyn Analyzers which NIX team uses to enforce coding standards

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •