-
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
Make CA1827 fire for 'is' patterns. #7213
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7213 +/- ##
========================================
Coverage 96.46% 96.46%
========================================
Files 1427 1427
Lines 341675 341928 +253
Branches 11259 11268 +9
========================================
+ Hits 329581 329846 +265
+ Misses 9245 9232 -13
- Partials 2849 2850 +1 |
@@ -314,6 +321,48 @@ private static bool AnalyzeParentInvocationOperation(IInvocationOperation parent | |||
return true; | |||
} | |||
|
|||
private static bool AnalyzeIsPatternOperation(IIsPatternOperation isPatternOperation, out bool shouldNegateIsEmpty) |
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 comment about the return values of this method.
|
||
if (isPatternOperation.Pattern is INegatedPatternOperation negatedPattern) | ||
{ | ||
if (negatedPattern.Pattern is IRelationalPatternOperation { OperatorKind: BinaryOperatorKind.GreaterThan, Value: ILiteralOperation { ConstantValue: { HasValue: true, Value: 0 } } } |
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 would suggest adding comments for each of these cases where you have the code corresponding to the condition for easy understanding, probably you can just copy over the corresponding test case code that you have added for each of the conditional branches in this method.
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.
The change looks good. Kindly add some comments and we can get this merged. Thanks!
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.
Thanks!
Fixes #7207