Example: Microsoft.CodeAnalysis.FxCopAnalyzers
Example: v2.9.1
AD0001 Analyzer 'Microsoft.NetCore.Analyzers.Security.SetViewStateUserKey' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'
There were no AD0001 errors with 2.9.0
Upgraded to 2.9.1 and errors started appearing
Reverted back to 2.9.0 and it stopped.
I expect no error, or some explanation for what I need to change in my code or project settings to avoid it.
AD0001 Analyzer 'Microsoft.NetCore.Analyzers.Security.SetViewStateUserKey' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'
Tagging @dotpaul
@lorenh do you have a repro project?
@genlu this seems like a new security rule that was added just after 2.9.0 release. We probably need to test the 2.9.1 packages against some real world projects to identify if this AD0001 is widespread for us to need to release 2.9.2 with a fix for this issue.
I was afraid you'd ask for a repro project :-) I don't have one whittled down to bare minimum at present that I can share, but I'll put it on my to-do list. Perhaps I can isolate just the offending parts, I have a suspicion I know what portion of the source in this one project it might be.
@lorenh if you are unable to create a small repro, can you please provide the exception call stack with following steps:
I might have a fix with #2261. If it's not too much trouble, it would be good to confirm if it's the same issue.
@genlu @dotpaul can we point @lorenh to the myget package with the fix to verify it fixes his AD0001?
@lorenh if you chance, would you mind trying out https://dotnet.myget.org/feed/roslyn-analyzers/package/nuget/Microsoft.CodeAnalysis.FxCopAnalyzers/2.9.1-beta2.19180.1+1c0148f2 and seeing if that fixes the issue for you?
If you don't have time, no worries!
@dotpaul: I had the same issue as @lorenh, and I can confirm that the beta build fixes it.
Sorry for delay, just had a chance to try it, and the updated version fixes the issue on our code base.
@lorenh and @jmosbech, thank you both!
I encounter same issue. Is any update on the fix?
We will be releasing the fix very soon. Thanks!
This seems to be solved in latest 2.9.2, suggest to close.
Yes, that is correct. Closing...