Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pshao25 committed Jul 24, 2023
1 parent 2130cd8 commit 6fdd59a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ private static void CheckProtocolMethodParameters(ISymbolAnalysisContext context
if (requestContent == null && method.Parameters.Last().IsOptional)
{
INamedTypeSymbol type = (INamedTypeSymbol)context.Symbol;
var methodList = type.GetMembers(method.Name).OfType<IMethodSymbol>().Where(member => !SymbolEqualityComparer.Default.Equals(member, method));
var convenienceMethod = FindMethod(methodList, method.TypeParameters, method.Parameters.RemoveAt(method.Parameters.Length - 1), symbol => IsCancellationToken(symbol), ParameterEquivalenceComparerOptionalIgnore.Default);
IEnumerable<IMethodSymbol> methodList = type.GetMembers(method.Name).OfType<IMethodSymbol>().Where(member => !SymbolEqualityComparer.Default.Equals(member, method));
ImmutableArray<IParameterSymbol> parametersWithoutLast = method.Parameters.RemoveAt(method.Parameters.Length - 1);
IMethodSymbol convenienceMethod = FindMethod(methodList, method.TypeParameters, parametersWithoutLast, symbol => IsCancellationToken(symbol), ParameterEquivalenceComparerOptionalIgnore.Default);
if (convenienceMethod != null)
{
context.ReportDiagnostic(Diagnostic.Create(Descriptors.AZC0018, method.Locations.FirstOrDefault()), method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ internal class Descriptors

public static DiagnosticDescriptor AZC0018 = new DiagnosticDescriptor(
nameof(AZC0018),
"Do ensure protocol methods take a RequestContext parameter called `context` and do not take models as parameter or return types. Do ensure protocol methods will not cause an ambiguous overload resolution with convenience methods.",
"Protocol method should have `requestContext` as the last parameter and not use a model as parameter or return types. Protocol methods should not have optional parameters if ambiguity exists between the protocol method and convenience methods.",
"Invalid protocl method signature.",
"Protocol method should take a RequestContext parameter called `context` and not use a model as parameter or return types. Protocol methods should not have optional parameters if ambiguity exists between the protocol method and convenience methods.",
"Usage", DiagnosticSeverity.Warning, isEnabledByDefault: true, description: null);
#endregion

Expand Down

0 comments on commit 6fdd59a

Please sign in to comment.