From ece6ad4ac63aa27372978c63c61186cddab86ea0 Mon Sep 17 00:00:00 2001 From: pshao25 <97225342+pshao25@users.noreply.github.com> Date: Thu, 27 Jul 2023 14:00:45 +0800 Subject: [PATCH] update --- .../ClientAnalyzerBase.cs | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/dotnet/Azure.ClientSdk.Analyzers/Azure.ClientSdk.Analyzers/ClientAnalyzerBase.cs b/src/dotnet/Azure.ClientSdk.Analyzers/Azure.ClientSdk.Analyzers/ClientAnalyzerBase.cs index ecbd156bf51..160745be0da 100644 --- a/src/dotnet/Azure.ClientSdk.Analyzers/Azure.ClientSdk.Analyzers/ClientAnalyzerBase.cs +++ b/src/dotnet/Azure.ClientSdk.Analyzers/Azure.ClientSdk.Analyzers/ClientAnalyzerBase.cs @@ -26,26 +26,16 @@ public override void Analyze(ISymbolAnalysisContext context) AnalyzeCore(context); } - protected class ParameterEquivalenceComparerOptionalIgnore : ParameterEquivalenceComparer - { - public static new ParameterEquivalenceComparerOptionalIgnore Default { get; } = new ParameterEquivalenceComparerOptionalIgnore(); - - public override bool Equals(IParameterSymbol x, IParameterSymbol y) - { - return x.Name.Equals(y.Name) && TypeSymbolEquals(x.Type, y.Type); - } - } - protected class ParameterEquivalenceComparer : IEqualityComparer, IEqualityComparer { public static ParameterEquivalenceComparer Default { get; } = new ParameterEquivalenceComparer(); - public virtual bool Equals(IParameterSymbol x, IParameterSymbol y) + public bool Equals(IParameterSymbol x, IParameterSymbol y) { return x.Name.Equals(y.Name) && TypeSymbolEquals(x.Type, y.Type) && x.IsOptional == y.IsOptional; } - protected virtual bool TypeSymbolEquals(ITypeSymbol x, ITypeSymbol y) + private bool TypeSymbolEquals(ITypeSymbol x, ITypeSymbol y) { switch (x) { @@ -96,19 +86,19 @@ protected static IMethodSymbol FindMethod(IEnumerable methodSymbo parameters.SequenceEqual(symbol.Parameters, ParameterEquivalenceComparer.Default)); } - protected static IMethodSymbol FindMethod(IEnumerable methodSymbols, ImmutableArray genericParameters, ImmutableArray parameters, Func lastParameter, ParameterEquivalenceComparer comparer = null) + protected static IMethodSymbol FindMethod(IEnumerable methodSymbols, ImmutableArray genericParameters, ImmutableArray parameters, Func lastParameter) { return methodSymbols.SingleOrDefault(symbol => { - if (!symbol.Parameters.Any() || !genericParameters.SequenceEqual(symbol.TypeParameters, comparer ?? ParameterEquivalenceComparer.Default)) + if (!symbol.Parameters.Any() || !genericParameters.SequenceEqual(symbol.TypeParameters, ParameterEquivalenceComparer.Default)) { return false; } var allButLast = symbol.Parameters.RemoveAt(symbol.Parameters.Length - 1); - return allButLast.SequenceEqual(parameters, comparer ?? ParameterEquivalenceComparer.Default) && lastParameter(symbol.Parameters.Last()); + return allButLast.SequenceEqual(parameters, ParameterEquivalenceComparer.Default) && lastParameter(symbol.Parameters.Last()); }); }