-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtime.InteropServices
Milestone
Description
Background and motivation
Some funcs are only used for native interop with static libraries and we don't want them exported, so we need a new field to UnmanagedCallersOnlyAttribute to control whether the method is exported.
API Proposal
[System.AttributeUsageAttribute(System.AttributeTargets.Method, Inherited = false)]
public sealed class UnmanagedCallersOnlyAttribute : System.Attribute
{
public UnmanagedCallersOnlyAttribute() { }
public System.Type[]? CallConvs;
public string? EntryPoint;
+ public bool Export = true;
}API Usage
[UnmanagedCallersOnly(EntryPoint = "InternalSum", Export = false)]
public static int InternalSum(int a, int b) => a + b;extern "C" int InternalSum(int a, int b);
extern "C" __declspec(dllexport) capi_get_number() {
return InternalSum(114, 514);
}Alternative Designs
No response
Risks
No response
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Runtime.InteropServices
Type
Projects
Status
No status