-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
…ictly equal
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,13 +74,32 @@ private static void Analyze(SyntaxNodeAnalysisContext context) | |
|
||
TypeInfo mockedMethodArgumentType = context.SemanticModel.GetTypeInfo(mockedMethodArguments[argumentIndex].Expression, context.CancellationToken); | ||
|
||
Check failure on line 76 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (windows-2022)
Check failure on line 76 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (windows-2022)
Check failure on line 76 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (ubuntu-22.04)
Check failure on line 76 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (ubuntu-22.04)
|
||
string? mockedMethodTypeName = mockedMethodArgumentType.ConvertedType?.ToString(); | ||
string? lambdaParameterTypeName = lambdaParameterType.ConvertedType?.ToString(); | ||
|
||
if (!string.Equals(mockedMethodTypeName, lambdaParameterTypeName, StringComparison.Ordinal)) | ||
|
||
// Check if types are assignable rather than strictly equal | ||
ITypeSymbol? lambdaParameterTypeSymbol = lambdaParameterType.Type; | ||
ITypeSymbol? mockedMethodTypeSymbol = mockedMethodArgumentType.Type; | ||
|
||
if (lambdaParameterTypeSymbol is not null && mockedMethodTypeSymbol is not null) | ||
{ | ||
Check failure on line 84 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (windows-2022)
Check failure on line 84 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (windows-2022)
Check failure on line 84 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (ubuntu-22.04)
Check failure on line 84 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (ubuntu-22.04)
|
||
|
||
if (!context.SemanticModel.Compilation.ClassifyConversion(lambdaParameterTypeSymbol, mockedMethodTypeSymbol).IsImplicit) | ||
Check failure on line 86 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs Codacy Production / Codacy Static Code Analysissrc/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs#L86
|
||
{ | ||
Check failure on line 87 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (windows-2022)
Check failure on line 87 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (windows-2022)
Check failure on line 87 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (ubuntu-22.04)
Check failure on line 87 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs GitHub Actions / build (ubuntu-22.04)
|
||
|
||
Diagnostic diagnostic = lambdaParameters[argumentIndex].GetLocation().CreateDiagnostic(Rule); | ||
context.ReportDiagnostic(diagnostic); | ||
} | ||
} | ||
else | ||
{ | ||
Diagnostic diagnostic = callbackLambda.ParameterList.CreateDiagnostic(Rule); | ||
context.ReportDiagnostic(diagnostic); | ||
string? mockedMethodTypeName = mockedMethodArgumentType.ConvertedType?.ToString(); | ||
string? lambdaParameterTypeName = lambdaParameterType.ConvertedType?.ToString(); | ||
|
||
if (!string.Equals(mockedMethodTypeName, lambdaParameterTypeName, StringComparison.Ordinal)) | ||
Check failure on line 98 in src/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs Codacy Production / Codacy Static Code Analysissrc/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs#L98
|
||
{ | ||
Diagnostic diagnostic = callbackLambda.ParameterList.CreateDiagnostic(Rule); | ||
context.ReportDiagnostic(diagnostic); | ||
} | ||
} | ||
} | ||
} | ||
|