dotnet / dotnet/linker

Private ctors are trimmed despite use in Marshal.GetDelegateForFunctionPointer

Open
#1,660 3 comments 0 reactions 0 assignees View on GitHub
area-Linker: Steps
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

I have a private SafeHandle ctor that is being trimmed, despite me using it in a delegate type passed to Marshal.GetDelegateForFunctionPointer, which has an `out MySafeHandle` parameter.

My code is failing on this line:

https://github.com/scalablecory/runtime/blob/720f3d7c3c60506f70123149c1a67a4a71aa81fc/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs#L60-L62

With the delegate looking like:

https://github.com/scalablecory/runtime/blob/720f3d7c3c60506f70123149c1a67a4a71aa81fc/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/MsQuicNativeMethods.cs#L76-L79

And the safe handle's private ctor:

https://github.com/scalablecory/runtime/blob/720f3d7c3c60506f70123149c1a67a4a71aa81fc/src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/SafeMsQuicRegistrationHandle.cs#L12-L14

Current workaround is to use `DynamicDependency`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.