-
Notifications
You must be signed in to change notification settings - Fork 231
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
.NET 8 and C# 12: add repros and UTs for rules starting with R in SonarWay #8093
.NET 8 and C# 12: add repros and UTs for rules starting with R in SonarWay #8093
Conversation
68bd2db
to
baed000
Compare
baed000
to
1806771
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.
Left some suggestions
...ts/SonarAnalyzer.UnitTest/TestCases/RedundancyInConstructorDestructorDeclaration.CSharp12.cs
Show resolved
Hide resolved
_ = new C2(41, 42); // FN, multiple violations | ||
// ~~ |
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.
Educational: what is this ~~
doing?
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.
It is supposed to be the equivalent of ^^^
, but for a FN
.
See here for example.
I have added it to test the multiple violations. When multiple violations are present on the same line, they can't be asserted with a single comment, but the ^^
has to be used. In the case of FN, I have used ~~
to indicate the location of each of the two False Negative cases.
However, I don't think there is a standard for that (because it doesn't really assert anything) and different people may use different notations.
Anyway, it was misplaced due to the vertical auto-alignment of comments, and that's also why it was hard to guess what those comments were about. I fixed the location.
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.
Very interesting, I never encountered such a method to indicate the FN location. Not a strong opinion: I think we should decide whether we want to keep it and document it somewhere (as of now it's not mentioned in the test cases comment pattern), or avoid using it entirely. WDYT?
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.
It's not defined in the IssueLocationCollector
because it's an FN location, so it cannot be asserted.
Moreover, it keeps being vertically aligned by Visual Studio to the // FN, multiple violations
of the line above, and different people use different notations.
So I have removed it.
...zers/tests/SonarAnalyzer.UnitTest/TestCases/RedundantDeclaration.CSharp12.ArraySize.Fixed.cs
Show resolved
Hide resolved
769ed49
to
fe8d841
Compare
fe8d841
to
34c1322
Compare
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ParameterValidationInYieldShouldBeWrapped.cs
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ParametersCorrectOrder.CSharp11.cs
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ParametersCorrectOrder.CSharp11.cs
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ParametersCorrectOrder.CSharp12.cs
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ParametersCorrectOrder.CSharp12.cs
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/ParametersCorrectOrder.cs
Show resolved
Hide resolved
@cristian-ambrosini-sonarsource As discussed offline, this PR, as for its title and description, only contains rules starting with R. The comments added in the second round of review are all on rules starting with P, which appear since Friday on this PR due to the automatic change of base made by GitHub when merging. I have created a new Trello card and a new PR to deal with comments on rules starting by P. I am going to recreate comments on the new PR, so that those can be resolved here so that this PR remains faithful to its title and description. |
@cristian-ambrosini-sonarsource I have referenced all the comments on rules starting with P in the new PR. Back to you for the validation of this PR. |
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.
LGTM!
record struct ARecordStructWithBody() { } // FN | ||
record struct ARecordStructWithoutBody(); // FN | ||
|
||
namespace FieldInitializerInStructRequiresConstructor |
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.
Optional: should we leave a comment here to give some context?
// https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/constructor-errors?f1url=%3FappId%3Droslyn%26k%3Dk(CS8983)#constructors-in-struct-types
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Rules affected by .NET 8 and C# 12 for rules starting with
R
in SonarWay.Adds repros:
Adds UTs with .NET 8 and C# 12 features for: