From 64545068f73b0952215f3a09cdd1aa466d92b0d1 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 30 Jan 2026 17:09:27 +0800 Subject: [PATCH 01/14] Remove BaseObjectWithCachedData --- src/coreclr/vm/object.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index c5206f13488635..b977a1ae33c349 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -930,19 +930,13 @@ inline STRINGREF* StringObject::GetEmptyStringRefPtr(void** pinnedString) { return refptr; } -// This is used to account for the remoting cache on RuntimeType, -// RuntimeMethodInfo, and RtFieldInfo. -class BaseObjectWithCachedData : public Object -{ -}; - // This is the Class version of the Reflection object. // A Class has adddition information. // For a ReflectClassBaseObject the m_pData is a pointer to a FieldDesc array that // contains all of the final static primitives if its defined. // m_cnt = the number of elements defined in the m_pData FieldDesc array. -1 means // this hasn't yet been defined. -class ReflectClassBaseObject : public BaseObjectWithCachedData +class ReflectClassBaseObject : public Object { friend class CoreLibBinder; @@ -1022,7 +1016,7 @@ class ReflectClassBaseObject : public BaseObjectWithCachedData // (RuntimeConstructorInfo, RuntimeMethodInfo, and RuntimeMethodInfoStub). These types are unrelated in the type // system except that they all implement a particular interface. It is important that such interface is not attached to any // type that does not sufficiently match this data structure. -class ReflectMethodObject : public BaseObjectWithCachedData +class ReflectMethodObject : public Object { friend class CoreLibBinder; @@ -1066,7 +1060,7 @@ class ReflectMethodObject : public BaseObjectWithCachedData // (RtFieldInfo and RuntimeFieldInfoStub). These types are unrelated in the type // system except that they all implement a particular interface. It is important that such interface is not attached to any // type that does not sufficiently match this data structure. -class ReflectFieldObject : public BaseObjectWithCachedData +class ReflectFieldObject : public Object { friend class CoreLibBinder; From f8642a75ca0a1218d316d31ab442816daa093e09 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 30 Jan 2026 18:19:40 +0800 Subject: [PATCH 02/14] CultureInfo cleanup --- src/coreclr/vm/corelib.h | 16 ---------------- src/coreclr/vm/object.h | 38 -------------------------------------- 2 files changed, 54 deletions(-) diff --git a/src/coreclr/vm/corelib.h b/src/coreclr/vm/corelib.h index 93e80be8c2bec9..c16b7196a004e0 100644 --- a/src/coreclr/vm/corelib.h +++ b/src/coreclr/vm/corelib.h @@ -214,25 +214,9 @@ DEFINE_METHOD(STUBMETHODINFO, FROMPTR, FromPtr, DEFINE_CLASS(CONSTRUCTOR_INFO, Reflection, ConstructorInfo) -DEFINE_CLASS_U(Globalization, CultureInfo, CultureInfoBaseObject) -DEFINE_FIELD_U(_compareInfo, CultureInfoBaseObject, _compareInfo) -DEFINE_FIELD_U(_textInfo, CultureInfoBaseObject, _textInfo) -DEFINE_FIELD_U(_numInfo, CultureInfoBaseObject, _numInfo) -DEFINE_FIELD_U(_dateTimeInfo, CultureInfoBaseObject, _dateTimeInfo) -DEFINE_FIELD_U(_calendar, CultureInfoBaseObject, _calendar) -DEFINE_FIELD_U(_consoleFallbackCulture, CultureInfoBaseObject, _consoleFallbackCulture) -DEFINE_FIELD_U(_name, CultureInfoBaseObject, _name) -DEFINE_FIELD_U(_nonSortName, CultureInfoBaseObject, _nonSortName) -DEFINE_FIELD_U(_sortName, CultureInfoBaseObject, _sortName) -DEFINE_FIELD_U(_parent, CultureInfoBaseObject, _parent) -DEFINE_FIELD_U(_isReadOnly, CultureInfoBaseObject, _isReadOnly) -DEFINE_FIELD_U(_isInherited, CultureInfoBaseObject, _isInherited) DEFINE_CLASS(CULTURE_INFO, Globalization, CultureInfo) -DEFINE_FIELD(CULTURE_INFO, CURRENT_CULTURE, s_userDefaultCulture) DEFINE_METHOD(CULTURE_INFO, INT_CTOR, .ctor, IM_Int_RetVoid) DEFINE_PROPERTY(CULTURE_INFO, ID, LCID, Int) -DEFINE_FIELD(CULTURE_INFO, CULTURE, s_currentThreadCulture) -DEFINE_FIELD(CULTURE_INFO, UI_CULTURE, s_currentThreadUICulture) DEFINE_STATIC_SET_PROPERTY(CULTURE_INFO, CURRENT_CULTURE, CurrentCulture, CultureInfo) DEFINE_STATIC_SET_PROPERTY(CULTURE_INFO, CURRENT_UI_CULTURE, CurrentUICulture, CultureInfo) diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index b977a1ae33c349..b703cc19e1d141 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -1157,51 +1157,13 @@ typedef DPTR(class CultureInfoBaseObject) PTR_CultureInfoBaseObject; #ifdef USE_CHECKED_OBJECTREFS typedef REF EXECUTIONCONTEXTREF; -typedef REF CULTUREINFOBASEREF; typedef REF ARRAYBASEREF; #else -typedef CultureInfoBaseObject* CULTUREINFOBASEREF; typedef ExecutionContextObject* EXECUTIONCONTEXTREF; typedef PTR_ArrayBase ARRAYBASEREF; #endif - -class CultureInfoBaseObject : public Object -{ - friend class CoreLibBinder; - -private: - OBJECTREF _compareInfo; - OBJECTREF _textInfo; - OBJECTREF _numInfo; - OBJECTREF _dateTimeInfo; - OBJECTREF _calendar; - OBJECTREF _cultureData; - OBJECTREF _consoleFallbackCulture; - STRINGREF _name; // "real" name - en-US, de-DE_phoneb or fj-FJ - STRINGREF _nonSortName; // name w/o sort info (de-DE for de-DE_phoneb) - STRINGREF _sortName; // Sort only name (de-DE_phoneb, en-us for fj-fj (w/us sort) - CULTUREINFOBASEREF _parent; - CLR_BOOL _isReadOnly; - CLR_BOOL _isInherited; - -public: - CULTUREINFOBASEREF GetParent() - { - LIMITED_METHOD_CONTRACT; - return _parent; - }// GetParent - - - STRINGREF GetName() - { - LIMITED_METHOD_CONTRACT; - return _name; - }// GetName - -}; // class CultureInfoBaseObject - typedef DPTR(class ThreadBaseObject) PTR_ThreadBaseObject; class ThreadBaseObject : public Object { From 28c3b8dc241b270475bbf9de02fe56ccd6a3e95b Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 30 Jan 2026 18:23:22 +0800 Subject: [PATCH 03/14] Delete base MarshalByRefObject --- src/coreclr/vm/object.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index b703cc19e1d141..f83a3a41663ee9 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -1266,13 +1266,6 @@ class ThreadBaseObject : public Object } }; -// MarshalByRefObjectBaseObject -// This class is the base class for MarshalByRefObject -// -class MarshalByRefObjectBaseObject : public Object -{ -}; - // AssemblyBaseObject // This class is the base class for assemblies // @@ -1476,7 +1469,7 @@ STRINGREF AllocateString(SString sstr); // // //------------------------------------------------------------- -class ComObject : public MarshalByRefObjectBaseObject +class ComObject : public Object { friend class CoreLibBinder; From 4629d25003cd5e9c89d5813e3cd442c3d98ea2d8 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 30 Jan 2026 18:31:32 +0800 Subject: [PATCH 04/14] Remove contract support --- src/coreclr/vm/corelib.h | 7 --- src/coreclr/vm/dwreport.cpp | 105 ------------------------------------ src/coreclr/vm/dwreport.h | 2 - src/coreclr/vm/object.h | 36 ------------- 4 files changed, 150 deletions(-) diff --git a/src/coreclr/vm/corelib.h b/src/coreclr/vm/corelib.h index c16b7196a004e0..73b650524a9c2d 100644 --- a/src/coreclr/vm/corelib.h +++ b/src/coreclr/vm/corelib.h @@ -1235,13 +1235,6 @@ DEFINE_CLASS_U(Reflection, LoaderAllocatorScout, LoaderAllocator DEFINE_FIELD_U(m_nativeLoaderAllocator, LoaderAllocatorScoutObject, m_nativeLoaderAllocator) DEFINE_CLASS(LOADERALLOCATORSCOUT, Reflection, LoaderAllocatorScout) -DEFINE_CLASS(CONTRACTEXCEPTION, CodeContracts, ContractException) - -DEFINE_CLASS_U(CodeContracts, ContractException, ContractExceptionObject) -DEFINE_FIELD_U(_kind, ContractExceptionObject, _Kind) -DEFINE_FIELD_U(_userMessage, ContractExceptionObject, _UserMessage) -DEFINE_FIELD_U(_condition, ContractExceptionObject, _Condition) - DEFINE_CLASS(MODULEBASE, Reflection, Module) DEFINE_CLASS(UTF8STRINGMARSHALLER, Marshalling, Utf8StringMarshaller) diff --git a/src/coreclr/vm/dwreport.cpp b/src/coreclr/vm/dwreport.cpp index a650f352b49118..c7de8cfb59dff3 100644 --- a/src/coreclr/vm/dwreport.cpp +++ b/src/coreclr/vm/dwreport.cpp @@ -1000,108 +1000,3 @@ VOID WINAPI DoFaultReportDoFavorCallback(LPVOID pFaultReportInfoAsVoid) CloseHandle(hThread); } } - -// look at the type of the contract failure. if it's a precondition then we want to blame the caller -// of the method that originated the ContractException not just the first non-contract runtime frame. -// if this isn't a ContractException then we default to Invariant which won't skip the extra frame. -ContractFailureKind GetContractFailureKind(OBJECTREF obj) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_COOPERATIVE; - PRECONDITION(obj != NULL); - } - CONTRACTL_END; - - PTR_MethodTable pMT = obj->GetMethodTable(); - - if (CoreLibBinder::IsException(pMT, kContractException)) - return CONTRACTEXCEPTIONREF(obj)->GetContractFailureKind(); - - // there are cases where the code contracts rewriter will use a ContractException - // type that's compiled into the user's assembly. if we get here then this is - // one of those cases. we will make a best guess if this is a ContractException - // so that we can return the value in the _Kind field. - - // NOTE: this really isn't meant to be a general-purpose solution for identifying ContractException types. - // we're making a few assumptions here since we're being called in context of WER bucket parameter generation. - - // just return anything that isn't precondition so that an extra frame won't be skipped. - ContractFailureKind result = CONTRACT_FAILURE_INVARIANT; - - // first compare the exception name. - PTR_MethodTable pContractExceptionMT = CoreLibBinder::GetClassIfExist(CLASS__CONTRACTEXCEPTION); - _ASSERTE(pContractExceptionMT); - - if (pContractExceptionMT) - { - LPCUTF8 contractExceptionNamespace = NULL; - LPCUTF8 contractExceptionName = pContractExceptionMT->GetFullyQualifiedNameInfo(&contractExceptionNamespace); - _ASSERTE(contractExceptionName); - - LPCUTF8 incomingExceptionNamespace = NULL; - LPCUTF8 incomingExceptionName = pMT->GetFullyQualifiedNameInfo(&incomingExceptionNamespace); - _ASSERTE(incomingExceptionName); - - // NOTE: we can't compare the namespaces since sometimes it comes back as an empty string - if (contractExceptionName && incomingExceptionName && strcmp(incomingExceptionName, contractExceptionName) == 0) - { - WORD requiredNumFields = pContractExceptionMT->GetNumInstanceFields(); - WORD numFields = pMT->GetNumInstanceFields(); - - // now see if this exception object has the required number of fields - if (numFields == requiredNumFields) - { - // getting closer, now look for all three fields on ContractException - const int requiredFieldMatches = 3; - - PTR_EEClass pEEClass = pMT->GetClass(); - - PTR_FieldDesc pFD = pEEClass->GetFieldDescList(); - PTR_FieldDesc pFDEnd = pFD + numFields; - PTR_FieldDesc pKindFD = NULL; - - int numMatchedFields = 0; - while ((pFD < pFDEnd) && (numMatchedFields != requiredFieldMatches)) - { - CorElementType fieldType = pFD->GetFieldType(); - if (fieldType == ELEMENT_TYPE_I4) - { - // found the _Kind field - LPCUTF8 name = NULL; - HRESULT hr = pFD->GetName_NoThrow(&name); - if (SUCCEEDED(hr) && name && (strcmp(name, "_Kind") == 0)) - { - // found the _Kind field, remember this FieldDesc in case we have a match - pKindFD = pFD; - ++numMatchedFields; - } - } - else if (fieldType == ELEMENT_TYPE_CLASS) - { - LPCUTF8 name = NULL; - HRESULT hr = pFD->GetName_NoThrow(&name); - if (SUCCEEDED(hr) && name && ((strcmp(name, "_UserMessage") == 0) || (strcmp(name, "_Condition") == 0))) - { - // found another matching field - ++numMatchedFields; - } - } - - ++pFD; - } - - if (numMatchedFields == requiredFieldMatches) - { - _ASSERTE(pKindFD != NULL); - ENABLE_FORBID_GC_LOADER_USE_IN_THIS_SCOPE(); - pKindFD->GetInstanceField(obj, reinterpret_cast(&result)); - } - } - } - } - - return result; -} diff --git a/src/coreclr/vm/dwreport.h b/src/coreclr/vm/dwreport.h index 6f2684b6d38f07..ea3083eb73b651 100644 --- a/src/coreclr/vm/dwreport.h +++ b/src/coreclr/vm/dwreport.h @@ -90,6 +90,4 @@ struct FaultReportInfo VOID WINAPI DoFaultReportDoFavorCallback(LPVOID pFaultReportInfoAsVoid); -ContractFailureKind GetContractFailureKind(OBJECTREF obj); - #endif // __DWREPORT_H__ diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index f83a3a41663ee9..f649d32832d024 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -2437,44 +2437,8 @@ struct cdac_data static constexpr size_t _xcode = offsetof(ExceptionObject, _xcode); }; -// Defined in Contracts.cs -enum ContractFailureKind -{ - CONTRACT_FAILURE_PRECONDITION = 0, - CONTRACT_FAILURE_POSTCONDITION, - CONTRACT_FAILURE_POSTCONDITION_ON_EXCEPTION, - CONTRACT_FAILURE_INVARIANT, - CONTRACT_FAILURE_ASSERT, - CONTRACT_FAILURE_ASSUME, -}; - -typedef DPTR(class ContractExceptionObject) PTR_ContractExceptionObject; -class ContractExceptionObject : public ExceptionObject -{ - friend class CoreLibBinder; - -public: - ContractFailureKind GetContractFailureKind() - { - LIMITED_METHOD_CONTRACT; - - return static_cast(_Kind); - } - -private: - // keep these in sync with ndp/clr/src/bcl/system/diagnostics/contracts/contractsbcl.cs - STRINGREF _UserMessage; - STRINGREF _Condition; - INT32 _Kind; -}; #include "poppack.h" -#ifdef USE_CHECKED_OBJECTREFS -typedef REF CONTRACTEXCEPTIONREF; -#else // USE_CHECKED_OBJECTREFS -typedef PTR_ContractExceptionObject CONTRACTEXCEPTIONREF; -#endif // USE_CHECKED_OBJECTREFS - //=============================================================================== // #NullableFeature // #NullableArchitecture From 5c57162e02cfc825c4f55dc706abd4e1b3ac7113 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 30 Jan 2026 18:58:23 +0800 Subject: [PATCH 05/14] Update comment to match hierarchy --- src/coreclr/vm/object.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index f649d32832d024..a8792c0c178e31 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -32,27 +32,26 @@ void ErectWriteBarrierForMT(MethodTable **dst, MethodTable *ref); * | it contains the MethodTable pointer and the * | sync block index, which is at a negative offset * | - * +-- code:StringObject - String objects are specialized objects for string + * +-- StringObject - String objects are specialized objects for string * | storage/retrieval for higher performance (UCS-2 / UTF-16 data) * | - * +-- code:Utf8StringObject - String objects are specialized objects for string - * | storage/retrieval for higher performance (UTF-8 data) + * +-- ReflectClassBaseObject - The base object for the RuntimeType class * | - * +-- BaseObjectWithCachedData - Object Plus one object field for caching. - * | | - * | +- ReflectClassBaseObject - The base object for the RuntimeType class - * | +- ReflectMethodObject - The base object for the RuntimeMethodInfo class - * | +- ReflectFieldObject - The base object for the RtFieldInfo class + * +-- ReflectMethodObject - The base object for the RuntimeMethodInfo class + * | + * +-- ReflectFieldObject - The base object for the RtFieldInfo class * | - * +-- code:ArrayBase - Base portion of all arrays + * +-- ArrayBase - Base portion of all arrays * | | - * | +- I1Array - Base type arrays + * | +- I1Array - Base type SZ arrays * | | I2Array * | | ... * | | - * | +- PtrArray - Array of OBJECTREFs, different than base arrays because of pObjectClass + * | +- PtrArray - SZ Array of OBJECTREFs, different than base arrays because of pObjectClass + * | + * +-- AssemblyBaseObject - The base object for the class Assembly * | - * +-- code:AssemblyBaseObject - The base object for the class Assembly + * | ... * * * PLEASE NOTE THE FOLLOWING WHEN ADDING A NEW OBJECT TYPE: From c89dd2d49e4791edf9374d708f29c6d281386583 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 30 Jan 2026 19:14:22 +0800 Subject: [PATCH 06/14] Dead method --- src/coreclr/vm/object.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/coreclr/vm/object.h b/src/coreclr/vm/object.h index a8792c0c178e31..24c76bc438526d 100644 --- a/src/coreclr/vm/object.h +++ b/src/coreclr/vm/object.h @@ -2493,7 +2493,6 @@ class Nullable { static OBJECTREF Box(void* src, MethodTable* nullable); static BOOL UnBox(void* dest, OBJECTREF boxedVal, MethodTable* destMT); - static BOOL UnBoxNoGC(void* dest, OBJECTREF boxedVal, MethodTable* destMT); static void UnBoxNoCheck(void* dest, OBJECTREF boxedVal, MethodTable* destMT); static OBJECTREF BoxedNullableNull(TypeHandle nullableType) { return NULL; } // if 'Obj' is a true boxed nullable, return the form we want (either null or a boxed T) From b5f250987d38bc070c2c596a49815ba732e3de7f Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Fri, 30 Jan 2026 19:14:35 +0800 Subject: [PATCH 07/14] NATIVE_LINK --- src/coreclr/inc/cor.h | 32 +----------------- src/coreclr/tools/metainfo/mdinfo.cpp | 47 --------------------------- src/coreclr/tools/metainfo/mdinfo.h | 1 - 3 files changed, 1 insertion(+), 79 deletions(-) diff --git a/src/coreclr/inc/cor.h b/src/coreclr/inc/cor.h index 74dceb2a4107e5..a6fa919e1f6b80 100644 --- a/src/coreclr/inc/cor.h +++ b/src/coreclr/inc/cor.h @@ -1577,40 +1577,10 @@ DECLARE_INTERFACE_(IMetaDataInfo, IUnknown) //********************************************************************** // -// Predefined CustomAttribute and structures for these custom value +// Predefined CustomAttribute // //********************************************************************** -// -// Native Link method custom value definitions. This is for N-direct support. -// - -#include -typedef struct -{ - BYTE m_linkType; // see CorNativeLinkType below - BYTE m_flags; // see CorNativeLinkFlags below - mdMemberRef m_entryPoint; // member ref token giving entry point, format is lib:entrypoint -} COR_NATIVE_LINK; -#include - -typedef enum -{ - nltNone = 1, // none of the keywords are specified - nltAnsi = 2, // ansi keyword specified - nltUnicode = 3, // unicode keyword specified - nltAuto = 4, // auto keyword specified - nltMaxValue = 7, // used so we can assert how many bits are required for this enum -} CorNativeLinkType; - -typedef enum -{ - nlfNone = 0x00, // no flags - nlfLastError = 0x01, // setLastError keyword specified - nlfNoMangle = 0x02, // nomangle keyword specified - nlfMaxValue = 0x03, // used so we can assert how many bits are required for this enum -} CorNativeLinkFlags; - // // Base class for security custom attributes. // diff --git a/src/coreclr/tools/metainfo/mdinfo.cpp b/src/coreclr/tools/metainfo/mdinfo.cpp index 2a5b6881ca7a4c..86646f316f4ced 100644 --- a/src/coreclr/tools/metainfo/mdinfo.cpp +++ b/src/coreclr/tools/metainfo/mdinfo.cpp @@ -2916,53 +2916,6 @@ HRESULT MDInfo::GetOneElementType(PCCOR_SIGNATURE pbSigBlob, ULONG ulSigBlob, UL // Display the fields of the PInvoke custom value structure. -void MDInfo::DisplayCorNativeLink(COR_NATIVE_LINK *pCorNLnk, const char *preFix) -{ - // Print the LinkType. - const char *curField = "\tLink Type : "; - switch(pCorNLnk->m_linkType) - { - case nltNone: - VWriteLine("%s%s%s(%02x)", preFix, curField, "nltNone", pCorNLnk->m_linkType); - break; - case nltAnsi: - VWriteLine("%s%s%s(%02x)", preFix, curField, "nltAnsi", pCorNLnk->m_linkType); - break; - case nltUnicode: - VWriteLine("%s%s%s(%02x)", preFix, curField, "nltUnicode", pCorNLnk->m_linkType); - break; - case nltAuto: - VWriteLine("%s%s%s(%02x)", preFix, curField, "nltAuto", pCorNLnk->m_linkType); - break; - default: - _ASSERTE(!"Invalid Native Link Type!"); - } - - // Print the link flags - curField = "\tLink Flags : "; - switch(pCorNLnk->m_flags) - { - case nlfNone: - VWriteLine("%s%s%s(%02x)", preFix, curField, "nlfNone", pCorNLnk->m_flags); - break; - case nlfLastError: - VWriteLine("%s%s%s(%02x)", preFix, curField, "nlfLastError", pCorNLnk->m_flags); - break; - default: - _ASSERTE(!"Invalid Native Link Flags!"); - } - - // Print the entry point. - WCHAR memRefName[STRING_BUFFER_LEN]; - char memRefNameUtf8[ARRAY_SIZE(memRefName) * MAX_UTF8_CVT]; - HRESULT hr; - hr = m_pImport->GetMemberRefProps( pCorNLnk->m_entryPoint, NULL, memRefName, - STRING_BUFFER_LEN, NULL, NULL, NULL); - if (FAILED(hr)) Error("GetMemberRefProps failed.", hr); - VWriteLine("%s\tEntry Point : %s (0x%08x)", - preFix, ConvertToUtf8(memRefName, memRefNameUtf8, ARRAY_SIZE(memRefNameUtf8)), pCorNLnk->m_entryPoint); -} // void MDInfo::DisplayCorNativeLink() - // Fills given varaint with value given in pValue and of type in bCPlusTypeFlag // // Taken from MetaInternal.cpp diff --git a/src/coreclr/tools/metainfo/mdinfo.h b/src/coreclr/tools/metainfo/mdinfo.h index bcbf3abb59caec..6d3251f6364b1f 100644 --- a/src/coreclr/tools/metainfo/mdinfo.h +++ b/src/coreclr/tools/metainfo/mdinfo.h @@ -88,7 +88,6 @@ class MDInfo { void DisplayMethodSpecs(void); void DisplayMethodSpecInfo(mdMethodSpec ms, const char *preFix); - void DisplayCorNativeLink(COR_NATIVE_LINK *pCorNLnk, const char *preFix); void DisplayCustomAttributeInfo(mdCustomAttribute inValue, const char *preFix); void DisplayCustomAttributes(mdToken inToken, const char *preFix); From 49cb093b834ed2a7f5519ce24b360c713d64f853 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 31 Jan 2026 18:43:52 +0800 Subject: [PATCH 08/14] VB trail byte helper --- src/coreclr/vm/object.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/coreclr/vm/object.cpp b/src/coreclr/vm/object.cpp index 877a565fda44b6..dea387ab644625 100644 --- a/src/coreclr/vm/object.cpp +++ b/src/coreclr/vm/object.cpp @@ -805,26 +805,6 @@ STRINGREF StringObject::NewString(LPCUTF8 psz, int cBytes) STRINGREF* StringObject::EmptyStringRefPtr = NULL; bool StringObject::EmptyStringIsFrozen = false; -//The special string helpers are used as flag bits for weird strings that have bytes -//after the terminating 0. The only case where we use this right now is the VB BSTR as -//byte array which is described in MakeStringAsByteArrayFromBytes. -#define SPECIAL_STRING_VB_BYTE_ARRAY 0x100 - -FORCEINLINE BOOL MARKS_VB_BYTE_ARRAY(WCHAR x) -{ - return static_cast(x & SPECIAL_STRING_VB_BYTE_ARRAY); -} - -FORCEINLINE WCHAR MAKE_VB_TRAIL_BYTE(BYTE x) -{ - return static_cast(x) | SPECIAL_STRING_VB_BYTE_ARRAY; -} - -FORCEINLINE BYTE GET_VB_TRAIL_BYTE(WCHAR x) -{ - return static_cast(x & 0xFF); -} - /*==============================InitEmptyStringRefPtr============================ **Action: Gets an empty string refptr, cache the result. From f18c72a945279d353bbf880f0f789caf3cd9dfd6 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 31 Jan 2026 18:55:34 +0800 Subject: [PATCH 09/14] CriticalFinalizerObject --- src/coreclr/vm/corelib.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/coreclr/vm/corelib.h b/src/coreclr/vm/corelib.h index 73b650524a9c2d..98e795c09d0ae1 100644 --- a/src/coreclr/vm/corelib.h +++ b/src/coreclr/vm/corelib.h @@ -199,9 +199,6 @@ DEFINE_CLASS(HANDLE_REF, Interop, HandleRef) DEFINE_FIELD(HANDLE_REF, WRAPPER, _wrapper) DEFINE_FIELD(HANDLE_REF, HANDLE, _handle) -DEFINE_CLASS(CRITICAL_FINALIZER_OBJECT, ConstrainedExecution, CriticalFinalizerObject) -DEFINE_METHOD(CRITICAL_FINALIZER_OBJECT, FINALIZE, Finalize, IM_RetVoid) - DEFINE_CLASS_U(Reflection, RuntimeConstructorInfo, NoClass) DEFINE_FIELD_U(m_handle, ReflectMethodObject, m_pMD) DEFINE_CLASS(CONSTRUCTOR, Reflection, RuntimeConstructorInfo) From 17df340eda59cf959896f997d9c5b122e07075b7 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 31 Jan 2026 19:04:06 +0800 Subject: [PATCH 10/14] Restore CorNativeLinkType --- src/coreclr/inc/cor.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/coreclr/inc/cor.h b/src/coreclr/inc/cor.h index a6fa919e1f6b80..4b9e9fe6953f02 100644 --- a/src/coreclr/inc/cor.h +++ b/src/coreclr/inc/cor.h @@ -1577,10 +1577,31 @@ DECLARE_INTERFACE_(IMetaDataInfo, IUnknown) //********************************************************************** // -// Predefined CustomAttribute +// Predefined CustomAttribute and structures for these custom value // //********************************************************************** +// +// Native Link method custom value definitions. This is for P/Invoke support. +// + +typedef enum +{ + nltNone = 1, // none of the keywords are specified + nltAnsi = 2, // ansi keyword specified + nltUnicode = 3, // unicode keyword specified + nltAuto = 4, // auto keyword specified + nltMaxValue = 7, // used so we can assert how many bits are required for this enum +} CorNativeLinkType; + +typedef enum +{ + nlfNone = 0x00, // no flags + nlfLastError = 0x01, // setLastError keyword specified + nlfNoMangle = 0x02, // nomangle keyword specified + nlfMaxValue = 0x03, // used so we can assert how many bits are required for this enum +} CorNativeLinkFlags; + // // Base class for security custom attributes. // From f3304ef0a927d044779fa5a455eb2e98b50bd946 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 31 Jan 2026 19:50:15 +0800 Subject: [PATCH 11/14] Other unused corelib type --- src/coreclr/vm/corelib.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/coreclr/vm/corelib.h b/src/coreclr/vm/corelib.h index 98e795c09d0ae1..0ede6fcbacb314 100644 --- a/src/coreclr/vm/corelib.h +++ b/src/coreclr/vm/corelib.h @@ -873,8 +873,6 @@ DEFINE_CLASS(CALLCONV_SWIFT, CompilerServices, CallConvSwi DEFINE_CLASS(SAFE_HANDLE, Interop, SafeHandle) DEFINE_FIELD(SAFE_HANDLE, HANDLE, handle) -DEFINE_CLASS(SECURITY_EXCEPTION, Security, SecurityException) - DEFINE_CLASS_U(Diagnostics, StackFrameHelper, StackFrameHelper) DEFINE_FIELD_U(rgiOffset, StackFrameHelper, rgiOffset) DEFINE_FIELD_U(rgiILOffset, StackFrameHelper, rgiILOffset) @@ -981,9 +979,6 @@ DEFINE_METHOD(AUTORELEASEPOOL, CREATEAUTORELEASEPOOL, CreateAutoreleasePoo DEFINE_METHOD(AUTORELEASEPOOL, DRAINAUTORELEASEPOOL, DrainAutoreleasePool, SM_RetVoid) #endif // FEATURE_OBJCMARSHAL -DEFINE_CLASS(TIMESPAN, System, TimeSpan) - - DEFINE_CLASS(TYPE, System, Type) DEFINE_METHOD(TYPE, GET_TYPE_FROM_HANDLE, GetTypeFromHandle, SM_RuntimeTypeHandle_RetType) DEFINE_PROPERTY(TYPE, IS_IMPORT, IsImport, Bool) From 922fb05f971a486e236468c1da7f04dd25fe7d75 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 1 Feb 2026 01:44:54 +0800 Subject: [PATCH 12/14] cer --- src/coreclr/vm/callhelpers.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/coreclr/vm/callhelpers.h b/src/coreclr/vm/callhelpers.h index 9526da60dbbe39..a60145d92f388a 100644 --- a/src/coreclr/vm/callhelpers.h +++ b/src/coreclr/vm/callhelpers.h @@ -81,8 +81,6 @@ void* DispatchCallSimple( void CopyReturnedFpStructFromRegisters(void* dest, UINT64 returnRegs[2], FpStructInRegistersInfo info, bool handleGcRefs); #endif // defined(TARGET_RISCV64) || defined(TARGET_LOONGARCH64) -bool IsCerRootMethod(MethodDesc *pMD); - class MethodDescCallSite { private: From 48254beb74729ecb70e854c762896ad81e26ecf5 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 2 Feb 2026 00:22:13 +0800 Subject: [PATCH 13/14] Update src/coreclr/tools/metainfo/mdinfo.cpp Co-authored-by: Jan Kotas --- src/coreclr/tools/metainfo/mdinfo.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/coreclr/tools/metainfo/mdinfo.cpp b/src/coreclr/tools/metainfo/mdinfo.cpp index 86646f316f4ced..33e92af4401f6e 100644 --- a/src/coreclr/tools/metainfo/mdinfo.cpp +++ b/src/coreclr/tools/metainfo/mdinfo.cpp @@ -2914,8 +2914,6 @@ HRESULT MDInfo::GetOneElementType(PCCOR_SIGNATURE pbSigBlob, ULONG ulSigBlob, UL return hr; } // HRESULT MDInfo::GetOneElementType() -// Display the fields of the PInvoke custom value structure. - // Fills given varaint with value given in pValue and of type in bCPlusTypeFlag // // Taken from MetaInternal.cpp From dd464c40e3c167b0e4a3875b04c8527de3ab35c0 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sun, 1 Feb 2026 13:35:54 -0800 Subject: [PATCH 14/14] Update src/coreclr/tools/metainfo/mdinfo.cpp --- src/coreclr/tools/metainfo/mdinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/metainfo/mdinfo.cpp b/src/coreclr/tools/metainfo/mdinfo.cpp index 33e92af4401f6e..1cd0bbcbfe4d1a 100644 --- a/src/coreclr/tools/metainfo/mdinfo.cpp +++ b/src/coreclr/tools/metainfo/mdinfo.cpp @@ -2914,7 +2914,7 @@ HRESULT MDInfo::GetOneElementType(PCCOR_SIGNATURE pbSigBlob, ULONG ulSigBlob, UL return hr; } // HRESULT MDInfo::GetOneElementType() -// Fills given varaint with value given in pValue and of type in bCPlusTypeFlag +// Fills given variant with value given in pValue and of type in bCPlusTypeFlag // // Taken from MetaInternal.cpp #ifdef FEATURE_COMINTEROP