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
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
namespaceSystem.Runtime.CompilerServices{publicstaticpartialclassRuntimeFeature{/// <summary>/// Name of the Portable PDB feature./// </summary>publicconststringPortablePdb=nameof(PortablePdb);
#if FEATURE_DEFAULT_INTERFACES/// <summary>/// Indicates that this version of runtime supports default interface method implementations./// </summary>publicconststringDefaultImplementationsOfInterfaces=nameof(DefaultImplementationsOfInterfaces);
#endif
+/// <summary>+/// Indicates that this version of runtime supports the platform default calling convention.+/// </summary>+publicconststringUnmanagedSignatureCallingConvention=nameof(UnmanagedSignatureCallingConvention);/// <summary>/// Checks whether a certain feature is supported by the Runtime./// </summary>publicstaticboolIsSupported(stringfeature){switch(feature){casePortablePdb:+case UnmanagedSignatureCallingConvention:
#if FEATURE_DEFAULT_INTERFACEScase DefaultImplementationsOfInterfaces:
#endif
returntrue;case nameof(IsDynamicCodeSupported):returnIsDynamicCodeSupported;casenameof(IsDynamicCodeCompiled):return IsDynamicCodeCompiled;}returnfalse;}}}
Would it make sense to attach this feature to the presence of UnmanagedCallersOnlyAttribute in the compiler instead of adding this? It is all one bundle of features.
If we decide to go ahead with this, the name should be synchronized with the name from #38133, e.g. RuntimeFeature.UnmanagedSignatureCallingConvention. There is no "Kind" in the other name.
I agree with @jkotas. RuntimeFeatures is intended for cases where there is no managed API the compiler could key this off of. In this case it seems the availability of the attribute is sufficient.
In this case it seems the availability of the attribute is sufficient
This would require any runtime that supports the new unmanaged calling convention bit (#38133) to also support UnmanagedCallersOnlyAttribute. I don't think that is necessarily bad, just wanted to ensure it was called out.
Would it make sense to attach this feature to the presence of UnmanagedCallersOnlyAttribute in the compiler instead of adding this? It is all one bundle of features.
Well, it seems inconsistent to me. The fact that the runtime is implementing UmanagedCallersOnlyAttribute at the same time doesn't feel particularly relevant to the calling convention support. For features we key off a type, those types are usually actually relevant to the feature. The presence of IAsyncEnumerable, for example. But being able to write delegate* unmanaged<void> doesn't feel very related to the presence of UnmanagedCallersOnlyAttribute.
This would require any runtime that supports the new unmanaged calling convention bit (#38133) to also support UnmanagedCallersOnlyAttribute. I don't think that is necessarily bad, just wanted to ensure it was called out.
Exactly. It's not necessarily bad, but it feels odd to require these to be tied together when it's a very simple and small API addition to not do so.
If we decide to go ahead with this, the name should be synchronized with the name from #38133, e.g. RuntimeFeature.UnmanagedSignatureCallingConvention. There is no "Kind" in the other name.
The fact that the runtime is implementing UmanagedCallersOnlyAttribute at the same time doesn't feel particularly relevant to the calling convention support.
I believe that there are number of feature bundles that can be more fine grained in theory, but are not for simplicity - to avoid dealing with the theoretical combinations that you have one, but not the other.
For example, static methods on interfaces are tied together with default implementations of interfaces, even though they are fairly independent features. In fact, static methods on interfaces were supported by the runtime since forever, and default implementations of interfaces were added just recently.
I agree with @jkotas. RuntimeFeatures is intended for cases where there is no managed API the compiler could key this off of. In this case it seems the availability of the attribute is sufficient.
If that's the litmus test, should we reconsider RuntimeFeature.CovariantReturnsOfClasses? Since that one can be deduced from the presence of PreserveBaseOverridesAttribute - #35315 (comment). Roslyn is already aware of that attribute since the attribute was a compiler request.
We considered keying it off of the presence of the attribute but the attribute isn't the same feature. Also, the compiler would want the type to exist in corlib (to ensure it's not user defined). That would feel odd, considering all modifiers live in System.Runtime.InteropServices.dll.
We agree that making that RuntimeFeature a dumping ground for all new compiler features would be bad, but it seems runtime type system constraints would be long to RuntimeFeature.
Activity
jkotas commentedon Jun 19, 2020
Would it make sense to attach this feature to the presence of
UnmanagedCallersOnlyAttributein the compiler instead of adding this? It is all one bundle of features.jkotas commentedon Jun 19, 2020
If we decide to go ahead with this, the name should be synchronized with the name from #38133, e.g.
RuntimeFeature.UnmanagedSignatureCallingConvention. There is no "Kind" in the other name.terrajobst commentedon Jun 19, 2020
I agree with @jkotas.
RuntimeFeaturesis intended for cases where there is no managed API the compiler could key this off of. In this case it seems the availability of the attribute is sufficient.tannergooding commentedon Jun 19, 2020
This would require any runtime that supports the new
unmanagedcalling convention bit (#38133) to also supportUnmanagedCallersOnlyAttribute. I don't think that is necessarily bad, just wanted to ensure it was called out.333fred commentedon Jun 19, 2020
Well, it seems inconsistent to me. The fact that the runtime is implementing
UmanagedCallersOnlyAttributeat the same time doesn't feel particularly relevant to the calling convention support. For features we key off a type, those types are usually actually relevant to the feature. The presence ofIAsyncEnumerable, for example. But being able to writedelegate* unmanaged<void>doesn't feel very related to the presence ofUnmanagedCallersOnlyAttribute.Exactly. It's not necessarily bad, but it feels odd to require these to be tied together when it's a very simple and small API addition to not do so.
333fred commentedon Jun 19, 2020
Updated.
jkotas commentedon Jun 19, 2020
I believe that there are number of feature bundles that can be more fine grained in theory, but are not for simplicity - to avoid dealing with the theoretical combinations that you have one, but not the other.
For example, static methods on interfaces are tied together with default implementations of interfaces, even though they are fairly independent features. In fact, static methods on interfaces were supported by the runtime since forever, and default implementations of interfaces were added just recently.
MichalStrehovsky commentedon Jun 22, 2020
If that's the litmus test, should we reconsider
RuntimeFeature.CovariantReturnsOfClasses? Since that one can be deduced from the presence of PreserveBaseOverridesAttribute - #35315 (comment). Roslyn is already aware of that attribute since the attribute was a compiler request.terrajobst commentedon Jul 2, 2020
Video
System.Runtime.InteropServices.dll.RuntimeFeaturea dumping ground for all new compiler features would be bad, but it seems runtime type system constraints would be long toRuntimeFeature.