Skip to content

Commit

Permalink
Convert from var to explicit type (#74)
Browse files Browse the repository at this point in the history
There is mixed use of explicit types and var keyword. There are also
cases where the var keyword cannot be used. Rather than have mixed
cases, update all code to use explicit types and enable .editorconfig
rule to enforce code style

Fixes #53
  • Loading branch information
rjmurillo authored Jun 7, 2024
1 parent 7a45b15 commit f52ba4b
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 78 deletions.
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ dotnet_remove_unnecessary_suppression_exclusions = none
[*.cs]

# var preferences
csharp_style_var_elsewhere = false:silent
csharp_style_var_for_built_in_types = false:silent
csharp_style_var_when_type_is_apparent = false:silent
csharp_style_var_elsewhere = false:warning
csharp_style_var_for_built_in_types = false:warning
csharp_style_var_when_type_is_apparent = false:warning

# Expression-bodied members
csharp_style_expression_bodied_accessors = true:silent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ public override void Initialize(AnalysisContext context)

private static void Analyze(SyntaxNodeAnalysisContext context)
{
var asInvocation = (InvocationExpressionSyntax)context.Node;
InvocationExpressionSyntax? asInvocation = (InvocationExpressionSyntax)context.Node;

if (asInvocation.Expression is MemberAccessExpressionSyntax memberAccessExpression
&& Helpers.IsMoqAsMethod(context.SemanticModel, memberAccessExpression)
&& memberAccessExpression.Name is GenericNameSyntax genericName
&& genericName.TypeArgumentList.Arguments.Count == 1)
{
var typeArgument = genericName.TypeArgumentList.Arguments[0];
var symbolInfo = context.SemanticModel.GetSymbolInfo(typeArgument, context.CancellationToken);
TypeSyntax? typeArgument = genericName.TypeArgumentList.Arguments[0];
SymbolInfo symbolInfo = context.SemanticModel.GetSymbolInfo(typeArgument, context.CancellationToken);
if (symbolInfo.Symbol is ITypeSymbol typeSymbol && typeSymbol.TypeKind != TypeKind.Interface)
{
var diagnostic = Diagnostic.Create(Rule, typeArgument.GetLocation());
Diagnostic? diagnostic = Diagnostic.Create(Rule, typeArgument.GetLocation());
context.ReportDiagnostic(diagnostic);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,46 @@ public override void Initialize(AnalysisContext context)

private static void Analyze(SyntaxNodeAnalysisContext context)
{
var callbackOrReturnsInvocation = (InvocationExpressionSyntax)context.Node;
InvocationExpressionSyntax? callbackOrReturnsInvocation = (InvocationExpressionSyntax)context.Node;

var callbackOrReturnsMethodArguments = callbackOrReturnsInvocation.ArgumentList.Arguments;
SeparatedSyntaxList<ArgumentSyntax> callbackOrReturnsMethodArguments = callbackOrReturnsInvocation.ArgumentList.Arguments;

// Ignoring Callback() and Return() calls without lambda arguments
if (callbackOrReturnsMethodArguments.Count == 0) return;

if (!Helpers.IsCallbackOrReturnInvocation(context.SemanticModel, callbackOrReturnsInvocation)) return;

var callbackLambda = callbackOrReturnsInvocation.ArgumentList.Arguments[0]?.Expression as ParenthesizedLambdaExpressionSyntax;
ParenthesizedLambdaExpressionSyntax? callbackLambda = callbackOrReturnsInvocation.ArgumentList.Arguments[0]?.Expression as ParenthesizedLambdaExpressionSyntax;

// Ignoring callbacks without lambda
if (callbackLambda == null) return;

// Ignoring calls with no arguments because those are valid in Moq
var lambdaParameters = callbackLambda.ParameterList.Parameters;
SeparatedSyntaxList<ParameterSyntax> lambdaParameters = callbackLambda.ParameterList.Parameters;
if (lambdaParameters.Count == 0) return;

var setupInvocation = Helpers.FindSetupMethodFromCallbackInvocation(context.SemanticModel, callbackOrReturnsInvocation);
var mockedMethodInvocation = Helpers.FindMockedMethodInvocationFromSetupMethod(setupInvocation);
InvocationExpressionSyntax? setupInvocation = Helpers.FindSetupMethodFromCallbackInvocation(context.SemanticModel, callbackOrReturnsInvocation);
InvocationExpressionSyntax? mockedMethodInvocation = Helpers.FindMockedMethodInvocationFromSetupMethod(setupInvocation);
if (mockedMethodInvocation == null) return;

var mockedMethodArguments = mockedMethodInvocation.ArgumentList.Arguments;
SeparatedSyntaxList<ArgumentSyntax> mockedMethodArguments = mockedMethodInvocation.ArgumentList.Arguments;

if (mockedMethodArguments.Count != lambdaParameters.Count)
{
var diagnostic = Diagnostic.Create(Rule, callbackLambda.ParameterList.GetLocation());
Diagnostic? diagnostic = Diagnostic.Create(Rule, callbackLambda.ParameterList.GetLocation());
context.ReportDiagnostic(diagnostic);
}
else
{
for (int i = 0; i < mockedMethodArguments.Count; i++)
{
var mockedMethodArgumentType = context.SemanticModel.GetTypeInfo(mockedMethodArguments[i].Expression, context.CancellationToken);
var lambdaParameterType = context.SemanticModel.GetTypeInfo(lambdaParameters[i].Type, context.CancellationToken);
TypeInfo mockedMethodArgumentType = context.SemanticModel.GetTypeInfo(mockedMethodArguments[i].Expression, context.CancellationToken);
TypeInfo lambdaParameterType = context.SemanticModel.GetTypeInfo(lambdaParameters[i].Type, context.CancellationToken);

Check warning on line 62 in Source/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

Possible null reference argument for parameter 'expression' in 'TypeInfo CSharpExtensions.GetTypeInfo(SemanticModel? semanticModel, ExpressionSyntax expression, CancellationToken cancellationToken = default(CancellationToken))'.

Check warning on line 62 in Source/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

Possible null reference argument for parameter 'expression' in 'TypeInfo CSharpExtensions.GetTypeInfo(SemanticModel? semanticModel, ExpressionSyntax expression, CancellationToken cancellationToken = default(CancellationToken))'.

Check warning on line 62 in Source/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

Possible null reference argument for parameter 'expression' in 'TypeInfo CSharpExtensions.GetTypeInfo(SemanticModel? semanticModel, ExpressionSyntax expression, CancellationToken cancellationToken = default(CancellationToken))'.

Check warning on line 62 in Source/Moq.Analyzers/CallbackSignatureShouldMatchMockedMethodAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

Possible null reference argument for parameter 'expression' in 'TypeInfo CSharpExtensions.GetTypeInfo(SemanticModel? semanticModel, ExpressionSyntax expression, CancellationToken cancellationToken = default(CancellationToken))'.
string? mockedMethodTypeName = mockedMethodArgumentType.ConvertedType?.ToString();
string? lambdaParameterTypeName = lambdaParameterType.ConvertedType?.ToString();
if (!string.Equals(mockedMethodTypeName, lambdaParameterTypeName, StringComparison.Ordinal))
{
var diagnostic = Diagnostic.Create(Rule, callbackLambda.ParameterList.GetLocation());
Diagnostic? diagnostic = Diagnostic.Create(Rule, callbackLambda.ParameterList.GetLocation());
context.ReportDiagnostic(diagnostic);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Text;

namespace Moq.Analyzers;

Expand All @@ -21,15 +22,15 @@ public sealed override FixAllProvider GetFixAllProvider()

public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
SyntaxNode? root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);

if (root == null)
{
return;
}

var diagnostic = context.Diagnostics.First();
var diagnosticSpan = diagnostic.Location.SourceSpan;
Diagnostic? diagnostic = context.Diagnostics.First();
TextSpan diagnosticSpan = diagnostic.Location.SourceSpan;

// Find the type declaration identified by the diagnostic.
ParameterListSyntax? badArgumentListSyntax = root.FindToken(diagnosticSpan.Start)
Expand All @@ -49,7 +50,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)

private async Task<Document> FixCallbackSignatureAsync(SyntaxNode root, Document document, ParameterListSyntax? oldParameters, CancellationToken cancellationToken)
{
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
SemanticModel? semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

Debug.Assert(semanticModel != null, nameof(semanticModel) + " != null");

Expand All @@ -63,23 +64,23 @@ private async Task<Document> FixCallbackSignatureAsync(SyntaxNode root, Document
return document;
}

var setupMethodInvocation = Helpers.FindSetupMethodFromCallbackInvocation(semanticModel, callbackInvocation);
InvocationExpressionSyntax? setupMethodInvocation = Helpers.FindSetupMethodFromCallbackInvocation(semanticModel, callbackInvocation);
Debug.Assert(setupMethodInvocation != null, nameof(setupMethodInvocation) + " != null");
var matchingMockedMethods = Helpers.GetAllMatchingMockedMethodSymbolsFromSetupMethodInvocation(semanticModel, setupMethodInvocation).ToArray();
IMethodSymbol[]? matchingMockedMethods = Helpers.GetAllMatchingMockedMethodSymbolsFromSetupMethodInvocation(semanticModel, setupMethodInvocation).ToArray();

if (matchingMockedMethods.Length != 1 || oldParameters == null)
{
return document;
}

var newParameters = SyntaxFactory.ParameterList(SyntaxFactory.SeparatedList(matchingMockedMethods[0].Parameters.Select(
ParameterListSyntax? newParameters = SyntaxFactory.ParameterList(SyntaxFactory.SeparatedList(matchingMockedMethods[0].Parameters.Select(
p =>
{
var type = SyntaxFactory.ParseTypeName(p.Type.ToMinimalDisplayString(semanticModel, oldParameters.SpanStart));
TypeSyntax? type = SyntaxFactory.ParseTypeName(p.Type.ToMinimalDisplayString(semanticModel, oldParameters.SpanStart));
return SyntaxFactory.Parameter(default, SyntaxFactory.TokenList(), type, SyntaxFactory.Identifier(p.Name), null);
})));

var newRoot = root.ReplaceNode(oldParameters, newParameters);
SyntaxNode? newRoot = root.ReplaceNode(oldParameters, newParameters);
return document.WithSyntaxRoot(newRoot);
}
}
30 changes: 15 additions & 15 deletions Source/Moq.Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ public override void Initialize(AnalysisContext context)

private static void Analyze(SyntaxNodeAnalysisContext context)
{
var objectCreation = (ObjectCreationExpressionSyntax)context.Node;
ObjectCreationExpressionSyntax? objectCreation = (ObjectCreationExpressionSyntax)context.Node;

var genericName = GetGenericNameSyntax(objectCreation.Type);
GenericNameSyntax? genericName = GetGenericNameSyntax(objectCreation.Type);
if (genericName == null) return;

if (!IsMockGenericType(genericName)) return;

// Full check that we are calling new Mock<T>()
var constructorSymbol = GetConstructorSymbol(context, objectCreation);
IMethodSymbol? constructorSymbol = GetConstructorSymbol(context, objectCreation);

// Vararg parameter is the one that takes all arguments for mocked class constructor
var varArgsConstructorParameter = constructorSymbol?.Parameters.FirstOrDefault(x => x.IsParams);
IParameterSymbol? varArgsConstructorParameter = constructorSymbol?.Parameters.FirstOrDefault(x => x.IsParams);

// Vararg parameter are not used, so there are no arguments for mocked class constructor
if (varArgsConstructorParameter == null) return;
Expand All @@ -50,22 +50,22 @@ private static void Analyze(SyntaxNodeAnalysisContext context)
return;
}

var varArgsConstructorParameterIdx = constructorSymbol.Parameters.IndexOf(varArgsConstructorParameter);
int varArgsConstructorParameterIdx = constructorSymbol.Parameters.IndexOf(varArgsConstructorParameter);

// Find mocked type
var mockedTypeSymbol = GetMockedSymbol(context, genericName);
INamedTypeSymbol? mockedTypeSymbol = GetMockedSymbol(context, genericName);
if (mockedTypeSymbol == null) return;

// Skip first argument if it is not vararg - typically it is MockingBehavior argument
var constructorArguments = objectCreation.ArgumentList?.Arguments.Skip(varArgsConstructorParameterIdx == 0 ? 0 : 1).ToArray();
ArgumentSyntax[]? constructorArguments = objectCreation.ArgumentList?.Arguments.Skip(varArgsConstructorParameterIdx == 0 ? 0 : 1).ToArray();

if (!mockedTypeSymbol.IsAbstract)
{
if (constructorArguments != null
&& IsConstructorMismatch(context, objectCreation, genericName, constructorArguments)
&& objectCreation.ArgumentList != null)
{
var diagnostic = Diagnostic.Create(Rule, objectCreation.ArgumentList.GetLocation());
Diagnostic? diagnostic = Diagnostic.Create(Rule, objectCreation.ArgumentList.GetLocation());
context.ReportDiagnostic(diagnostic);
}
}
Expand Down Expand Up @@ -95,7 +95,7 @@ private static void Analyze(SyntaxNodeAnalysisContext context)

Debug.Assert(objectCreation.ArgumentList != null, "objectCreation.ArgumentList != null");

var diagnostic = Diagnostic.Create(Rule, objectCreation.ArgumentList?.GetLocation());
Diagnostic? diagnostic = Diagnostic.Create(Rule, objectCreation.ArgumentList?.GetLocation());
context.ReportDiagnostic(diagnostic);
}
}
Expand All @@ -104,9 +104,9 @@ private static void Analyze(SyntaxNodeAnalysisContext context)
SyntaxNodeAnalysisContext context,
GenericNameSyntax genericName)
{
var typeArguments = genericName.TypeArgumentList.Arguments;
SeparatedSyntaxList<TypeSyntax> typeArguments = genericName.TypeArgumentList.Arguments;
if (typeArguments.Count != 1) return null;
var mockedTypeSymbolInfo = context.SemanticModel.GetSymbolInfo(typeArguments[0], context.CancellationToken);
SymbolInfo mockedTypeSymbolInfo = context.SemanticModel.GetSymbolInfo(typeArguments[0], context.CancellationToken);
if (mockedTypeSymbolInfo.Symbol is not INamedTypeSymbol { TypeKind: TypeKind.Class } mockedTypeSymbol) return null;
return mockedTypeSymbol;
}
Expand Down Expand Up @@ -154,8 +154,8 @@ private static bool IsMockGenericType(GenericNameSyntax genericName)

private static IMethodSymbol? GetConstructorSymbol(SyntaxNodeAnalysisContext context, ObjectCreationExpressionSyntax objectCreation)
{
var constructorSymbolInfo = context.SemanticModel.GetSymbolInfo(objectCreation, context.CancellationToken);
var constructorSymbol = constructorSymbolInfo.Symbol as IMethodSymbol;
SymbolInfo constructorSymbolInfo = context.SemanticModel.GetSymbolInfo(objectCreation, context.CancellationToken);
IMethodSymbol? constructorSymbol = constructorSymbolInfo.Symbol as IMethodSymbol;
return constructorSymbol?.MethodKind == MethodKind.Constructor &&
string.Equals(
constructorSymbol.ContainingType?.ConstructedFrom.ToDisplayString(),
Expand All @@ -167,12 +167,12 @@ private static bool IsMockGenericType(GenericNameSyntax genericName)

private static bool IsConstructorMismatch(SyntaxNodeAnalysisContext context, ObjectCreationExpressionSyntax objectCreation, GenericNameSyntax genericName, ArgumentSyntax[] constructorArguments)
{
var fakeConstructorCall = SyntaxFactory.ObjectCreationExpression(
ObjectCreationExpressionSyntax? fakeConstructorCall = SyntaxFactory.ObjectCreationExpression(
genericName.TypeArgumentList.Arguments.First(),
SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(constructorArguments)),
null);

var mockedClassConstructorSymbolInfo = context.SemanticModel.GetSpeculativeSymbolInfo(
SymbolInfo mockedClassConstructorSymbolInfo = context.SemanticModel.GetSpeculativeSymbolInfo(
objectCreation.SpanStart, fakeConstructorCall, SpeculativeBindingOption.BindAsExpression);

return mockedClassConstructorSymbolInfo.Symbol == null;
Expand Down
22 changes: 11 additions & 11 deletions Source/Moq.Analyzers/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal static bool IsMoqAsMethod(SemanticModel semanticModel, MemberAccessExpr

internal static bool IsCallbackOrReturnInvocation(SemanticModel semanticModel, InvocationExpressionSyntax callbackOrReturnsInvocation)
{
var callbackOrReturnsMethod = callbackOrReturnsInvocation.Expression as MemberAccessExpressionSyntax;
MemberAccessExpressionSyntax? callbackOrReturnsMethod = callbackOrReturnsInvocation.Expression as MemberAccessExpressionSyntax;

Debug.Assert(callbackOrReturnsMethod != null, nameof(callbackOrReturnsMethod) + " != null");

Expand All @@ -30,7 +30,7 @@ internal static bool IsCallbackOrReturnInvocation(SemanticModel semanticModel, I
return false;
}

var methodName = callbackOrReturnsMethod.Name.ToString();
string? methodName = callbackOrReturnsMethod.Name.ToString();

// First fast check before walking semantic model
if (!string.Equals(methodName, "Callback", StringComparison.Ordinal)
Expand All @@ -39,7 +39,7 @@ internal static bool IsCallbackOrReturnInvocation(SemanticModel semanticModel, I
return false;
}

var symbolInfo = semanticModel.GetSymbolInfo(callbackOrReturnsMethod);
SymbolInfo symbolInfo = semanticModel.GetSymbolInfo(callbackOrReturnsMethod);
return symbolInfo.CandidateReason switch
{
CandidateReason.OverloadResolutionFailure => symbolInfo.CandidateSymbols.Any(IsCallbackOrReturnSymbol),
Expand All @@ -50,39 +50,39 @@ internal static bool IsCallbackOrReturnInvocation(SemanticModel semanticModel, I

internal static InvocationExpressionSyntax? FindSetupMethodFromCallbackInvocation(SemanticModel semanticModel, ExpressionSyntax expression)
{
var invocation = expression as InvocationExpressionSyntax;
InvocationExpressionSyntax? invocation = expression as InvocationExpressionSyntax;
if (invocation?.Expression is not MemberAccessExpressionSyntax method) return null;
if (IsMoqSetupMethod(semanticModel, method)) return invocation;
return FindSetupMethodFromCallbackInvocation(semanticModel, method.Expression);
}

internal static InvocationExpressionSyntax? FindMockedMethodInvocationFromSetupMethod(InvocationExpressionSyntax? setupInvocation)
{
var setupLambdaArgument = setupInvocation?.ArgumentList.Arguments[0].Expression as LambdaExpressionSyntax;
LambdaExpressionSyntax? setupLambdaArgument = setupInvocation?.ArgumentList.Arguments[0].Expression as LambdaExpressionSyntax;
return setupLambdaArgument?.Body as InvocationExpressionSyntax;
}

internal static ExpressionSyntax? FindMockedMemberExpressionFromSetupMethod(InvocationExpressionSyntax? setupInvocation)
{
var setupLambdaArgument = setupInvocation?.ArgumentList.Arguments[0].Expression as LambdaExpressionSyntax;
LambdaExpressionSyntax? setupLambdaArgument = setupInvocation?.ArgumentList.Arguments[0].Expression as LambdaExpressionSyntax;
return setupLambdaArgument?.Body as ExpressionSyntax;
}

internal static IEnumerable<IMethodSymbol> GetAllMatchingMockedMethodSymbolsFromSetupMethodInvocation(SemanticModel semanticModel, InvocationExpressionSyntax? setupMethodInvocation)
{
var setupLambdaArgument = setupMethodInvocation?.ArgumentList.Arguments[0].Expression as LambdaExpressionSyntax;
var mockedMethodInvocation = setupLambdaArgument?.Body as InvocationExpressionSyntax;
LambdaExpressionSyntax? setupLambdaArgument = setupMethodInvocation?.ArgumentList.Arguments[0].Expression as LambdaExpressionSyntax;
InvocationExpressionSyntax? mockedMethodInvocation = setupLambdaArgument?.Body as InvocationExpressionSyntax;

return GetAllMatchingSymbols<IMethodSymbol>(semanticModel, mockedMethodInvocation);
}

internal static IEnumerable<T> GetAllMatchingSymbols<T>(SemanticModel semanticModel, ExpressionSyntax? expression)
where T : class
{
var matchingSymbols = new List<T>();
List<T>? matchingSymbols = new List<T>();
if (expression != null)
{
var symbolInfo = semanticModel.GetSymbolInfo(expression);
SymbolInfo symbolInfo = semanticModel.GetSymbolInfo(expression);
if (symbolInfo is { CandidateReason: CandidateReason.None, Symbol: T })
{
matchingSymbols.Add(symbolInfo.Symbol as T);

Check warning on line 88 in Source/Moq.Analyzers/Helpers.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

Possible null reference argument for parameter 'item' in 'void List<T>.Add(T item)'.

Check warning on line 88 in Source/Moq.Analyzers/Helpers.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

Possible null reference argument for parameter 'item' in 'void List<T>.Add(T item)'.

Check warning on line 88 in Source/Moq.Analyzers/Helpers.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

Possible null reference argument for parameter 'item' in 'void List<T>.Add(T item)'.

Check warning on line 88 in Source/Moq.Analyzers/Helpers.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

Possible null reference argument for parameter 'item' in 'void List<T>.Add(T item)'.
Expand All @@ -100,7 +100,7 @@ private static bool IsCallbackOrReturnSymbol(ISymbol? symbol)
{
// TODO: Check what is the best way to do such checks

Check warning on line 101 in Source/Moq.Analyzers/Helpers.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

TODO Check what is the best way to do such checks (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0026.md)

Check warning on line 101 in Source/Moq.Analyzers/Helpers.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

TODO Check what is the best way to do such checks (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0026.md)

Check warning on line 101 in Source/Moq.Analyzers/Helpers.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022)

TODO Check what is the best way to do such checks (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0026.md)

Check warning on line 101 in Source/Moq.Analyzers/Helpers.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04)

TODO Check what is the best way to do such checks (https://github.com/meziantou/Meziantou.Analyzer/blob/main/docs/Rules/MA0026.md)
if (symbol is not IMethodSymbol methodSymbol) return false;
var methodName = methodSymbol.ToString();
string? methodName = methodSymbol.ToString();
return methodName.StartsWith("Moq.Language.ICallback", StringComparison.Ordinal)
|| methodName.StartsWith("Moq.Language.IReturns", StringComparison.Ordinal);
}
Expand Down
Loading

0 comments on commit f52ba4b

Please sign in to comment.