-
Notifications
You must be signed in to change notification settings - Fork 468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AD0001: Analyzer 'Microsoft.NetCore.Analyzers.Security.UseAutoValidateAntiforgeryToken' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null.' #4772
Comments
@notnotchris Thanks for the detailed repro steps. The issue happens when the filter used doesn't directly contain "OnAuthorizationAsync" method. The problematic part of the analyzer implementation is the following: Lines 196 to 207 in 3fb8781
The call to FirstOrDefault will return null, which is passed as the key to Note: The fix should consider a scenario where the abstract filter has a |
Tagging @dotpaul |
Thanks @notnotchris and @Youssef1313! I will work on a fix. |
@dotpaul when will your fix be released? Is it available in the latest preview release? |
Analyser
AD0001:
Analyzer 'Microsoft.NetCore.Analyzers.Security.UseAutoValidateAntiforgeryToken' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null.'
Analyser source
SDK: Built-in CA analysers in .NET 5 SDK or later
Version: SDK 5.0.102
Describe the bug
An
ArgumentNullException
occurs, causing anAD0001
warning, when building a project that registers an asynchronous authorization filter (implementsIAsyncAuthorizationFilter
) that derives from an abstract class and all rules are enabled by default (<AnalysisMode>AllEnabledByDefault</AnalysisMode>
in the project file).Steps to Reproduce
AddControllers
.Expected behaviour
Either the project builds successfully without warnings, or the relevant code analysis warning is displayed.
Actual behaviour
An
AD0001
warning is generated.Additional context
Adding the latest NuGet package version (5.0.3) of the analysers makes no difference. The
AD0001
warning is still generated.The
AD0001
warning does not occur when all rules are not enabled by default (i.e.<AnalysisMode>AllEnabledByDefault</AnalysisMode>
is omitted from the project file).A minimum repro is available here.
The text was updated successfully, but these errors were encountered: