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

Fix TODOs and update unit tests with diagnostics #5287

Merged
merged 4 commits into from
Jul 27, 2021

Conversation

pgovind
Copy link
Contributor

@pgovind pgovind commented Jul 23, 2021

Addresses 3 of 4 points in #5227.

@pgovind pgovind requested a review from a team as a code owner July 23, 2021 23:32
@pgovind pgovind requested a review from buyaa-n July 23, 2021 23:32
@@ -59,7 +56,7 @@ public class Program
static void Main(string[] args)
{
var a = new Fraction();
var b = [|+a|];
var b = {|CA2252:+a|};
Copy link
Member

Choose a reason for hiding this comment

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

Are the different rules ids for distinguishing diagnostics? You can verify with the diagnostic descriptor instead

VerifyCS.Diagnostic(AvoidZeroLengthArrayAllocationsAnalyzer.UseArrayEmptyDescriptor).WithLocation(8, 22).WithArguments("Array.Empty<int>()"),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup I added the new ruleIDs so I could use the easy markup syntax for the unit tests. Multiple diagnostics defined in the same rule ID didn't seem to work well with the markup syntax.

Do you feel strongly about having only 1 diagnostic ID here? Is it wrong to use multiple diagnostic IDs in 1 analyzer? If I have to change to using VerifyCS.Diagnostic, I have to modify every unit test with the row and column numbers. Seems like a waste of time?

Copy link
Member

Choose a reason for hiding this comment

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

Is it wrong to use multiple diagnostic IDs in 1 analyzer?

Is there a reason a developer would want to configure them independently, e.g. different warning levels or some enabled and some not? If not, we should have only one. We shouldn't add additional IDs just for testing purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a reason a developer would want to configure them independently

I can't think of a natural reason for this. I'll change to using VerifyCS.Diagnostic

Copy link
Member

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

I don't see any reason using different diagnostics id for this analyzer

Prashanth Govindarajan added 2 commits July 26, 2021 15:30
@pgovind
Copy link
Contributor Author

pgovind commented Jul 26, 2021

I don't see any reason using different diagnostics id for this analyzer

Fixed now, this can be reviewed again. Hopefully this fixed the weird CI issue too

@codecov
Copy link

codecov bot commented Jul 26, 2021

Codecov Report

Merging #5287 (5a245e5) into release/6.0.1xx (3897eb2) will increase coverage by 0.01%.
The diff coverage is 99.08%.

@@                 Coverage Diff                 @@
##           release/6.0.1xx    #5287      +/-   ##
===================================================
+ Coverage            95.60%   95.62%   +0.01%     
===================================================
  Files                 1233     1233              
  Lines               283395   283449      +54     
  Branches             16971    16968       -3     
===================================================
+ Hits                270939   271047     +108     
+ Misses               10162    10108      -54     
  Partials              2294     2294              

Copy link
Member

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

Left some NIT comments for styling, overall LGTM

@pgovind pgovind merged commit d36599d into dotnet:release/6.0.1xx Jul 27, 2021
@pgovind
Copy link
Contributor Author

pgovind commented Jul 27, 2021

Thanks for the review @buyaa-n

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

Successfully merging this pull request may close these issues.

3 participants