Skip to content

Use nint for native-sized integers in Marshal #11652

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

Merged
merged 1 commit into from
Aug 5, 2025

Conversation

xtqqczze
Copy link
Contributor

@xtqqczze xtqqczze commented Aug 5, 2025

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit 369ed46 into dotnet:main Aug 5, 2025
6 checks passed
@jkotas
Copy link
Member

jkotas commented Aug 5, 2025

This is the first place that where MemberSignature Language="C#" uses nint instead IntPtr in this repo. @gewarren Are there any non-obvious consequences?

@xtqqczze
Copy link
Contributor Author

xtqqczze commented Aug 5, 2025

This is the first place that where MemberSignature Language="C#" uses nint instead IntPtr in this repo. @gewarren Are there any non-obvious consequences?

nint is used for Math.Abs, but with a FrameworkAlternate attribute. Since nint/nuint become full aliases to IntPtr/UIntPtr in .NET 7 this suggests there could be consequences.

<MemberSignature Language="C#" Value="public static IntPtr Abs (IntPtr value);" FrameworkAlternate="net-10.0;net-7.0;net-8.0;net-9.0" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig native int Abs(native int value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Math.Abs(System.IntPtr)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Abs (value As IntPtr) As IntPtr" />
<MemberSignature Language="F#" Value="static member Abs : nativeint -&gt; nativeint" Usage="System.Math.Abs value" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; static IntPtr Abs(IntPtr value);" />
<MemberSignature Language="C#" Value="public static nint Abs (nint value);" FrameworkAlternate="net-6.0" />

xtqqczze added a commit to xtqqczze/dotnet-api-docs that referenced this pull request Aug 5, 2025
Use `nint`/`nuint` from .NET 7 to clarify intent; they became full aliases to `IntPtr`/`UIntPtr` from this version.

Follow-up dotnet#11652
@xtqqczze xtqqczze deleted the nint-Marshal branch August 5, 2025 17:03
@gewarren
Copy link
Contributor

gewarren commented Aug 5, 2025

This is the first place that where MemberSignature Language="C#" uses nint instead IntPtr in this repo. @gewarren Are there any non-obvious consequences?

@jkotas The member signatures are autogenerated and will be overwritten. I'm not sure if the autogenerated signature will be the same as the change that was merged here, or if this user story (which was bulk removed in June :-( ) will prevent the proper display.

xtqqczze added a commit to xtqqczze/dotnet-api-docs that referenced this pull request Aug 5, 2025
jkotas pushed a commit that referenced this pull request Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Runtime.InteropServices community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants