IDE0004 false positive when casting int litral to nint and trying to assign to IntPtr #64825
Closed as not planned
Closed as not planned
Description
opened on Oct 19, 2022
Version Used:
Microsoft Visual Studio Community 2022 (64-bit) - Current
Version 17.3.6
Steps to Reproduce:
- Set
<LangVersion>10.0</LangVersion>
in csproj. - Write a following code:
System.IntPtr x = (nint)1;
Expected Behavior:
There is no IDE0004.
Actual Behavior:
There is an IDE0004 Cast is redundant
on (nint)
.
If I remove the cast then I get an error: CS0266 Cannot implicitly convert type 'int' to 'System.IntPtr'. An explicit conversion exists (are you missing a cast?)
Note: The cast may be really redundant when using C# 11 because there is a new feature "numeric IntPtr".
Activity