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 S3655 FP: Recognize ??= for nullable types #7308

Closed
pavel-mikula-sonarsource opened this issue May 30, 2023 · 0 comments · Fixed by #7312
Closed

Fix S3655 FP: Recognize ??= for nullable types #7308

pavel-mikula-sonarsource opened this issue May 30, 2023 · 0 comments · Fixed by #7312
Assignees
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone

Comments

@pavel-mikula-sonarsource
Copy link
Contributor

The ??= doesn't call property int?.HasValue, but invokes int?.HasValue.get method instead.

We need to recognize that in the engine and make them behave the same.

int? i = null;
i ??= 1;
var r1 = (int)i;    // Noncompliant FP
@pavel-mikula-sonarsource pavel-mikula-sonarsource added Area: CFG/SE CFG and SE related issues. Area: C# C# rules related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules. Sprint: SE labels May 30, 2023
@pavel-mikula-sonarsource pavel-mikula-sonarsource added this to the 9.3 milestone May 30, 2023
@gregory-paidis-sonarsource gregory-paidis-sonarsource modified the milestones: 9.3, 9.4 Jun 6, 2023
@pavel-mikula-sonarsource pavel-mikula-sonarsource changed the title Fix S1944 FP: Recognize ??= for nullable types Fix S3655 FP: Recognize ??= for nullable types Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants