You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Equivalence between nint/IntPtr and nuint/UIntPtr for:
interface implementations
overloads
partial methods
generic type constraints
type inference
type unification
Retargeting when a compilation reference that uses wrapped nint is referenced in a compilation that uses .NET 7 (see RetargetingFromNonNumericToNumericIntPtrCorlib and RetargetingFromNumericIntPtrToNonNumericCorlib)
Built-in operators for nint/nuint apply to IntPtr/UIntPtr (and IntPtr?/UIntPtr?)
built-in conversions
built-in unary and binary operators
Constants (in int/uint range) supported for IntPtr/UIntPtr:
const allowed
constant folding
parameter default values
switch value
fix better conversion rules (issue) and update specs accordingly
Verify with >>> (see UnsignedRightShift)
Breaking changes:
for checked operator+ and operator- with IntPtr/UIntPtr
Championed issue: dotnet/csharplang#6065
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-11.0/numeric-intptr.md
Compiler
IsNativeIntegerTypeCreateNativeIntegerTypeSymbol()TargetFramework.Net70and use that for our tests (issue Add TargetFramework.Net70 #61463)-langversion[NativeInteger]attributes emittedRetargetingFromNonNumericToNumericIntPtrCorlibandRetargetingFromNumericIntPtrToNonNumericCorlib)constallowedswitchvalue>>>(seeUnsignedRightShift)checkedoperator+ and operator- with IntPtr/UIntPtrBCL
RuntimeFeature.NumericIntPtrmember for C# 11 runtime#69322)System.IntPtrandSystem.UIntPtr(needs to include>>>) (not applicable)Productivity
SemanticClassifierTests.NativeInteger)MetadataAsSource.MetadataAsSourceTests+CSharp.TestNativeInteger)UseExplicitTypeTests.InNativeIntIntrinsicType, this should follow the preference for built-in types)using x = System.IntPtr;should not simplify tonintIntPtrtonintif that option is set<see cref="nint"/>,<see cref="System.IntPtr"/>(completion issue, should offer to simplify tonint)nint x = default(nint);to eithernint x = default;ornint x = 0;Relates to test plan for native ints: #38821
Relates to statics in interfaces and numerics design: https://github.com/dotnet/designs/blob/main/accepted/2021/statics-in-interfaces/README.md