-
Notifications
You must be signed in to change notification settings - Fork 470
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
Fix TODOs and update unit tests with diagnostics #5287
Conversation
src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs
Outdated
Show resolved
Hide resolved
@@ -59,7 +56,7 @@ public class Program | |||
static void Main(string[] args) | |||
{ | |||
var a = new Fraction(); | |||
var b = [|+a|]; | |||
var b = {|CA2252:+a|}; |
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.
Are the different rules ids for distinguishing diagnostics? You can verify with the diagnostic descriptor instead
Line 118 in 682876f
VerifyCS.Diagnostic(AvoidZeroLengthArrayAllocationsAnalyzer.UseArrayEmptyDescriptor).WithLocation(8, 22).WithArguments("Array.Empty<int>()"), |
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.
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?
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 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.
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 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
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.
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 Report
@@ 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 |
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 NIT comments for styling, overall LGTM
src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureAnalyzer.cs
Outdated
Show resolved
Hide resolved
src/NetAnalyzers/UnitTests/Microsoft.NetCore.Analyzers/Runtime/DetectPreviewFeatureUnitTests.cs
Show resolved
Hide resolved
Thanks for the review @buyaa-n |
Addresses 3 of 4 points in #5227.