-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersTestTest failures in roslyn-CITest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverageDescribes a specific feature or scenario that does not have test coverage
Milestone
Description
Test plan for "native ints" #38821
- ** Specification checked in to
dotnet/csharplang - Open language issues (Open LDM issues with native integers csharplang#3259) resolved and implemented accordingly.
- ** LangVersion
- ** Blocks the use of the "reserved" words [NativeIntegerTests.LanguageVersion]
- Blocks the use of the
nint/nuintoperators?
-
nintandnuintcontextual keywords- bind to new types only when name lookup does not find a viable result [NativeIntegerTests.{ClassName, AliasName_*, MemberName_01}]
- examples: [NativeIntegerTests.{NameOf_*, MemberName_02}]
-
nint x = 3; -
_ = nameof(nint); -
_ = nint.Equals(x, 3);[MemberName_02]
-
- Compile-time constants in
intanduintranges [NativeIntegerTests.Constants_FromMetadata] - Constant folding supported for all unary and binary operators [NativeIntegerTests.ConstantFolding]
- Compile-time evaluation in
checkedanduncheckedcontexts withinint/uintranges - Runtime evaluation in
uncheckedcontext otherwise (we have an open issue)
- Compile-time evaluation in
- Conversions
- Identity conversions between
System.IntPtrandnint, and betweenSystem.UIntPtrandnuint[NativeIntegerTests.Conversions] - Common type of
nintandIntPtr? - Common type of
A<nint>andA<IntPtr>? - Type inference when
nintandIntPtrare both bounds - Identity conversions between arrays,
Nullable<>, constructed types, tuples that differ only by native integers and underlying types - ImplicitNumeric conversions from integer types with smaller range to native integers; ExplicitNumeric otherwise [NativeIntegerTests.Conversions]
- ImplicitNumeric conversions from native integers to integer types with larger range; ExplicitNumeric otherwise [NativeIntegerTests.Conversions]
- Boxing/Unboxing conversions between
objectand native integer types [NativeIntegerTests.Conversions] -
IEquatable<nint> - PointerToVoid conversions between
void*and native integer types [NativeIntegerTests.Conversions] - Implicit/explicit nullable conversion from
AtoB?if implicit/explict conversion fromAtoB[NativeIntegerTests.Conversions] - Explicit nullable conversion from
A?toBif identity or implicit/explicit conversion fromAtoB[NativeIntegerTests.Conversions] - Explicit nullable conversion from from
A?toB?if implicit/explicit conversion fromAtoB[NativeIntegerTests.Conversions]
- Identity conversions between
- Built-in operators provided by the compiler: unary {
++,--,+,-,~}, binary {+,-,*,/,%,<,<=,>,>=,<<,>>,==,!=,|,&,^}- Operations are emitted directly using IL operators for native integers [NativeIntegerTests.{UnaryOperators, BinaryOperators}]
- Lifted operators provided by the compiler for the above [NativeIntegerTests.{UnaryOperators, BinaryOperators}]
- SemanticModel exposes fake operator method syms
- Overridiing, interface implementation, hiding consider native integers and underlying types as equivalent
- Overrides and interface implementations may differ by native integers and underlying types alone [NativeIntegerTests.Overrides_*]
- Overloads cannot differ by native integers and underlying types alone [NativeIntegerTests.Overloads_*]
- Methods hide other methods that differ by native integers and underlying types alone [NativeIntegerTests.Overloads_*]
- Type members from underlying types:
- Constructors from underlying types are hidden for
nintandnuint[NativeIntegerTests.ConstructorsAndOperators] - Operators from underlying types (including implicit and explicit conversion operators) are hidden for
nintandnuint[NativeIntegerTests.ConstructorsAndOperators] - Instance and static members from underlying types are hidden except for an explicit opt-in list [NativeIntegerTests.{InstanceMembers, StaticMembers}]
- Interfaces implemented by underlying types are implemented, with substitution for generic interfaces such as
IEquatable<IntPtr>[NativeIntegerTests.Interfaces] - Request
IComparable<nint>etc and we can expose it
- Constructors from underlying types are hidden for
- Type unification of interfaces that differ by native integers and underlying types
- No changes for
dynamic: runtime binding to underlying types only - Can be used as default parameter value [NativeIntegerTests.Constants_ParameterDefaults]
- Cannot be used as attribute argument (neither positional nor named arguments) [NativeIntegerTests.AttributeValue_*]
- Native integers cannot be used as
enumbase type - Native integer fields may be marked
volatile -
typeof(nint)istypeof(IntPtr) -
sizeof(nint)is supported in unsafe context only and is defined assizeof(IntPtr)notIntPtr.Size[NativeIntegerTests.SizeOf_*] - Compiler diagnostics refer to
nintandnuintrather than underlying types [NativeIntegerTests.ConstantConversions_*] -
SymbolDisplayusesnintandnuintalways regardless ofSymbolDisplayFormat[NativeIntegerTests.TypeDefinitions_FromMetadata] - Metadata representation uses
System.IntPtrandSystem.UIntPtrwith additionalNativeIntegerAttributeon containing type reference [AttributeTests_NativeInteger] - Doc for metadata representation in spec. NativeIntegerAttribute.md
- Public API allows:
- determine if
ITypeSymbolis native integer:ITypeSymbol.IsNativeInteger[NativeIntegerTests.TypeDefinitions_FromMetadata] - get underlying
INamedTypeSymbolfor native integer:INamedTypeSymbol.NativeIntegerUnderlyingType[NativeIntegerTests.TypeDefinitions_FromMetadata] - get signed and unsigned native integer
INamedTypeSymbolinstances from compilation:Compilation.CreateNativeIntegerTypeSymbol()[NativeIntegerTests.CreateNativeIntegerTypeSymbol_FromMetadata]
- determine if
-
Add(see Add NativeIntegerAttribute runtime#38683)NativeIntegerAttributedefinition to .NET 5.0 - ** The semantic model GetTypeInfo API should return the new types when appropriate, even when compiling at an older language version. Language behavior agrees with semantic model.
- The set of members of
nintandnuintas seen through the language is tested to be as specified. - The set of built-in operators as seen through the language is tested to be as specified.
- When using the built-in operators, they obey the appropriate checked/unchecked context for overflow, on platforms with 32-bit nints and 64-bit nints. [NativeIntegerTests.{UnaryOperators, BinaryOperators}]
- Test that constant folding works as specified (including checked/unchecked) [NativeIntegerTests.ConstantFolding]
- Test pattern-matching for nint constants, e.g.
o is (nint)1 - Test switching on a value of type
nint. Do we generate an ILswitchinstruction? - Test decoding of
nintin a modreq (we don't do it, intentional)
BCL
-
we should consider what Interlocked overloads the BCL/runtime should provide for those new types.
IDE Scenarios
- ** Completion offers nint and nuint (PR Add native integer keyword recommenders #42976)
- ** Highlight as keywords
- Generating syntax (issue Generating syntax for
nintandnuintshould use those keywords #42986)- Refactor to change var to nint (make explicit type)
- Generate override uses keyword
- Implement interface uses keyword
- View metadata as source works
- Extract local for subexpression (of type nint)
- Extract method that uses nint
- Offer langversion if you try to use nint/nuint (jcouv verified)
- Quick info
- Find all references for nint works like int (issue Recognize references for
nintandnuint#42988) - Go to definition of nint (goes to
IntPtr) - ?Symbol key and anything that depends on it?
Reactions are currently unavailable
Metadata
Metadata
Labels
Area-CompilersTestTest failures in roslyn-CITest failures in roslyn-CITest-GapDescribes a specific feature or scenario that does not have test coverageDescribes a specific feature or scenario that does not have test coverage