You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LibraryImport methods should be implicitly RequiresUnsafe #125801
Methods attributed with LibraryImportAttribute are implicitly unsafe. Although the marshalling logic could be analyzed to be considered memory-safe, the compiler cannot validate that the underlying externDllImport is targeting a method with a valid signature.
Today, the stubs generated by LibraryImportGenerator will not generate the RequiresUnsafeAttribute on the produced stubs. This causes inconsistency with stubs that have no marshalling (they are just a raw DllImport, which is extern).
The LibraryImportGenerator should add the RequiresUnsafeAttribute to all generated stubs to provide a consistent experience.
Activity
dotnet-policy-service commentedon Mar 19, 2026
Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.
dotnet-policy-service commentedon Apr 13, 2026
Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.
AaronRobinsonMSFT commentedon Jul 15, 2026
Moved this to .NET 12. @jkoritzinsky if you can do this in .NET 11 that is also fine.
jkoritzinsky commentedon Jul 20, 2026
Closing this as we're taking a different approach (see dotnet/roslyn#84555)