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 S2583 FP: Delegate unsubscription #8457

Merged
merged 3 commits into from
Dec 18, 2023

Conversation

zsolt-kolbay-sonarsource
Copy link
Contributor

Fixes #8094

@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource marked this pull request as ready for review December 11, 2023 09:01
@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource force-pushed the Zsolt/S2583-fix-delegate-FP branch 2 times, most recently from b22e397 to a96061b Compare December 11, 2023 12:22
state = state
.SetOperationValue(assignment, value)
.SetOperationValue(assignment.Target, value);
state = state.SetSymbolValue(assignment.Target.TrackedSymbol(state), value);
Copy link
Contributor Author

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.

Copy link
Contributor

@Tim-Pohlmann Tim-Pohlmann left a 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).

Copy link
Contributor

@Tim-Pohlmann Tim-Pohlmann left a 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.

Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource merged commit 4541c82 into master Dec 18, 2023
23 checks passed
@zsolt-kolbay-sonarsource zsolt-kolbay-sonarsource deleted the Zsolt/S2583-fix-delegate-FP branch December 18, 2023 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants