Skip to content

Commit cedda43

Browse files
BillWagnerjnm2Nigel-Ecma
authored
Apply suggestions from code review
Co-authored-by: Joseph Musser <me@jnm2.com> Co-authored-by: Nigel-Ecma <6654683+Nigel-Ecma@users.noreply.github.com>
1 parent 8519f77 commit cedda43

3 files changed

Lines changed: 8 additions & 22 deletions

File tree

standard/conversions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ This implicit conversion seemingly violates the advice in the beginning of [§10
322322
323323
An implicit constant expression conversion permits the following conversions:
324324
325-
- A *constant_expression* ([§12.25](expressions.md#1225-constant-expressions)) of type `int` can be converted to type `sbyte`, `byte`, `short`, `ushort`, `uint`, `nint`, `nuint`, or `ulong`, provided the value of the *constant_expression* is within the range of the destination type.
325+
- A *constant_expression* ([§12.25](expressions.md#1225-constant-expressions)) of type `int` can be converted to type `sbyte`, `byte`, `short`, `ushort`, `uint`, `nuint`, or `ulong`, provided the value of the *constant_expression* is within the range of the destination type.
326326
- A *constant_expression* of type `long` can be converted to type `ulong`, provided the value of the *constant_expression* is not negative.
327327
328328
The range for constants of type `nint` is the same range as `int`, and the range for constants of type `nuint` is the same range as `uint` ([§12.25](expressions.md#1225-constant-expressions)).

standard/expressions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ When overload resolution rules ([§12.6.4](expressions.md#1264-overload-resoluti
297297

298298
**This subclause is informative.**
299299

300-
Unary numeric promotion occurs for the operands of the predefined `+`, `-`, and `~` unary operators. Unary numeric promotion simply consists of converting operands of type `sbyte`, `byte`, `short`, `ushort`, or `char` to type `int`. Additionally, for the unary - operator, unary numeric promotion converts operands of type `uint` or `nint` to type `long`.
300+
Unary numeric promotion occurs for the operands of the predefined `+`, `-`, and `~` unary operators. Unary numeric promotion simply consists of converting operands of type `sbyte`, `byte`, `short`, `ushort`, or `char` to type `int`. Additionally, for the unary `-` operator, unary numeric promotion converts operands of type `uint` or `nint` to type `long`.
301301

302302
**End of informative text.**
303303

@@ -7055,7 +7055,7 @@ A constant expression may be either a value type or a reference type. If a const
70557055
- have a value of `null`; or
70567056
- be a default value expression ([§12.8.21](expressions.md#12821-default-value-expressions)) of reference type.
70577057

7058-
A *constant_expression* of type `nint` shall have a value in the range \[`int.MinValue`,`int.MaxValue`\]. A *constant_expression* of type `nuint` shall have a value in the range \[`uint.MinValue`,`uint.MaxValue`\].
7058+
A *constant_expression* of type `nint` shall have a value in the range \[-2147483648, 2147483647\]. A *constant_expression* of type `nuint` shall have a value in the range \[0, 4294967295\].
70597059

70607060
Only the following constructs are permitted in constant expressions:
70617061

standard/types.md

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -319,27 +319,13 @@ Every simple type has members. Each simple type that is an alias for a predefine
319319
>
320320
> *end note*.
321321
322-
<!-- C# 11: In C# 11, nint and nuint become true aliases for System.IntPtr and System.UIntPtr.
323-
The following paragraphs describing the non-alias relationship should be updated or removed. -->
322+
<!-- C# 11: In C# 11, nint and nuint become true aliases for System.IntPtr and System.UIntPtr. The following paragraphs describing the non-alias relationship should be updated or removed. -->
324323
325-
Although `nint` and `nuint` are represented by the types `System.IntPtr` and `System.UIntPtr`, respectively, `nint` and `nuint` are *not* aliases for those types. There is an identity conversion ([§10.2.2](conversions.md#1022-identity-conversion)) between `nint` and `System.IntPtr`, and between `nuint` and `System.UIntPtr`.
324+
The types `nint` and `nuint` are represented by the types `System.IntPtr` and `System.UIntPtr`, respectively, and are *not* aliases for these types. In this context being *represented by* means:
326325
327-
The language provides conversions ([§10.2](conversions.md#102-implicit-conversions)), unary operators ([§12.9](expressions.md#129-unary-operators)), and binary operators ([§12.12](expressions.md#1212-arithmetic-operators)) for `nint` and `nuint` that are appropriate for integral types. These operators follow the same patterns as the corresponding operators for `int`/`long` and `uint`/`ulong`.
328-
329-
> *Note*: Operations performed through `dynamic` binding on `System.IntPtr` and `System.UIntPtr` values do not have access to the `nint` and `nuint` operators. *end note*
330-
331-
`sizeof(nint)` and `sizeof(nuint)` return the size of a native integer ([§23.6.9](unsafe-code.md#2369-the-sizeof-operator)).
332-
333-
`typeof(nint)` is `typeof(System.IntPtr)`, and `typeof(nuint)` is `typeof(System.UIntPtr)`.
334-
335-
<!-- C# 11: The following three paragraphs about overriding/hiding equivalence can be removed
336-
when nint/nuint become true aliases for IntPtr/UIntPtr. -->
337-
338-
`nint` and `System.IntPtr`, and `nuint` and `System.UIntPtr`, are considered equivalent for overriding, hiding, and implementing.
339-
340-
Overloads cannot differ by `nint` and `System.IntPtr`, or by `nuint` and `System.UIntPtr`, alone. However, overrides and implementations may differ by `nint` and `System.IntPtr`, or by `nuint` and `System.UIntPtr`, alone.
341-
342-
Methods hide other methods that differ by `nint` and `System.IntPtr`, or by `nuint` and `System.UIntPtr`, alone.
326+
- The only members directly accessible for `nint` and `nuint` are the required methods of `Object` ([§C.2](standard-library.md#c2-standard-library-types-defined-in-isoiec-23271)). Any other members of System.IntPtr` and `System.UIntPtr` may be accessed via those types.
327+
- Operations performed through `dynamic` binding on `System.IntPtr` and `System.UIntPtr` values do not have access to the `nint` and `nuint` operators.
328+
- In all other respects `nint` and `nuint` behave as if they are aliases of `System.IntPtr` and `System.UIntPtr`.
343329
344330
### 8.3.6 Integral types
345331

0 commit comments

Comments
 (0)