Skip to content

[Proposal] System.Runtime.CompilerServices.RuntimeFeature.UnmanagedCallKind #38135

@333fred

Description

@333fred

Background and Motivation

With .NET 5, we're going to be adding support for a new CallKind bit (tracked here: #38133). From the compiler side, we need a feature flag to know when the target platform supports that bit, so we can error in cases when it's not supported (like we do with DIMs).

Proposed API

namespace System.Runtime.CompilerServices
{
    public static partial class RuntimeFeature
    {
        /// <summary>
        /// Name of the Portable PDB feature.
        /// </summary>
        public const string PortablePdb = nameof(PortablePdb);
 
#if FEATURE_DEFAULT_INTERFACES
        /// <summary>
        /// Indicates that this version of runtime supports default interface method implementations.
        /// </summary>
        public const string DefaultImplementationsOfInterfaces = nameof(DefaultImplementationsOfInterfaces);
#endif

+       /// <summary>
+       /// Indicates that this version of runtime supports the platform default calling convention.
+       /// </summary>
+       public const string UnmanagedSignatureCallingConvention = nameof(UnmanagedSignatureCallingConvention);
 
        /// <summary>
        /// Checks whether a certain feature is supported by the Runtime.
        /// </summary>
        public static bool IsSupported(string feature)
        {
            switch (feature)
            {
                case PortablePdb:
+               case UnmanagedSignatureCallingConvention:
#if FEATURE_DEFAULT_INTERFACES
                case DefaultImplementationsOfInterfaces:
#endif
                    return true;
                case nameof(IsDynamicCodeSupported):
                    return IsDynamicCodeSupported;
                case nameof(IsDynamicCodeCompiled):
                    return IsDynamicCodeCompiled;
            }
 
            return false;
        }
    }
}

Usage Examples

In the C# compiler for determining errors.

Alternative Designs

N/A

Risks

N/A

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions