Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jjonescz
Copy link
Member

Test plan: #81207

Follow up on #81581 (i.e., still only for methods and properties).

Implements this speclet section: https://github.com/dotnet/csharplang/blob/80f7e032a3131f1d9c2c6822b8a03cf56eeda005/proposals/unsafe-evolution.md#compat-mode

@jjonescz jjonescz requested a review from a team as a code owner December 15, 2025 16:26
@jjonescz jjonescz requested review from 333fred and jcouv December 15, 2025 16:26
@jcouv jcouv self-assigned this Dec 15, 2025
@jjonescz jjonescz marked this pull request as draft December 16, 2025 12:34
@jjonescz jjonescz marked this pull request as ready for review December 16, 2025 14:56
return IsDeclaredRequiresUnsafe ? CallerUnsafeMode.Explicit : CallerUnsafeMode.None;
}

return this.HasParameterContainingPointerType() || ReturnType.ContainsPointerOrFunctionPointer()
Copy link
Member

@jcouv jcouv Dec 16, 2025

Choose a reason for hiding this comment

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

Can a pointer appear elsewhere in the signature? For instance, where T : I<int*[]>
Comment also applies to PEPropertySymbol: E.extension<T>(T).Property (with constraint like above) or E.extension(int*[]).Property (I saw that second example is already covered) may be scenarios

Copy link
Member Author

@jjonescz jjonescz Dec 17, 2025

Choose a reason for hiding this comment

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

I'm not sure that should be considered caller-unsafe in the compat mode, because calling such method wouldn't be considered unsafe previously either. Similarly we were discussing extern unsafe rule (I will add you to the chat.) @333fred thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated the speclet: dotnet/csharplang#9883
Will add tests for this too depending on what we decide (doesn't have to be a final decision of course).

Copy link
Member

Choose a reason for hiding this comment

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

Feels like we shouldn't do that. If the substituted type has a pointer in it, then it'll get marked as unsafe.

Copy link
Member Author

@jjonescz jjonescz Dec 18, 2025

Choose a reason for hiding this comment

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

I've updated the speclet: dotnet/csharplang#9883

Turns out the PR was stuck in GitHub UI, I've force-pushed to it and it should now be at the commit I was talking about.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

Done with review pass (commit 3)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

Done with review pass (commit 4). Only open question about unsafe constraints remains

@jjonescz jjonescz requested a review from 333fred December 17, 2025 18:01
@jjonescz
Copy link
Member Author

@AlekseyTs for a second review if you are available, thanks

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants