WORKAROUND: AD0001 Analyzer Microsoft.AspNetCore.Mvc.Analyzers.TopLevelParameterNameAnalyzer threw an exception
Summary
This is just a quick blog post to show a workaround to https://github.com/dotnet/aspnetcore/issues/14723 (couldnt comment there because the msftbot locked the issue as resolved and limited the conversation to collaborators). Im currently building a .NET 5 WebAPI project, that references Application Insights between other dependencies, causing that when building the project Im getting a lot errors like the one below: CSC : warning AD0001: Analyzer Microsoft.AspNetCore.Mvc.Analyzers.TopLevelParameterNameAnalyzer threw an exception of type System.NullReferenceException with message Object reference not set to an instance of an object.. As described in the GitHub thread, the cause is because we are mixing dependencies of 5.0 and 2.2 core versions. The proposed workaround in the thread is to completely disable the Code Analysis, but I wanted to find a less dramatic approach. But surprise, when testing disabling the rules, seems that the one causing the "TopLevelParameterNameAnalyzer" exception was the MVC1004. {cs,vb}] section, add the rule "dotnet_diagnostic.MVC1004.severity = none" to disable this rule, and save the file • Build the project and voilà, problem solved!