-
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
Fix S2583 FP: Delegate unsubscription #8457
Conversation
b22e397
to
a96061b
Compare
state = state | ||
.SetOperationValue(assignment, value) | ||
.SetOperationValue(assignment.Target, value); | ||
state = state.SetSymbolValue(assignment.Target.TrackedSymbol(state), value); |
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.
Note: the left side of the -= operator must be a field, property, or indexer. In the first two cases, the symbol is always available. For indexers, I haven't been able to create a test case where the indexer would have NotNull
as a constraint.
e.g.
this[42] = delegate { };
this[42] += Callback; // this[42] doesn't have the NotNull constraint
this[42] -= Callback;
So I don't check whether the tracked symbol is null
.
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.
Looks very nice! Clean implementation. Just add a few more UTs where the delegate is not a local variable (field, proper, indexer).
.../src/SonarAnalyzer.Common/SymbolicExecution/Roslyn/OperationProcessors/CompoundAssignment.cs
Outdated
Show resolved
Hide resolved
a96061b
to
3e6c5ce
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.
Yes, looks good! Just add a few UTs for fields and properties.
|
|
Fixes #8094