-
Notifications
You must be signed in to change notification settings - Fork 468
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 bug when exception declared in filter is thrown #4285
Fix bug when exception declared in filter is thrown #4285
Conversation
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.
Small suggestion for the symbol comparison but otherwise LGTM.
I totally didn't think about this scenario (never used it).
...zers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RethrowToPreserveStackDetails.cs
Outdated
Show resolved
Hide resolved
...zers/Core/Microsoft.CodeQuality.Analyzers/QualityGuidelines/RethrowToPreserveStackDetails.cs
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #4285 +/- ##
========================================
Coverage 95.80% 95.81%
========================================
Files 1168 1168
Lines 264635 264966 +331
Branches 15964 15974 +10
========================================
+ Hits 253539 253879 +340
+ Misses 9078 9076 -2
+ Partials 2018 2011 -7 |
@@ -49,7 +49,8 @@ public override void Initialize(AnalysisContext analysisContext) | |||
if (ancestor.Kind == OperationKind.CatchClause && | |||
ancestor is ICatchClauseOperation catchClause) | |||
{ | |||
if (catchClause.Locals.Contains(localReference.Local) && | |||
if ((catchClause.ExceptionDeclarationOrExpression is not IVariableDeclaratorOperation variableDeclaratorOperation || SymbolEqualityComparer.Default.Equals(variableDeclaratorOperation.Symbol, localReference.Local)) && |
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.
Why are we skipping the check if this not a variable declaration?
if ((catchClause.ExceptionDeclarationOrExpression is not IVariableDeclaratorOperation variableDeclaratorOperation || SymbolEqualityComparer.Default.Equals(variableDeclaratorOperation.Symbol, localReference.Local)) && | |
if (catchClause.ExceptionDeclarationOrExpression is IVariableDeclaratorOperation variableDeclaratorOperation && SymbolEqualityComparer.Default.Equals(variableDeclaratorOperation.Symbol, localReference.Local) && |
Fixes #4280