-
Notifications
You must be signed in to change notification settings - Fork 268
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
base: main
Are you sure you want to change the base?
Conversation
3457435
to
1051fdc
Compare
abaf1b1
to
245cf50
Compare
There was a problem hiding this 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)); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
Fixes #5085