summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/inc/winrtprojectedtypes.h18
-rw-r--r--src/md/winmd/adapter.cpp4
-rw-r--r--src/md/winmd/inc/adapter.h12
-rw-r--r--src/vm/appdomain.cpp151
-rw-r--r--src/vm/appdomain.hpp16
-rw-r--r--src/vm/class.cpp2
-rw-r--r--src/vm/classnames.h12
-rw-r--r--src/vm/clsload.cpp33
-rw-r--r--src/vm/clsload.hpp10
-rw-r--r--src/vm/interoputil.cpp88
-rw-r--r--src/vm/methodtablebuilder.cpp49
-rw-r--r--src/vm/winrtredirector.h14
-rw-r--r--src/vm/winrttypenameconverter.cpp144
-rw-r--r--src/vm/winrttypenameconverter.h5
14 files changed, 269 insertions, 289 deletions
diff --git a/src/inc/winrtprojectedtypes.h b/src/inc/winrtprojectedtypes.h
index f8e0d11bb3..45ccb0c268 100644
--- a/src/inc/winrtprojectedtypes.h
+++ b/src/inc/winrtprojectedtypes.h
@@ -140,7 +140,7 @@ DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "Point",
DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "Rect", "Windows.Foundation", "Rect", SystemRuntimeWindowsRuntime, SystemRuntimeWindowsRuntime, Windows_Foundation_Rect, Windows_Foundation_Rect_clr, STRUCT_FIELDS(W("Single"), W("Single"), W("Single"), W("Single")))
DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "Size", "Windows.Foundation", "Size", SystemRuntimeWindowsRuntime, SystemRuntimeWindowsRuntime, Windows_Foundation_Size, Windows_Foundation_Size_clr, STRUCT_FIELDS(W("Single"), W("Single")))
DEFINE_PROJECTED_STRUCT ("Windows.Foundation", "TimeSpan", "System", "TimeSpan", Mscorlib, SystemRuntime, Windows_Foundation_TimeSpan, System_TimeSpan, STRUCT_FIELDS(W("Int64")))
-DEFINE_PROJECTED_RUNTIMECLASS("Windows.Foundation", "Uri", "System", "Uri", InternalUri, SystemRuntime, Windows_Foundation_Uri, System_Uri, "Windows.Foundation.IUriRuntimeClass", __uuidof(ABI::Windows::Foundation::IUriRuntimeClass))
+DEFINE_PROJECTED_RUNTIMECLASS("Windows.Foundation", "Uri", "System", "Uri", SystemRuntime, SystemRuntime, Windows_Foundation_Uri, System_Uri, "Windows.Foundation.IUriRuntimeClass", __uuidof(ABI::Windows::Foundation::IUriRuntimeClass))
DEFINE_PROJECTED_INTERFACE ("Windows.Foundation", "IClosable", "System", "IDisposable", Mscorlib, SystemRuntime, Windows_Foundation_IClosable, System_IDisposable, PIID(0x30d5a829, 0x7fa4, 0x4026, {0x83, 0xbb, 0xd7, 0x5b, 0xae, 0x4e, 0xa9, 0x9e}))
@@ -151,19 +151,19 @@ DEFINE_PROJECTED_PINTERFACE ("Windows.Foundation.Collections", "IMap`2",
DEFINE_PROJECTED_PINTERFACE ("Windows.Foundation.Collections", "IMapView`2", "System.Collections.Generic", "IReadOnlyDictionary`2", Mscorlib, SystemRuntime, Windows_Foundation_Collections_IMapView, System_Collections_Generic_IReadOnlyDictionary, 2, PIID(0xe480ce40, 0xa338, 0x4ada, {0xad, 0xcf, 0x27, 0x22, 0x72, 0xe4, 0x8c, 0xb9}))
DEFINE_PROJECTED_PINTERFACE ("Windows.Foundation.Collections", "IKeyValuePair`2", "System.Collections.Generic", "KeyValuePair`2", Mscorlib, SystemRuntime, Windows_Foundation_Collections_IKeyValuePair, System_Collections_Generic_KeyValuePair, 2, PIID(0x02b51929, 0xc1c4, 0x4a7e, {0x89, 0x40, 0x03, 0x12, 0xb5, 0xc1, 0x85, 0x00}))
-DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Input", "ICommand", "System.Windows.Input", "ICommand", System, SystemObjectModel, Windows_UI_Xaml_Input_ICommand, System_Windows_Input_ICommand, PIID(0xE5AF3542, 0xCA67, 0x4081, {0x99, 0x5B, 0x70, 0x9D, 0xD1, 0x37, 0x92, 0xDF}))
+DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Input", "ICommand", "System.Windows.Input", "ICommand", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Input_ICommand, System_Windows_Input_ICommand, PIID(0xE5AF3542, 0xCA67, 0x4081, {0x99, 0x5B, 0x70, 0x9D, 0xD1, 0x37, 0x92, 0xDF}))
DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Interop", "IBindableIterable", "System.Collections", "IEnumerable", Mscorlib, SystemRuntime, Windows_UI_Xaml_Interop_IBindableIterable, System_Collections_IEnumerable, PIID(0x036d2c08, 0xdf29, 0x41af, {0x8a, 0xa2, 0xd7, 0x74, 0xbe, 0x62, 0xba, 0x6f}))
DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Interop", "IBindableVector", "System.Collections", "IList", Mscorlib, SystemRuntime, Windows_UI_Xaml_Interop_IBindableVector, System_Collections_IList, PIID(0x393de7de, 0x6fd0, 0x4c0d, {0xbb, 0x71, 0x47, 0x24, 0x4a, 0x11, 0x3e, 0x93}))
-DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Interop", "INotifyCollectionChanged", "System.Collections.Specialized", "INotifyCollectionChanged", System, SystemObjectModel, Windows_UI_Xaml_Interop_INotifyCollectionChanged, System_Collections_Specialized_INotifyCollectionChanged, PIID(0x28b167d5, 0x1a31, 0x465b, {0x9b, 0x25, 0xd5, 0xc3, 0xae, 0x68, 0x6c, 0x40}))
-DEFINE_PROJECTED_DELEGATE ("Windows.UI.Xaml.Interop", "NotifyCollectionChangedEventHandler", "System.Collections.Specialized", "NotifyCollectionChangedEventHandler", System, SystemObjectModel, Windows_UI_Xaml_Interop_NotifyCollectionChangedEventHandler, System_Collections_Specialized_NotifyCollectionChangedEventHandler, PIID(0xca10b37c, 0xf382, 0x4591, {0x85, 0x57, 0x5e, 0x24, 0x96, 0x52, 0x79, 0xb0}))
-DEFINE_PROJECTED_RUNTIMECLASS("Windows.UI.Xaml.Interop", "NotifyCollectionChangedEventArgs", "System.Collections.Specialized", "NotifyCollectionChangedEventArgs", System, SystemObjectModel, Windows_UI_Xaml_Interop_NotifyCollectionChangedEventArgs, System_Collections_Specialized_NotifyCollectionChangedEventArgs, "Windows.UI.Xaml.Interop.INotifyCollectionChangedEventArgs", PIID(0x4cf68d33, 0xe3f2, 0x4964, {0xb8, 0x5e, 0x94, 0x5b, 0x4f, 0x7e, 0x2f, 0x21}))
-DEFINE_PROJECTED_ENUM ("Windows.UI.Xaml.Interop", "NotifyCollectionChangedAction", "System.Collections.Specialized", "NotifyCollectionChangedAction", System, SystemObjectModel, Windows_UI_Xaml_Interop_NotifyCollectionChangedAction, System_Collections_Specialized_NotifyCollectionChangedAction, "Int32")
+DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Interop", "INotifyCollectionChanged", "System.Collections.Specialized", "INotifyCollectionChanged", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Interop_INotifyCollectionChanged, System_Collections_Specialized_INotifyCollectionChanged, PIID(0x28b167d5, 0x1a31, 0x465b, {0x9b, 0x25, 0xd5, 0xc3, 0xae, 0x68, 0x6c, 0x40}))
+DEFINE_PROJECTED_DELEGATE ("Windows.UI.Xaml.Interop", "NotifyCollectionChangedEventHandler", "System.Collections.Specialized", "NotifyCollectionChangedEventHandler", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Interop_NotifyCollectionChangedEventHandler, System_Collections_Specialized_NotifyCollectionChangedEventHandler, PIID(0xca10b37c, 0xf382, 0x4591, {0x85, 0x57, 0x5e, 0x24, 0x96, 0x52, 0x79, 0xb0}))
+DEFINE_PROJECTED_RUNTIMECLASS("Windows.UI.Xaml.Interop", "NotifyCollectionChangedEventArgs", "System.Collections.Specialized", "NotifyCollectionChangedEventArgs", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Interop_NotifyCollectionChangedEventArgs, System_Collections_Specialized_NotifyCollectionChangedEventArgs, "Windows.UI.Xaml.Interop.INotifyCollectionChangedEventArgs", PIID(0x4cf68d33, 0xe3f2, 0x4964, {0xb8, 0x5e, 0x94, 0x5b, 0x4f, 0x7e, 0x2f, 0x21}))
+DEFINE_PROJECTED_ENUM ("Windows.UI.Xaml.Interop", "NotifyCollectionChangedAction", "System.Collections.Specialized", "NotifyCollectionChangedAction", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Interop_NotifyCollectionChangedAction, System_Collections_Specialized_NotifyCollectionChangedAction, "Int32")
-DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Data", "INotifyPropertyChanged", "System.ComponentModel", "INotifyPropertyChanged", System, SystemObjectModel, Windows_UI_Xaml_Data_INotifyPropertyChanged, System_ComponentModel_INotifyPropertyChanged, PIID(0xcf75d69c, 0xf2f4, 0x486b, {0xb3, 0x02, 0xbb, 0x4c, 0x09, 0xba, 0xeb, 0xfa}))
-DEFINE_PROJECTED_DELEGATE ("Windows.UI.Xaml.Data", "PropertyChangedEventHandler", "System.ComponentModel", "PropertyChangedEventHandler", System, SystemObjectModel, Windows_UI_Xaml_Data_PropertyChangedEventHandler, System_ComponentModel_PropertyChangedEventHandler, PIID(0x50f19c16, 0x0a22, 0x4d8e, {0xa0, 0x89, 0x1e, 0xa9, 0x95, 0x16, 0x57, 0xd2}))
-DEFINE_PROJECTED_RUNTIMECLASS("Windows.UI.Xaml.Data", "PropertyChangedEventArgs", "System.ComponentModel", "PropertyChangedEventArgs", System, SystemObjectModel, Windows_UI_Xaml_Data_PropertyChangedEventArgs, System_ComponentModel_PropertyChangedEventArgs, "Windows.UI.Xaml.Data.IPropertyChangedEventArgs", PIID(0x4f33a9a0, 0x5cf4, 0x47a4, {0xb1, 0x6f, 0xd7, 0xfa, 0xaf, 0x17, 0x45, 0x7e}))
+DEFINE_PROJECTED_INTERFACE ("Windows.UI.Xaml.Data", "INotifyPropertyChanged", "System.ComponentModel", "INotifyPropertyChanged", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Data_INotifyPropertyChanged, System_ComponentModel_INotifyPropertyChanged, PIID(0xcf75d69c, 0xf2f4, 0x486b, {0xb3, 0x02, 0xbb, 0x4c, 0x09, 0xba, 0xeb, 0xfa}))
+DEFINE_PROJECTED_DELEGATE ("Windows.UI.Xaml.Data", "PropertyChangedEventHandler", "System.ComponentModel", "PropertyChangedEventHandler", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Data_PropertyChangedEventHandler, System_ComponentModel_PropertyChangedEventHandler, PIID(0x50f19c16, 0x0a22, 0x4d8e, {0xa0, 0x89, 0x1e, 0xa9, 0x95, 0x16, 0x57, 0xd2}))
+DEFINE_PROJECTED_RUNTIMECLASS("Windows.UI.Xaml.Data", "PropertyChangedEventArgs", "System.ComponentModel", "PropertyChangedEventArgs", SystemObjectModel, SystemObjectModel, Windows_UI_Xaml_Data_PropertyChangedEventArgs, System_ComponentModel_PropertyChangedEventArgs, "Windows.UI.Xaml.Data.IPropertyChangedEventArgs", PIID(0x4f33a9a0, 0x5cf4, 0x47a4, {0xb1, 0x6f, 0xd7, 0xfa, 0xaf, 0x17, 0x45, 0x7e}))
DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml", "CornerRadius", "Windows.UI.Xaml", "CornerRadius", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_CornerRadius, Windows_UI_Xaml_CornerRadius_clr, STRUCT_FIELDS(W("Double"), W("Double"), W("Double"), W("Double")))
DEFINE_PROJECTED_JUPITER_STRUCT("Windows.UI.Xaml", "Duration", "Windows.UI.Xaml", "Duration", SystemRuntimeWindowsRuntimeUIXaml, SystemRuntimeWindowsRuntimeUIXaml, Windows_UI_Xaml_Duration, Windows_UI_Xaml_Duration_clr, STRUCT_FIELDS(W("Windows.Foundation.TimeSpan"), W("Windows.UI.Xaml.DurationType")))
diff --git a/src/md/winmd/adapter.cpp b/src/md/winmd/adapter.cpp
index 64cc25ce49..45c695c1d3 100644
--- a/src/md/winmd/adapter.cpp
+++ b/src/md/winmd/adapter.cpp
@@ -1126,7 +1126,7 @@ void WinMDAdapter::GetExtraAssemblyRefProps(FrameworkAssemblyIndex index,
if (ppPublicKeytoken)
{
#ifdef FEATURE_CORECLR
- if (index == FrameworkAssembly_System || index == FrameworkAssembly_Mscorlib)
+ if (index == FrameworkAssembly_Mscorlib)
{
*ppPublicKeytoken = g_rbTheSilverlightPlatformKeyToken;
*pTokenLength = sizeof(g_rbTheSilverlightPlatformKeyToken);
@@ -1134,7 +1134,7 @@ void WinMDAdapter::GetExtraAssemblyRefProps(FrameworkAssemblyIndex index,
else
#endif
{
- if (index == FrameworkAssembly_SystemNumericsVectors || index == FrameworkAssembly_InternalUri)
+ if (index == FrameworkAssembly_SystemNumericsVectors || index == FrameworkAssembly_SystemRuntime || index == FrameworkAssembly_SystemObjectModel)
{
*ppPublicKeytoken = s_pbContractPublicKeyToken;
*pTokenLength = sizeof(s_pbContractPublicKeyToken);
diff --git a/src/md/winmd/inc/adapter.h b/src/md/winmd/inc/adapter.h
index 14a26b56b1..87fc410a77 100644
--- a/src/md/winmd/inc/adapter.h
+++ b/src/md/winmd/inc/adapter.h
@@ -83,11 +83,11 @@ public:
enum FrameworkAssemblyIndex
{
FrameworkAssembly_Mscorlib,
- FrameworkAssembly_System,
+ FrameworkAssembly_SystemObjectModel,
+ FrameworkAssembly_SystemRuntime,
FrameworkAssembly_SystemRuntimeWindowsRuntime,
FrameworkAssembly_SystemRuntimeWindowsRuntimeUIXaml,
FrameworkAssembly_SystemNumericsVectors,
- FrameworkAssembly_InternalUri,
FrameworkAssembly_Count,
};
@@ -626,16 +626,16 @@ public:
_ASSERTE(index != FrameworkAssembly_Mscorlib);
switch(index)
{
- case FrameworkAssembly_System:
- return "System";
+ case FrameworkAssembly_SystemObjectModel:
+ return "System.ObjectModel";
+ case FrameworkAssembly_SystemRuntime:
+ return "System.Runtime";
case FrameworkAssembly_SystemRuntimeWindowsRuntime:
return "System.Runtime.WindowsRuntime";
case FrameworkAssembly_SystemRuntimeWindowsRuntimeUIXaml:
return "System.Runtime.WindowsRuntime.UI.Xaml";
case FrameworkAssembly_SystemNumericsVectors:
return "System.Numerics.Vectors";
- case FrameworkAssembly_InternalUri:
- return "Internal.Uri";
default:
_ASSERTE(!"Invalid AssemblyRef token!");
return NULL;
diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp
index 4c02f35f7f..64bd4410bf 100644
--- a/src/vm/appdomain.cpp
+++ b/src/vm/appdomain.cpp
@@ -4865,11 +4865,6 @@ AppDomain::AppDomain()
m_pLicenseInteropHelperMT = NULL;
m_COMorRemotingFlag = COMorRemoting_NotInitialized;
memset(m_rpCLRTypes, 0, sizeof(m_rpCLRTypes));
- m_pSystemDll = nullptr;
- m_pSystemRuntimeWindowsRuntimeDll = nullptr;
- m_pSystemRuntimeWindowsRuntimeUIXamlDll = nullptr;
- m_pSystemNumericsVectors = nullptr;
- m_pInternalUri = nullptr;
#endif // FEATURE_COMINTEROP
m_pUMEntryThunkCache = NULL;
@@ -5912,106 +5907,10 @@ MethodTable* AppDomain::LoadRedirectedType(WinMDAdapter::RedirectedTypeIndex ind
CLASS_LOAD_EXACTPARENTS).GetMethodTable();
}
}
-
-bool AppDomain::FindRedirectedAssembly(Assembly* pAssembly, WinMDAdapter::FrameworkAssemblyIndex* pIndex)
-{
- CONTRACTL
- {
- STANDARD_VM_CHECK;
- PRECONDITION(CheckPointer(pAssembly));
- PRECONDITION(CheckPointer(pIndex));
- }
- CONTRACTL_END;
-
- DomainAssembly *pDomainAssembly = pAssembly->GetDomainAssembly();
-
- if (pDomainAssembly->IsSystem())
- {
- *pIndex = WinMDAdapter::FrameworkAssembly_Mscorlib;
- return true;
- }
- else if (pDomainAssembly == m_pSystemDll)
- {
- *pIndex = WinMDAdapter::FrameworkAssembly_System;
- return true;
- }
- else if (pDomainAssembly == m_pSystemRuntimeWindowsRuntimeDll)
- {
- *pIndex = WinMDAdapter::FrameworkAssembly_SystemRuntimeWindowsRuntime;
- return true;
- }
- else if (pDomainAssembly == m_pSystemRuntimeWindowsRuntimeUIXamlDll)
- {
- *pIndex = WinMDAdapter::FrameworkAssembly_SystemRuntimeWindowsRuntimeUIXaml;
- return true;
- }
- else if (pDomainAssembly == m_pSystemNumericsVectors)
- {
- *pIndex = WinMDAdapter::FrameworkAssembly_SystemNumericsVectors;
- return true;
- }
- else if (pDomainAssembly == m_pInternalUri)
- {
- *pIndex = WinMDAdapter::FrameworkAssembly_InternalUri;
- return true;
- }
-
- return false;
-}
-
#endif //FEATURE_COMINTEROP
#endif //!DACCESS_COMPILE
-
-#ifdef FEATURE_COMINTEROP
-BOOL AppDomain::FindRedirectedAssemblyFromIndexIfLoaded(WinMDAdapter::FrameworkAssemblyIndex index, Assembly ** ppAssembly)
-{
- LIMITED_METHOD_CONTRACT;
-
- // If new redirected assemblies are added, this function probably needs to be updated
- C_ASSERT(WinMDAdapter::FrameworkAssembly_Count == 6);
-
- DomainAssembly * pDomainAssembly = NULL;
-
- if (index == WinMDAdapter::FrameworkAssembly_Mscorlib)
- {
- *ppAssembly = SystemDomain::SystemAssembly();
- return TRUE;
- }
- else if (index == WinMDAdapter::FrameworkAssembly_System)
- {
- pDomainAssembly = m_pSystemDll;
- }
- else if (index == WinMDAdapter::FrameworkAssembly_SystemRuntimeWindowsRuntime)
- {
- pDomainAssembly = m_pSystemRuntimeWindowsRuntimeDll;
- }
- else if (index == WinMDAdapter::FrameworkAssembly_SystemRuntimeWindowsRuntimeUIXaml)
- {
- pDomainAssembly = m_pSystemRuntimeWindowsRuntimeUIXamlDll;
- }
- else if (index == WinMDAdapter::FrameworkAssembly_SystemNumericsVectors)
- {
- pDomainAssembly = m_pSystemNumericsVectors;
- }
- else if (index == WinMDAdapter::FrameworkAssembly_InternalUri)
- {
- pDomainAssembly = m_pInternalUri;
- }
-
- if (pDomainAssembly != NULL)
- {
- *ppAssembly = pDomainAssembly->GetAssembly();
- return TRUE;
- }
-
- *ppAssembly = NULL;
- return FALSE;
-}
-
-#endif // FEATURE_COMINTEROP
-
#ifndef DACCESS_COMPILE
void AppDomain::CreateSecurityDescriptor()
@@ -6084,56 +5983,6 @@ void AppDomain::AddAssembly(DomainAssembly * assem)
// If empty space not found, simply add to end of list
IfFailThrow(m_Assemblies.Append_Unlocked(assem));
}
-
-#ifdef FEATURE_COMINTEROP
- // See if this is one of the well-known assemblies that we look for
- if (m_pSystemDll == nullptr && IsPlatformAssembly("System", assem))
- {
- m_pSystemDll = assem;
- return;
- }
-
- if (m_pSystemRuntimeWindowsRuntimeDll == nullptr && IsPlatformAssembly("System.Runtime.WindowsRuntime", assem))
- {
- m_pSystemRuntimeWindowsRuntimeDll = assem;
- return;
- }
- if (m_pSystemRuntimeWindowsRuntimeUIXamlDll == nullptr && IsPlatformAssembly("System.Runtime.WindowsRuntime.UI.Xaml", assem))
- {
- m_pSystemRuntimeWindowsRuntimeUIXamlDll = assem;
- return;
- }
- if (m_pSystemNumericsVectors == nullptr)
- {
- PEAssembly *pPEAssembly = assem->GetFile();
-
- if (strcmp("System.Numerics.Vectors", pPEAssembly->GetSimpleName()) == 0)
- {
- DWORD cbPublicKey;
- const BYTE *pbPublicKey = static_cast<const BYTE *>(pPEAssembly->GetPublicKey(&cbPublicKey));
-
- if (cbPublicKey == sizeof(s_pbContractPublicKey) && memcmp(pbPublicKey, s_pbContractPublicKey, cbPublicKey) == 0)
- {
- m_pSystemNumericsVectors = assem;
- }
- }
- }
- if (m_pInternalUri == nullptr)
- {
- PEAssembly *pPEAssembly = assem->GetFile();
-
- if (strcmp("Internal.Uri", pPEAssembly->GetSimpleName()) == 0)
- {
- DWORD cbPublicKey;
- const BYTE *pbPublicKey = static_cast<const BYTE *>(pPEAssembly->GetPublicKey(&cbPublicKey));
-
- if (cbPublicKey == sizeof(s_pbContractPublicKey) && memcmp(pbPublicKey, s_pbContractPublicKey, cbPublicKey) == 0)
- {
- m_pInternalUri = assem;
- }
- }
- }
-#endif // FEATURE_COMINTEROP
}
void AppDomain::RemoveAssembly_Unlocked(DomainAssembly * pAsm)
diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp
index 49e6a72759..a48cafbac9 100644
--- a/src/vm/appdomain.hpp
+++ b/src/vm/appdomain.hpp
@@ -2103,7 +2103,6 @@ public:
HRESULT GetComIPForExposedObject(IUnknown **pComIP);
MethodTable *GetRedirectedType(WinMDAdapter::RedirectedTypeIndex index);
- bool FindRedirectedAssembly(Assembly* pAssembly, WinMDAdapter::FrameworkAssemblyIndex* pIndex);
#endif // FEATURE_COMINTEROP
@@ -3409,21 +3408,6 @@ private:
COMorRemotingFlag m_COMorRemotingFlag;
OBJECTHANDLE m_hndMissing; //Handle points to Missing.Value Object which is used for [Optional] arg scenario during IDispatch CCW Call
- PTR_DomainAssembly m_pSystemDll; // System.dll loaded into this domain
- PTR_DomainAssembly m_pSystemRuntimeWindowsRuntimeDll; // System.Runtime.WindowsRuntime.dll loaded into this domain
- PTR_DomainAssembly m_pSystemRuntimeWindowsRuntimeUIXamlDll; // System.Runtime.WindowsRuntime.UI.Xaml.dll loaded into this domain
- PTR_DomainAssembly m_pSystemNumericsVectors; // System.Numerics.Vectors.dll loaded into this domain
- PTR_DomainAssembly m_pInternalUri; // Internal.Uri.dll loaded into this domain
-public:
- BOOL FindRedirectedAssemblyFromIndexIfLoaded(WinMDAdapter::FrameworkAssemblyIndex index, Assembly** ppAssembly);
-
- BOOL IsSystemDll(Assembly *pAssembly)
- {
- LIMITED_METHOD_CONTRACT;
- return (m_pSystemDll != NULL && m_pSystemDll->GetCurrentAssembly() == pAssembly);
- }
-private:
-
MethodTable* m_rpCLRTypes[WinMDAdapter::RedirectedTypeIndex_Count];
MethodTable* LoadRedirectedType(WinMDAdapter::RedirectedTypeIndex index, WinMDAdapter::FrameworkAssemblyIndex assembly);
diff --git a/src/vm/class.cpp b/src/vm/class.cpp
index 108016537e..932f8bed00 100644
--- a/src/vm/class.cpp
+++ b/src/vm/class.cpp
@@ -3782,7 +3782,7 @@ HRESULT EEClass::WriteCompactLayoutTypeFlags(ICompactLayoutWriter *pICLW)
_ASSERTE("MDIL Compiler has determined that a winrt type needs per-type-RCW data, but is not a platform type." &&
(GetMethodTable()->GetModule()->GetAssembly()->GetManifestFile()->IsProfileAssembly() ||
GetMethodTable()->GetModule()->GetAssembly()->IsWinMD() ||
- GetAppDomain()->IsSystemDll(GetMethodTable()->GetModule()->GetAssembly())));
+ GetWinRTRedirectedTypeIndex() != WinMDAdapter::RedirectedTypeIndex_Invalid));
#endif
#ifdef _DEBUG
if (GetMethodTable()->GetModule()->GetAssembly()->IsWinMD())
diff --git a/src/vm/classnames.h b/src/vm/classnames.h
index fe75f7aa52..8d53eb0216 100644
--- a/src/vm/classnames.h
+++ b/src/vm/classnames.h
@@ -52,7 +52,19 @@
#define g_ICommandName "System.Windows.Input.ICommand"
#define g_ComObjectName "__ComObject"
#define g_RuntimeClassName "RuntimeClass"
+#define g_INotifyCollectionChanged_WinRTName "System.Runtime.InteropServices.WindowsRuntime.INotifyCollectionChanged_WinRT"
+#define g_NotifyCollectionChangedToManagedAdapterName "System.Runtime.InteropServices.WindowsRuntime.NotifyCollectionChangedToManagedAdapter"
+#define g_NotifyCollectionChangedToWinRTAdapterName "System.Runtime.InteropServices.WindowsRuntime.NotifyCollectionChangedToWinRTAdapter"
+#define g_INotifyPropertyChanged_WinRTName "System.Runtime.InteropServices.WindowsRuntime.INotifyPropertyChanged_WinRT"
+#define g_NotifyPropertyChangedToManagedAdapterName "System.Runtime.InteropServices.WindowsRuntime.NotifyPropertyChangedToManagedAdapter"
+#define g_NotifyPropertyChangedToWinRTAdapterName "System.Runtime.InteropServices.WindowsRuntime.NotifyPropertyChangedToWinRTAdapter"
+#define g_ICommand_WinRTName "System.Runtime.InteropServices.WindowsRuntime.ICommand_WinRT"
+#define g_ICommandToManagedAdapterName "System.Runtime.InteropServices.WindowsRuntime.ICommandToManagedAdapter"
+#define g_ICommandToWinRTAdapterName "System.Runtime.InteropServices.WindowsRuntime.ICommandToWinRTAdapter"
+#define g_NotifyCollectionChangedEventHandler_WinRT "System.Runtime.InteropServices.WindowsRuntime.NotifyCollectionChangedEventHandler_WinRT"
+#define g_PropertyChangedEventHandler_WinRT_Name "System.Runtime.InteropServices.WindowsRuntime.PropertyChangedEventHandler_WinRT"
#endif // FEATURE_COMINTEROP
+
#ifdef FEATURE_REMOTING
#define g_ContextBoundObjectClassName "System.ContextBoundObject"
#endif
diff --git a/src/vm/clsload.cpp b/src/vm/clsload.cpp
index 59ceddd9e8..2798ce2c77 100644
--- a/src/vm/clsload.cpp
+++ b/src/vm/clsload.cpp
@@ -3069,11 +3069,38 @@ ClassLoader::ResolveTokenToTypeDefThrowing(
{
nameHandle.SetTokenNotToLoad(tdAllTypes);
}
-
+
+ return ResolveNameToTypeDefThrowing(pFoundRefModule, &nameHandle, ppTypeDefModule, pTypeDefToken, loadFlag, pfUsesTypeForwarder);
+}
+
+/*static*/
+BOOL
+ClassLoader::ResolveNameToTypeDefThrowing(
+ Module * pModule,
+ NameHandle * pName,
+ Module ** ppTypeDefModule,
+ mdTypeDef * pTypeDefToken,
+ Loader::LoadFlag loadFlag,
+ BOOL * pfUsesTypeForwarder) // The semantic of this parameter: TRUE if a type forwarder is found. It is never set to FALSE.
+{
+ CONTRACT(BOOL)
+ {
+ if (FORBIDGC_LOADER_USE_ENABLED()) NOTHROW; else THROWS;
+ if (FORBIDGC_LOADER_USE_ENABLED()) GC_NOTRIGGER; else GC_TRIGGERS;
+ MODE_ANY;
+ if (FORBIDGC_LOADER_USE_ENABLED()) FORBID_FAULT; else { INJECT_FAULT(COMPlusThrowOM()); }
+ PRECONDITION(CheckPointer(pModule));
+ PRECONDITION(CheckPointer(pName));
+ SUPPORTS_DAC;
+ }
+ CONTRACT_END;
+
+ TypeHandle typeHnd;
mdToken foundTypeDef;
Module * pFoundModule;
mdExportedType foundExportedType;
- Module * pSourceModule = pFoundRefModule;
+ Module * pSourceModule = pModule;
+ Module * pFoundRefModule = pModule;
for (UINT32 nTypeForwardingChainSize = 0; nTypeForwardingChainSize < const_cMaxTypeForwardingChainSize; nTypeForwardingChainSize++)
{
@@ -3081,7 +3108,7 @@ ClassLoader::ResolveTokenToTypeDefThrowing(
pFoundModule = NULL;
foundExportedType = mdTokenNil;
if (!pSourceModule->GetClassLoader()->FindClassModuleThrowing(
- &nameHandle,
+ pName,
&typeHnd,
&foundTypeDef,
&pFoundModule,
diff --git a/src/vm/clsload.hpp b/src/vm/clsload.hpp
index 2b56a8e20e..5a16245be0 100644
--- a/src/vm/clsload.hpp
+++ b/src/vm/clsload.hpp
@@ -733,6 +733,16 @@ public:
mdTypeDef * pTypeDefToken,
Loader::LoadFlag loadFlag = Loader::Load,
BOOL * pfUsesTypeForwarder = NULL);
+
+ // Resolve a name to a TypeDef
+ // Return FALSE if operation failed (e.g. type does not exist)
+ // *pfUsesTypeForwarder is set to TRUE if a type forwarder is found. It is never set to FALSE.
+ static BOOL ResolveNameToTypeDefThrowing(Module * pTypeRefModule,
+ NameHandle * pName,
+ Module ** ppTypeDefModule,
+ mdTypeDef * pTypeDefToken,
+ Loader::LoadFlag loadFlag = Loader::Load,
+ BOOL * pfUsesTypeForwarder = NULL);
#endif // !BINDER
static void EnsureLoaded(TypeHandle typeHnd, ClassLoadLevel level = CLASS_LOADED);
diff --git a/src/vm/interoputil.cpp b/src/vm/interoputil.cpp
index 6dbc7c1e50..efdc12a0e3 100644
--- a/src/vm/interoputil.cpp
+++ b/src/vm/interoputil.cpp
@@ -295,20 +295,44 @@ static const BinderMethodID s_stubsDisposableToClosable[] =
METHOD__IDISPOSABLE_TO_ICLOSABLE_ADAPTER__CLOSE
};
+#ifdef FEATURE_CORECLR
+#define FX_PLATFORM_KEY g_CoreClrKeyToken
+#else
+#define FX_PLATFORM_KEY g_ECMAKeyToken
+#endif
+
+DEFINE_ASM_QUAL_TYPE_NAME(NCCWINRT_ASM_QUAL_TYPE_NAME, g_INotifyCollectionChanged_WinRTName, g_SystemAsmName, VER_ASSEMBLYVERSION_STR, FX_PLATFORM_KEY);
+DEFINE_ASM_QUAL_TYPE_NAME(NCCMA_ASM_QUAL_TYPE_NAME, g_NotifyCollectionChangedToManagedAdapterName, g_SystemAsmName, VER_ASSEMBLYVERSION_STR, FX_PLATFORM_KEY);
+DEFINE_ASM_QUAL_TYPE_NAME(NCCWA_ASM_QUAL_TYPE_NAME, g_NotifyCollectionChangedToWinRTAdapterName, g_SystemAsmName, VER_ASSEMBLYVERSION_STR, FX_PLATFORM_KEY);
+DEFINE_ASM_QUAL_TYPE_NAME(NPCWINRT_ASM_QUAL_TYPE_NAME, g_INotifyPropertyChanged_WinRTName, g_SystemAsmName, VER_ASSEMBLYVERSION_STR, FX_PLATFORM_KEY);
+DEFINE_ASM_QUAL_TYPE_NAME(NPCMA_ASM_QUAL_TYPE_NAME, g_NotifyPropertyChangedToManagedAdapterName, g_SystemAsmName, VER_ASSEMBLYVERSION_STR, FX_PLATFORM_KEY);
+DEFINE_ASM_QUAL_TYPE_NAME(NPCWA_ASM_QUAL_TYPE_NAME, g_NotifyPropertyChangedToWinRTAdapterName, g_SystemAsmName, VER_ASSEMBLYVERSION_STR, FX_PLATFORM_KEY);
+DEFINE_ASM_QUAL_TYPE_NAME(CMDWINRT_ASM_QUAL_TYPE_NAME, g_ICommand_WinRTName, g_SystemAsmName, VER_ASSEMBLYVERSION_STR, FX_PLATFORM_KEY);
+DEFINE_ASM_QUAL_TYPE_NAME(CMDMA_ASM_QUAL_TYPE_NAME, g_ICommandToManagedAdapterName, g_SystemAsmName, VER_ASSEMBLYVERSION_STR, FX_PLATFORM_KEY);
+DEFINE_ASM_QUAL_TYPE_NAME(CMDWA_ASM_QUAL_TYPE_NAME, g_ICommandToWinRTAdapterName, g_SystemAsmName, VER_ASSEMBLYVERSION_STR, FX_PLATFORM_KEY);
+DEFINE_ASM_QUAL_TYPE_NAME(NCCEHWINRT_ASM_QUAL_TYPE_NAME, g_NotifyCollectionChangedEventHandler_WinRT, g_SystemAsmName, VER_ASSEMBLYVERSION_STR, FX_PLATFORM_KEY);
+DEFINE_ASM_QUAL_TYPE_NAME(PCEHWINRT_ASM_QUAL_TYPE_NAME, g_PropertyChangedEventHandler_WinRT_Name, g_SystemAsmName, VER_ASSEMBLYVERSION_STR, FX_PLATFORM_KEY);
+
const WinRTInterfaceRedirector::NonMscorlibRedirectedInterfaceInfo WinRTInterfaceRedirector::s_rNonMscorlibInterfaceInfos[3] =
{
- { WinMDAdapter::FrameworkAssembly_System, W("System.Runtime.InteropServices.WindowsRuntime.INotifyCollectionChanged_WinRT"),
- W("System.Runtime.InteropServices.WindowsRuntime.NotifyCollectionChangedToManagedAdapter"),
- W("System.Runtime.InteropServices.WindowsRuntime.NotifyCollectionChangedToWinRTAdapter"),
- s_stubNamesNotifyCollectionChanged },
- { WinMDAdapter::FrameworkAssembly_System, W("System.Runtime.InteropServices.WindowsRuntime.INotifyPropertyChanged_WinRT"),
- W("System.Runtime.InteropServices.WindowsRuntime.NotifyPropertyChangedToManagedAdapter"),
- W("System.Runtime.InteropServices.WindowsRuntime.NotifyPropertyChangedToWinRTAdapter"),
- s_stubNamesNotifyPropertyChanged },
- { WinMDAdapter::FrameworkAssembly_System, W("System.Runtime.InteropServices.WindowsRuntime.ICommand_WinRT"),
- W("System.Runtime.InteropServices.WindowsRuntime.ICommandToManagedAdapter"),
- W("System.Runtime.InteropServices.WindowsRuntime.ICommandToWinRTAdapter"),
- s_stubNamesICommand },
+ {
+ NCCWINRT_ASM_QUAL_TYPE_NAME,
+ NCCMA_ASM_QUAL_TYPE_NAME,
+ NCCWA_ASM_QUAL_TYPE_NAME,
+ s_stubNamesNotifyCollectionChanged
+ },
+ {
+ NPCWINRT_ASM_QUAL_TYPE_NAME,
+ NPCMA_ASM_QUAL_TYPE_NAME,
+ NPCWA_ASM_QUAL_TYPE_NAME,
+ s_stubNamesNotifyPropertyChanged
+ },
+ {
+ CMDWINRT_ASM_QUAL_TYPE_NAME,
+ CMDMA_ASM_QUAL_TYPE_NAME,
+ CMDWA_ASM_QUAL_TYPE_NAME,
+ s_stubNamesICommand
+ },
};
#define SYSTEMDLL__INOTIFYCOLLECTIONCHANGED ((BinderClassID)(WinRTInterfaceRedirector::NON_MSCORLIB_MARKER | 0))
@@ -6065,31 +6089,14 @@ MethodTable *WinRTInterfaceRedirector::GetWinRTTypeForRedirectedInterfaceIndex(W
{
// the redirected interface lives in some other Framework assembly
const NonMscorlibRedirectedInterfaceInfo *pInfo = &s_rNonMscorlibInterfaceInfos[id & ~NON_MSCORLIB_MARKER];
- RETURN LoadTypeFromRedirectedAssembly(pInfo->m_AssemblyIndex, pInfo->m_wzWinRTInterfaceTypeName);
- }
-}
+ SString assemblyQualifiedTypeName(SString::Utf8, pInfo->m_szWinRTInterfaceAssemblyQualifiedTypeName);
-//
-MethodTable *WinRTInterfaceRedirector::LoadTypeFromRedirectedAssembly(WinMDAdapter::FrameworkAssemblyIndex index, LPCWSTR wzTypeName)
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
+ RETURN TypeName::GetTypeFromAsmQualifiedName(assemblyQualifiedTypeName.GetUnicode(), FALSE).GetMethodTable();
}
- CONTRACTL_END;
-
- Assembly *pAssembly;
-
- if (!::GetAppDomain()->FindRedirectedAssemblyFromIndexIfLoaded(index, &pAssembly))
- return NULL;
-
- return TypeName::GetTypeFromAssembly(wzTypeName, pAssembly).GetMethodTable();
}
//
-MethodDesc *WinRTInterfaceRedirector::LoadMethodFromRedirectedAssembly(WinMDAdapter::FrameworkAssemblyIndex index, LPCWSTR wzTypeName, LPCUTF8 szMethodName)
+MethodDesc *WinRTInterfaceRedirector::LoadMethodFromRedirectedAssembly(LPCUTF8 szAssemblyQualifiedTypeName, LPCUTF8 szMethodName)
{
CONTRACTL
{
@@ -6099,7 +6106,9 @@ MethodDesc *WinRTInterfaceRedirector::LoadMethodFromRedirectedAssembly(WinMDAdap
}
CONTRACTL_END;
- MethodTable *pMT = LoadTypeFromRedirectedAssembly(index, wzTypeName);
+ SString assemblyQualifiedTypeName(SString::Utf8, szAssemblyQualifiedTypeName);
+
+ MethodTable *pMT = TypeName::GetTypeFromAsmQualifiedName(assemblyQualifiedTypeName.GetUnicode(), FALSE).GetMethodTable();
return MemberLoader::FindMethodByName(pMT, szMethodName);
}
@@ -6215,8 +6224,7 @@ MethodDesc *WinRTInterfaceRedirector::GetStubMethodForRedirectedInterface(WinMDA
const NonMscorlibRedirectedInterfaceInfo *pInfo = &s_rNonMscorlibInterfaceInfos[pStubInfo->m_WinRTInterface & ~NON_MSCORLIB_MARKER];
pMD = LoadMethodFromRedirectedAssembly(
- pInfo->m_AssemblyIndex,
- (interopKind == TypeHandle::Interop_NativeToManaged) ? pInfo->m_wzWinRTStubClassTypeName : pInfo->m_wzCLRStubClassTypeName,
+ (interopKind == TypeHandle::Interop_NativeToManaged) ? pInfo->m_szWinRTStubClassAssemblyQualifiedTypeName : pInfo->m_szCLRStubClassAssemblyQualifiedTypeName,
pInfo->m_rszMethodNames[method]);
}
@@ -6368,16 +6376,14 @@ MethodTable *WinRTDelegateRedirector::GetWinRTTypeForRedirectedDelegateIndex(Win
case WinMDAdapter::RedirectedTypeIndex_System_Collections_Specialized_NotifyCollectionChangedEventHandler:
{
- Assembly *pAssembly;
- VERIFY(::GetAppDomain()->FindRedirectedAssemblyFromIndexIfLoaded(WinMDAdapter::FrameworkAssembly_System, &pAssembly));
- return TypeName::GetTypeFromAssembly(W("System.Runtime.InteropServices.WindowsRuntime.NotifyCollectionChangedEventHandler_WinRT"), pAssembly).GetMethodTable();
+ SString assemblyQualifiedTypeName(SString::Utf8, NCCEHWINRT_ASM_QUAL_TYPE_NAME);
+ return TypeName::GetTypeFromAsmQualifiedName(assemblyQualifiedTypeName.GetUnicode(), FALSE).GetMethodTable();
}
case WinMDAdapter::RedirectedTypeIndex_System_ComponentModel_PropertyChangedEventHandler:
{
- Assembly *pAssembly;
- VERIFY(::GetAppDomain()->FindRedirectedAssemblyFromIndexIfLoaded(WinMDAdapter::FrameworkAssembly_System, &pAssembly));
- return TypeName::GetTypeFromAssembly(W("System.Runtime.InteropServices.WindowsRuntime.PropertyChangedEventHandler_WinRT"), pAssembly).GetMethodTable();
+ SString assemblyQualifiedTypeName(SString::Utf8, PCEHWINRT_ASM_QUAL_TYPE_NAME);
+ return TypeName::GetTypeFromAsmQualifiedName(assemblyQualifiedTypeName.GetUnicode(), FALSE).GetMethodTable();
}
default:
diff --git a/src/vm/methodtablebuilder.cpp b/src/vm/methodtablebuilder.cpp
index db099e2996..02846290f1 100644
--- a/src/vm/methodtablebuilder.cpp
+++ b/src/vm/methodtablebuilder.cpp
@@ -58,20 +58,6 @@ const char* FormatSig(MethodDesc* pMD, LoaderHeap *pHeap, AllocMemTracker *pamTr
unsigned g_dupMethods = 0;
#endif // _DEBUG
-#ifdef FEATURE_COMINTEROP
-WinMDAdapter::RedirectedTypeIndex CalculateWinRTRedirectedTypeIndex(IMDInternalImport * pInternalImport, Module * pModule, mdTypeDef cl)
-{
- STANDARD_VM_CONTRACT;
-
- Assembly * pAssembly = pModule->GetAssembly();
- WinMDAdapter::FrameworkAssemblyIndex assemblyIndex;
- if (!GetAppDomain()->FindRedirectedAssembly(pAssembly, &assemblyIndex))
- return WinMDAdapter::RedirectedTypeIndex_Invalid;
-
- return WinRTTypeNameConverter::GetRedirectedTypeIndexByName(pInternalImport, cl, assemblyIndex);
-}
-#endif // FEATURE_COMINTEROP
-
//==========================================================================
// This function is very specific about how it constructs a EEClass. It first
// determines the necessary size of the vtable and the number of statics that
@@ -262,8 +248,8 @@ MethodTableBuilder::CreateClass( Module *pModule,
}
}
- WinMDAdapter::RedirectedTypeIndex redirectedTypeIndex;
- redirectedTypeIndex = CalculateWinRTRedirectedTypeIndex(pInternalImport, pModule, cl);
+ WinMDAdapter::RedirectedTypeIndex redirectedTypeIndex;
+ redirectedTypeIndex = WinRTTypeNameConverter::GetRedirectedTypeIndexByName(pModule, cl);
if (redirectedTypeIndex != WinMDAdapter::RedirectedTypeIndex_Invalid)
{
EnsureOptionalFieldsAreAllocated(pEEClass, pamTracker, pAllocator->GetLowFrequencyHeap());
@@ -11741,30 +11727,29 @@ VOID MethodTableBuilder::CheckForSpecialTypes()
}
}
}
- else if (GetAppDomain()->IsSystemDll(pModule->GetAssembly()))
+ else if ((IsInterface() || IsDelegate()) &&
+ IsTdPublic(GetHalfBakedClass()->GetAttrClass()) &&
+ GetHalfBakedClass()->GetWinRTRedirectedTypeIndex() != WinMDAdapter::RedirectedTypeIndex_Invalid)
{
// 7. System.Collections.Specialized.INotifyCollectionChanged
// 8. System.Collections.Specialized.NotifyCollectionChangedEventHandler
// 9. System.ComponentModel.INotifyPropertyChanged
// 10. System.ComponentModel.PropertyChangedEventHandler
// 11. System.Windows.Input.ICommand
- if ((IsInterface() || IsDelegate()) && IsTdPublic(GetHalfBakedClass()->GetAttrClass()))
+ LPCUTF8 pszClassName;
+ LPCUTF8 pszClassNamespace;
+ if (SUCCEEDED(pMDImport->GetNameOfTypeDef(GetCl(), &pszClassName, &pszClassNamespace)))
{
- LPCUTF8 pszClassName;
- LPCUTF8 pszClassNamespace;
- if (SUCCEEDED(pMDImport->GetNameOfTypeDef(GetCl(), &pszClassName, &pszClassNamespace)))
- {
- LPUTF8 pszFullyQualifiedName = NULL;
- MAKE_FULLY_QUALIFIED_NAME(pszFullyQualifiedName, pszClassNamespace, pszClassName);
+ LPUTF8 pszFullyQualifiedName = NULL;
+ MAKE_FULLY_QUALIFIED_NAME(pszFullyQualifiedName, pszClassNamespace, pszClassName);
- if (strcmp(pszFullyQualifiedName, g_INotifyCollectionChangedName) == 0 ||
- strcmp(pszFullyQualifiedName, g_NotifyCollectionChangedEventHandlerName) == 0 ||
- strcmp(pszFullyQualifiedName, g_INotifyPropertyChangedName) == 0 ||
- strcmp(pszFullyQualifiedName, g_PropertyChangedEventHandlerName) == 0 ||
- strcmp(pszFullyQualifiedName, g_ICommandName) == 0)
- {
- bmtProp->fNeedsRCWPerTypeData = true;
- }
+ if (strcmp(pszFullyQualifiedName, g_INotifyCollectionChangedName) == 0 ||
+ strcmp(pszFullyQualifiedName, g_NotifyCollectionChangedEventHandlerName) == 0 ||
+ strcmp(pszFullyQualifiedName, g_INotifyPropertyChangedName) == 0 ||
+ strcmp(pszFullyQualifiedName, g_PropertyChangedEventHandlerName) == 0 ||
+ strcmp(pszFullyQualifiedName, g_ICommandName) == 0)
+ {
+ bmtProp->fNeedsRCWPerTypeData = true;
}
}
}
diff --git a/src/vm/winrtredirector.h b/src/vm/winrtredirector.h
index 2ab807c88e..595eeb7e86 100644
--- a/src/vm/winrtredirector.h
+++ b/src/vm/winrtredirector.h
@@ -36,12 +36,9 @@ public:
// Returns MethodTable (typical instantiation) of the Framework copy of the specified redirected WinRT interface.
static MethodTable *GetWinRTTypeForRedirectedInterfaceIndex(WinMDAdapter::RedirectedTypeIndex index);
-
- // Loads a type from the given Framework assembly.
- static MethodTable *LoadTypeFromRedirectedAssembly(WinMDAdapter::FrameworkAssemblyIndex index, LPCWSTR wzTypeName);
-
+
// Loads a method from the given Framework assembly.
- static MethodDesc *LoadMethodFromRedirectedAssembly(WinMDAdapter::FrameworkAssemblyIndex index, LPCWSTR wzTypeName, LPCUTF8 szMethodName);
+ static MethodDesc *LoadMethodFromRedirectedAssembly(LPCUTF8 szAssemblyQualifiedTypeName, LPCUTF8 szMethodName);
// Lists WinRT-legal types assignable from .NET reference types that are projected from WinRT structures/arrays/delegates.
enum WinRTLegalStructureBaseType
@@ -120,10 +117,9 @@ private:
struct NonMscorlibRedirectedInterfaceInfo
{
- const WinMDAdapter::FrameworkAssemblyIndex m_AssemblyIndex;
- const LPCWSTR m_wzWinRTInterfaceTypeName;
- const LPCWSTR m_wzCLRStubClassTypeName;
- const LPCWSTR m_wzWinRTStubClassTypeName;
+ const LPCUTF8 m_szWinRTInterfaceAssemblyQualifiedTypeName;
+ const LPCUTF8 m_szCLRStubClassAssemblyQualifiedTypeName;
+ const LPCUTF8 m_szWinRTStubClassAssemblyQualifiedTypeName;
const LPCUTF8 *m_rszMethodNames;
};
diff --git a/src/vm/winrttypenameconverter.cpp b/src/vm/winrttypenameconverter.cpp
index f3108a83ac..dfb38cc657 100644
--- a/src/vm/winrttypenameconverter.cpp
+++ b/src/vm/winrttypenameconverter.cpp
@@ -17,7 +17,6 @@
#include "winrttypenameconverter.h"
#include "typeresolution.h"
-
struct RedirectedTypeNames
{
LPCSTR szClrNamespace;
@@ -36,6 +35,48 @@ static const RedirectedTypeNames g_redirectedTypeNames[WinMDAdapter::RedirectedT
#undef DEFINE_PROJECTED_TYPE
+struct RedirectedTypeNamesKey
+{
+ RedirectedTypeNamesKey(LPCSTR szNamespace, LPCSTR szName) :
+ m_szNamespace(szNamespace),
+ m_szName(szName)
+ {
+ LIMITED_METHOD_CONTRACT;
+ }
+
+ LPCSTR m_szNamespace;
+ LPCSTR m_szName;
+};
+
+class RedirectedTypeNamesTraits : public NoRemoveSHashTraits< DefaultSHashTraits<const RedirectedTypeNames *> >
+{
+public:
+ typedef RedirectedTypeNamesKey key_t;
+
+ static key_t GetKey(element_t e)
+ {
+ LIMITED_METHOD_CONTRACT;
+ return RedirectedTypeNamesKey(e->szClrNamespace, e->szClrName);
+ }
+ static BOOL Equals(key_t k1, key_t k2)
+ {
+ LIMITED_METHOD_CONTRACT;
+ return (strcmp(k1.m_szName, k2.m_szName) == 0) && (strcmp(k1.m_szNamespace, k2.m_szNamespace) == 0);
+ }
+ static count_t Hash(key_t k)
+ {
+ LIMITED_METHOD_CONTRACT;
+ // Only use the Name when calculating the hash value. Many redirected types share the same namespace so
+ // there isn't a lot of value in using the namespace when calculating the hash value.
+ return HashStringA(k.m_szName);
+ }
+
+ static const element_t Null() { LIMITED_METHOD_CONTRACT; return NULL; }
+ static bool IsNull(const element_t &e) { LIMITED_METHOD_CONTRACT; return e == NULL; }
+};
+
+typedef SHash< RedirectedTypeNamesTraits > RedirectedTypeNamesHashTable;
+static RedirectedTypeNamesHashTable * s_pRedirectedTypeNamesHashTable = NULL;
//
// Return the redirection index and type kind if the MethodTable* is a redirected type
@@ -580,33 +621,104 @@ bool WinRTTypeNameConverter::IsRedirectedType(MethodTable *pMT, WinMDAdapter::Wi
// static
WinMDAdapter::RedirectedTypeIndex WinRTTypeNameConverter::GetRedirectedTypeIndexByName(
- IMDInternalImport *pMDImport,
- mdTypeDef token,
- WinMDAdapter::FrameworkAssemblyIndex assemblyIndex)
+ Module *pModule,
+ mdTypeDef token)
{
CONTRACTL
{
STANDARD_VM_CHECK;
- PRECONDITION(CheckPointer(pMDImport));
+ PRECONDITION(CheckPointer(pModule));
}
CONTRACTL_END;
+ // If the redirected type hashtable has not been initialized initialize it
+ if (s_pRedirectedTypeNamesHashTable == NULL)
+ {
+ NewHolder<RedirectedTypeNamesHashTable> pRedirectedTypeNamesHashTable = new RedirectedTypeNamesHashTable();
+ pRedirectedTypeNamesHashTable->Reallocate(2 * COUNTOF(g_redirectedTypeNames));
+
+ for (int i = 0; i < COUNTOF(g_redirectedTypeNames); ++i)
+ {
+ pRedirectedTypeNamesHashTable->Add(&(g_redirectedTypeNames[i]));
+ }
+
+ if (InterlockedCompareExchangeT(&s_pRedirectedTypeNamesHashTable, pRedirectedTypeNamesHashTable.GetValue(), NULL) == NULL)
+ {
+ pRedirectedTypeNamesHashTable.SuppressRelease();
+ }
+ }
+
+ IMDInternalImport *pInternalImport = pModule->GetMDImport();
LPCSTR szName;
LPCSTR szNamespace;
- IfFailThrow(pMDImport->GetNameOfTypeDef(token, &szName, &szNamespace));
+ IfFailThrow(pInternalImport->GetNameOfTypeDef(token, &szName, &szNamespace));
- // Check each of the redirected types to see if it is our type
- for (int i = 0; i < COUNTOF(g_redirectedTypeNames); ++i)
+ const RedirectedTypeNames *const * ppRedirectedNames = s_pRedirectedTypeNamesHashTable->LookupPtr(RedirectedTypeNamesKey(szNamespace, szName));
+ if (ppRedirectedNames == NULL)
{
- // Do the fast checks first
- if (g_redirectedTypeNames[i].assembly == assemblyIndex)
+ return WinMDAdapter::RedirectedTypeIndex_Invalid;
+ }
+
+ UINT redirectedTypeIndex = (UINT)(*ppRedirectedNames - g_redirectedTypeNames);
+ _ASSERTE(redirectedTypeIndex < COUNTOF(g_redirectedTypeNames));
+
+ // If the redirected assembly is mscorlib just compare it directly. This is necessary because
+ // WinMDAdapter::GetExtraAssemblyRefProps does not support mscorlib
+ if (g_redirectedTypeNames[redirectedTypeIndex].assembly == WinMDAdapter::FrameworkAssembly_Mscorlib)
+ {
+ return MscorlibBinder::GetModule()->GetAssembly() == pModule->GetAssembly() ?
+ (WinMDAdapter::RedirectedTypeIndex)redirectedTypeIndex :
+ WinMDAdapter::RedirectedTypeIndex_Invalid;
+ }
+
+ LPCSTR pSimpleName;
+ AssemblyMetaDataInternal context;
+ const BYTE * pbKeyToken;
+ DWORD cbKeyTokenLength;
+ DWORD dwFlags;
+ WinMDAdapter::GetExtraAssemblyRefProps(
+ g_redirectedTypeNames[redirectedTypeIndex].assembly,
+ &pSimpleName,
+ &context,
+ &pbKeyToken,
+ &cbKeyTokenLength,
+ &dwFlags);
+
+ AssemblySpec spec;
+ IfFailThrow(spec.Init(
+ pSimpleName,
+ &context,
+ pbKeyToken,
+ cbKeyTokenLength,
+ dwFlags));
+ Assembly* pRedirectedAssembly = spec.LoadAssembly(
+ FILE_LOADED,
+ NULL, // pLoadSecurity
+ FALSE); // fThrowOnFileNotFound
+
+ if (pRedirectedAssembly == NULL)
+ {
+ return WinMDAdapter::RedirectedTypeIndex_Invalid;
+ }
+
+ // Resolve the name in the redirected assembly to the actual type def and assembly
+ NameHandle nameHandle(szNamespace, szName);
+ nameHandle.SetTokenNotToLoad(tdAllTypes);
+ Module * pTypeDefModule;
+ mdTypeDef typeDefToken;
+
+ if (ClassLoader::ResolveNameToTypeDefThrowing(
+ pRedirectedAssembly->GetManifestModule(),
+ &nameHandle,
+ &pTypeDefModule,
+ &typeDefToken,
+ Loader::DontLoad))
+ {
+ // Finally check if the assembly from this type def token mathes the assembly type forwareded from the
+ // redirected assembly
+ if (pTypeDefModule->GetAssembly() == pModule->GetAssembly())
{
- // This is in the right assembly, see if the name matches
- if (strcmp(g_redirectedTypeNames[i].szClrName, szName) == 0 &&
- strcmp(g_redirectedTypeNames[i].szClrNamespace, szNamespace) == 0)
- {
- return (WinMDAdapter::RedirectedTypeIndex)i;
- }
+ return (WinMDAdapter::RedirectedTypeIndex)redirectedTypeIndex;
}
}
diff --git a/src/vm/winrttypenameconverter.h b/src/vm/winrttypenameconverter.h
index 53cb5ebfe0..4648ccb15e 100644
--- a/src/vm/winrttypenameconverter.h
+++ b/src/vm/winrttypenameconverter.h
@@ -75,9 +75,8 @@ public :
// calculate the redirected type index at EEClass creation time.
//
static WinMDAdapter::RedirectedTypeIndex GetRedirectedTypeIndexByName(
- IMDInternalImport *pMDImport,
- mdTypeDef token,
- WinMDAdapter::FrameworkAssemblyIndex assemblyIndex);
+ Module *pModule,
+ mdTypeDef token);
public :
//==============================================================================================
// WinRT -> Managed