NativeCallableAttribute to UnmanagedCallersOnlyAttribute (#35592)
authorAaron Robinson <arobins@microsoft.com>
Wed, 29 Apr 2020 06:00:39 +0000 (23:00 -0700)
committerGitHub <noreply@github.com>
Wed, 29 Apr 2020 06:00:39 +0000 (23:00 -0700)
* NativeCallableAttribute to UnmanagedCallersOnlyAttribute

Replace NativeCallableAttribute usage with UnmanagedCallersOnlyAttribute.
Update tests.
Update coreclr implementation to reflect new name.

44 files changed:
src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs
src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs
src/coreclr/src/inc/corcompile.h
src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs
src/coreclr/src/tools/Common/TypeSystem/CodeGen/MethodDelegator.CodeGen.cs
src/coreclr/src/tools/Common/TypeSystem/CodeGen/MethodDesc.CodeGen.cs
src/coreclr/src/tools/Common/TypeSystem/Common/ExceptionStringID.cs
src/coreclr/src/tools/Common/TypeSystem/Ecma/EcmaMethod.cs
src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
src/coreclr/src/vm/cgensys.h
src/coreclr/src/vm/classnames.h
src/coreclr/src/vm/comdelegate.cpp
src/coreclr/src/vm/compile.cpp
src/coreclr/src/vm/compile.h
src/coreclr/src/vm/corhost.cpp
src/coreclr/src/vm/dllimportcallback.cpp
src/coreclr/src/vm/eetwain.cpp
src/coreclr/src/vm/excep.cpp
src/coreclr/src/vm/exceptionhandling.cpp
src/coreclr/src/vm/frames.h
src/coreclr/src/vm/gccover.cpp
src/coreclr/src/vm/i386/umthunkstub.S
src/coreclr/src/vm/ilstubcache.cpp
src/coreclr/src/vm/jitinterface.cpp
src/coreclr/src/vm/method.cpp
src/coreclr/src/vm/method.hpp
src/coreclr/src/vm/prestub.cpp
src/coreclr/src/vm/tieredcompilation.cpp
src/coreclr/src/vm/wellknownattributes.h
src/coreclr/src/zap/zapimport.cpp
src/coreclr/src/zap/zapinfo.cpp
src/coreclr/tests/src/Interop/CMakeLists.txt
src/coreclr/tests/src/Interop/NativeCallable/CMakeLists.txt [deleted file]
src/coreclr/tests/src/Interop/UnmanagedCallersOnly/CMakeLists.txt [new file with mode: 0644]
src/coreclr/tests/src/Interop/UnmanagedCallersOnly/UnmanagedCallersOnlyDll.cpp [moved from src/coreclr/tests/src/Interop/NativeCallable/NativeCallableDll.cpp with 100% similarity]
src/coreclr/tests/src/Interop/UnmanagedCallersOnly/UnmanagedCallersOnlyTest.cs [moved from src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.cs with 65% similarity]
src/coreclr/tests/src/Interop/UnmanagedCallersOnly/UnmanagedCallersOnlyTest.csproj [moved from src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.csproj with 90% similarity]
src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Nls.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Nls.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CallingConvention.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/UnmanagedCallersOnlyAttribute.cs [moved from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeCallableAttribute.cs with 82% similarity]
src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs

index 8f7d8ec..2b6c9b7 100644 (file)
@@ -231,7 +231,7 @@ namespace Internal.Runtime.InteropServices
         /// </summary>
         /// <param name="pCxtInt">Pointer to a <see cref="ComActivationContextInternal"/> instance</param>
         [CLSCompliant(false)]
-        [NativeCallable]
+        [UnmanagedCallersOnly]
         public static unsafe int GetClassFactoryForTypeInternal(ComActivationContextInternal* pCxtInt)
         {
             ref ComActivationContextInternal cxtInt = ref *pCxtInt;
@@ -268,7 +268,7 @@ $@"{nameof(GetClassFactoryForTypeInternal)} arguments:
         /// </summary>
         /// <param name="pCxtInt">Pointer to a <see cref="ComActivationContextInternal"/> instance</param>
         [CLSCompliant(false)]
-        [NativeCallable]
+        [UnmanagedCallersOnly]
         public static unsafe int RegisterClassForTypeInternal(ComActivationContextInternal* pCxtInt)
         {
             ref ComActivationContextInternal cxtInt = ref *pCxtInt;
@@ -308,7 +308,7 @@ $@"{nameof(RegisterClassForTypeInternal)} arguments:
         /// Internal entry point for unregistering a managed COM server API from native code
         /// </summary>
         [CLSCompliant(false)]
-        [NativeCallable]
+        [UnmanagedCallersOnly]
         public static unsafe int UnregisterClassForTypeInternal(ComActivationContextInternal* pCxtInt)
         {
             ref ComActivationContextInternal cxtInt = ref *pCxtInt;
index ac47d03..1c25db0 100644 (file)
@@ -47,7 +47,7 @@ namespace Internal.Runtime.InteropServices
         /// <param name="delegateTypeNative">Assembly qualified delegate type name</param>
         /// <param name="reserved">Extensibility parameter (currently unused)</param>
         /// <param name="functionHandle">Pointer where to store the function pointer result</param>
-        [NativeCallable]
+        [UnmanagedCallersOnly]
         public static int LoadAssemblyAndGetFunctionPointer(IntPtr assemblyPathNative,
                                                             IntPtr typeNameNative,
                                                             IntPtr methodNameNative,
index a14a979..2973b7a 100644 (file)
@@ -1728,8 +1728,8 @@ class ICorCompileInfo
     // to 1 on the clone. The buffer has to be large enough to hold the stub object and the code
     virtual HRESULT GetStubClone(void *pStub, BYTE *pBuffer, DWORD dwBufferSize) = 0;
 
-    // true if the method has [NativeCallableAttribute]
-    virtual BOOL IsNativeCallableMethod(CORINFO_METHOD_HANDLE handle) = 0;
+    // true if the method has [UnmanagedCallersOnlyAttribute]
+    virtual BOOL IsUnmanagedCallersOnlyMethod(CORINFO_METHOD_HANDLE handle) = 0;
 
     virtual BOOL GetIsGeneratingNgenPDB() = 0;
     virtual void SetIsGeneratingNgenPDB(BOOL fGeneratingNgenPDB) = 0;
index 66f33ea..aefad66 100644 (file)
@@ -2623,7 +2623,7 @@ namespace Internal.JitInterface
 
             if (funcKind == CorJitFuncKind.CORJIT_FUNC_ROOT)
             {
-                if (this.MethodBeingCompiled.IsNativeCallable)
+                if (this.MethodBeingCompiled.IsUnmanagedCallersOnly)
                     flags |= FrameInfoFlags.ReversePInvoke;
             }
 
@@ -2912,12 +2912,12 @@ namespace Internal.JitInterface
             if (targetArchitecture == TargetArchitecture.ARM && !_compilation.TypeSystemContext.Target.IsWindows)
                 flags.Set(CorJitFlag.CORJIT_FLAG_RELATIVE_CODE_RELOCS);
 
-            if (this.MethodBeingCompiled.IsNativeCallable)
+            if (this.MethodBeingCompiled.IsUnmanagedCallersOnly)
             {
 #if READYTORUN
                 if (targetArchitecture == TargetArchitecture.X86)
                 {
-                    throw new RequiresRuntimeJitException("ReadyToRun: Methods with NativeCallableAttribute not implemented");
+                    throw new RequiresRuntimeJitException("ReadyToRun: Methods with UnmanagedCallersOnlyAttribute not implemented");
                 }
 #endif
 
index 7091ea8..afee75c 100644 (file)
@@ -78,11 +78,11 @@ namespace Internal.TypeSystem
             }
         }
 
-        public override bool IsNativeCallable
+        public override bool IsUnmanagedCallersOnly
         {
             get
             {
-                return _wrappedMethod.IsNativeCallable;
+                return _wrappedMethod.IsUnmanagedCallersOnly;
             }
         }
 
index 5884f1d..b15a81d 100644 (file)
@@ -122,7 +122,7 @@ namespace Internal.TypeSystem
         /// Gets a value specifying whether this method is directly callable
         /// by external unmanaged code.
         /// </summary>
-        public virtual bool IsNativeCallable
+        public virtual bool IsUnmanagedCallersOnly
         {
             get
             {
@@ -230,11 +230,11 @@ namespace Internal.TypeSystem
             }
         }
 
-        public override bool IsNativeCallable
+        public override bool IsUnmanagedCallersOnly
         {
             get
             {
-                return _methodDef.IsNativeCallable;
+                return _methodDef.IsUnmanagedCallersOnly;
             }
         }
 
@@ -322,11 +322,11 @@ namespace Internal.TypeSystem
             }
         }
 
-        public override bool IsNativeCallable
+        public override bool IsUnmanagedCallersOnly
         {
             get
             {
-                return _typicalMethodDef.IsNativeCallable;
+                return _typicalMethodDef.IsUnmanagedCallersOnly;
             }
         }
 
index 9c0ef31..d510e79 100644 (file)
@@ -31,7 +31,7 @@ namespace Internal.TypeSystem
         InvalidProgramSpecific,
         InvalidProgramVararg,
         InvalidProgramCallVirtFinalize,
-        InvalidProgramNativeCallable,
+        InvalidProgramUnmanagedCallersOnly,
         InvalidProgramCallAbstractMethod,
         InvalidProgramCallVirtStatic,
         InvalidProgramNonStaticMethod,
index 6d1aa8a..d4e0fbd 100644 (file)
@@ -30,7 +30,7 @@ namespace Internal.TypeSystem.Ecma
 
             public const int AttributeMetadataCache = 0x02000;
             public const int Intrinsic              = 0x04000;
-            public const int NativeCallable         = 0x08000;
+            public const int UnmanagedCallersOnly   = 0x08000;
             public const int RuntimeExport          = 0x10000;
         };
 
@@ -197,9 +197,9 @@ namespace Internal.TypeSystem.Ecma
                     else
                     if (metadataReader.StringComparer.Equals(namespaceHandle, "System.Runtime.InteropServices"))
                     {
-                        if (metadataReader.StringComparer.Equals(nameHandle, "NativeCallableAttribute"))
+                        if (metadataReader.StringComparer.Equals(nameHandle, "UnmanagedCallersOnlyAttribute"))
                         {
-                            flags |= MethodFlags.NativeCallable;
+                            flags |= MethodFlags.UnmanagedCallersOnly;
                         }
                     }
                     else
@@ -334,11 +334,11 @@ namespace Internal.TypeSystem.Ecma
             }
         }
 
