Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add analyzer for duplicate data row #5144

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Feb 26, 2025

Fixes #5085

@Youssef1313 Youssef1313 marked this pull request as ready for review March 11, 2025 08:43
@Youssef1313 Youssef1313 requested a review from nohwnd March 11, 2025 08:43
Copy link
Member

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test where you have 2 pairs of duplicate attributes on the same method


if (!dataRowArguments.Add(attribute.ConstructorArguments))
{
context.ReportDiagnostic((attribute.ApplicationSyntaxReference?.GetSyntax(context.CancellationToken).GetLocation() ?? Location.None).CreateDiagnostic(Rule));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no helper for that on roslyn-analyzers? Or maybe it's already available in the code I copied.

@@ -573,4 +573,10 @@ The type declaring these methods should also respect the following rules:
<data name="UseConditionBaseWithTestClassMessageFormat" xml:space="preserve">
<value>The attribute '{0}' which derives from 'ConditionBaseAttribute' should be used only on classes marked with `TestClassAttribute`</value>
</data>
<data name="DuplicateDataRowTitle" xml:space="preserve">
<value>A duplicate 'DataRow' attribute is found</value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like Avoid duplicated 'DataRow' entries? or Do not duplicate 'DataRow' entries

<value>A duplicate 'DataRow' attribute is found</value>
</data>
<data name="DuplicateDataRowMessageFormat" xml:space="preserve">
<value>Do not duplicate 'DataRow' attributes. This is usually a copy/paste error.</value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering if we should point out the indexes of duplicated entries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Analyzer suggestion: Duplicate DataRow
2 participants