Skip to content

Commit

Permalink
HashSet.Contains
Browse files Browse the repository at this point in the history
  • Loading branch information
ninedan committed May 3, 2023
1 parent 7b8c31d commit 589f040
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,11 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl
continue;
}

if (documentationTexts.Contains(documentation))
if (!documentationTexts.Add(documentation))
{
// Add violation
context.ReportDiagnostic(Diagnostic.Create(Descriptor, documentationSyntax.GetLocation()));
}
else
{
documentationTexts.Add(documentation);
}
}

objectPool.ClearAndFree(documentationTexts);
Expand Down Expand Up @@ -148,15 +144,11 @@ protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext co
continue;
}

if (documentationTexts.Contains(documentation))
if (!documentationTexts.Add(documentation))
{
// Add violation
context.ReportDiagnostic(Diagnostic.Create(Descriptor, diagnosticLocations.First()));
}
else
{
documentationTexts.Add(documentation);
}
}

objectPool.ClearAndFree(documentationTexts);
Expand Down

0 comments on commit 589f040

Please sign in to comment.