From cb1df204b06c0aa3aae7e0a269a62fcd989bbcec Mon Sep 17 00:00:00 2001 From: Manfred Brands Date: Wed, 10 Apr 2024 13:16:50 +0800 Subject: [PATCH] We no longer need ComparerParameterIndex --- .../CollectionAssertUsageAnalyzer.cs | 10 ---------- src/nunit.analyzers/Constants/AnalyzerPropertyKeys.cs | 1 - 2 files changed, 11 deletions(-) diff --git a/src/nunit.analyzers/CollectionAssertUsage/CollectionAssertUsageAnalyzer.cs b/src/nunit.analyzers/CollectionAssertUsage/CollectionAssertUsageAnalyzer.cs index 6cd1bb4a..b4504399 100644 --- a/src/nunit.analyzers/CollectionAssertUsage/CollectionAssertUsageAnalyzer.cs +++ b/src/nunit.analyzers/CollectionAssertUsage/CollectionAssertUsageAnalyzer.cs @@ -67,26 +67,16 @@ protected override void AnalyzeAssertInvocation(OperationAnalysisContext context TwoCollectionParameterAsserts.TryGetValue(methodSymbol.Name, out constraint) || CollectionAndItemParameterAsserts.TryGetValue(methodSymbol.Name, out constraint)) { - var parameters = methodSymbol.Parameters; - string comparerParameterIndex = parameters.Length > 1 && IsIComparer(parameters[1]) ? "1" : - (parameters.Length > 2 && IsIComparer(parameters[2]) ? "2" : "0"); - context.ReportDiagnostic(Diagnostic.Create( collectionAssertDescriptor, assertOperation.Syntax.GetLocation(), new Dictionary { [AnalyzerPropertyKeys.ModelName] = methodSymbol.Name, - [AnalyzerPropertyKeys.ComparerParameterIndex] = comparerParameterIndex, }.ToImmutableDictionary(), constraint, methodSymbol.Name)); } } - - private static bool IsIComparer(IParameterSymbol parameterSymbol) - { - return parameterSymbol.Type.Name == "IComparer"; - } } } diff --git a/src/nunit.analyzers/Constants/AnalyzerPropertyKeys.cs b/src/nunit.analyzers/Constants/AnalyzerPropertyKeys.cs index c0882331..10b5bdc0 100644 --- a/src/nunit.analyzers/Constants/AnalyzerPropertyKeys.cs +++ b/src/nunit.analyzers/Constants/AnalyzerPropertyKeys.cs @@ -4,6 +4,5 @@ internal static class AnalyzerPropertyKeys { internal const string ModelName = nameof(AnalyzerPropertyKeys.ModelName); internal const string MinimumNumberOfArguments = nameof(AnalyzerPropertyKeys.MinimumNumberOfArguments); - internal const string ComparerParameterIndex = nameof(AnalyzerPropertyKeys.ComparerParameterIndex); } }