diff options
author | Luqun Lou <luqunl@microsoft.com> | 2017-09-14 20:36:57 +0300 |
---|---|---|
committer | Luqun Lou <luqunl@microsoft.com> | 2017-09-14 20:36:57 +0300 |
commit | 2d1abafe4cad18b40108c7dabd5423758c3022db (patch) | |
tree | d7dd84d9687f8f48ebcb746de4c3af80ef3617ad /src/System.Private.Interop | |
parent | 23ad74dff62fc7e7ef38d76d58ef83976188770a (diff) |
Enable Dynamic Support for GenericArguments
For Generic Argument type, we should able to dynamic create them even its mcg data doesn't exist.
In future, we should remove these generic argument mcg data, since type system will help us to create them as demand.
[tfs-changeset: 1674129]
Diffstat (limited to 'src/System.Private.Interop')
-rw-r--r-- | src/System.Private.Interop/src/Shared/McgTypeHelpers.cs | 54 | ||||
-rw-r--r-- | src/System.Private.Interop/src/Shared/__ComObject.cs | 2 |
2 files changed, 55 insertions, 1 deletions
diff --git a/src/System.Private.Interop/src/Shared/McgTypeHelpers.cs b/src/System.Private.Interop/src/Shared/McgTypeHelpers.cs index 115c84b6b..e965835b0 100644 --- a/src/System.Private.Interop/src/Shared/McgTypeHelpers.cs +++ b/src/System.Private.Interop/src/Shared/McgTypeHelpers.cs @@ -27,6 +27,11 @@ using System.Diagnostics.Contracts; using Internal.NativeFormat; using System.Runtime.CompilerServices; +#if !RHTESTCL && !CORECLR && !CORERT +using Internal.Runtime.Augments; +using Internal.Runtime.TypeLoader; +#endif + namespace System.Runtime.InteropServices { internal static class McgTypeHelpers @@ -1106,6 +1111,13 @@ namespace System.Runtime.InteropServices return mcgGenericArgumentMarshalInfo.IteratorType; } +#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT + if (McgModuleManager.UseDynamicInterop) + return DynamicInteropTypeHelper.ReplaceOpenGenericTypeInGenericInstantiation( + interfaceType, + typeof(global::Windows.Foundation.Collections.IIterator<>).TypeHandle + ); +#endif return default(RuntimeTypeHandle); } @@ -1117,6 +1129,16 @@ namespace System.Runtime.InteropServices return mcgGenericArgumentMarshalInfo.ElementClassType; } +#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT + if (McgModuleManager.UseDynamicInterop) + { + RuntimeTypeHandle[] genericTypeArgumentHandles; + RuntimeAugments.GetGenericInstantiation(interfaceType, out genericTypeArgumentHandles); + + if(genericTypeArgumentHandles.Length == 1) + return genericTypeArgumentHandles[0]; + } +#endif return default(RuntimeTypeHandle); } @@ -1128,6 +1150,15 @@ namespace System.Runtime.InteropServices return mcgGenericArgumentMarshalInfo.ElementInterfaceType; } +#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT + if (McgModuleManager.UseDynamicInterop) + { + RuntimeTypeHandle[] genericTypeArgumentHandles; + RuntimeAugments.GetGenericInstantiation(interfaceType, out genericTypeArgumentHandles); + if(genericTypeArgumentHandles.Length == 1) + return genericTypeArgumentHandles[0].GetDefaultInterface(); + } +#endif return default(RuntimeTypeHandle); } @@ -1139,6 +1170,13 @@ namespace System.Runtime.InteropServices return mcgGenericArgumentMarshalInfo.VectorViewType; } +#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT + if (McgModuleManager.UseDynamicInterop) + return DynamicInteropTypeHelper.ReplaceOpenGenericTypeInGenericInstantiation( + interfaceType, + typeof(System.Collections.Generic.IReadOnlyList<>).TypeHandle + ); +#endif return default(RuntimeTypeHandle); } @@ -1150,6 +1188,13 @@ namespace System.Runtime.InteropServices return mcgGenericArgumentMarshalInfo.AsyncOperationType; } +#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT + if (McgModuleManager.UseDynamicInterop) + return DynamicInteropTypeHelper.ReplaceOpenGenericTypeInGenericInstantiation( + interfaceType, + typeof(global::Windows.Foundation.IAsyncOperation<>).TypeHandle + ); +#endif return default(RuntimeTypeHandle); } @@ -1161,6 +1206,15 @@ namespace System.Runtime.InteropServices return (int)mcgGenericArgumentMarshalInfo.ElementSize; } +#if !RHTESTCL && !CORECLR && !CORERT && ENABLE_WINRT + if (McgModuleManager.UseDynamicInterop) + { + RuntimeTypeHandle[] genericTypeArgumentHandles; + RuntimeAugments.GetGenericInstantiation(interfaceType, out genericTypeArgumentHandles); + if (genericTypeArgumentHandles.Length == 1) + return genericTypeArgumentHandles[0].GetValueTypeSize(); + } +#endif return -1; } #endregion diff --git a/src/System.Private.Interop/src/Shared/__ComObject.cs b/src/System.Private.Interop/src/Shared/__ComObject.cs index bcf57430d..3a3cb1aab 100644 --- a/src/System.Private.Interop/src/Shared/__ComObject.cs +++ b/src/System.Private.Interop/src/Shared/__ComObject.cs @@ -2149,7 +2149,7 @@ namespace System // We may not have QI'd for this interface yet. Do so now, in case the object directly supports // the requested interface. If we find it, call ourselves again so our fast path will pick it up. // - if (QueryInterface_NoAddRef_Internal(requestedType, /* cacheOnly= */ false, /* throwOnQueryInterfaceFailure= */ false) != default(IntPtr)) + if (QueryInterface_NoAddRef_Internal(requestedType, /* cacheOnly= */ false, /* throwOnQueryInterfaceFailure= */ false) != default(IntPtr) && requestedType.HasDynamicAdapterClass()) return GetDynamicAdapterInternal(requestedType, default(RuntimeTypeHandle)); return null; |