Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 7, 2025

The documentation for nint and nuint constants was misleading, as it only mentioned the 32-bit ranges without clarifying that these restrictions apply specifically to compile-time constants, not runtime values.

Problem

The original text stated:

You can use constant values in the following ranges:

  • For nint: Int32.MinValue to Int32.MaxValue.
  • For nuint: UInt32.MinValue to UInt32.MaxValue.

This was confusing because nint and nuint are native-sized integers that can have larger ranges at runtime on 64-bit platforms, but compile-time constants are always restricted to 32-bit ranges regardless of the target platform.

Solution

Updated the documentation to clarify the distinction:

While the full range of nint and nuint may be larger, compile-time constants are restricted to a 32-bit range:

  • For nint: Int32.MinValue to Int32.MaxValue.
  • For nuint: UInt32.MinValue to UInt32.MaxValue.

This change follows the recommendation from @tannergooding in the issue discussion and makes it clear that:

  • Runtime values of nint/nuint can use the full platform-dependent range
  • Compile-time constants are always limited to 32-bit ranges for portability

Fixes #24287.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/csharp/language-reference/builtin-types/integral-numeric-types.md docs/csharp/language-reference/builtin-types/integral-numeric-types

Copilot AI changed the title [WIP] nint and nuint types Constants specifies range for 32-bit process Fix nint/nuint constants documentation to clarify compile-time vs runtime ranges Jul 7, 2025
Copilot AI requested a review from BillWagner July 7, 2025 18:20
Copilot finished work on behalf of BillWagner July 7, 2025 18:20
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @copilot

This LGTM. It's ready for a final review.

@BillWagner BillWagner marked this pull request as ready for review July 8, 2025 14:00
@BillWagner BillWagner requested a review from a team as a code owner July 8, 2025 14:00
@BillWagner BillWagner requested a review from IEvangelist July 8, 2025 14:00
@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Jul 8, 2025
@BillWagner BillWagner enabled auto-merge (squash) July 8, 2025 14:03
@BillWagner BillWagner merged commit 2bde317 into main Jul 8, 2025
15 checks passed
@BillWagner BillWagner deleted the copilot/fix-24287 branch July 8, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dotnet-csharp/svc lang-reference/subsvc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nint and nuint types Constants specifies range for 32-bit process

3 participants