Skip to content

C#: Improve the unsafe predicate on Modifiable. #12370

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 5 commits into from
Mar 8, 2023

Conversation

michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Mar 2, 2023

It turns out that the unsafe keyword is discarded during compilation, which means that when extracting from referenced assemblies, we are not able to identify whether a member is unsafe.
The compiler requires methods, delegates and properties that make any use of pointer like types is declared unsafe.
As this might not be that relevant for our queries it is relevant for stub generation.

One example of a nasty delegate type declared in .NET Runtime (ie. a delegate with a delagate* (function pointer) return type).

// Generated from `System.Runtime.InteropServices.ObjectiveC.ObjectiveCMarshal+UnhandledExceptionPropagationHandler` in `System.Runtime.InteropServices, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a`
unsafe public delegate delegate* unmanaged<System.IntPtr, void> UnhandledExceptionPropagationHandler(System.Exception exception, System.RuntimeMethodHandle lastMethod, out System.IntPtr context);

@michaelnebel michaelnebel requested review from hvitved and removed request for hvitved March 2, 2023 13:49
@michaelnebel michaelnebel force-pushed the csharp/unsafemember branch from 88df0ea to bae0892 Compare March 3, 2023 14:06
@michaelnebel michaelnebel force-pushed the csharp/unsafemember branch from bae0892 to 4ab627b Compare March 7, 2023 09:37
@michaelnebel michaelnebel force-pushed the csharp/unsafemember branch from 4ab627b to f070065 Compare March 7, 2023 10:31
@michaelnebel michaelnebel marked this pull request as ready for review March 7, 2023 10:36
@michaelnebel michaelnebel requested a review from a team as a code owner March 7, 2023 10:37
@michaelnebel michaelnebel force-pushed the csharp/unsafemember branch from f070065 to 0714310 Compare March 8, 2023 09:15
@michaelnebel michaelnebel merged commit 6adc04e into github:main Mar 8, 2023
@michaelnebel michaelnebel deleted the csharp/unsafemember branch March 8, 2023 12:48
@michaelnebel
Copy link
Contributor Author

DCA looks good.

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