diff --git a/src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs b/src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs index 8f7d8ecd550be..2b6c9b7ebad22 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.cs @@ -231,7 +231,7 @@ public static void ClassRegistrationScenarioForType(ComActivationContext cxt, bo /// /// Pointer to a instance [CLSCompliant(false)] - [NativeCallable] + [UnmanagedCallersOnly] public static unsafe int GetClassFactoryForTypeInternal(ComActivationContextInternal* pCxtInt) { ref ComActivationContextInternal cxtInt = ref *pCxtInt; @@ -268,7 +268,7 @@ public static unsafe int GetClassFactoryForTypeInternal(ComActivationContextInte /// /// Pointer to a instance [CLSCompliant(false)] - [NativeCallable] + [UnmanagedCallersOnly] public static unsafe int RegisterClassForTypeInternal(ComActivationContextInternal* pCxtInt) { ref ComActivationContextInternal cxtInt = ref *pCxtInt; @@ -308,7 +308,7 @@ public static unsafe int RegisterClassForTypeInternal(ComActivationContextIntern /// Internal entry point for unregistering a managed COM server API from native code /// [CLSCompliant(false)] - [NativeCallable] + [UnmanagedCallersOnly] public static unsafe int UnregisterClassForTypeInternal(ComActivationContextInternal* pCxtInt) { ref ComActivationContextInternal cxtInt = ref *pCxtInt; diff --git a/src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs b/src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs index ac47d036b1966..1c25db0cfd24e 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs @@ -47,7 +47,7 @@ private static string MarshalToString(IntPtr arg, string argName) /// Assembly qualified delegate type name /// Extensibility parameter (currently unused) /// Pointer where to store the function pointer result - [NativeCallable] + [UnmanagedCallersOnly] public static int LoadAssemblyAndGetFunctionPointer(IntPtr assemblyPathNative, IntPtr typeNameNative, IntPtr methodNameNative, diff --git a/src/coreclr/src/inc/corcompile.h b/src/coreclr/src/inc/corcompile.h index a14a979bd0a26..2973b7a2fa42b 100644 --- a/src/coreclr/src/inc/corcompile.h +++ b/src/coreclr/src/inc/corcompile.h @@ -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; diff --git a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs index 66f33ea70a622..aefad664d2336 100644 --- a/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs @@ -2623,7 +2623,7 @@ private void allocUnwindInfo(byte* pHotCode, byte* pColdCode, uint startOffset, if (funcKind == CorJitFuncKind.CORJIT_FUNC_ROOT) { - if (this.MethodBeingCompiled.IsNativeCallable) + if (this.MethodBeingCompiled.IsUnmanagedCallersOnly) flags |= FrameInfoFlags.ReversePInvoke; } @@ -2912,12 +2912,12 @@ private uint getJitFlags(ref CORJIT_FLAGS flags, uint sizeInBytes) 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 diff --git a/src/coreclr/src/tools/Common/TypeSystem/CodeGen/MethodDelegator.CodeGen.cs b/src/coreclr/src/tools/Common/TypeSystem/CodeGen/MethodDelegator.CodeGen.cs index 7091ea8a95544..afee75c163616 100644 --- a/src/coreclr/src/tools/Common/TypeSystem/CodeGen/MethodDelegator.CodeGen.cs +++ b/src/coreclr/src/tools/Common/TypeSystem/CodeGen/MethodDelegator.CodeGen.cs @@ -78,11 +78,11 @@ public override bool IsSynchronized } } - public override bool IsNativeCallable + public override bool IsUnmanagedCallersOnly { get { - return _wrappedMethod.IsNativeCallable; + return _wrappedMethod.IsUnmanagedCallersOnly; } } diff --git a/src/coreclr/src/tools/Common/TypeSystem/CodeGen/MethodDesc.CodeGen.cs b/src/coreclr/src/tools/Common/TypeSystem/CodeGen/MethodDesc.CodeGen.cs index 5884f1dcb4cac..b15a81d9c3cb0 100644 --- a/src/coreclr/src/tools/Common/TypeSystem/CodeGen/MethodDesc.CodeGen.cs +++ b/src/coreclr/src/tools/Common/TypeSystem/CodeGen/MethodDesc.CodeGen.cs @@ -122,7 +122,7 @@ public virtual bool IsSynchronized /// Gets a value specifying whether this method is directly callable /// by external unmanaged code. /// - public virtual bool IsNativeCallable + public virtual bool IsUnmanagedCallersOnly { get { @@ -230,11 +230,11 @@ public override bool IsSynchronized } } - public override bool IsNativeCallable + public override bool IsUnmanagedCallersOnly { get { - return _methodDef.IsNativeCallable; + return _methodDef.IsUnmanagedCallersOnly; } } @@ -322,11 +322,11 @@ public override bool IsSynchronized } } - public override bool IsNativeCallable + public override bool IsUnmanagedCallersOnly { get { - return _typicalMethodDef.IsNativeCallable; + return _typicalMethodDef.IsUnmanagedCallersOnly; } } diff --git a/src/coreclr/src/tools/Common/TypeSystem/Common/ExceptionStringID.cs b/src/coreclr/src/tools/Common/TypeSystem/Common/ExceptionStringID.cs index 9c0ef31e11b99..d510e7933f718 100644 --- a/src/coreclr/src/tools/Common/TypeSystem/Common/ExceptionStringID.cs +++ b/src/coreclr/src/tools/Common/TypeSystem/Common/ExceptionStringID.cs @@ -31,7 +31,7 @@ public enum ExceptionStringID InvalidProgramSpecific, InvalidProgramVararg, InvalidProgramCallVirtFinalize, - InvalidProgramNativeCallable, + InvalidProgramUnmanagedCallersOnly, InvalidProgramCallAbstractMethod, InvalidProgramCallVirtStatic, InvalidProgramNonStaticMethod, diff --git a/src/coreclr/src/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/src/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index 6d1aa8a59bc5d..d4e0fbd9915e5 100644 --- a/src/coreclr/src/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/src/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -30,7 +30,7 @@ private static class MethodFlags 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 @@ private int InitializeMethodFlags(int mask) 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 @@ public override bool IsSynchronized } } - 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; } } diff --git a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index 5c59632ff448a..6f4d54831777c 100644 --- a/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/src/tools/crossgen2/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -1154,7 +1154,7 @@ private void ceeInfoGetCallInfo( } 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 @@ private void getCallInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_RESO 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) diff --git a/src/coreclr/src/vm/cgensys.h b/src/coreclr/src/vm/cgensys.h index 047725ca0f361..17213af0e7594 100644 --- a/src/coreclr/src/vm/cgensys.h +++ b/src/coreclr/src/vm/cgensys.h @@ -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 diff --git a/src/coreclr/src/vm/classnames.h b/src/coreclr/src/vm/classnames.h index 1aec1ce1eaad4..8385bf4828afc 100644 --- a/src/coreclr/src/vm/classnames.h +++ b/src/coreclr/src/vm/classnames.h @@ -150,7 +150,7 @@ #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" diff --git a/src/coreclr/src/vm/comdelegate.cpp b/src/coreclr/src/vm/comdelegate.cpp index 52e55a3eb6caa..791421ce0a18c 100644 --- a/src/coreclr/src/vm/comdelegate.cpp +++ b/src/coreclr/src/vm/comdelegate.cpp @@ -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) diff --git a/src/coreclr/src/vm/compile.cpp b/src/coreclr/src/vm/compile.cpp index 399947bad4b77..2d02eb3de5154 100644 --- a/src/coreclr/src/vm/compile.cpp +++ b/src/coreclr/src/vm/compile.cpp @@ -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, diff --git a/src/coreclr/src/vm/compile.h b/src/coreclr/src/vm/compile.h index 36edc7f49b026..aaa25cf08721d 100644 --- a/src/coreclr/src/vm/compile.h +++ b/src/coreclr/src/vm/compile.h @@ -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() { diff --git a/src/coreclr/src/vm/corhost.cpp b/src/coreclr/src/vm/corhost.cpp index 6563b6c847486..e52bef8f0c49a 100644 --- a/src/coreclr/src/vm/corhost.cpp +++ b/src/coreclr/src/vm/corhost.cpp @@ -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); diff --git a/src/coreclr/src/vm/dllimportcallback.cpp b/src/coreclr/src/vm/dllimportcallback.cpp index 67b660f59ebd8..4ecd77d2da768 100644 --- a/src/coreclr/src/vm/dllimportcallback.cpp +++ b/src/coreclr/src/vm/dllimportcallback.cpp @@ -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.") ); } diff --git a/src/coreclr/src/vm/eetwain.cpp b/src/coreclr/src/vm/eetwain.cpp index 972b7ae7cbe3a..ffdf79b6afd20 100644 --- a/src/coreclr/src/vm/eetwain.cpp +++ b/src/coreclr/src/vm/eetwain.cpp @@ -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; } diff --git a/src/coreclr/src/vm/excep.cpp b/src/coreclr/src/vm/excep.cpp index 831d99a07761c..2dd54dbb42ac0 100644 --- a/src/coreclr/src/vm/excep.cpp +++ b/src/coreclr/src/vm/excep.cpp @@ -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) diff --git a/src/coreclr/src/vm/exceptionhandling.cpp b/src/coreclr/src/vm/exceptionhandling.cpp index e900abbf914b5..e8f835a43b6c8 100644 --- a/src/coreclr/src/vm/exceptionhandling.cpp +++ b/src/coreclr/src/vm/exceptionhandling.cpp @@ -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); diff --git a/src/coreclr/src/vm/frames.h b/src/coreclr/src/vm/frames.h index 7e519763bbef3..5c8a1ca869d74 100644 --- a/src/coreclr/src/vm/frames.h +++ b/src/coreclr/src/vm/frames.h @@ -2788,7 +2788,7 @@ class UMThkCallFrame : public UnmanagedToManagedFrame }; #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; diff --git a/src/coreclr/src/vm/gccover.cpp b/src/coreclr/src/vm/gccover.cpp index 96cd53ce2c3f0..9a985e6a42182 100644 --- a/src/coreclr/src/vm/gccover.cpp +++ b/src/coreclr/src/vm/gccover.cpp @@ -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; } diff --git a/src/coreclr/src/vm/i386/umthunkstub.S b/src/coreclr/src/vm/i386/umthunkstub.S index e40b1917f8dcb..a88fbefcf1680 100644 --- a/src/coreclr/src/vm/i386/umthunkstub.S +++ b/src/coreclr/src/vm/i386/umthunkstub.S @@ -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) diff --git a/src/coreclr/src/vm/ilstubcache.cpp b/src/coreclr/src/vm/ilstubcache.cpp index 60670e16548ab..0ea66d4fbbbea 100644 --- a/src/coreclr/src/vm/ilstubcache.cpp +++ b/src/coreclr/src/vm/ilstubcache.cpp @@ -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); } diff --git a/src/coreclr/src/vm/jitinterface.cpp b/src/coreclr/src/vm/jitinterface.cpp index 641a78837855d..552cffc77e46a 100644 --- a/src/coreclr/src/vm/jitinterface.cpp +++ b/src/coreclr/src/vm/jitinterface.cpp @@ -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 diff --git a/src/coreclr/src/vm/method.cpp b/src/coreclr/src/vm/method.cpp index a458fa9d65cd6..314b777052cd8 100644 --- a/src/coreclr/src/vm/method.cpp +++ b/src/coreclr/src/vm/method.cpp @@ -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; diff --git a/src/coreclr/src/vm/method.hpp b/src/coreclr/src/vm/method.hpp index 5973cd6d6053f..8870e7a5f5a23 100644 --- a/src/coreclr/src/vm/method.hpp +++ b/src/coreclr/src/vm/method.hpp @@ -662,7 +662,7 @@ class MethodDesc return GetMethodTable()->IsInterface(); } - BOOL HasNativeCallableAttribute(); + BOOL HasUnmanagedCallersOnlyAttribute(); BOOL ShouldSuppressGCTransition(); #ifdef FEATURE_COMINTEROP @@ -2605,20 +2605,20 @@ class DynamicMethodDesc : public StoredSigMethodDesc 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 @@ class DynamicMethodDesc : public StoredSigMethodDesc } 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()); } diff --git a/src/coreclr/src/vm/prestub.cpp b/src/coreclr/src/vm/prestub.cpp index 704627f074d24..c32ca111f19b4 100644 --- a/src/coreclr/src/vm/prestub.cpp +++ b/src/coreclr/src/vm/prestub.cpp @@ -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; diff --git a/src/coreclr/src/vm/tieredcompilation.cpp b/src/coreclr/src/vm/tieredcompilation.cpp index e2ff313e8f1f5..90458ec5b7e4d 100644 --- a/src/coreclr/src/vm/tieredcompilation.cpp +++ b/src/coreclr/src/vm/tieredcompilation.cpp @@ -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", diff --git a/src/coreclr/src/vm/wellknownattributes.h b/src/coreclr/src/vm/wellknownattributes.h index de71eb459f90c..b3fef4b4fda8c 100644 --- a/src/coreclr/src/vm/wellknownattributes.h +++ b/src/coreclr/src/vm/wellknownattributes.h @@ -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: diff --git a/src/coreclr/src/zap/zapimport.cpp b/src/coreclr/src/zap/zapimport.cpp index 599fbcef38bbf..6c76fa7faca49 100644 --- a/src/coreclr/src/zap/zapimport.cpp +++ b/src/coreclr/src/zap/zapimport.cpp @@ -1249,7 +1249,7 @@ class ZapFunctionEntryImport : public ZapImport 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, diff --git a/src/coreclr/src/zap/zapinfo.cpp b/src/coreclr/src/zap/zapinfo.cpp index d16f4a1d5ca0e..1bff622e6d4af 100644 --- a/src/coreclr/src/zap/zapinfo.cpp +++ b/src/coreclr/src/zap/zapinfo.cpp @@ -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 diff --git a/src/coreclr/tests/src/Interop/CMakeLists.txt b/src/coreclr/tests/src/Interop/CMakeLists.txt index 6f0464527650e..8a39e97624f93 100644 --- a/src/coreclr/tests/src/Interop/CMakeLists.txt +++ b/src/coreclr/tests/src/Interop/CMakeLists.txt @@ -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 index d428cd0178ce2..0000000000000 --- a/src/coreclr/tests/src/Interop/NativeCallable/CMakeLists.txt +++ /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 index 0000000000000..d770209f98239 --- /dev/null +++ b/src/coreclr/tests/src/Interop/UnmanagedCallersOnly/CMakeLists.txt @@ -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) diff --git a/src/coreclr/tests/src/Interop/NativeCallable/NativeCallableDll.cpp b/src/coreclr/tests/src/Interop/UnmanagedCallersOnly/UnmanagedCallersOnlyDll.cpp similarity index 100% rename from src/coreclr/tests/src/Interop/NativeCallable/NativeCallableDll.cpp rename to src/coreclr/tests/src/Interop/UnmanagedCallersOnly/UnmanagedCallersOnlyDll.cpp diff --git a/src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.cs b/src/coreclr/tests/src/Interop/UnmanagedCallersOnly/UnmanagedCallersOnlyTest.cs similarity index 65% rename from src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.cs rename to src/coreclr/tests/src/Interop/UnmanagedCallersOnly/UnmanagedCallersOnlyTest.cs index 121379c3155cd..cb3cded544982 100644 --- a/src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.cs +++ b/src/coreclr/tests/src/Interop/UnmanagedCallersOnly/UnmanagedCallersOnlyTest.cs @@ -13,15 +13,15 @@ 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 static int Main(string[] args) { 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 static int Main(string[] args) return 100; } - [NativeCallable] + [UnmanagedCallersOnly] public static int ManagedDoubleCallback(int n) { return DoubleImpl(n); @@ -76,12 +76,12 @@ private static int DoubleImpl(int n) 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 @@ .locals init ([0] native int ptr) IL_0008: ldloc.0 IL_0009: ldc.i4 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 @@ .locals init ([0] native int ptr) 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 @@ .locals init ([0] native int ptr) IL_0008: ldloc.0 IL_0009: ldc.i4 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 @@ .locals init ([0] native int ptr) 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 @@ .locals init ([0] native int ptr) IL_0008: ldloc.0 IL_0009: ldc.i4 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 @@ .locals init ([0] native int ptr) 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 @@ .locals init ([0] native int ptr) 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 @@ .locals init ([0] native int ptr) IL_0008: ldloc.0 IL_0009: ldc.i4 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 @@ .locals init ([0] native int ptr) 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 @@ void CallAsDelegate() } } - [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 static void NegativeTest_NonStaticMethod() Console.WriteLine($"Running {nameof(NegativeTest_NonStaticMethod)}..."); /* - void TestNativeCallableNonStatic() + void TestUnmanagedCallersOnlyNonStatic() { .locals init ([0] native int ptr) IL_0000: nop @@ -289,8 +289,8 @@ .locals init ([0] native int ptr) 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 @@ .locals init ([0] native int ptr) 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(() => { 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 static void NegativeTest_NonBlittable() Console.WriteLine($"Running {nameof(NegativeTest_NonBlittable)}..."); /* - void TestNativeCallableNonBlittable() + void TestUnmanagedCallersOnlyNonBlittable() { .locals init ([0] native int ptr) IL_0000: nop @@ -325,8 +325,8 @@ .locals init ([0] native int ptr) 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 @@ .locals init ([0] native int ptr) 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(() => { testNativeMethod(); }); } - [NativeCallable] + [UnmanagedCallersOnly] public static void CallbackMethodGeneric(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 static void NegativeTest_NonInstantiatedGenericArguments() Console.WriteLine($"Running {nameof(NegativeTest_NonInstantiatedGenericArguments)}..."); /* - void TestNativeCallableNonInstGenericArguments() + void TestUnmanagedCallersOnlyNonInstGenericArguments() { .locals init ([0] native int ptr) IL_0000: nop @@ -361,8 +361,8 @@ .locals init ([0] native int ptr) 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 @@ .locals init ([0] native int ptr) 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(() => { testNativeMethod(); }); @@ -382,7 +382,7 @@ public static void NegativeTest_InstantiatedGenericArguments() Console.WriteLine($"Running {nameof(NegativeTest_InstantiatedGenericArguments)}..."); /* - void TestNativeCallableInstGenericArguments() + void TestUnmanagedCallersOnlyInstGenericArguments() { .locals init ([0] native int ptr) IL_0000: nop @@ -391,8 +391,8 @@ .locals init ([0] native int ptr) 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 @@ .locals init ([0] native int ptr) 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(() => { testNativeMethod(); }); @@ -409,10 +409,10 @@ .locals init ([0] native int ptr) public class GenericClass { - [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 static void NegativeTest_FromInstantiatedGenericClass() Console.WriteLine($"Running {nameof(NegativeTest_FromInstantiatedGenericClass)}..."); /* - void TestNativeCallableInstGenericType() + void TestUnmanagedCallersOnlyInstGenericType() { .locals init ([0] native int ptr) IL_0000: nop @@ -430,8 +430,8 @@ .locals init ([0] native int ptr) 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 @@ .locals init ([0] native int ptr) 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(() => { 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 static void NegativeTest_ViaCalli() 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 @@ .locals init (native int V_0) 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 @@ .locals init (native int V_0) 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 @@ .locals init (native int V_0) 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 @@ .locals init (native int V_0) 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 @@ .locals init (native int V_0) 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 @@ .locals init (native int V_0) 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 @@ .locals init (native int V_0) il.Emit(OpCodes.Ret); - IntNativeMethodInvoker testNativeMethod = (IntNativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(IntNativeMethodInvoker)); + IntNativeMethodInvoker testNativeMethod = (IntNativeMethodInvoker)testUnmanagedCallersOnly.CreateDelegate(typeof(IntNativeMethodInvoker)); try { diff --git a/src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.csproj b/src/coreclr/tests/src/Interop/UnmanagedCallersOnly/UnmanagedCallersOnlyTest.csproj similarity index 90% rename from src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.csproj rename to src/coreclr/tests/src/Interop/UnmanagedCallersOnly/UnmanagedCallersOnlyTest.csproj index a485b23e3b68e..efd50bf70f9b5 100644 --- a/src/coreclr/tests/src/Interop/NativeCallable/NativeCallableTest.csproj +++ b/src/coreclr/tests/src/Interop/UnmanagedCallersOnly/UnmanagedCallersOnlyTest.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index c816a9b0fbf7c..9f004bd9ea447 100644 --- a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx @@ -2882,7 +2882,7 @@ Collection was of a fixed size. - Generic methods with NativeCallableAttribute are invalid. + Generic methods with UnmanagedCallersOnlyAttribute are invalid. This operation is invalid on overlapping buffers. @@ -2911,20 +2911,20 @@ Module argument must be a ModuleBuilder. - - Methods with NativeCallableAttribute cannot be used as delegate target. + + Methods with UnmanagedCallersOnlyAttribute cannot be used as delegate target. No data is available for encoding {0}. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. - Non-blittable parameter types are invalid for NativeCallable methods. + Non-blittable parameter types are invalid for UnmanagedCallersOnly methods. Not supported in a non-reflected type. - Non-static methods with NativeCallableAttribute are invalid. + Non-static methods with UnmanagedCallersOnlyAttribute are invalid. Parent does not have a default constructor. The default constructor must be explicitly defined. diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 23bb6cb96aefa..e41bafc50c432 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -731,7 +731,7 @@ - + diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Nls.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Nls.cs index 79ff55073850d..a42c8724af72c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Nls.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Nls.cs @@ -271,7 +271,7 @@ private struct EnumData } // 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(ref *(byte*)lParam); @@ -424,7 +424,7 @@ public struct NlsEnumCalendarsData public List 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(ref *(byte*)lParam); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Nls.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Nls.cs index 49a2b1d0615e0..ed07e20db3710 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Nls.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Nls.cs @@ -494,7 +494,7 @@ private struct EnumLocaleData } // 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(ref *(byte*)contextHandle); @@ -517,7 +517,7 @@ private static unsafe Interop.BOOL EnumSystemLocalesProc(char* lpLocaleString, u } // 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(ref *(byte*)contextHandle); @@ -539,7 +539,7 @@ private struct EnumData } // 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(ref *(byte*)lParam); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CallingConvention.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CallingConvention.cs index 3b18fdee3a8b5..1b515eda81910 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CallingConvention.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CallingConvention.cs @@ -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, diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeCallableAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/UnmanagedCallersOnlyAttribute.cs similarity index 82% rename from src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeCallableAttribute.cs rename to src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/UnmanagedCallersOnlyAttribute.cs index 459815f8e8ca7..4acf93de99475 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeCallableAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/UnmanagedCallersOnlyAttribute.cs @@ -5,7 +5,7 @@ namespace System.Runtime.InteropServices { /// - /// Any method marked with can be directly called from + /// Any method marked with can be directly called from /// native code. The function token can be loaded to a local variable using the address-of operator /// in C# and passed as a callback to a native method. /// @@ -16,9 +16,9 @@ namespace System.Runtime.InteropServices /// * Must only have blittable arguments. /// [AttributeUsage(AttributeTargets.Method)] - public sealed class NativeCallableAttribute : Attribute + public sealed class UnmanagedCallersOnlyAttribute : Attribute { - public NativeCallableAttribute() + public UnmanagedCallersOnlyAttribute() { } @@ -28,7 +28,7 @@ public NativeCallableAttribute() public CallingConvention CallingConvention; /// - /// 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. /// public string? EntryPoint; } diff --git a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs index caa1aab42e89f..965afd86333ab 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -1010,9 +1010,9 @@ public void RegisterAsGlobalInstance() { } 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; }