Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test plan for "numeric IntPtr" #60578

Closed
40 of 49 tasks
jcouv opened this issue Apr 5, 2022 · 3 comments
Closed
40 of 49 tasks

Test plan for "numeric IntPtr" #60578

jcouv opened this issue Apr 5, 2022 · 3 comments
Assignees
Milestone

Comments

@jcouv
Copy link
Member

jcouv commented Apr 5, 2022

Championed issue: dotnet/csharplang#6065
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-11.0/numeric-intptr.md

Compiler

  • Public API:
    • IsNativeIntegerType
    • CreateNativeIntegerTypeSymbol()
  • Built-in conversions are standard implicit and explicit (see PR Treat some nint/nuint conversions as standard conversions #61034)
  • Add TargetFramework.Net70 and use that for our tests (issue Add TargetFramework.Net70 #61463)
  • spec (PR)
  • Tied to runtime feature flag
  • Not tied to -langversion
  • No [NativeInteger] attributes emitted
  • Members defined on IntPtr/UIntPtr are available from IntPtr/UIntPtr and nint/nuint:
    • interfaces
    • static members
    • instance members
    • constructors
    • implicit and explicit conversion operators
    • overridden implementations: ToString(), GetHashCode(), Equals()
  • 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
    • breaking changes documented
  • Other scenarios called out by [Proposal]: First class native integer support csharplang#4385

BCL

Productivity

  • QuickInfo (validated manually in PR Unify nint and IntPtr #60913, but can't be unittested because IDE tests run on .NET 6 BCL)
  • Classification (SemanticClassifierTests.NativeInteger)
  • MetadataAsSource (MetadataAsSource.MetadataAsSourceTests+CSharp.TestNativeInteger)
  • Prefer keyword over full type name (UseExplicitTypeTests.InNativeIntIntrinsicType, this should follow the preference for built-in types)
  • Simplify type name
    • using x = System.IntPtr; should not simplify to nint
  • Update simplification defaults to suggest updating IntPtr to nint if that option is set
    • In cref: <see cref="nint"/>, <see cref="System.IntPtr"/> (completion issue, should offer to simplify to nint)
  • Simplify nint x = default(nint); to either nint x = default; or nint 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

@jcouv jcouv added this to the C# 11.0 milestone Apr 5, 2022
@jcouv jcouv self-assigned this Apr 5, 2022
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Apr 5, 2022
@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label Apr 5, 2022
@marek-safar
Copy link
Contributor

/cc @SamMonoRT

@jcouv
Copy link
Member Author

jcouv commented May 23, 2022

Feature was merged into 17.3p2

@cston
Copy link
Member

cston commented Oct 18, 2022

Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

5 participants