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 S2201 FN: Support native ints #6399

Closed
gregory-paidis-sonarsource opened this issue Nov 21, 2022 · 0 comments · Fixed by #6462
Closed

Fix S2201 FN: Support native ints #6399

gregory-paidis-sonarsource opened this issue Nov 21, 2022 · 0 comments · Fixed by #6462
Assignees
Labels
Type: False Negative Rule is NOT triggered when it should be.
Milestone

Comments

@gregory-paidis-sonarsource
Copy link
Contributor

Description

FN for S2201 (ReturnValueIgnored).

Using C#11 native ints, the rule is not raising an issue.

Repro steps

 using System;

int x = 2;

nint n = 2;
nuint nu = 2;

IntPtr intPtr = 2;
UIntPtr uintPtr = 2;

n.ToInt32(); // Compliant, FN, pure function
nu.ToUInt32(); // Compliant, FN, pure function

intPtr.ToInt64(); // Compliant, FN, pure function
uintPtr.ToUInt64(); // Compliant, FN, pure function

unsafe
{
    n.ToPointer(); // Compliant, FN, pure function
    intPtr.ToPointer(); // Compliant, FN, pure function


    nu.ToPointer(); // Compliant, FN, pure function
    uintPtr.ToPointer(); // Compliant, FN, pure function

    x.ToString(); // Noncompliant
}

Expected behavior

The rule should raise an issue.

Actual behavior

The rule does not raise an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: False Negative Rule is NOT triggered when it should be.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants