Skip to content

.NET: Use UnmanagedCallersOnlyAttribute instead of (or in addition to) MonoPInvokeCallbackAttribute #10470

@rolfbjarne

Description

@rolfbjarne

.NET 5/C# 9 has a new UnmanagedCallersOnlyAttribute, which we should start using instead of the MonoPInvokeCallbackAttribute (the main advantage is that the compiler will tell you if you use it wrong, as opposed to the MonoPInvokeCallbackAttribute, where the AOT compiler will crash and not tell you why if you use it wrong).

Ref: dotnet/runtime#47177

Using UnmanagedCallersOnlyAttribute for block callbacks is rather complex, and has been moved to a separate issue: #15783 (see #10470 (comment)).

Metadata

Metadata

Labels

dotnetAn issue or pull request related to .NET (6)enhancementThe issue or pull request is an enhancementiOSIssues affecting iOSmacOSIssues affecting macOSperformanceIf an issue or pull request is related to performance

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions