Skip to content

Commit

Permalink
We no longer need ComparerParameterIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
manfred-brands committed Apr 10, 2024
1 parent 54ed245 commit 3b5fe01
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string?>
{
[AnalyzerPropertyKeys.ModelName] = methodSymbol.Name,
[AnalyzerPropertyKeys.ComparerParameterIndex] = comparerParameterIndex,
}.ToImmutableDictionary(),
constraint,
methodSymbol.Name));
}
}

private static bool IsIComparer(IParameterSymbol parameterSymbol)
{
return parameterSymbol.Type.Name == "IComparer";
}
}
}
1 change: 0 additions & 1 deletion src/nunit.analyzers/Constants/AnalyzerPropertyKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 3b5fe01

Please sign in to comment.