Unsafe evolution: implement compat mode#81701
Conversation
| return IsDeclaredRequiresUnsafe ? CallerUnsafeMode.Explicit : CallerUnsafeMode.None; | ||
| } | ||
|
|
||
| return this.HasParameterContainingPointerType() || ReturnType.ContainsPointerOrFunctionPointer() |
There was a problem hiding this comment.
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 (I saw that second example is already covered) may be scenarios #ClosedE.extension(int*[]).Property
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Feels like we shouldn't do that. If the substituted type has a pointer in it, then it'll get marked as unsafe.
There was a problem hiding this comment.
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.
jcouv
left a comment
There was a problem hiding this comment.
Done with review pass (commit 3)
jcouv
left a comment
There was a problem hiding this comment.
Done with review pass (commit 4). Only open question about unsafe constraints remains
|
@AlekseyTs for a second review if you are available, thanks |
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