Skip to content

Update find-refs to find references to nint/nuint#67139

Merged
CyrusNajmabadi merged 3 commits intodotnet:mainfrom
CyrusNajmabadi:nintRefs
Mar 1, 2023
Merged

Update find-refs to find references to nint/nuint#67139
CyrusNajmabadi merged 3 commits intodotnet:mainfrom
CyrusNajmabadi:nintRefs

Conversation

@CyrusNajmabadi
Copy link
Contributor

Fixes #42988

Properly understands if nint/nuint are true aliases to IntPtr/UIntPtr or not depending on underlying framework.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner March 1, 2023 22:17
@ghost ghost added the Area-IDE label Mar 1, 2023
PredefinedType.String => SpecialType.System_String,
PredefinedType.DateTime => SpecialType.System_DateTime,
PredefinedType.IntPtr => SpecialType.System_IntPtr,
PredefinedType.UIntPtr => SpecialType.System_UIntPtr,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

last two lines are added.

{
void M()
{
$${|Reference:nint|} n1 = 1;
Copy link
Member

Choose a reason for hiding this comment

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

Why the behavior changes when CommonReferencesNet7=true?

Copy link
Member

Choose a reason for hiding this comment

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

Oh I just realize this is the design decision of .net 7

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:)

Copy link
Member

Choose a reason for hiding this comment

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

How does this actually work when the runtime is different? (i.e. I am surprised with how this work, are the symbols we get from the compiler side different?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the compiler produces different symbols. They differ with this property:

https://github.com/dotnet/roslyn/blob/main/src/Compilers/Core/Portable/Symbols/ITypeSymbol.cs#L82

On .net7 and above, both of these will return true for IsNativeIntegerType. Prior to .net 7, only nint/nuint would, and IntPtr/UIntPtr would return false.

@CyrusNajmabadi CyrusNajmabadi requested a review from Cosifne March 1, 2023 23:10
Copy link
Member

@Cosifne Cosifne left a comment

Choose a reason for hiding this comment

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

Some minor questions. Other than that lgtm

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge March 1, 2023 23:21
@CyrusNajmabadi CyrusNajmabadi merged commit 9590007 into dotnet:main Mar 1, 2023
@ghost ghost added this to the Next milestone Mar 1, 2023
@CyrusNajmabadi CyrusNajmabadi deleted the nintRefs branch March 1, 2023 23:49
@RikkiGibson RikkiGibson modified the milestones: Next, 17.6 P2 Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recognize references for nint and nuint

3 participants