diff --git a/src/coreclr/System.Private.CoreLib/src/System/BadImageFormatException.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/BadImageFormatException.CoreCLR.cs index 6e44e7e1cfdd65..88a951412d6a05 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/BadImageFormatException.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/BadImageFormatException.CoreCLR.cs @@ -5,8 +5,7 @@ namespace System { public partial class BadImageFormatException { - // Do not delete: this is invoked from native code. - private BadImageFormatException(string? fileName, int hResult) + internal BadImageFormatException(string? fileName, int hResult) : base(null) { HResult = hResult; diff --git a/src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs index 3c4c5623e76a9a..f71851e59c63aa 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs @@ -396,5 +396,35 @@ internal static unsafe void CreateTargetInvocationException(Exception* pInnerExc *pException = ex; } } + + // See clrex.cpp for native version. + internal enum ArgumentExceptionKind + { + Argument, + ArgumentNull, + ArgumentOutOfRange + } + + [UnmanagedCallersOnly] + internal static unsafe void CreateArgumentException(ArgumentExceptionKind kind, char* pResourceName, char* pParamName, object* pThrowable, Exception* pException) + { + try + { + string? message = pResourceName is not null ? SR.GetResourceString(new string(pResourceName)) : null; + string? paramName = pParamName is not null ? new string(pParamName) : null; + + Debug.Assert(Enum.IsDefined(kind)); + *pThrowable = kind switch + { + ArgumentExceptionKind.ArgumentNull => new ArgumentNullException(paramName, message), + ArgumentExceptionKind.ArgumentOutOfRange => new ArgumentOutOfRangeException(paramName, message), + _ /* ArgumentExceptionKind.Argument */ => new ArgumentException(message, paramName) + }; + } + catch (Exception ex) + { + *pException = ex; + } + } } } diff --git a/src/coreclr/System.Private.CoreLib/src/System/IO/FileLoadException.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/IO/FileLoadException.CoreCLR.cs index 439689ca9adc26..927e08905606eb 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/IO/FileLoadException.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/IO/FileLoadException.CoreCLR.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -8,7 +9,6 @@ namespace System.IO { public partial class FileLoadException { - // Do not delete: this is invoked from native code. private FileLoadException(string? fileName, int hResult) : base(null) { @@ -36,5 +36,35 @@ internal static string FormatFileLoadExceptionMessage(string? fileName, int hRes [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "FileLoadException_GetMessageForHR")] private static partial void GetMessageForHR(int hresult, StringHandleOnStack retString); + + // See clrex.cpp for native version. + internal enum FileLoadExceptionKind + { + FileLoad, + BadImageFormat, + FileNotFound, + OutOfMemory + } + + [UnmanagedCallersOnly] + internal static unsafe void Create(FileLoadExceptionKind kind, char* pFileName, int hresult, object* pThrowable, Exception* pException) + { + try + { + string? fileName = pFileName is not null ? new string(pFileName) : null; + Debug.Assert(Enum.IsDefined(kind)); + *pThrowable = kind switch + { + FileLoadExceptionKind.BadImageFormat => new BadImageFormatException(fileName, hresult), + FileLoadExceptionKind.FileNotFound => new FileNotFoundException(fileName, hresult), + FileLoadExceptionKind.OutOfMemory => new OutOfMemoryException(), + _ /* FileLoadExceptionKind.FileLoad */ => new FileLoadException(fileName, hresult), + }; + } + catch (Exception ex) + { + *pException = ex; + } + } } } diff --git a/src/coreclr/System.Private.CoreLib/src/System/IO/FileNotFoundException.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/IO/FileNotFoundException.CoreCLR.cs index fbd2a6d02e6953..15d54ec5b367c8 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/IO/FileNotFoundException.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/IO/FileNotFoundException.CoreCLR.cs @@ -5,8 +5,7 @@ namespace System.IO { public partial class FileNotFoundException { - // Do not delete: this is invoked from native code. - private FileNotFoundException(string? fileName, int hResult) + internal FileNotFoundException(string? fileName, int hResult) : base(null) { HResult = hResult; diff --git a/src/coreclr/System.Private.CoreLib/src/System/TypeLoadException.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/TypeLoadException.CoreCLR.cs index 4de0449e86958c..eb13a78c9e2a50 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/TypeLoadException.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/TypeLoadException.CoreCLR.cs @@ -8,7 +8,6 @@ namespace System { public partial class TypeLoadException : SystemException { - // This is called from inside the EE. private TypeLoadException(string? className, string? assemblyName, string? messageArg, @@ -48,5 +47,21 @@ private void SetMessageField() [LibraryImport(RuntimeHelpers.QCall)] private static partial void GetTypeLoadExceptionMessage(int resourceId, StringHandleOnStack retString); + + [UnmanagedCallersOnly] + internal static unsafe void Create(char* pClassName, char* pAssemblyName, char* pMessageArg, int resourceId, object* pResult, Exception* pException) + { + try + { + string? className = pClassName is not null ? new string(pClassName) : null; + string? assemblyName = pAssemblyName is not null ? new string(pAssemblyName) : null; + string? messageArg = pMessageArg is not null ? new string(pMessageArg) : null; + *pResult = new TypeLoadException(className, assemblyName, messageArg, resourceId); + } + catch (Exception ex) + { + *pException = ex; + } + } } } diff --git a/src/coreclr/vm/clrex.cpp b/src/coreclr/vm/clrex.cpp index 2766d1b1de3c17..565f8ec633b68e 100644 --- a/src/coreclr/vm/clrex.cpp +++ b/src/coreclr/vm/clrex.cpp @@ -1281,6 +1281,26 @@ BOOL EETypeAccessException::GetThrowableMessage(SString &result) // EEArgumentException is an EE exception subclass representing a bad argument // --------------------------------------------------------------------------- +// See Exception.CoreCLR.cs for managed mapping. +enum class ArgumentExceptionKind : int32_t +{ + Argument, + ArgumentNull, + ArgumentOutOfRange +}; + +static ArgumentExceptionKind GetArgumentExceptionKind(RuntimeExceptionKind reKind) +{ + LIMITED_METHOD_CONTRACT; + switch (reKind) + { + case kArgumentException: return ArgumentExceptionKind::Argument; + case kArgumentNullException: return ArgumentExceptionKind::ArgumentNull; + case kArgumentOutOfRangeException: return ArgumentExceptionKind::ArgumentOutOfRange; + default: UNREACHABLE(); + } +} + OBJECTREF EEArgumentException::CreateThrowable() { @@ -1297,53 +1317,19 @@ OBJECTREF EEArgumentException::CreateThrowable() struct { OBJECTREF pThrowable; - STRINGREF s1; - OBJECTREF pTmpThrowable; } gc; gc.pThrowable = NULL; - gc.s1 = NULL; - gc.pTmpThrowable = NULL; GCPROTECT_BEGIN(gc); - ResMgrGetString(m_resourceName, &gc.s1); - - MethodTable *pMT = CoreLibBinder::GetException(m_kind); - gc.pThrowable = AllocateObject(pMT); - - MethodDesc* pMD = MemberLoader::FindMethod(gc.pThrowable->GetMethodTable(), - COR_CTOR_METHOD_NAME, &gsig_IM_Str_Str_RetVoid); - - if (!pMD) - { - MAKE_WIDEPTR_FROMUTF8(wzMethodName, COR_CTOR_METHOD_NAME); - COMPlusThrowNonLocalized(kMissingMethodException, wzMethodName); - } - - MethodDescCallSite exceptionCtor(pMD); - STRINGREF argName = StringObject::NewString(m_argumentName); + UnmanagedCallersOnlyCaller createArgException(METHOD__EXCEPTION__CREATE_ARGUMENT_EXCEPTION); + ArgumentExceptionKind kind = GetArgumentExceptionKind(m_kind); + createArgException.InvokeThrowing( + kind, + m_resourceName.IsEmpty() ? NULL : m_resourceName.GetUnicode(), + m_argumentName.IsEmpty() ? NULL : m_argumentName.GetUnicode(), + &gc.pThrowable); - // Note that ArgumentException takes arguments to its constructor in a different order, - // for usability reasons. However it is inconsistent with our other exceptions. - if (m_kind == kArgumentException) - { - ARG_SLOT args1[] = { - ObjToArgSlot(gc.pThrowable), - ObjToArgSlot(gc.s1), - ObjToArgSlot(argName), - }; - exceptionCtor.Call(args1); - } - else - { - ARG_SLOT args1[] = { - ObjToArgSlot(gc.pThrowable), - ObjToArgSlot(argName), - ObjToArgSlot(gc.s1), - }; - exceptionCtor.Call(args1); - } - - GCPROTECT_END(); //Prot + GCPROTECT_END(); return gc.pThrowable; } @@ -1424,54 +1410,19 @@ OBJECTREF EETypeLoadException::CreateThrowable() } CONTRACTL_END; - MethodTable *pMT = CoreLibBinder::GetException(kTypeLoadException); - - struct { - OBJECTREF pNewException; - STRINGREF pNewAssemblyString; - STRINGREF pNewClassString; - STRINGREF pNewMessageArgString; - } gc; - gc.pNewException = NULL; - gc.pNewAssemblyString = NULL; - gc.pNewClassString = NULL; - gc.pNewMessageArgString = NULL; - GCPROTECT_BEGIN(gc); - - gc.pNewClassString = StringObject::NewString(m_fullName); - - if (!m_pMessageArg.IsEmpty()) - gc.pNewMessageArgString = StringObject::NewString(m_pMessageArg); - - if (!m_pAssemblyName.IsEmpty()) - gc.pNewAssemblyString = StringObject::NewString(m_pAssemblyName); - - gc.pNewException = AllocateObject(pMT); - - MethodDesc* pMD = MemberLoader::FindMethod(gc.pNewException->GetMethodTable(), - COR_CTOR_METHOD_NAME, &gsig_IM_Str_Str_Str_Int_RetVoid); - - if (!pMD) - { - MAKE_WIDEPTR_FROMUTF8(wzMethodName, COR_CTOR_METHOD_NAME); - COMPlusThrowNonLocalized(kMissingMethodException, wzMethodName); - } - - MethodDescCallSite exceptionCtor(pMD); + OBJECTREF throwable = NULL; + GCPROTECT_BEGIN(throwable); - ARG_SLOT args[] = { - ObjToArgSlot(gc.pNewException), - ObjToArgSlot(gc.pNewClassString), - ObjToArgSlot(gc.pNewAssemblyString), - ObjToArgSlot(gc.pNewMessageArgString), - (ARG_SLOT)m_resIDWhy, - }; + LPCWSTR pClassName = m_fullName.GetUnicode(); + LPCWSTR pAssemblyName = m_pAssemblyName.IsEmpty() ? NULL : m_pAssemblyName.GetUnicode(); + LPCWSTR pMessageArg = m_pMessageArg.IsEmpty() ? NULL : m_pMessageArg.GetUnicode(); - exceptionCtor.Call(args); + UnmanagedCallersOnlyCaller createTypeLoadEx(METHOD__TYPE_LOAD_EXCEPTION__CREATE); + createTypeLoadEx.InvokeThrowing(pClassName, pAssemblyName, pMessageArg, (int)m_resIDWhy, &throwable); GCPROTECT_END(); - return gc.pNewException; + return throwable; } // --------------------------------------------------------------------------- @@ -1564,33 +1515,56 @@ RuntimeExceptionKind EEFileLoadException::GetFileLoadKind(HRESULT hr) if (Assembly::FileNotFound(hr)) return kFileNotFoundException; - else + + // Make sure this matches the list in rexcep.h + switch (hr) + { + case COR_E_BADIMAGEFORMAT: + case CLDB_E_FILE_OLDVER: + case CLDB_E_INDEX_NOTFOUND: + case CLDB_E_FILE_CORRUPT: + case COR_E_NEWER_RUNTIME: + case COR_E_ASSEMBLYEXPECTED: + case HRESULT_FROM_WIN32(ERROR_BAD_EXE_FORMAT): + case HRESULT_FROM_WIN32(ERROR_EXE_MARKED_INVALID): + case CORSEC_E_INVALID_IMAGE_FORMAT: + case HRESULT_FROM_WIN32(ERROR_NOACCESS): + case HRESULT_FROM_WIN32(ERROR_INVALID_ORDINAL): + case HRESULT_FROM_WIN32(ERROR_INVALID_DLL): + case HRESULT_FROM_WIN32(ERROR_FILE_CORRUPT): + case (HRESULT)IDS_CLASSLOAD_32BITCLRLOADING64BITASSEMBLY: + case COR_E_LOADING_REFERENCE_ASSEMBLY: + case META_E_BAD_SIGNATURE: + return kBadImageFormatException; + + case E_OUTOFMEMORY: + case NTE_NO_MEMORY: + return kOutOfMemoryException; + + default: + return kFileLoadException; + } +} + +// See FileLoadException.CoreCLR.cs for managed mapping. +enum class FileLoadExceptionKind : int32_t +{ + FileLoad, + BadImageFormat, + FileNotFound, + OutOfMemory +}; + +static FileLoadExceptionKind GetFileLoadExceptionKind(HRESULT hr) +{ + RuntimeExceptionKind kind = EEFileLoadException::GetFileLoadKind(hr); + switch (kind) { - // Make sure this matches the list in rexcep.h - if ((hr == COR_E_BADIMAGEFORMAT) || - (hr == CLDB_E_FILE_OLDVER) || - (hr == CLDB_E_INDEX_NOTFOUND) || - (hr == CLDB_E_FILE_CORRUPT) || - (hr == COR_E_NEWER_RUNTIME) || - (hr == COR_E_ASSEMBLYEXPECTED) || - (hr == HRESULT_FROM_WIN32(ERROR_BAD_EXE_FORMAT)) || - (hr == HRESULT_FROM_WIN32(ERROR_EXE_MARKED_INVALID)) || - (hr == CORSEC_E_INVALID_IMAGE_FORMAT) || - (hr == HRESULT_FROM_WIN32(ERROR_NOACCESS)) || - (hr == HRESULT_FROM_WIN32(ERROR_INVALID_ORDINAL)) || - (hr == HRESULT_FROM_WIN32(ERROR_INVALID_DLL)) || - (hr == HRESULT_FROM_WIN32(ERROR_FILE_CORRUPT)) || - (hr == (HRESULT) IDS_CLASSLOAD_32BITCLRLOADING64BITASSEMBLY) || - (hr == COR_E_LOADING_REFERENCE_ASSEMBLY) || - (hr == META_E_BAD_SIGNATURE)) - return kBadImageFormatException; - else - { - if ((hr == E_OUTOFMEMORY) || (hr == NTE_NO_MEMORY)) - return kOutOfMemoryException; - else - return kFileLoadException; - } + case kFileLoadException: return FileLoadExceptionKind::FileLoad; + case kBadImageFormatException: return FileLoadExceptionKind::BadImageFormat; + case kFileNotFoundException: return FileLoadExceptionKind::FileNotFound; + case kOutOfMemoryException: return FileLoadExceptionKind::OutOfMemory; + default: UNREACHABLE(); } } @@ -1605,35 +1579,19 @@ OBJECTREF EEFileLoadException::CreateThrowable() } CONTRACTL_END; - struct { + struct + { OBJECTREF pNewException; - STRINGREF pNewFileString; } gc; gc.pNewException = NULL; - gc.pNewFileString = NULL; GCPROTECT_BEGIN(gc); - gc.pNewFileString = StringObject::NewString(m_name); - gc.pNewException = AllocateObject(CoreLibBinder::GetException(m_kind)); - - MethodDesc* pMD = MemberLoader::FindMethod(gc.pNewException->GetMethodTable(), - COR_CTOR_METHOD_NAME, &gsig_IM_Str_Int_RetVoid); - - if (!pMD) - { - MAKE_WIDEPTR_FROMUTF8(wzMethodName, COR_CTOR_METHOD_NAME); - COMPlusThrowNonLocalized(kMissingMethodException, wzMethodName); - } - - MethodDescCallSite exceptionCtor(pMD); - - ARG_SLOT args[] = { - ObjToArgSlot(gc.pNewException), - ObjToArgSlot(gc.pNewFileString), - (ARG_SLOT) m_hr - }; + LPCWSTR pFileName = m_name.GetUnicode(); + UnmanagedCallersOnlyCaller createFileLoadEx(METHOD__FILE_LOAD_EXCEPTION__CREATE); - exceptionCtor.Call(args); + FileLoadExceptionKind kind = GetFileLoadExceptionKind(m_hr); + createFileLoadEx.InvokeThrowing(kind, pFileName, (int)m_hr, &gc.pNewException); + _ASSERTE(gc.pNewException->GetMethodTable() == CoreLibBinder::GetException(m_kind)); GCPROTECT_END(); diff --git a/src/coreclr/vm/corelib.h b/src/coreclr/vm/corelib.h index c0f18baa3aeb7b..065e5f39b71764 100644 --- a/src/coreclr/vm/corelib.h +++ b/src/coreclr/vm/corelib.h @@ -309,6 +309,7 @@ DEFINE_METHOD(EXCEPTION, GET_SOURCE_BSTR, GetSourceBstr, DEFINE_METHOD(EXCEPTION, GET_HELP_CONTEXT_BSTR, GetHelpContextBstr, SM_PtrException_PtrIntPtr_PtrUInt_PtrException_RetVoid) #endif // FEATURE_COMINTEROP DEFINE_METHOD(EXCEPTION, CREATE_TARGET_INVOCATION_EXCEPTION, CreateTargetInvocationException, SM_PtrException_PtrObj_PtrException_RetVoid) +DEFINE_METHOD(EXCEPTION, CREATE_ARGUMENT_EXCEPTION, CreateArgumentException, NoSig) DEFINE_CLASS(SYSTEM_EXCEPTION, System, SystemException) @@ -317,6 +318,12 @@ DEFINE_METHOD(SYSTEM_EXCEPTION, STR_EX_CTOR, .ctor, DEFINE_CLASS(TYPE_INIT_EXCEPTION, System, TypeInitializationException) +DEFINE_CLASS(TYPE_LOAD_EXCEPTION, System, TypeLoadException) +DEFINE_METHOD(TYPE_LOAD_EXCEPTION, CREATE, Create, NoSig) + +DEFINE_CLASS(FILE_LOAD_EXCEPTION, IO, FileLoadException) +DEFINE_METHOD(FILE_LOAD_EXCEPTION, CREATE, Create, NoSig) + DEFINE_CLASS(VALUETASK_1, Tasks, ValueTask`1) DEFINE_METHOD(VALUETASK_1, GET_ISCOMPLETED, get_IsCompleted, NoSig) DEFINE_METHOD(VALUETASK_1, GET_RESULT, get_Result, NoSig) diff --git a/src/coreclr/vm/metasig.h b/src/coreclr/vm/metasig.h index 2a53071e05d781..4f2487cd2d8b1d 100644 --- a/src/coreclr/vm/metasig.h +++ b/src/coreclr/vm/metasig.h @@ -373,9 +373,6 @@ DEFINE_METASIG(SM(Str_RetStr, s, s)) DEFINE_METASIG_T(SM(PtrPtrChar_PtrPtrChar_Int_PtrException_RetVoid, P(P(u)) P(P(u)) i P(C(EXCEPTION)), v)) DEFINE_METASIG(SM(PtrChar_Int_PtrPtrChar_RetArrStr, P(u) i P(P(u)), a(s))) DEFINE_METASIG_T(IM(Str_Exception_RetVoid, s C(EXCEPTION), v)) -DEFINE_METASIG(IM(Str_Str_RetVoid, s s, v)) -DEFINE_METASIG(IM(Str_Int_RetVoid, s i, v)) -DEFINE_METASIG(IM(Str_Str_Str_Int_RetVoid, s s s i, v)) DEFINE_METASIG_T(IM(Str_BindingFlags_Binder_Obj_ArrObj_ArrParameterModifier_CultureInfo_ArrStr_RetObj, \ s g(BINDING_FLAGS) C(BINDER) j a(j) a(g(PARAMETER_MODIFIER)) C(CULTURE_INFO) a(s), j)) DEFINE_METASIG_T(SM(Delegate_RetIntPtr, C(DELEGATE), I)) diff --git a/src/coreclr/vm/wasm/callhelpers-reverse.cpp b/src/coreclr/vm/wasm/callhelpers-reverse.cpp index 2e9f5716e8bd06..fa45712b37dded 100644 --- a/src/coreclr/vm/wasm/callhelpers-reverse.cpp +++ b/src/coreclr/vm/wasm/callhelpers-reverse.cpp @@ -274,6 +274,45 @@ static void Call_System_Private_CoreLib_System_Reflection_LoaderAllocator_Create ExecuteInterpretedMethodFromUnmanaged(MD_System_Private_CoreLib_System_Reflection_LoaderAllocator_Create_I32_I32_RetVoid, (int8_t*)args, sizeof(args), nullptr, (PCODE)&Call_System_Private_CoreLib_System_Reflection_LoaderAllocator_Create_I32_I32_RetVoid); } +static MethodDesc* MD_System_Private_CoreLib_System_IO_FileLoadException_Create_I32_I32_I32_I32_I32_RetVoid = nullptr; +static void Call_System_Private_CoreLib_System_IO_FileLoadException_Create_I32_I32_I32_I32_I32_RetVoid(int32_t arg0, void * arg1, int32_t arg2, void * arg3, void * arg4) +{ + int64_t args[5] = { (int64_t)arg0, (int64_t)arg1, (int64_t)arg2, (int64_t)arg3, (int64_t)arg4 }; + + // Lazy lookup of MethodDesc for the function export scenario. + if (!MD_System_Private_CoreLib_System_IO_FileLoadException_Create_I32_I32_I32_I32_I32_RetVoid) + { + LookupUnmanagedCallersOnlyMethodByName("System.IO.FileLoadException, System.Private.CoreLib", "Create", &MD_System_Private_CoreLib_System_IO_FileLoadException_Create_I32_I32_I32_I32_I32_RetVoid); + } + ExecuteInterpretedMethodFromUnmanaged(MD_System_Private_CoreLib_System_IO_FileLoadException_Create_I32_I32_I32_I32_I32_RetVoid, (int8_t*)args, sizeof(args), nullptr, (PCODE)&Call_System_Private_CoreLib_System_IO_FileLoadException_Create_I32_I32_I32_I32_I32_RetVoid); +} + +static MethodDesc* MD_System_Private_CoreLib_System_TypeLoadException_Create_I32_I32_I32_I32_I32_I32_RetVoid = nullptr; +static void Call_System_Private_CoreLib_System_TypeLoadException_Create_I32_I32_I32_I32_I32_I32_RetVoid(void * arg0, void * arg1, void * arg2, int32_t arg3, void * arg4, void * arg5) +{ + int64_t args[6] = { (int64_t)arg0, (int64_t)arg1, (int64_t)arg2, (int64_t)arg3, (int64_t)arg4, (int64_t)arg5 }; + + // Lazy lookup of MethodDesc for the function export scenario. + if (!MD_System_Private_CoreLib_System_TypeLoadException_Create_I32_I32_I32_I32_I32_I32_RetVoid) + { + LookupUnmanagedCallersOnlyMethodByName("System.TypeLoadException, System.Private.CoreLib", "Create", &MD_System_Private_CoreLib_System_TypeLoadException_Create_I32_I32_I32_I32_I32_I32_RetVoid); + } + ExecuteInterpretedMethodFromUnmanaged(MD_System_Private_CoreLib_System_TypeLoadException_Create_I32_I32_I32_I32_I32_I32_RetVoid, (int8_t*)args, sizeof(args), nullptr, (PCODE)&Call_System_Private_CoreLib_System_TypeLoadException_Create_I32_I32_I32_I32_I32_I32_RetVoid); +} + +static MethodDesc* MD_System_Private_CoreLib_System_Exception_CreateArgumentException_I32_I32_I32_I32_I32_RetVoid = nullptr; +static void Call_System_Private_CoreLib_System_Exception_CreateArgumentException_I32_I32_I32_I32_I32_RetVoid(int32_t arg0, void * arg1, void * arg2, void * arg3, void * arg4) +{ + int64_t args[5] = { (int64_t)arg0, (int64_t)arg1, (int64_t)arg2, (int64_t)arg3, (int64_t)arg4 }; + + // Lazy lookup of MethodDesc for the function export scenario. + if (!MD_System_Private_CoreLib_System_Exception_CreateArgumentException_I32_I32_I32_I32_I32_RetVoid) + { + LookupUnmanagedCallersOnlyMethodByName("System.Exception, System.Private.CoreLib", "CreateArgumentException", &MD_System_Private_CoreLib_System_Exception_CreateArgumentException_I32_I32_I32_I32_I32_RetVoid); + } + ExecuteInterpretedMethodFromUnmanaged(MD_System_Private_CoreLib_System_Exception_CreateArgumentException_I32_I32_I32_I32_I32_RetVoid, (int8_t*)args, sizeof(args), nullptr, (PCODE)&Call_System_Private_CoreLib_System_Exception_CreateArgumentException_I32_I32_I32_I32_I32_RetVoid); +} + static MethodDesc* MD_System_Private_CoreLib_System_Reflection_AssemblyName_CreateAssemblyName_I32_I32_I32_RetVoid = nullptr; static void Call_System_Private_CoreLib_System_Reflection_AssemblyName_CreateAssemblyName_I32_I32_I32_RetVoid(void * arg0, void * arg1, void * arg2) { @@ -1016,6 +1055,9 @@ const ReverseThunkMapEntry g_ReverseThunks[] = { 4090197812, "ConvertToManaged#3:System.Private.CoreLib:System.StubHelpers:BSTRMarshaler", { &MD_System_Private_CoreLib_System_StubHelpers_BSTRMarshaler_ConvertToManaged_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_StubHelpers_BSTRMarshaler_ConvertToManaged_I32_I32_I32_RetVoid } }, { 1901425681, "ConvertToNative#2:System.Private.CoreLib:System.StubHelpers:BSTRMarshaler", { &MD_System_Private_CoreLib_System_StubHelpers_BSTRMarshaler_ConvertToNative_I32_I32_RetI32, (void*)&Call_System_Private_CoreLib_System_StubHelpers_BSTRMarshaler_ConvertToNative_I32_I32_RetI32 } }, { 1243134822, "Create#2:System.Private.CoreLib:System.Reflection:LoaderAllocator", { &MD_System_Private_CoreLib_System_Reflection_LoaderAllocator_Create_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Reflection_LoaderAllocator_Create_I32_I32_RetVoid } }, + { 1899576323, "Create#5:System.Private.CoreLib:System.IO:FileLoadException", { &MD_System_Private_CoreLib_System_IO_FileLoadException_Create_I32_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_IO_FileLoadException_Create_I32_I32_I32_I32_I32_RetVoid } }, + { 1263271190, "Create#6:System.Private.CoreLib:System:TypeLoadException", { &MD_System_Private_CoreLib_System_TypeLoadException_Create_I32_I32_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_TypeLoadException_Create_I32_I32_I32_I32_I32_I32_RetVoid } }, + { 509807279, "CreateArgumentException#5:System.Private.CoreLib:System:Exception", { &MD_System_Private_CoreLib_System_Exception_CreateArgumentException_I32_I32_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Exception_CreateArgumentException_I32_I32_I32_I32_I32_RetVoid } }, { 1570902419, "CreateAssemblyName#3:System.Private.CoreLib:System.Reflection:AssemblyName", { &MD_System_Private_CoreLib_System_Reflection_AssemblyName_CreateAssemblyName_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Reflection_AssemblyName_CreateAssemblyName_I32_I32_I32_RetVoid } }, { 3054399043, "CreateRuntimeWrappedException#3:System.Private.CoreLib:System:Exception", { &MD_System_Private_CoreLib_System_Exception_CreateRuntimeWrappedException_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Exception_CreateRuntimeWrappedException_I32_I32_I32_RetVoid } }, { 271519467, "CreateTargetInvocationException#3:System.Private.CoreLib:System:Exception", { &MD_System_Private_CoreLib_System_Exception_CreateTargetInvocationException_I32_I32_I32_RetVoid, (void*)&Call_System_Private_CoreLib_System_Exception_CreateTargetInvocationException_I32_I32_I32_RetVoid } }, diff --git a/src/native/libs/Common/JavaScript/loader/dotnet.d.ts b/src/native/libs/Common/JavaScript/loader/dotnet.d.ts index 0d8cd952ea62b3..1468d116b94289 100644 --- a/src/native/libs/Common/JavaScript/loader/dotnet.d.ts +++ b/src/native/libs/Common/JavaScript/loader/dotnet.d.ts @@ -48,6 +48,10 @@ interface DotnetHostBuilder { * @param config default values for the runtime configuration. It will be merged with the default values. */ withConfig(config: LoaderConfig): DotnetHostBuilder; + /** + * @deprecated This method is no longer supported and will be removed in a future version. + */ + withConfigSrc(configSrc: string): DotnetHostBuilder; /** * "command line" arguments for the Main() method. * @param args