Top 10 Static Code Quality Analysers for ASP.NET Core

Bharat Dwarkani
2 min readAug 8, 2019

--

Static Analysers are great to enforce code quality and style guides in projects. Most analyzers just provide option to fix on click automatically.

Sample project with Analyzers included along with Cake Build Script can be found in GitHub

FXCopAnalyzers

Created by Microsoft, a set of analyzers, called Microsoft.CodeAnalysis.FxCopAnalyzers, that contains the most important “FxCop” rules from static code analysis, converted to Roslyn analyzers. These analyzers check your code for security, performance, and design issues, among others.

You can install these FxCop analyzers either as a NuGet package or as a VSIX extension to Visual Studio.

https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers

StyleCopAnalyzers

An implementation of StyleCop rules using the .NET Compiler Platform. It helps in enforcing standard style for code.

https://www.nuget.org/packages/StyleCop.Analyzers/

Security Code Scan

Detects various security vulnerability patterns: SQL Injection, Cross-Site Scripting (XSS), Cross-Site Request Forgery (CSRF), XML eXternal Entity Injection (XXE), etc.

https://security-code-scan.github.io/

Roslynator 2019

A collection of 500+ analyzers, refactorings, and fixes for C#, powered by Roslyn.
https://github.com/JosefPihrt/Roslynator

AsyncFixer

AsyncFixer helps developers in finding and correcting common async/await misuses (anti-patterns). AsyncFixer was tested with hundreds of open-source C# apps and successfully handles many corner cases. Here are anti-patterns that AsyncFixer can detect:

Nugget — https://www.nuget.org/packages/AsyncFixer

https://marketplace.visualstudio.com/items?itemName=SemihOkur.AsyncFixer

Web API analyzers

ASP.NET Core 2.2 and later includes the Microsoft.AspNetCore.Mvc.Api.Analyzers NuGet package containing analyzers for web APIs.

https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Api.Analyzers

SonarAnalyzer

Analyzers which spot bugs and code smells in your code.

https://www.sonarqube.org/
https://www.nuget.org/packages/SonarAnalyzer.CSharp

NSubstitute.Analyzers.CSharp

Provides diagnostic analyzers to warn about incorrect usage of NSubstitute in C#.

https://www.nuget.org/packages/NSubstitute.Analyzers.CSharp

xUnit.net [Code Analyzers]

Code Analyzers for projects using xUnit.net that help finds and fix frequent issues when writing tests.

https://www.nuget.org/packages/xunit.analyzers

Microsoft.CodeQuality.Analyzers

CodeQuality Analyzers

https://www.nuget.org/packages/Microsoft.CodeQuality.Analyzers

Microsoft.CodeAnalysis.VersionCheckAnalyzer

Microsoft.CodeAnalysis Version Check Analyzer
https://www.nuget.org/packages/Microsoft.CodeAnalysis.VersionCheckAnalyzer

Few more analyzers https://github.com/dotnet/roslyn-analyzers

If you are interested in more resources related to ASP.NET Core check out my site https://sharetechlinks.com/

--

--

Bharat Dwarkani

Tech Enthusiast, Full Stack Software Engineer, Product Manager, Engineering Enterprise SaaS product