summaryrefslogtreecommitdiff
path: root/src/vm/interoputil.cpp
diff options
context:
space:
mode:
authorRyan Byington <ryanbyi@microsoft.com>2015-04-28 17:53:30 -0700
committerRyan Byington <ryanbyi@microsoft.com>2015-04-28 17:53:30 -0700
commitfb68f332e9123d74bd1cc7187be000bc3cbf67d2 (patch)
treee8aca912b70dd791502d977beb6262e264dda1e2 /src/vm/interoputil.cpp
parent2fd35925a66be17a46467050751c309b93f2013b (diff)
downloadcoreclr-fb68f332e9123d74bd1cc7187be000bc3cbf67d2.tar.gz
coreclr-fb68f332e9123d74bd1cc7187be000bc3cbf67d2.tar.bz2
coreclr-fb68f332e9123d74bd1cc7187be000bc3cbf67d2.zip
Updating WinRT Projections to use Facades
WinRT projections currently depend on implementation assemblies like System.Uri living in System.dll. System.Uri has already been moved out of System.dll to Internal.Uri.dll which breaks the projection for System.Uri. This change updates the WinRT projection to understand Facades like System.Runtime to resolve System.Uri. When we load a type like System.Uri we need to know if it is a projected type. We currently do this by comparing the namespace plus type name and assembly however this only works because we know the implementation assembly at compile time. I am changing it so that we use ClassLoader to resolve the typedef and assembly and compare the resolved assembly with the current one. Also removing the cached assemblies as they don’t add a lot of value anymore. [tfs-changeset: 1461733]
Diffstat (limited to 'src/vm/interoputil.cpp')
-rw-r--r--src/vm/interoputil.cpp88
1 files changed, 47 insertions, 41 deletions
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: