-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Runtime.CompilerServices
Milestone
Description
Background and motivation
As part of the statics in interfaces and numerics work, the IntPtr and UIntPtr types are going to be expanded and become numeric types.
This API request is to help Roslyn recognize platforms where it should treat nint/nuint as aliases for IntPtr/UIntPtr (tracking feature).
API Proposal
namespace System.Runtime.CompilerServices
{
public static partial class RuntimeFeature
{
+ /// <summary>
+ /// The presence of this field indicates a runtime where `System.IntPtr`/`System.UIntPtr` are numeric types.
+ /// </summary>
+ public const string NumericIntPtr = nameof(NumericIntPtr);
}
}API Usage
Used by Roslyn to detect if a runtime supports numeric IntPtr/UIntPtr types.
Alternative Designs
A conceivable alternative would be to look at some API markers on the IntPtr type (for example, does it implement a given numeric interface).
But a runtime feature flag is the preferred/typical way to indicate a feature to Roslyn.
In terms of names, some other options are UnifiedIntPtr or PrimitiveIntPtr.
Risks
None
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Runtime.CompilerServices