IDE0049 should be updated to suggest converting IntPtr to nint and UIntPtr to nuint.
See original GitHub issueBrief description:
As mentioned in https://github.com/dotnet/runtime/issues/72348 with the numeric IntPtr feature, nint
is now an alias for System.IntPtr
and nuint
is alias for System.UIntPtr
, the analyzer IDE0049
should be updated to suggest converting IntPtr
to nint
and UIntPtr
to nuint
. Preferably default to “Info” level.
Languages applicable:
C# only
Additional information:
Related to https://github.com/dotnet/runtime/issues/72348
Documentation requirements:
When this analyzer is updated, the Documentation for IDE0049 analyzers could be updated accordingly.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How can I convert IntPtr to UIntPtr?
According to the site: "Changed IntPtr to UIntPtr: When invoking with IntPtr for the handles, you will run into an Overflow. UIntPtr is...
Read more >CA2020: Prevent behavioral change caused by built-in ...
This rule fires when it detects a behavioral change between .NET 6 and .NET 7 introduced by the new built-in operators of IntPtr...
Read more >C# Tutorial For Beginners: Native Sized Integers C# 9 | IntPtr C#
It can be converted to and from other pointer types, ... Beginners: Native Sized Integers C# 9 | IntPtr C# | UIntPtr C#...
Read more >Converting from an Integer to an IntPtr - Duncan Mackenzie
A friend of mine at work just asked me this VB question, and it is an interesting one to me because it isn't...
Read more >Introducing C# 11: Numeric IntPtr and UIntPtr
Here is the specification from C# 9 (source: Microsoft): “The types nint and nuint are represented by the underlying types System.IntPtr and ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The compiler treats
nint
/nuint
as aliases forSystem.IntPtr
/System.UIntPtr
when compiling with a corlib that includesSystem.Runtime.CompilerServices.RuntimeFeature.NumericIntPtr
. Otherwise, the pairs of types are considered distinct.This also should consider @jkotas suggestion in the original issue: