@@ -49,6 +49,7 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, FluentAs
49
49
return ;
50
50
}
51
51
52
+ context . Options . AnalyzerConfigOptionsProvider . GetOptions ( invocation . Syntax . SyntaxTree ) . TryGetValue ( "use_diagnostic_per_assertion" , out var useDiagnosticPerAssertion ) ;
52
53
if ( HasConditionalAccessAncestor ( invocation ) )
53
54
{
54
55
var expressionStatement = invocation . GetFirstAncestor < IExpressionStatementOperation > ( ) ;
@@ -211,10 +212,12 @@ private static void AnalyzeInvocation(OperationAnalysisContext context, FluentAs
211
212
case nameof ( string . StartsWith ) when invocationBeforeShould . IsContainedInType ( SpecialType . System_String ) :
212
213
context . ReportDiagnostic ( CreateDiagnostic ( assertion , DiagnosticMetadata . StringShouldStartWith_StartsWithShouldBeTrue ) ) ;
213
214
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 ) ) :
215
217
context . ReportDiagnostic ( CreateDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldContainKey_ContainsKeyShouldBeTrue ) ) ;
216
218
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 ) ) :
218
221
context . ReportDiagnostic ( CreateDiagnostic ( assertion , DiagnosticMetadata . DictionaryShouldContainValue_ContainsValueShouldBeTrue ) ) ;
219
222
return ;
220
223
}
0 commit comments