Improve AspNetMvcHelper.ReferencesControllers method: add parameter for .NET Core #9251
Labels
Area: C#
C# rules related issues.
Sprint: Hardening
Fix FPs/FNs/improvements
Type: Improvement
Making existing code better.
Projects
Milestone
Currently the AspNetMvcHelper.ReferencesController() method returns true if the analyzed project references ASP.NET MVC Core or ASP.NET MVC (.NET Framework).
Several rules misuse this method to check whether the analyzer should be registered for the given project.
e.g.
AnnotateApiActionsWithHttpVerb
is only implemented for ASP.NET Core, but it uses this method to check if the analyzer should be used on the project or not. If the project uses ASP.NET MVC controllers under the old .NET Framework then it will still (needlessly) analyze it, but it won't report anything, because the rule only works with types from ASP.NET Core.TODO
Add a
bool
parameter to the method:ReferencesController(bool onlyAspNetCore)
. When set totrue
it will only returntrue
if the project references ASP.NET Core MVC Controllers. When the parameter is set tofalse
, it will returntrue
if the project references either ASP.NET Core MVC Controller or the classical .NET Framework MVC Controllers.Then update all ASP.NET rules to use it correctly: if the rule is only implemented for ASP.NET Core then call
ReferencesController(onlyAspNetCore: true)
The text was updated successfully, but these errors were encountered: