@@ -49,6 +49,7 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, FluentAs
4949 return ;
5050 }
5151
52+ context . Options . AnalyzerConfigOptionsProvider . GetOptions ( invocation . Syntax . SyntaxTree ) . TryGetValue ( "use_diagnostic_per_assertion" , out var useDiagnosticPerAssertion ) ;
5253 if ( HasConditionalAccessAncestor ( invocation ) )
5354 {
5455 var expressionStatement = invocation . GetFirstAncestor < IExpressionStatementOperation > ( ) ;
@@ -211,10 +212,12 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, FluentAs
211212 case nameof ( string . StartsWith ) when invocationBeforeShould . IsContainedInType ( SpecialType . System_String ) :
212213 context . ReportDiagnostic ( CreateDiagnostic ( assertion , DiagnosticMetadata . StringShouldStartWith_StartsWithShouldBeTrue ) ) ;
213214 return ;
214- case nameof ( IDictionary < string , object > . ContainsKey ) when invocationBeforeShould . ImplementsOrIsInterface ( metadata . IDictionaryOfT2 ) || invocationBeforeShould . ImplementsOrIsInterface ( metadata . IReadonlyDictionaryOfT2 ) :
215+ case nameof ( Dictionary < string , object > . ContainsKey ) when ( invocationBeforeShould . ImplementsOrIsInterface ( metadata . IDictionaryOfT2 ) || invocationBeforeShould . ImplementsOrIsInterface ( metadata . IReadonlyDictionaryOfT2 ) )
216+ && invocationBeforeShould . AreMethodParameterSameTypeAsContainingTypeArguments ( ( parameter : 0 , typeArgument : 0 ) ) :
215217 context . ReportDiagnostic ( CreateDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldContainKey_ContainsKeyShouldBeTrue ) ) ;
216218 return ;
217- case nameof ( Dictionary < string , object > . ContainsValue ) when invocationBeforeShould . IsContainedInType ( metadata . DictionaryOfT2 ) :
219+ case nameof ( Dictionary < string , object > . ContainsValue ) when invocationBeforeShould . IsContainedInType ( metadata . DictionaryOfT2 )
220+ && invocationBeforeShould . AreMethodParameterSameTypeAsContainingTypeArguments ( ( parameter : 0 , typeArgument : 1 ) ) :
218221 context . ReportDiagnostic ( CreateDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldContainValue_ContainsValueShouldBeTrue ) ) ;
219222 return ;
220223 }
0 commit comments