Skip to content

Convert IntPtr to nint to int incorrectly reported as redundant #51123

@RamType0

Description

@RamType0

Version Used:
Microsoft Visual Studio Community 2019
Version 16.8.4
Steps to Reproduce:

var x = (IntPtr)long.MaxValue; // Only works in 64bit platform. OverflowException will be thrown in 32bit platform
//var y = (int)x; // OverflowException
var y = (int)(nint)x; // IDE0004 says (nint) is redundant

Expected Behavior:
(nint) is not reported as redundant
Actual Behavior:
(nint) is reported as redundant

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEBugIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringshelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions