-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-Interop-coreclr
Milestone
Description
Update This API's name has changed. See #35433.
The NativeCallableAttribute
should be made public since it will provide a symmetrical solution with the C# Function pointer proposal.
Proposed API
namespace System.Runtime.InteropServices
{
/// <summary>
/// Any method marked with <see cref="System.Runtime.InteropServices.NativeCallableAttribute" /> can be directly called from
/// native code. The function token can be loaded to a local variable using LDFTN
/// and passed as a callback to native method.
/// </summary>
/// <remarks>
/// Methods marked with this attribute have the following restrictions:
/// * Method must be marked "static".
/// * Must not be called from managed code.
/// * Must only have <see href="https://docs.microsoft.com/dotnet/framework/interop/blittable-and-non-blittable-types">blittable</see> arguments.
/// </remarks>
[AttributeUsage(AttributeTargets.Method)]
public sealed class NativeCallableAttribute : Attribute
{
public NativeCallableAttribute();
/// <summary>
/// Optional. If omitted, compiler will choose one for you.
/// </summary>
public CallingConvention CallingConvention;
/// <summary>
/// Optional. If omitted, then the method is native callable, but no export is emitted during AOT compilation.
/// </summary>
public string? EntryPoint;
}
}
Related:
- C# Function pointer concerns.
- COM Wrappers API.
- CoreCLR tests for usage examples.
jkotas, jkoritzinsky and andrew-boyarshin
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-Interop-coreclr