Repository navigation
Read IntPtr as nint where they are the same type - #107
Merged
Merged
Conversation
Since C# 11, on a runtime that has RuntimeFeature.NumericIntPtr (.NET 7 and later), IntPtr and nint are one type and the compiler no longer marks which a signature meant, so the reader showed every nint in a modern library as IntPtr. An assembly that targets .NET 7 or later, or a core library that declares NumericIntPtr itself, now reads them as nint and nuint; one for an older runtime keeps IntPtr where NativeIntegerAttribute does not say otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An .api file written before this reader has IntPtr where a new one has nint; they are one type to C# since 11, so comparing them is not a change, rather than a Minor one noted as nullability. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes one of the known gaps.
Since C# 11, on a runtime with
RuntimeFeature.NumericIntPtr(.NET 7 and later),IntPtrandnintare the same type. The compiler no longer emitsNativeIntegerAttribute, so the reader showed everynintin a modern library asIntPtr. The rule now:nintandnuint: an assembly whoseTargetFrameworkAttributesays .NET 7 or later, or a core library that declaresNumericIntPtritself.IntPtr: anything older, unlessNativeIntegerAttributesays otherwise, as before.The signatures sample now declares itself a .NET 11 build, as every SDK build does. Roslyn-compiled tests otherwise carry no target framework. The comparison now treats
nintandIntPtras the same type even when comparing exactly. Before this, a committed file withIntPtrcompared with a new one withnintwould have been reported as a Minor "nullability" change. A test covers it, and dropping that rule makes the test fail.Checks:
mise run cipasses, with 82 library tests and 630 tool tests, andapi/is unchanged.🤖 Generated with Claude Code