Open davkean opened 5 years ago
Seems to be a Roslyn bug - the analyzer is invoking a public API, which seems to cause an NRE deep inside Microsoft.CodeAnalysis.CSharp.Symbols.MemberSignatureComparer.HaveSameReturnTypes
Tagging @jmarolf , who also seemed to have hit this previously. Jon, did you file a Roslyn bug for it?
Ran into this again, this time SetMap:
Severity Code Description Project File Line Category Suppression State Detail Description
Error AD0001 Analyzer 'Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines.PropertiesShouldNotBeWriteOnlyAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. Microsoft.VisualStudio.ProjectSystem.Managed.VS 1 Compiler Active Analyzer 'Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines.PropertiesShouldNotBeWriteOnlyAnalyzer' threw the following exception:
'Exception occurred with following context:
Compilation: Microsoft.VisualStudio.ProjectSystem.Managed.VS
ISymbol: SetMap (Property)
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.CodeAnalysis.CSharp.Symbols.MemberSignatureComparer.HaveSameReturnTypes(Symbol member1, TypeMap typeMap1, Symbol member2, TypeMap typeMap2, TypeCompareKind typeComparison)
at Microsoft.CodeAnalysis.CSharp.Symbols.MemberSignatureComparer.Equals(Symbol member1, Symbol member2)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.IsInterfaceMemberImplementation(Symbol candidateMember, Symbol interfaceMember, Boolean implementingTypeIsFromSomeCompilation)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.FindPotentialImplicitImplementationMemberDeclaredInType(Symbol interfaceMember, Boolean implementingTypeIsFromSomeCompilation, TypeSymbol currType, Symbol& implicitImpl, Symbol& closeMismatch)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.ComputeImplementationForInterfaceMember(Symbol interfaceMember, TypeSymbol implementingType, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.ComputeImplementationAndDiagnosticsForInterfaceMember(Symbol interfaceMember)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.FindImplementationForInterfaceMemberWithDiagnostics(Symbol interfaceMember)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.FindImplementationForInterfaceMember(Symbol interfaceMember)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.Microsoft.CodeAnalysis.ITypeSymbol.FindImplementationForInterfaceMember(ISymbol interfaceMember)
at Analyzer.Utilities.Extensions.ISymbolExtensions.IsImplementationOfAnyImplicitInterfaceMember[TSymbol](ISymbol symbol)
at Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines.PropertiesShouldNotBeWriteOnlyAnalyzer.AnalyzeSymbol(SymbolAnalysisContext context)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.<ExecuteSymbolActionsCore>b__40_1(ValueTuple`2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
This needs to be ported to Roslyn repo. @jinujoseph do you have permissions to port issues from here to that repo?
Done.
I hit this today while dogfooding:
Severity Code Description Project File Line Suppression State Detail Description
Error AD0001 Analyzer 'Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines.CancellationTokenParametersMustComeLastAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. Microsoft.CodeAnalysis.CSharp.Workspaces 1 Active Analyzer 'Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines.CancellationTokenParametersMustComeLastAnalyzer' threw the following exception:
'Exception occurred with following context:
Compilation: Microsoft.CodeAnalysis.CSharp.Workspaces
ISymbol: .ctor (Method)
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.CodeAnalysis.CSharp.Symbols.MemberSignatureComparer.HaveSameReturnTypes(Symbol member1, TypeMap typeMap1, Symbol member2, TypeMap typeMap2, TypeCompareKind typeComparison)
at Microsoft.CodeAnalysis.CSharp.Symbols.MemberSignatureComparer.Equals(Symbol member1, Symbol member2)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.IsInterfaceMemberImplementation(Symbol candidateMember, Symbol interfaceMember, Boolean implementingTypeIsFromSomeCompilation)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.FindPotentialImplicitImplementationMemberDeclaredInType(Symbol interfaceMember, Boolean implementingTypeIsFromSomeCompilation, TypeSymbol currType, Symbol& implicitImpl, Symbol& closeMismatch)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.ComputeImplementationForInterfaceMember(Symbol interfaceMember, TypeSymbol implementingType, DiagnosticBag diagnostics)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.ComputeImplementationAndDiagnosticsForInterfaceMember(Symbol interfaceMember)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.FindImplementationForInterfaceMemberInNonInterfaceWithDiagnostics(Symbol interfaceMember)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.FindImplementationForInterfaceMember(Symbol interfaceMember)
at Microsoft.CodeAnalysis.CSharp.Symbols.TypeSymbol.Microsoft.CodeAnalysis.ITypeSymbol.FindImplementationForInterfaceMember(ISymbol interfaceMember)
at Analyzer.Utilities.Extensions.ISymbolExtensions.IsImplementationOfAnyImplicitInterfaceMember[TSymbol](ISymbol symbol)
at Microsoft.CodeQuality.Analyzers.ApiDesignGuidelines.CancellationTokenParametersMustComeLastAnalyzer.<>c__DisplayClass6_0.<Initialize>b__1(SymbolAnalysisContext symbolContext)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c.<ExecuteSymbolActionsCore>b__40_1(ValueTuple`2 data)
at Microsoft.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock[TArg](DiagnosticAnalyzer analyzer, Action`1 analyze, TArg argument, Nullable`1 info)
-----
'.
Different analyzer, but same API being busted. @jcouv or @agocke this one on your radar?
Another instance of the same NRE: https://github.com/dotnet/roslyn-analyzers/issues/2659
Another report of the same NRE: https://github.com/dotnet/roslyn-analyzers/issues/2694 from @jnm2
@gafter @jcouv @agocke
I hit this again via Microsoft.VisualStudio.Threading.Analyzers.VSTHRD102AvoidJtfRunInNonPublicMembersAnalyzer
...and again via Microsoft.NetCore.Analyzers.Data.ReviewSqlQueriesForSecurityVulnerabilities