-        public override bool IsNativeCallable
+        public override bool IsUnmanagedCallersOnly
         {
             get
             {
-                return (GetMethodFlags(MethodFlags.AttributeMetadataCache | MethodFlags.NativeCallable) & MethodFlags.NativeCallable) != 0;
+                return (GetMethodFlags(MethodFlags.AttributeMetadataCache | MethodFlags.UnmanagedCallersOnly) & MethodFlags.UnmanagedCallersOnly) != 0;
             }
         }
 
index 5c59632..6f4d548 100644 (file)
@@ -1154,7 +1154,7 @@ namespace Internal.JitInterface
             }
 
             if ((flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_LDFTN) != 0
-                && originalMethod.IsNativeCallable)
+                && originalMethod.IsUnmanagedCallersOnly)
             {
                 if (!originalMethod.Signature.IsStatic) // Must be a static method
                 {
@@ -1534,9 +1534,9 @@ namespace Internal.JitInterface
                 out useInstantiatingStub);
 
             var targetDetails = _compilation.TypeSystemContext.Target;
-            if (targetDetails.Architecture == TargetArchitecture.X86 && targetMethod.IsNativeCallable)
+            if (targetDetails.Architecture == TargetArchitecture.X86 && targetMethod.IsUnmanagedCallersOnly)
             {
-                throw new RequiresRuntimeJitException("ReadyToRun: References to methods with NativeCallableAttribute not implemented");
+                throw new RequiresRuntimeJitException("ReadyToRun: References to methods with UnmanagedCallersOnlyAttribute not implemented");
             }
 
             if (pResult->thisTransform == CORINFO_THIS_TRANSFORM.CORINFO_BOX_THIS)
index 047725c..17213af 100644 (file)
@@ -46,7 +46,7 @@ enum class CallerGCMode
 {
     Unknown,
     Coop,
-    Preemptive    // (e.g. NativeCallableAttribute)
+    Preemptive    // (e.g. UnmanagedCallersOnlyAttribute)
 };
 
 // Non-CPU-specific helper functions called by the CPU-dependent code
index 1aec1ce..8385bf4 100644 (file)
 #define g_CompilerServicesIntrinsicAttribute "System.Runtime.CompilerServices.IntrinsicAttribute"
 #define g_UnmanagedFunctionPointerAttribute "System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute"
 #define g_DefaultDllImportSearchPathsAttribute "System.Runtime.InteropServices.DefaultDllImportSearchPathsAttribute"
-#define g_NativeCallableAttribute "System.Runtime.InteropServices.NativeCallableAttribute"
+#define g_UnmanagedCallersOnlyAttribute "System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute"
 #define g_FixedBufferAttribute "System.Runtime.CompilerServices.FixedBufferAttribute"
 
 #define g_CompilerServicesTypeDependencyAttribute "System.Runtime.CompilerServices.TypeDependencyAttribute"
index 52e55a3..791421c 100644 (file)
@@ -1153,18 +1153,18 @@ PCODE COMDelegate::ConvertToCallback(MethodDesc* pMD)
 
 #if !defined(FEATURE_STUBS_AS_IL)
 
-    // System.Runtime.InteropServices.NativeCallableAttribute
+    // System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute
     BYTE* pData = NULL;
     LONG cData = 0;
     CorPinvokeMap callConv = (CorPinvokeMap)0;
 
-    HRESULT hr = pMD->GetCustomAttribute(WellKnownAttribute::NativeCallable, (const VOID **)(&pData), (ULONG *)&cData);
+    HRESULT hr = pMD->GetCustomAttribute(WellKnownAttribute::UnmanagedCallersOnly, (const VOID **)(&pData), (ULONG *)&cData);
     IfFailThrow(hr);
 
     if (cData > 0)
     {
         CustomAttributeParser ca(pData, cData);
-        // NativeCallable has two optional named arguments CallingConvention and EntryPoint.
+        // UnmanagedCallersOnly has two optional named arguments CallingConvention and EntryPoint.
         CaNamedArg namedArgs[2];
         CaTypeCtor caType(SERIALIZATION_TYPE_STRING);
         // First, the void constructor.
@@ -2945,11 +2945,11 @@ MethodDesc* COMDelegate::GetDelegateCtor(TypeHandle delegateType, MethodDesc *pT
     // associated with the instantiation.
     BOOL fMaybeCollectibleAndStatic = FALSE;
 
-    // Do not allow static methods with [NativeCallableAttribute] to be a delegate target.
-    // A native callable method is special and allowing it to be delegate target will destabilize the runtime.
-    if (pTargetMethod->HasNativeCallableAttribute())
+    // Do not allow static methods with [UnmanagedCallersOnlyAttribute] to be a delegate target.
+    // A method marked UnmanagedCallersOnly is special and allowing it to be delegate target will destabilize the runtime.
+    if (pTargetMethod->HasUnmanagedCallersOnlyAttribute())
     {
-        COMPlusThrow(kNotSupportedException, W("NotSupported_NativeCallableTarget"));
+        COMPlusThrow(kNotSupportedException, W("NotSupported_UnmanagedCallersOnlyTarget"));
     }
 
     if (isStatic)
index 399947b..2d02eb3 100644 (file)
@@ -1223,11 +1223,11 @@ BOOL CEEPreloader::CanEmbedFunctionEntryPoint(
 
     MethodDesc * pMethod = GetMethod(methodHandle);
 
-    // Methods with native callable attribute are special , since
-    // they are used as LDFTN targets.Native Callable methods
+    // Methods with UnmanagedCallersOnlyAttribute are special, since
+    // they are used as LDFTN targets. UnmanagedCallersOnly methods
     // uses the same code path as reverse pinvoke and embedding them
     // in an ngen image require saving the reverse pinvoke stubs.
-    if (pMethod->HasNativeCallableAttribute())
+    if (pMethod->HasUnmanagedCallersOnlyAttribute())
         return FALSE;
 
     return TRUE;
@@ -1272,12 +1272,12 @@ BOOL CEEPreloader::DoesMethodNeedRestoringBeforePrestubIsRun(
     return FALSE;
 }
 
-BOOL CEECompileInfo::IsNativeCallableMethod(CORINFO_METHOD_HANDLE handle)
+BOOL CEECompileInfo::IsUnmanagedCallersOnlyMethod(CORINFO_METHOD_HANDLE handle)
 {
     WRAPPER_NO_CONTRACT;
 
     MethodDesc * pMethod = GetMethod(handle);
-    return pMethod->HasNativeCallableAttribute();
+    return pMethod->HasUnmanagedCallersOnlyAttribute();
 }
 
 BOOL CEEPreloader::CanSkipDependencyActivation(CORINFO_METHOD_HANDLE   context,
index 36edc7f..aaa25cf 100644 (file)
@@ -288,7 +288,7 @@ class CEECompileInfo : public ICorCompileInfo
     BOOL IsEmptyString(mdString token,
                        CORINFO_MODULE_HANDLE module);
 
-    BOOL IsNativeCallableMethod(CORINFO_METHOD_HANDLE handle);
+    BOOL IsUnmanagedCallersOnlyMethod(CORINFO_METHOD_HANDLE handle);
 
     BOOL IsCachingOfInliningHintsEnabled()
     {
index 6563b6c..e52bef8 100644 (file)
@@ -799,7 +799,7 @@ HRESULT CorHost2::CreateDelegate(
         if (pMD==NULL || !pMD->IsStatic() || pMD->HasClassOrMethodInstantiation())
             ThrowHR(COR_E_MISSINGMETHOD);
 
-        if (pMD->HasNativeCallableAttribute())
+        if (pMD->HasUnmanagedCallersOnlyAttribute())
         {
             if (NDirect::MarshalingRequired(pMD, pMD->GetSig(), pMD->GetModule()))
                 ThrowHR(COR_E_INVALIDPROGRAM);
index 67b660f..4ecd77d 100644 (file)
@@ -848,8 +848,9 @@ UMEntryThunk *UMEntryThunkCache::GetUMEntryThunk(MethodDesc *pMD)
     RETURN pThunk;
 }
 
-// FailFast if a native callable method invoked directly from managed code.
-// UMThunkStub.asm check the mode and call this function to failfast.
+// FailFast if a method marked UnmanagedCallersOnlyAttribute is
+// invoked directly from managed code. UMThunkStub.asm check the
+// mode and call this function to failfast.
 extern "C" VOID STDCALL ReversePInvokeBadTransition()
 {
     STATIC_CONTRACT_THROWS;
@@ -857,7 +858,7 @@ extern "C" VOID STDCALL ReversePInvokeBadTransition()
     // Fail
     EEPOLICY_HANDLE_FATAL_ERROR_WITH_MESSAGE(
                                              COR_E_EXECUTIONENGINE,
-                                             W("Invalid Program: attempted to call a NativeCallable method from managed code.")
+                                             W("Invalid Program: attempted to call a UnmanagedCallersOnly method from managed code.")
                                             );
 }
 
index 972b7ae..ffdf79b 100644 (file)
@@ -5757,7 +5757,7 @@ bool EECodeManager::GetReturnAddressHijackInfo(GCInfoToken gcInfoToken, ReturnKi
 
     if (gcInfoDecoder.GetReversePInvokeFrameStackSlot() != NO_REVERSE_PINVOKE_FRAME)
     {
-        // Hijacking of NativeCallable method is not allowed
+        // Hijacking of UnmanagedCallersOnly method is not allowed
         return false;
     }
 
index 831d99a..2dd54db 100644 (file)
@@ -8101,7 +8101,7 @@ LONG WINAPI CLRVectoredExceptionHandlerShim(PEXCEPTION_POINTERS pExceptionInfo)
     //
     // 1) We have a valid Thread object (implies exception on managed thread)
     // 2) Not a valid Thread object but the IP is in the execution engine (implies native thread within EE faulted)
-    // 3) The exception occurred in a GC marked location when no thread exists (i.e. reverse P/Invoke with NativeCallableAttribute).
+    // 3) The exception occurred in a GC marked location when no thread exists (i.e. reverse P/Invoke with UnmanagedCallersOnlyAttribute).
     if (pThread || fExceptionInEE)
     {
         if (!bIsGCMarker)
index e900abb..e8f835a 100644 (file)
@@ -1226,7 +1226,7 @@ lExit: ;
                 GcInfoDecoder gcInfoDecoder(codeInfo.GetGCInfoToken(), DECODE_REVERSE_PINVOKE_VAR);
                 if (gcInfoDecoder.GetReversePInvokeFrameStackSlot() != NO_REVERSE_PINVOKE_FRAME)
                 {
-                    // Exception is being propagated from a native callable method into its native caller.
+                    // Exception is being propagated from a method marked UnmanagedCallersOnlyAttribute into its native caller.
                     // The explicit frame chain needs to be unwound at this boundary.
                     bool fIsSO = pExceptionRecord->ExceptionCode == STATUS_STACK_OVERFLOW;
                     CleanUpForSecondPass(pThread, fIsSO, (void*)MemoryStackFp, (void*)MemoryStackFp);
@@ -4630,7 +4630,7 @@ VOID DECLSPEC_NORETURN UnwindManagedExceptionPass1(PAL_SEHException& ex, CONTEXT
 
         if (gcInfoDecoder.GetReversePInvokeFrameStackSlot() != NO_REVERSE_PINVOKE_FRAME)
         {
-            // Propagating exception from a method marked by NativeCallable attribute is prohibited on Unix
+            // Propagating exception from a method marked by UnmanagedCallersOnly attribute is prohibited on Unix
             if (!GetThread()->HasThreadStateNC(Thread::TSNC_ProcessedUnhandledException))
             {
                 LONG disposition = InternalUnhandledExceptionFilter_Worker(&ex.ExceptionPointers);
index 7e51976..5c8a1ca 100644 (file)
@@ -2788,7 +2788,7 @@ protected:
 };
 #endif // TARGET_X86 && !TARGET_UNIX
 
-// Frame for the Reverse PInvoke (i.e. NativeCallableAttribute).
+// Frame for the Reverse PInvoke (i.e. UnmanagedCallersOnlyAttribute).
 struct ReversePInvokeFrame
 {
     Thread* currentThread;
index 96cd53c..9a985e6 100644 (file)
@@ -1403,10 +1403,10 @@ BOOL OnGcCoverageInterrupt(PCONTEXT regs)
     if (!pThread)
     {
         // No thread at the moment so we aren't doing coverage for this function.
-        // This should only occur for methods with the NativeCallableAttribute,
+        // This should only occur for methods with the UnmanagedCallersOnlyAttribute,
         // where the call could be coming from a thread unknown to the CLR and
         // we haven't created a thread yet - see PreStubWorker_Preemptive().
-        _ASSERTE(pMD->HasNativeCallableAttribute());
+        _ASSERTE(pMD->HasUnmanagedCallersOnlyAttribute());
         RemoveGcCoverageInterrupt(instrPtr, savedInstrPtr);
         return TRUE;
     }
index e40b191..a88fbef 100644 (file)
@@ -61,7 +61,7 @@ LOCAL_LABEL(HaveThread):
 
     mov     dword ptr [ebp - UMThunkStub_THREAD_OFFSET], eax
 
-    // FailFast if a native callable method is invoked via ldftn and calli.
+    // FailFast if a method marked UnmanagedCallersOnlyAttribute is invoked via ldftn and calli.
     cmp     dword ptr [eax + Thread_m_fPreemptiveGCDisabled], 1
     jz      LOCAL_LABEL(InvalidTransition)
 
index 60670e1..0ea66d4 100644 (file)
@@ -298,7 +298,7 @@ MethodDesc* ILStubCache::CreateNewMethodDesc(LoaderHeap* pCreationHeap, MethodTa
         {
             pMD->m_dwExtendedFlags |= DynamicMethodDesc::nomdReverseStub;
 #if !defined(TARGET_X86)
-            pMD->m_dwExtendedFlags |= DynamicMethodDesc::nomdNativeCallableStub;
+            pMD->m_dwExtendedFlags |= DynamicMethodDesc::nomdUnmanagedCallersOnlyStub;
 #endif
             pMD->GetILStubResolver()->SetStubType(ILStubResolver::NativeToCLRInteropStub);
         }
index 641a788..552cffc 100644 (file)
@@ -5095,9 +5095,9 @@ void CEEInfo::getCallInfo(
         EX_THROW(EEMessageException, (kMissingMethodException, IDS_EE_MISSING_METHOD, W("?")));
     }
 
-    // If this call is for a LDFTN and the target method has the NativeCallableAttribute,
+    // If this call is for a LDFTN and the target method has the UnmanagedCallersOnlyAttribute,
     // then validate it adheres to the limitations.
-    if ((flags & CORINFO_CALLINFO_LDFTN) && pMD->HasNativeCallableAttribute())
+    if ((flags & CORINFO_CALLINFO_LDFTN) && pMD->HasUnmanagedCallersOnlyAttribute())
     {
         if (!pMD->IsStatic())
             EX_THROW(EEResourceException, (kInvalidProgramException, W("InvalidProgram_NonStaticMethod")));
@@ -9223,7 +9223,7 @@ void CEEInfo::getFunctionFixedEntryPoint(CORINFO_METHOD_HANDLE   ftn,
     // Deferring X86 support until a need is observed or
     // time permits investigation into all the potential issues.
     // https://github.com/dotnet/runtime/issues/33582
-    if (pMD->HasNativeCallableAttribute())
+    if (pMD->HasUnmanagedCallersOnlyAttribute())
     {
         pResult->addr = (void*)COMDelegate::ConvertToCallback(pMD);
     }
@@ -12439,7 +12439,7 @@ CorJitResult CallCompileMethodWithSEHWrapper(EEJitManager *jitMgr,
     }
 
 #if !defined(TARGET_X86)
-    if (ftn->HasNativeCallableAttribute())
+    if (ftn->HasUnmanagedCallersOnlyAttribute())
         flags.Set(CORJIT_FLAGS::CORJIT_FLAG_REVERSE_PINVOKE);
 #endif // !TARGET_X86
 
index a458fa9..314b777 100644 (file)
@@ -5405,7 +5405,7 @@ void NDirectMethodDesc::InitEarlyBoundNDirectTarget()
 #endif // !CROSSGEN_COMPILE
 
 //*******************************************************************************
-BOOL MethodDesc::HasNativeCallableAttribute()
+BOOL MethodDesc::HasUnmanagedCallersOnlyAttribute()
 {
     CONTRACTL
     {
@@ -5417,11 +5417,11 @@ BOOL MethodDesc::HasNativeCallableAttribute()
 
     if (IsILStub())
     {
-        return AsDynamicMethodDesc()->IsNativeCallableStub();
+        return AsDynamicMethodDesc()->IsUnmanagedCallersOnlyStub();
     }
 
     HRESULT hr = GetCustomAttribute(
-        WellKnownAttribute::NativeCallable,
+        WellKnownAttribute::UnmanagedCallersOnly,
         nullptr,
         nullptr);
     return (hr == S_OK) ? TRUE : FALSE;
index 5973cd6..8870e7a 100644 (file)
@@ -662,7 +662,7 @@ public:
         return GetMethodTable()->IsInterface();
     }
 
-    BOOL HasNativeCallableAttribute();
+    BOOL HasUnmanagedCallersOnlyAttribute();
     BOOL ShouldSuppressGCTransition();
 
 #ifdef FEATURE_COMINTEROP
@@ -2605,20 +2605,20 @@ protected:
         nomdILStubAttrs     = mdMemberAccessMask | mdStatic, //  method attributes (IL stubs)
 
         // attributes (except mdStatic and mdMemberAccessMask) have different meaning for IL stubs
-        // mdMemberAccessMask     = 0x0007,
-        nomdReverseStub           = 0x0008,
-        // mdStatic               = 0x0010,
-        nomdCALLIStub             = 0x0020,
-        nomdDelegateStub          = 0x0040,
-        nomdStructMarshalStub     = 0x0080,
-        nomdUnbreakable           = 0x0100,
-        nomdDelegateCOMStub       = 0x0200,  // CLR->COM or COM->CLR call via a delegate (WinRT specific)
-        nomdSignatureNeedsRestore = 0x0400,
-        nomdStubNeedsCOMStarted   = 0x0800,  // EnsureComStarted must be called before executing the method
-        nomdMulticastStub         = 0x1000,
-        nomdUnboxingILStub        = 0x2000,
-        nomdWrapperDelegateStub   = 0x4000,
-        nomdNativeCallableStub    = 0x8000,
+        // mdMemberAccessMask        = 0x0007,
+        nomdReverseStub              = 0x0008,
+        // mdStatic                  = 0x0010,
+        nomdCALLIStub                = 0x0020,
+        nomdDelegateStub             = 0x0040,
+        nomdStructMarshalStub        = 0x0080,
+        nomdUnbreakable              = 0x0100,
+        nomdDelegateCOMStub          = 0x0200,  // CLR->COM or COM->CLR call via a delegate (WinRT specific)
+        nomdSignatureNeedsRestore    = 0x0400,
+        nomdStubNeedsCOMStarted      = 0x0800,  // EnsureComStarted must be called before executing the method
+        nomdMulticastStub            = 0x1000,
+        nomdUnboxingILStub           = 0x2000,
+        nomdWrapperDelegateStub      = 0x4000,
+        nomdUnmanagedCallersOnlyStub = 0x8000,
 
         nomdILStub          = 0x00010000,
         nomdLCGMethod       = 0x00020000,
@@ -2711,7 +2711,7 @@ public:
     }
 
     bool IsReverseStub()     { LIMITED_METHOD_DAC_CONTRACT; _ASSERTE(IsILStub()); return (0 != (m_dwExtendedFlags & nomdReverseStub));  }
-    bool IsNativeCallableStub() { LIMITED_METHOD_DAC_CONTRACT; _ASSERTE(IsILStub()); return (0 != (m_dwExtendedFlags & nomdNativeCallableStub)); }
+    bool IsUnmanagedCallersOnlyStub() { LIMITED_METHOD_DAC_CONTRACT; _ASSERTE(IsILStub()); return (0 != (m_dwExtendedFlags & nomdUnmanagedCallersOnlyStub)); }
     bool IsCALLIStub()       { LIMITED_METHOD_DAC_CONTRACT; _ASSERTE(IsILStub()); return (0 != (m_dwExtendedFlags & nomdCALLIStub));    }
     bool IsDelegateStub()    { LIMITED_METHOD_DAC_CONTRACT; _ASSERTE(IsILStub()); return (0 != (m_dwExtendedFlags & nomdDelegateStub)); }
     bool IsCLRToCOMStub()    { LIMITED_METHOD_CONTRACT; _ASSERTE(IsILStub()); return ((0 == (m_dwExtendedFlags & mdStatic)) && !IsReverseStub() && !IsDelegateStub() && !IsStructMarshalStub()); }
index 704627f..c32ca11 100644 (file)
@@ -443,12 +443,12 @@ PCODE MethodDesc::GetPrecompiledCode(PrepareCodeConfig* pConfig)
             CallerGCMode callerGcMode = pConfig->GetCallerGCMode();
             // If the method is eligible for tiering but is being
             // called from a Preemptive GC Mode thread or the method
-            // has the NativeCallableAttribute then the Tiered Compilation
+            // has the UnmanagedCallersOnlyAttribute then the Tiered Compilation
             // should be disabled.
             if (shouldTier
                 && (callerGcMode == CallerGCMode::Preemptive
                     || (callerGcMode == CallerGCMode::Unknown
-                        && HasNativeCallableAttribute())))
+                        && HasUnmanagedCallersOnlyAttribute())))
             {
                 NativeCodeVersion codeVersion = pConfig->GetCodeVersion();
                 if (codeVersion.IsDefaultVersion())
@@ -1806,14 +1806,14 @@ extern "C" MethodDesc * STDCALL PreStubGetMethodDescForCompactEntryPoint (PCODE
 
 //=============================================================================
 // This function generates the real code when from Preemptive mode.
-// It is specifically designed to work with the NativeCallableAttribute.
+// It is specifically designed to work with the UnmanagedCallersOnlyAttribute.
 //=============================================================================
 static PCODE PreStubWorker_Preemptive(
     _In_ TransitionBlock* pTransitionBlock,
     _In_ MethodDesc* pMD,
     _In_opt_ Thread* currentThread)
 {
-    _ASSERTE(pMD->HasNativeCallableAttribute());
+    _ASSERTE(pMD->HasUnmanagedCallersOnlyAttribute());
 
     PCODE pbRetVal = NULL;
 
@@ -1835,7 +1835,7 @@ static PCODE PreStubWorker_Preemptive(
     MAKE_CURRENT_THREAD_AVAILABLE_EX(currentThread);
 
     // No GC frame is needed here since there should be no OBJECTREFs involved
-    // in this call due to NativeCallableAttribute semantics.
+    // in this call due to UnmanagedCallersOnlyAttribute semantics.
 
     INSTALL_MANAGED_EXCEPTION_DISPATCHER;
     INSTALL_UNWIND_AND_CONTINUE_HANDLER;
index e2ff313..90458ec 100644 (file)
@@ -775,7 +775,7 @@ BOOL TieredCompilationManager::CompileCodeVersion(NativeCodeVersion nativeCodeVe
 
         // This is a recompiling request which means the caller was
         // in COOP mode since the code already ran.
-        _ASSERTE(!pMethod->HasNativeCallableAttribute());
+        _ASSERTE(!pMethod->HasUnmanagedCallersOnlyAttribute());
         config->SetCallerGCMode(CallerGCMode::Coop);
         pCode = pMethod->PrepareCode(config);
         LOG((LF_TIEREDCOMPILATION, LL_INFO10000, "TieredCompilationManager::CompileCodeVersion Method=0x%pM (%s::%s), code version id=0x%x, code ptr=0x%p\n",
index de71eb4..b3fef4b 100644 (file)
@@ -30,7 +30,7 @@ enum class WellKnownAttribute : DWORD
     IsByRefLike,
     PrimaryInteropAssembly,
     ManagedToNativeComInteropStub,
-    NativeCallable,
+    UnmanagedCallersOnly,
     TypeIdentifier,
     UnmanagedFunctionPointer,
     ThreadStatic,
@@ -89,8 +89,8 @@ inline const char *GetWellKnownAttributeName(WellKnownAttribute attribute)
             return "System.Runtime.InteropServices.PrimaryInteropAssemblyAttribute";
         case WellKnownAttribute::ManagedToNativeComInteropStub:
             return "System.Runtime.InteropServices.ManagedToNativeComInteropStubAttribute";
-        case WellKnownAttribute::NativeCallable:
-            return "System.Runtime.InteropServices.NativeCallableAttribute";
+        case WellKnownAttribute::UnmanagedCallersOnly:
+            return "System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute";
         case WellKnownAttribute::TypeIdentifier:
             return "System.Runtime.InteropServices.TypeIdentifierAttribute";
         case WellKnownAttribute::UnmanagedFunctionPointer:
index 599fbce..6c76fa7 100644 (file)
@@ -1249,7 +1249,7 @@ public:
         if (token != mdTokenNil)
         {
             _ASSERTE(TypeFromToken(token) == mdtMethodDef || TypeFromToken(token) == mdtMemberRef);
-            _ASSERTE(!pTable->GetCompileInfo()->IsNativeCallableMethod(handle));
+            _ASSERTE(!pTable->GetCompileInfo()->IsUnmanagedCallersOnlyMethod(handle));
 
             pTable->EncodeModule(
                 (TypeFromToken(token) == mdtMethodDef) ? ENCODE_METHOD_ENTRY_DEF_TOKEN : ENCODE_METHOD_ENTRY_REF_TOKEN,
index 5c88c08..0892717 100644 (file)
@@ -483,10 +483,10 @@ void ZapInfo::CompileMethod()
 #endif
 
 #ifdef TARGET_X86
-    if (GetCompileInfo()->IsNativeCallableMethod(m_currentMethodHandle))
+    if (GetCompileInfo()->IsUnmanagedCallersOnlyMethod(m_currentMethodHandle))
     {
         if (m_zapper->m_pOpt->m_verbose)
-            m_zapper->Warning(W("ReadyToRun:  Methods with NativeCallableAttribute not implemented\n"));
+            m_zapper->Warning(W("ReadyToRun:  Methods with UnmanagedCallersOnlyAttribute not implemented\n"));
         ThrowHR(E_NOTIMPL);
     }
 #endif // TARGET_X86
@@ -2309,10 +2309,10 @@ void ZapInfo::getCallInfo(CORINFO_RESOLVED_TOKEN * pResolvedToken,
 #endif
 
 #ifdef TARGET_X86
-    if (GetCompileInfo()->IsNativeCallableMethod(pResult->hMethod))
+    if (GetCompileInfo()->IsUnmanagedCallersOnlyMethod(pResult->hMethod))
     {
         if (m_zapper->m_pOpt->m_verbose)
-            m_zapper->Warning(W("ReadyToRun: References to methods with NativeCallableAttribute not implemented\n"));
+            m_zapper->Warning(W("ReadyToRun: References to methods with UnmanagedCallersOnlyAttribute not implemented\n"));
         ThrowHR(E_NOTIMPL);
     }
 #endif // TARGET_X86
index 6f04645..8a39e97 100644 (file)
@@ -35,7 +35,7 @@ add_subdirectory(PInvoke/Generics)
 add_subdirectory(PInvoke/AsAny)
 add_subdirectory(PInvoke/SafeHandles)
 add_subdirectory(PInvoke/Vector2_3_4)
-add_subdirectory(NativeCallable)
+add_subdirectory(UnmanagedCallersOnly)
 add_subdirectory(PrimitiveMarshalling/Bool)
 add_subdirectory(PrimitiveMarshalling/UIntPtr)
 add_subdirectory(ArrayMarshalling/BoolArray)
diff --git a/src/coreclr/tests/src/Interop/NativeCallable/CMakeLists.txt b/src/coreclr/tests/src/Interop/NativeCallable/CMakeLists.txt
deleted file mode 100644 (file)
index d428cd0..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-project (NativeCallableDll)
-include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") 
-set(SOURCES NativeCallableDll.cpp )
-
-# add the executable
-add_library (NativeCallableDll SHARED ${SOURCES})
-target_link_libraries(NativeCallableDll ${LINK_LIBRARIES_ADDITIONAL}) 
-
-# add the install targets
-install (TARGETS NativeCallableDll DESTINATION bin)
diff --git a/src/coreclr/tests/src/Interop/UnmanagedCallersOnly/CMakeLists.txt b/src/coreclr/tests/src/Interop/UnmanagedCallersOnly/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d770209
--- /dev/null
@@ -0,0 +1,10 @@
+project (UnmanagedCallersOnlyDll)
+include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") 
+set(SOURCES UnmanagedCallersOnlyDll.cpp )
+
+# add the executable
+add_library (UnmanagedCallersOnlyDll SHARED ${SOURCES})
+target_link_libraries(UnmanagedCallersOnlyDll ${LINK_LIBRARIES_ADDITIONAL}) 
+
+# add the install targets
+install (TARGETS UnmanagedCallersOnlyDll DESTINATION bin)
@@ -13,15 +13,15 @@ using TestLibrary;
 
 public class Program
 {
-    public static class NativeCallableDll
+    public static class UnmanagedCallersOnlyDll
     {
-        [DllImport(nameof(NativeCallableDll))]
+        [DllImport(nameof(UnmanagedCallersOnlyDll))]
         public static extern int CallManagedProc(IntPtr callbackProc, int n);
 
-        [DllImport(nameof(NativeCallableDll))]
+        [DllImport(nameof(UnmanagedCallersOnlyDll))]
         public static extern int CallManagedProcOnNewThread(IntPtr callbackProc, int n);
 
-        [DllImport(nameof(NativeCallableDll))]
+        [DllImport(nameof(UnmanagedCallersOnlyDll))]
         // Returns -1 if exception was throw and caught.
         public static extern int CallManagedProcCatchException(IntPtr callbackProc, int n);
     }
@@ -33,22 +33,22 @@ public class Program
     {
         try
         {
-            TestNativeCallableValid();
-            TestNativeCallableValid_OnNewNativeThread();
-            TestNativeCallableValid_PrepareMethod();
+            TestUnmanagedCallersOnlyValid();
+            TestUnmanagedCallersOnlyValid_OnNewNativeThread();
+            TestUnmanagedCallersOnlyValid_PrepareMethod();
             NegativeTest_NonStaticMethod();
             NegativeTest_ViaDelegate();
             NegativeTest_NonBlittable();
             NegativeTest_NonInstantiatedGenericArguments();
             NegativeTest_InstantiatedGenericArguments();
             NegativeTest_FromInstantiatedGenericClass();
-            TestNativeCallableViaUnmanagedCalli();
+            TestUnmanagedCallersOnlyViaUnmanagedCalli();
 
             // Exception handling is only supported on Windows.
             if (TestLibrary.Utilities.IsWindows)
             {
-                TestNativeCallableValid_ThrowException();
-                TestNativeCallableViaUnmanagedCalli_ThrowException();
+                TestUnmanagedCallersOnlyValid_ThrowException();
+                TestUnmanagedCallersOnlyViaUnmanagedCalli_ThrowException();
             }
 
             if (args.Length != 0 && args[0].Equals("calli"))
@@ -65,7 +65,7 @@ public class Program
         return 100;
     }
 
-    [NativeCallable]
+    [UnmanagedCallersOnly]
     public static int ManagedDoubleCallback(int n)
     {
         return DoubleImpl(n);
@@ -76,12 +76,12 @@ public class Program
         return 2 * n;
     }
 
-    public static void TestNativeCallableValid()
+    public static void TestUnmanagedCallersOnlyValid()
     {
-        Console.WriteLine($"Running {nameof(TestNativeCallableValid)}...");
+        Console.WriteLine($"Running {nameof(TestUnmanagedCallersOnlyValid)}...");
 
         /*
-           void NativeCallable()
+           void UnmanagedCallersOnly()
            {
                 .locals init ([0] native int ptr)
                 IL_0000:  nop
@@ -90,13 +90,13 @@ public class Program
 
                 IL_0008:  ldloc.0
                 IL_0009:  ldc.i4     <n> local
-                IL_000e:  call       bool NativeCallableDll::CallManagedProc(native int, int)
+                IL_000e:  call       bool UnmanagedCallersOnlyDll::CallManagedProc(native int, int)
 
                 IL_0013:  ret
              }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("NativeCallable", typeof(int), null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("UnmanagedCallersOnly", typeof(int), null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -107,20 +107,20 @@ public class Program
 
         int n = 12345;
         il.Emit(OpCodes.Ldc_I4, n);
-        il.Emit(OpCodes.Call, typeof(NativeCallableDll).GetMethod("CallManagedProc"));
+        il.Emit(OpCodes.Call, typeof(UnmanagedCallersOnlyDll).GetMethod("CallManagedProc"));
         il.Emit(OpCodes.Ret);
-        var testNativeMethod = (IntNativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(IntNativeMethodInvoker));
+        var testNativeMethod = (IntNativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(IntNativeMethodInvoker));
 
         int expected = DoubleImpl(n);
         Assert.AreEqual(expected, testNativeMethod());
     }
 
-    public static void TestNativeCallableValid_OnNewNativeThread()
+    public static void TestUnmanagedCallersOnlyValid_OnNewNativeThread()
     {
-        Console.WriteLine($"Running {nameof(TestNativeCallableValid_OnNewNativeThread)}...");
+        Console.WriteLine($"Running {nameof(TestUnmanagedCallersOnlyValid_OnNewNativeThread)}...");
 
         /*
-           void NativeCallableOnNewNativeThread()
+           void UnmanagedCallersOnlyOnNewNativeThread()
            {
                 .locals init ([0] native int ptr)
                 IL_0000:  nop
@@ -129,13 +129,13 @@ public class Program
 
                 IL_0008:  ldloc.0
                 IL_0009:  ldc.i4     <n> local
-                IL_000e:  call       bool NativeCallableDll::CallManagedProcOnNewThread(native int, int)
+                IL_000e:  call       bool UnmanagedCallersOnlyDll::CallManagedProcOnNewThread(native int, int)
 
                 IL_0013:  ret
              }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("NativeCallableOnNewNativeThread", typeof(int), null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("UnmanagedCallersOnlyOnNewNativeThread", typeof(int), null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -146,27 +146,27 @@ public class Program
 
         int n = 12345;
         il.Emit(OpCodes.Ldc_I4, n);
-        il.Emit(OpCodes.Call, typeof(NativeCallableDll).GetMethod("CallManagedProcOnNewThread"));
+        il.Emit(OpCodes.Call, typeof(UnmanagedCallersOnlyDll).GetMethod("CallManagedProcOnNewThread"));
         il.Emit(OpCodes.Ret);
-        var testNativeMethod = (IntNativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(IntNativeMethodInvoker));
+        var testNativeMethod = (IntNativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(IntNativeMethodInvoker));
 
         int expected = DoubleImpl(n);
         Assert.AreEqual(expected, testNativeMethod());
     }
 
-    [NativeCallable]
+    [UnmanagedCallersOnly]
     public static int ManagedCallback_Prepared(int n)
     {
         return DoubleImpl(n);
     }
 
-    // This test is about the interaction between Tiered Compilation and the NativeCallableAttribute.
-    public static void TestNativeCallableValid_PrepareMethod()
+    // This test is about the interaction between Tiered Compilation and the UnmanagedCallersOnlyAttribute.
+    public static void TestUnmanagedCallersOnlyValid_PrepareMethod()
     {
-        Console.WriteLine($"Running {nameof(TestNativeCallableValid_PrepareMethod)}...");
+        Console.WriteLine($"Running {nameof(TestUnmanagedCallersOnlyValid_PrepareMethod)}...");
 
         /*
-           void NativeCallableOnNewNativeThread()
+           void UnmanagedCallersOnlyOnNewNativeThread()
            {
                 .locals init ([0] native int ptr)
                 IL_0000:  nop
@@ -175,13 +175,13 @@ public class Program
 
                 IL_0008:  ldloc.0
                 IL_0009:  ldc.i4     <n> local
-                IL_000e:  call       bool NativeCallableDll::CallManagedProcOnNewThread(native int, int)
+                IL_000e:  call       bool UnmanagedCallersOnlyDll::CallManagedProcOnNewThread(native int, int)
 
                 IL_0013:  ret
              }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("NativeCallableValid_PrepareMethod", typeof(int), null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("UnmanagedCallersOnlyValid_PrepareMethod", typeof(int), null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -196,9 +196,9 @@ public class Program
 
         int n = 12345;
         il.Emit(OpCodes.Ldc_I4, n);
-        il.Emit(OpCodes.Call, typeof(NativeCallableDll).GetMethod("CallManagedProcOnNewThread"));
+        il.Emit(OpCodes.Call, typeof(UnmanagedCallersOnlyDll).GetMethod("CallManagedProcOnNewThread"));
         il.Emit(OpCodes.Ret);
-        var testNativeMethod = (IntNativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(IntNativeMethodInvoker));
+        var testNativeMethod = (IntNativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(IntNativeMethodInvoker));
 
         // Call enough to attempt to trigger Tiered Compilation from a new thread.
         for (int i = 0; i < 100; ++i)
@@ -209,18 +209,18 @@ public class Program
 
     private const int CallbackThrowsErrorCode = 27;
 
-    [NativeCallable]
+    [UnmanagedCallersOnly]
     public static int CallbackThrows(int val)
     {
         throw new Exception() { HResult = CallbackThrowsErrorCode };
     }
 
-    public static void TestNativeCallableValid_ThrowException()
+    public static void TestUnmanagedCallersOnlyValid_ThrowException()
     {
-        Console.WriteLine($"Running {nameof(TestNativeCallableValid_ThrowException)}...");
+        Console.WriteLine($"Running {nameof(TestUnmanagedCallersOnlyValid_ThrowException)}...");
 
         /*
-           void NativeCallableValid_ThrowException()
+           void UnmanagedCallersOnlyValid_ThrowException()
            {
                 .locals init ([0] native int ptr)
                 IL_0000:  nop
@@ -229,13 +229,13 @@ public class Program
 
                 IL_0008:  ldloc.0
                 IL_0009:  ldc.i4     <n> local
-                IL_000e:  call       bool NativeCallableDll::CallManagedProcCatchException(native int, int)
+                IL_000e:  call       bool UnmanagedCallersOnlyDll::CallManagedProcCatchException(native int, int)
 
                 IL_0013:  ret
              }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("NativeCallableValid_ThrowException", typeof(int), null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("UnmanagedCallersOnlyValid_ThrowException", typeof(int), null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -246,9 +246,9 @@ public class Program
 
         int n = 12345;
         il.Emit(OpCodes.Ldc_I4, n);
-        il.Emit(OpCodes.Call, typeof(NativeCallableDll).GetMethod("CallManagedProcCatchException"));
+        il.Emit(OpCodes.Call, typeof(UnmanagedCallersOnlyDll).GetMethod("CallManagedProcCatchException"));
         il.Emit(OpCodes.Ret);
-        var testNativeMethod = (IntNativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(IntNativeMethodInvoker));
+        var testNativeMethod = (IntNativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(IntNativeMethodInvoker));
 
         // Method should have thrown and caught an exception.
         Assert.AreEqual(-1, testNativeMethod());
@@ -269,10 +269,10 @@ public class Program
         }
     }
 
-    [NativeCallable]
+    [UnmanagedCallersOnly]
     public void CallbackNonStatic()
     {
-        Assert.Fail($"Instance functions with attribute {nameof(NativeCallableAttribute)} are invalid");
+        Assert.Fail($"Instance functions with attribute {nameof(UnmanagedCallersOnlyAttribute)} are invalid");
     }
 
     public static void NegativeTest_NonStaticMethod()
@@ -280,7 +280,7 @@ public class Program
         Console.WriteLine($"Running {nameof(NegativeTest_NonStaticMethod)}...");
 
         /*
-           void TestNativeCallableNonStatic()
+           void TestUnmanagedCallersOnlyNonStatic()
            {
                 .locals init ([0] native int ptr)
                 IL_0000:  nop
@@ -289,8 +289,8 @@ public class Program
                 IL_0008:  ret
              }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("TestNativeCallableNonStatic", null, null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("TestUnmanagedCallersOnlyNonStatic", null, null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -299,16 +299,16 @@ public class Program
         il.Emit(OpCodes.Stloc_0);
 
         il.Emit(OpCodes.Ret);
-        var testNativeMethod = (NativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(NativeMethodInvoker));
+        var testNativeMethod = (NativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(NativeMethodInvoker));
 
         // Try invoking method
         Assert.Throws<InvalidProgramException>(() => { testNativeMethod(); });
     }
 
-    [NativeCallable]
+    [UnmanagedCallersOnly]
     public static void CallbackMethodNonBlittable(bool x1)
     {
-        Assert.Fail($"Functions with attribute {nameof(NativeCallableAttribute)} cannot have non-blittable arguments");
+        Assert.Fail($"Functions with attribute {nameof(UnmanagedCallersOnlyAttribute)} cannot have non-blittable arguments");
     }
 
     public static void NegativeTest_NonBlittable()
@@ -316,7 +316,7 @@ public class Program
         Console.WriteLine($"Running {nameof(NegativeTest_NonBlittable)}...");
 
         /*
-           void TestNativeCallableNonBlittable()
+           void TestUnmanagedCallersOnlyNonBlittable()
            {
                 .locals init ([0] native int ptr)
                 IL_0000:  nop
@@ -325,8 +325,8 @@ public class Program
                 IL_0008:  ret
              }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("TestNativeCallableNonBlittable", null, null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("TestUnmanagedCallersOnlyNonBlittable", null, null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -335,16 +335,16 @@ public class Program
         il.Emit(OpCodes.Stloc_0);
 
         il.Emit(OpCodes.Ret);
-        var testNativeMethod = (NativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(NativeMethodInvoker));
+        var testNativeMethod = (NativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(NativeMethodInvoker));
 
         // Try invoking method
         Assert.Throws<InvalidProgramException>(() => { testNativeMethod(); });
     }
 
-    [NativeCallable]
+    [UnmanagedCallersOnly]
     public static void CallbackMethodGeneric<T>(T arg)
     {
-        Assert.Fail($"Functions with attribute {nameof(NativeCallableAttribute)} cannot have generic arguments");
+        Assert.Fail($"Functions with attribute {nameof(UnmanagedCallersOnlyAttribute)} cannot have generic arguments");
     }
 
     public static void NegativeTest_NonInstantiatedGenericArguments()
@@ -352,7 +352,7 @@ public class Program
         Console.WriteLine($"Running {nameof(NegativeTest_NonInstantiatedGenericArguments)}...");
 
         /*
-           void TestNativeCallableNonInstGenericArguments()
+           void TestUnmanagedCallersOnlyNonInstGenericArguments()
            {
                 .locals init ([0] native int ptr)
                 IL_0000:  nop
@@ -361,8 +361,8 @@ public class Program
                 IL_0008:  ret
              }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("TestNativeCallableNonInstGenericArguments", null, null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("TestUnmanagedCallersOnlyNonInstGenericArguments", null, null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -371,7 +371,7 @@ public class Program
         il.Emit(OpCodes.Stloc_0);
 
         il.Emit(OpCodes.Ret);
-        var testNativeMethod = (NativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(NativeMethodInvoker));
+        var testNativeMethod = (NativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(NativeMethodInvoker));
 
         // Try invoking method
         Assert.Throws<InvalidProgramException>(() => { testNativeMethod(); });
@@ -382,7 +382,7 @@ public class Program
         Console.WriteLine($"Running {nameof(NegativeTest_InstantiatedGenericArguments)}...");
 
         /*
-           void TestNativeCallableInstGenericArguments()
+           void TestUnmanagedCallersOnlyInstGenericArguments()
            {
                 .locals init ([0] native int ptr)
                 IL_0000:  nop
@@ -391,8 +391,8 @@ public class Program
                 IL_0008:  ret
              }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("TestNativeCallableInstGenericArguments", null, null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("TestUnmanagedCallersOnlyInstGenericArguments", null, null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -401,7 +401,7 @@ public class Program
         il.Emit(OpCodes.Stloc_0);
 
         il.Emit(OpCodes.Ret);
-        var testNativeMethod = (NativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(NativeMethodInvoker));
+        var testNativeMethod = (NativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(NativeMethodInvoker));
 
         // Try invoking method
         Assert.Throws<InvalidProgramException>(() => { testNativeMethod(); });
@@ -409,10 +409,10 @@ public class Program
 
     public class GenericClass<T>
     {
-        [NativeCallable]
+        [UnmanagedCallersOnly]
         public static void CallbackMethod(int n)
         {
-            Assert.Fail($"Functions with attribute {nameof(NativeCallableAttribute)} within a generic type are invalid");
+            Assert.Fail($"Functions with attribute {nameof(UnmanagedCallersOnlyAttribute)} within a generic type are invalid");
         }
     }
 
@@ -421,7 +421,7 @@ public class Program
         Console.WriteLine($"Running {nameof(NegativeTest_FromInstantiatedGenericClass)}...");
 
         /*
-           void TestNativeCallableInstGenericType()
+           void TestUnmanagedCallersOnlyInstGenericType()
            {
                 .locals init ([0] native int ptr)
                 IL_0000:  nop
@@ -430,8 +430,8 @@ public class Program
                 IL_0008:  ret
              }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("TestNativeCallableInstGenericClass", null, null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("TestUnmanagedCallersOnlyInstGenericClass", null, null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -440,16 +440,16 @@ public class Program
         il.Emit(OpCodes.Stloc_0);
 
         il.Emit(OpCodes.Ret);
-        var testNativeMethod = (NativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(NativeMethodInvoker));
+        var testNativeMethod = (NativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(NativeMethodInvoker));
 
         // Try invoking method
         Assert.Throws<InvalidProgramException>(() => { testNativeMethod(); });
     }
 
-    [NativeCallable]
+    [UnmanagedCallersOnly]
     public static void CallbackViaCalli(int val)
     {
-        Assert.Fail($"Functions with attribute {nameof(NativeCallableAttribute)} cannot be called via calli");
+        Assert.Fail($"Functions with attribute {nameof(UnmanagedCallersOnlyAttribute)} cannot be called via calli");
     }
 
     public static void NegativeTest_ViaCalli()
@@ -457,7 +457,7 @@ public class Program
         Console.WriteLine($"{nameof(NegativeTest_ViaCalli)} function via calli instruction. The CLR _will_ crash.");
 
         /*
-           void TestNativeCallableViaCalli()
+           void TestUnmanagedCallersOnlyViaCalli()
            {
                 .locals init (native int V_0)
                 IL_0000:  nop
@@ -472,8 +472,8 @@ public class Program
                 IL_0014:  ret
            }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("TestNativeCallableViaCalli", null, null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("TestUnmanagedCallersOnlyViaCalli", null, null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -488,7 +488,7 @@ public class Program
         il.Emit(OpCodes.Nop);
         il.Emit(OpCodes.Ret);
 
-        NativeMethodInvoker testNativeMethod = (NativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(NativeMethodInvoker));
+        NativeMethodInvoker testNativeMethod = (NativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(NativeMethodInvoker));
 
         // It is not possible to catch the resulting ExecutionEngineException exception.
         // To observe the crashing behavior set a breakpoint in the ReversePInvokeBadTransition() function
@@ -496,18 +496,18 @@ public class Program
         testNativeMethod();
     }
 
-    [NativeCallable(CallingConvention = CallingConvention.StdCall)]
+    [UnmanagedCallersOnly(CallingConvention = CallingConvention.StdCall)]
     public static int CallbackViaUnmanagedCalli(int val)
     {
         return DoubleImpl(val);
     }
 
-    public static void TestNativeCallableViaUnmanagedCalli()
+    public static void TestUnmanagedCallersOnlyViaUnmanagedCalli()
     {
-        Console.WriteLine($"Running {nameof(TestNativeCallableViaUnmanagedCalli)}...");
+        Console.WriteLine($"Running {nameof(TestUnmanagedCallersOnlyViaUnmanagedCalli)}...");
 
         /*
-           void NativeCallableViaCalli()
+           void UnmanagedCallersOnlyViaCalli()
            {
                 .locals init (native int V_0)
                 IL_0000:  nop
@@ -521,8 +521,8 @@ public class Program
                 IL_0014:  ret
            }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("NativeCallableViaUnmanagedCalli", typeof(int), null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("UnmanagedCallersOnlyViaUnmanagedCalli", typeof(int), null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -538,24 +538,24 @@ public class Program
 
         il.Emit(OpCodes.Ret);
 
-        IntNativeMethodInvoker testNativeMethod = (IntNativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(IntNativeMethodInvoker));
+        IntNativeMethodInvoker testNativeMethod = (IntNativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(IntNativeMethodInvoker));
 
         int expected = DoubleImpl(n);
         Assert.AreEqual(expected, testNativeMethod());
     }
 
-    [NativeCallable(CallingConvention = CallingConvention.StdCall)]
+    [UnmanagedCallersOnly(CallingConvention = CallingConvention.StdCall)]
     public static int CallbackViaUnmanagedCalliThrows(int val)
     {
         throw new Exception() { HResult = CallbackThrowsErrorCode };
     }
 
-    public static void TestNativeCallableViaUnmanagedCalli_ThrowException()
+    public static void TestUnmanagedCallersOnlyViaUnmanagedCalli_ThrowException()
     {
-        Console.WriteLine($"Running {nameof(TestNativeCallableViaUnmanagedCalli_ThrowException)}...");
+        Console.WriteLine($"Running {nameof(TestUnmanagedCallersOnlyViaUnmanagedCalli_ThrowException)}...");
 
         /*
-           void NativeCallableViaUnmanagedCalli_ThrowException()
+           void UnmanagedCallersOnlyViaUnmanagedCalli_ThrowException()
            {
                 .locals init (native int V_0)
                 IL_0000:  nop
@@ -569,8 +569,8 @@ public class Program
                 IL_0014:  ret
            }
         */
-        DynamicMethod testNativeCallable = new DynamicMethod("NativeCallableViaUnmanagedCalli_ThrowException", typeof(int), null, typeof(Program).Module);
-        ILGenerator il = testNativeCallable.GetILGenerator();
+        DynamicMethod testUnmanagedCallersOnly = new DynamicMethod("UnmanagedCallersOnlyViaUnmanagedCalli_ThrowException", typeof(int), null, typeof(Program).Module);
+        ILGenerator il = testUnmanagedCallersOnly.GetILGenerator();
         il.DeclareLocal(typeof(IntPtr));
         il.Emit(OpCodes.Nop);
 
@@ -586,7 +586,7 @@ public class Program
 
         il.Emit(OpCodes.Ret);
 
-        IntNativeMethodInvoker testNativeMethod = (IntNativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(IntNativeMethodInvoker));
+        IntNativeMethodInvoker testNativeMethod = (IntNativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(IntNativeMethodInvoker));
 
         try
         {
@@ -5,7 +5,7 @@
   </PropertyGroup>
   <Import Project="$([MSBuild]::GetPathOfFileAbove(Interop.settings.targets))" />
   <ItemGroup>
-    <Compile Include="NativeCallableTest.cs" />
+    <Compile Include="UnmanagedCallersOnlyTest.cs" />
   </ItemGroup>
   <ItemGroup>
     <!-- This is needed to make sure native binary gets installed in the right location -->
index c816a9b..9f004bd 100644 (file)
     <value>Collection was of a fixed size.</value>
   </data>
   <data name="InvalidProgram_GenericMethod" xml:space="preserve">
-    <value>Generic methods with NativeCallableAttribute are invalid.</value>
+    <value>Generic methods with UnmanagedCallersOnlyAttribute are invalid.</value>
   </data>
   <data name="InvalidOperation_SpanOverlappedOperation" xml:space="preserve">
     <value>This operation is invalid on overlapping buffers.</value>
   <data name="NotSupported_MustBeModuleBuilder" xml:space="preserve">
     <value>Module argument must be a ModuleBuilder.</value>
   </data>
-  <data name="NotSupported_NativeCallableTarget" xml:space="preserve">
-    <value>Methods with NativeCallableAttribute cannot be used as delegate target.</value>
+  <data name="NotSupported_UnmanagedCallersOnlyTarget" xml:space="preserve">
+    <value>Methods with UnmanagedCallersOnlyAttribute cannot be used as delegate target.</value>
   </data>
   <data name="NotSupported_NoCodepageData" xml:space="preserve">
     <value>No data is available for encoding {0}. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.</value>
   </data>
   <data name="InvalidProgram_NonBlittableTypes" xml:space="preserve">
-    <value>Non-blittable parameter types are invalid for NativeCallable methods.</value>
+    <value>Non-blittable parameter types are invalid for UnmanagedCallersOnly methods.</value>
   </data>
   <data name="NotSupported_NonReflectedType" xml:space="preserve">
     <value>Not supported in a non-reflected type.</value>
   </data>
   <data name="InvalidProgram_NonStaticMethod" xml:space="preserve">
-    <value>Non-static methods with NativeCallableAttribute are invalid.</value>
+    <value>Non-static methods with UnmanagedCallersOnlyAttribute are invalid.</value>
   </data>
   <data name="NotSupported_NoParentDefaultConstructor" xml:space="preserve">
     <value>Parent does not have a default constructor. The default constructor must be explicitly defined.</value>
index 8ae9ebc..bc17256 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\MarshalAsAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\MarshalDirectiveException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\MemoryMarshal.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\NativeCallableAttribute.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\UnmanagedCallersOnlyAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\NativeLibrary.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\OptionalAttribute.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\OutAttribute.cs" />
index 79ff550..a42c872 100644 (file)
@@ -271,7 +271,7 @@ namespace System.Globalization
         }
 
         // EnumCalendarInfoExEx callback itself.
-        // [NativeCallable(CallingConvention = CallingConvention.StdCall)]
+        // [UnmanagedCallersOnly(CallingConvention = CallingConvention.StdCall)]
         private static unsafe Interop.BOOL EnumCalendarInfoCallback(char* lpCalendarInfoString, uint calendar, IntPtr pReserved, void* lParam)
         {
             ref EnumData context = ref Unsafe.As<byte, EnumData>(ref *(byte*)lParam);
@@ -424,7 +424,7 @@ namespace System.Globalization
             public List<int> calendars;      // list of calendars found so far
         }
 
-        // [NativeCallable(CallingConvention = CallingConvention.StdCall)]
+        // [UnmanagedCallersOnly(CallingConvention = CallingConvention.StdCall)]
         private static unsafe Interop.BOOL EnumCalendarsCallback(char* lpCalendarInfoString, uint calendar, IntPtr reserved, void* lParam)
         {
             ref NlsEnumCalendarsData context = ref Unsafe.As<byte, NlsEnumCalendarsData>(ref *(byte*)lParam);
index 49a2b1d..ed07e20 100644 (file)
@@ -494,7 +494,7 @@ namespace System.Globalization
         }
 
         // EnumSystemLocaleEx callback.
-        // [NativeCallable(CallingConvention = CallingConvention.StdCall)]
+        // [UnmanagedCallersOnly(CallingConvention = CallingConvention.StdCall)]
         private static unsafe Interop.BOOL EnumSystemLocalesProc(char* lpLocaleString, uint flags, void* contextHandle)
         {
             ref EnumLocaleData context = ref Unsafe.As<byte, EnumLocaleData>(ref *(byte*)contextHandle);
@@ -517,7 +517,7 @@ namespace System.Globalization
         }
 
         // EnumSystemLocaleEx callback.
-        // [NativeCallable(CallingConvention = CallingConvention.StdCall)]
+        // [UnmanagedCallersOnly(CallingConvention = CallingConvention.StdCall)]
         private static unsafe Interop.BOOL EnumAllSystemLocalesProc(char* lpLocaleString, uint flags, void* contextHandle)
         {
             ref EnumData context = ref Unsafe.As<byte, EnumData>(ref *(byte*)contextHandle);
@@ -539,7 +539,7 @@ namespace System.Globalization
         }
 
         // EnumTimeFormatsEx callback itself.
-        // [NativeCallable(CallingConvention = CallingConvention.StdCall)]
+        // [UnmanagedCallersOnly(CallingConvention = CallingConvention.StdCall)]
         private static unsafe Interop.BOOL EnumTimeCallback(char* lpTimeFormatString, void* lParam)
         {
             ref EnumData context = ref Unsafe.As<byte, EnumData>(ref *(byte*)lParam);
index 3b18fde..1b515ed 100644 (file)
@@ -4,7 +4,7 @@
 
 namespace System.Runtime.InteropServices
 {
-    // Used for the CallingConvention named argument to the DllImport and NativeCallable attribute
+    // Used for the CallingConvention named argument to the DllImport and UnmanagedCallersOnly attribute
     public enum CallingConvention
     {
         Winapi = 1,
@@ -5,7 +5,7 @@
 namespace System.Runtime.InteropServices
 {
     /// <summary>
-    /// Any method marked with <see cref="System.Runtime.InteropServices.NativeCallableAttribute" /> can be directly called from
+    /// Any method marked with <see cref="System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute" /> can be directly called from
     /// native code. The function token can be loaded to a local variable using the <see href="https://docs.microsoft.com/dotnet/csharp/language-reference/operators/pointer-related-operators#address-of-operator-">address-of</see> operator
     /// in C# and passed as a callback to a native method.
     /// </summary>
@@ -16,9 +16,9 @@ namespace System.Runtime.InteropServices
     ///   * 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 sealed class UnmanagedCallersOnlyAttribute : Attribute
     {
-        public NativeCallableAttribute()
+        public UnmanagedCallersOnlyAttribute()
         {
         }
 
@@ -28,7 +28,7 @@ namespace System.Runtime.InteropServices
         public CallingConvention CallingConvention;
 
         /// <summary>
-        /// Optional. If omitted, then the method is native callable, but no export is emitted during compilation.
+        /// Optional. If omitted, no named export is emitted during compilation.
         /// </summary>
         public string? EntryPoint;
     }
index caa1aab..965afd8 100644 (file)
@@ -1010,9 +1010,9 @@ namespace System.Runtime.InteropServices
         protected static void GetIUnknownImpl(out System.IntPtr fpQueryInterface, out System.IntPtr fpAddRef, out System.IntPtr fpRelease) { throw null; }
     }
     [System.AttributeUsageAttribute(System.AttributeTargets.Method)]
-    public sealed class NativeCallableAttribute : System.Attribute
+    public sealed class UnmanagedCallersOnlyAttribute : System.Attribute
     {
-        public NativeCallableAttribute() { }
+        public UnmanagedCallersOnlyAttribute() { }
         public System.Runtime.InteropServices.CallingConvention CallingConvention;
         public string? EntryPoint;
     }