summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuqun Lou <luqunl@users.noreply.github.com>2018-06-22 11:33:35 -0700
committerGitHub <noreply@github.com>2018-06-22 11:33:35 -0700
commit3fb4483277c7b12841b9ea7672bccdc6f23d3d52 (patch)
tree96a208b5927506651473da3d45880c48de973f4f
parent8aad994743a1332a21a56728799c293a21115050 (diff)
downloadcoreclr-3fb4483277c7b12841b9ea7672bccdc6f23d3d52.tar.gz
coreclr-3fb4483277c7b12841b9ea7672bccdc6f23d3d52.tar.bz2
coreclr-3fb4483277c7b12841b9ea7672bccdc6f23d3d52.zip
Add public implementation MarshalerSupport (#18530)
-rw-r--r--src/System.Private.CoreLib/System.Private.CoreLib.csproj2
-rw-r--r--src/System.Private.CoreLib/src/System/StubHelpers.cs37
-rw-r--r--src/vm/classnames.h2
-rw-r--r--src/vm/ecalllist.h8
-rw-r--r--src/vm/interopconverter.cpp2
-rw-r--r--src/vm/mlinfo.cpp25
-rw-r--r--src/vm/mlinfo.h55
-rw-r--r--src/vm/stubhelpers.cpp57
-rw-r--r--src/vm/stubhelpers.h6
9 files changed, 3 insertions, 191 deletions
diff --git a/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/System.Private.CoreLib.csproj
index ccb3050e58..4df5b8295a 100644
--- a/src/System.Private.CoreLib/System.Private.CoreLib.csproj
+++ b/src/System.Private.CoreLib/System.Private.CoreLib.csproj
@@ -301,7 +301,7 @@
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\Augments\EnvironmentAugments.cs" />
<Compile Include="$(BclSourcesRoot)\Internal\Runtime\Augments\RuntimeThread.cs" />
<Compile Include="$(BclSourcesRoot)\Internal\Console.cs" />
- <Compile Condition="'$(FeatureCominterop)' == 'true'" Include="$(BclSourcesRoot)\Internal\Threading\Tasks\AsyncCausalitySupport.cs" />
+ <Compile Condition="'$(FeatureCominterop)' == 'true'" Include="$(BclSourcesRoot)\Internal\Threading\Tasks\AsyncCausalitySupport.cs" />
<Compile Condition="'$(FeatureCominterop)' == 'true'" Include="$(BclSourcesRoot)\Internal\Runtime\InteropServices\WindowsRuntime\ExceptionSupport.cs" />
<Compile Condition="'$(FeatureAppX)' == 'true'" Include="$(BclSourcesRoot)\Internal\Resources\WindowsRuntimeResourceManagerBase.cs" />
<Compile Condition="'$(FeatureAppX)' == 'true'" Include="$(BclSourcesRoot)\Internal\Resources\PRIExceptionInfo.cs" />
diff --git a/src/System.Private.CoreLib/src/System/StubHelpers.cs b/src/System.Private.CoreLib/src/System/StubHelpers.cs
index f64fcd4d63..35aa214c67 100644
--- a/src/System.Private.CoreLib/src/System/StubHelpers.cs
+++ b/src/System.Private.CoreLib/src/System/StubHelpers.cs
@@ -609,7 +609,6 @@ namespace System.StubHelpers
} // class DateMarshaler
#if FEATURE_COMINTEROP
- // [FriendAccessAllowed]
internal static class InterfaceMarshaler
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
@@ -621,7 +620,6 @@ namespace System.StubHelpers
[DllImport(JitHelpers.QCall)]
internal static extern void ClearNative(IntPtr pUnk);
- // [FriendAccessAllowed]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern object ConvertToManagedWithoutUnboxing(IntPtr pNative);
} // class InterfaceMarshaler
@@ -645,41 +643,6 @@ namespace System.StubHelpers
}
} // class InterfaceMarshaler
- // [FriendAccessAllowed]
- internal static class EventArgsMarshaler
- {
- // [FriendAccessAllowed]
- internal static IntPtr CreateNativeNCCEventArgsInstance(int action, object newItems, object oldItems, int newIndex, int oldIndex)
- {
- IntPtr newItemsIP = IntPtr.Zero;
- IntPtr oldItemsIP = IntPtr.Zero;
-
- RuntimeHelpers.PrepareConstrainedRegions();
- try
- {
- if (newItems != null)
- newItemsIP = Marshal.GetComInterfaceForObject(newItems, typeof(IBindableVector));
- if (oldItems != null)
- oldItemsIP = Marshal.GetComInterfaceForObject(oldItems, typeof(IBindableVector));
-
- return CreateNativeNCCEventArgsInstanceHelper(action, newItemsIP, oldItemsIP, newIndex, oldIndex);
- }
- finally
- {
- if (oldItemsIP != IntPtr.Zero)
- Marshal.Release(oldItemsIP);
- if (newItemsIP != IntPtr.Zero)
- Marshal.Release(newItemsIP);
- }
- }
-
- // [FriendAccessAllowed]
- [DllImport(JitHelpers.QCall)]
- static internal extern IntPtr CreateNativePCEventArgsInstance([MarshalAs(UnmanagedType.HString)]string name);
-
- [DllImport(JitHelpers.QCall)]
- static internal extern IntPtr CreateNativeNCCEventArgsInstanceHelper(int action, IntPtr newItem, IntPtr oldItem, int newIndex, int oldIndex);
- }
#endif // FEATURE_COMINTEROP
internal static class MngdNativeArrayMarshaler
diff --git a/src/vm/classnames.h b/src/vm/classnames.h
index 08286f8013..fec3052326 100644
--- a/src/vm/classnames.h
+++ b/src/vm/classnames.h
@@ -42,12 +42,10 @@
#define g_NotifyCollectionChangedEventHandlerName "System.Collections.Specialized.NotifyCollectionChangedEventHandler"
#define g_NotifyCollectionChangedEventArgsName "System.Collections.Specialized.NotifyCollectionChangedEventArgs"
#define g_NotifyCollectionChangedEventArgsMarshalerName "System.Runtime.InteropServices.WindowsRuntime.NotifyCollectionChangedEventArgsMarshaler"
-#define g_WinRTNotifyCollectionChangedEventArgsNameW W("Windows.UI.Xaml.Interop.NotifyCollectionChangedEventArgs")
#define g_INotifyPropertyChangedName "System.ComponentModel.INotifyPropertyChanged"
#define g_PropertyChangedEventHandlerName "System.ComponentModel.PropertyChangedEventHandler"
#define g_PropertyChangedEventArgsName "System.ComponentModel.PropertyChangedEventArgs"
#define g_PropertyChangedEventArgsMarshalerName "System.Runtime.InteropServices.WindowsRuntime.PropertyChangedEventArgsMarshaler"
-#define g_WinRTPropertyChangedEventArgsNameW W("Windows.UI.Xaml.Data.PropertyChangedEventArgs")
#define g_WinRTIIteratorClassName "Windows.Foundation.Collections.IIterator`1"
#define g_WinRTIIteratorClassNameW W("Windows.Foundation.Collections.IIterator`1")
#define g_ICommandName "System.Windows.Input.ICommand"
diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h
index df69bef58a..e1f1110876 100644
--- a/src/vm/ecalllist.h
+++ b/src/vm/ecalllist.h
@@ -1054,11 +1054,6 @@ FCFuncStart(gUriMarshalerFuncs)
FCFuncElement("CreateNativeUriInstanceHelper", StubHelpers::UriMarshaler__CreateNativeUriInstance)
FCFuncEnd()
-FCFuncStart(gEventArgsMarshalerFuncs)
- QCFuncElement("CreateNativeNCCEventArgsInstanceHelper", StubHelpers::EventArgsMarshaler__CreateNativeNCCEventArgsInstance)
- QCFuncElement("CreateNativePCEventArgsInstance", StubHelpers::EventArgsMarshaler__CreateNativePCEventArgsInstance)
-FCFuncEnd()
-
FCFuncStart(gMngdSafeArrayMarshalerFuncs)
FCFuncElement("CreateMarshaler", MngdSafeArrayMarshaler::CreateMarshaler)
FCFuncElement("ConvertSpaceToNative", MngdSafeArrayMarshaler::ConvertSpaceToNative)
@@ -1287,9 +1282,6 @@ FCClassElement("EncodingTable", "System.Text", gEncodingTableFuncs)
#endif // !defined(FEATURE_COREFX_GLOBALIZATION)
FCClassElement("Enum", "System", gEnumFuncs)
FCClassElement("Environment", "System", gEnvironmentFuncs)
-#ifdef FEATURE_COMINTEROP
-FCClassElement("EventArgsMarshaler", "System.StubHelpers", gEventArgsMarshalerFuncs)
-#endif // FEATURE_COMINTEROP
#if defined(FEATURE_PERFTRACING)
FCClassElement("EventPipeInternal", "System.Diagnostics.Tracing", gEventPipeInternalFuncs)
#endif // FEATURE_PERFTRACING
diff --git a/src/vm/interopconverter.cpp b/src/vm/interopconverter.cpp
index cb42f9cdfe..e98d4addc9 100644
--- a/src/vm/interopconverter.cpp
+++ b/src/vm/interopconverter.cpp
@@ -574,7 +574,7 @@ void GetObjectRefFromComIP(OBJECTREF* pObjOut, IUnknown **ppUnk, MethodTable *pM
}
else
{
- *pObjOut = marshaler.FindOrCreateObjectRef(pUnk, pItfMT);
+ *pObjOut = marshaler.FindOrCreateObjectRef(pUnk, pItfMT);
}
}
}
diff --git a/src/vm/mlinfo.cpp b/src/vm/mlinfo.cpp
index e5138db97f..12be6d3b95 100644
--- a/src/vm/mlinfo.cpp
+++ b/src/vm/mlinfo.cpp
@@ -894,7 +894,6 @@ void *EventArgsMarshalingInfo::operator new(size_t size, LoaderHeap *pHeap)
RETURN mem;
}
-
void EventArgsMarshalingInfo::operator delete(void *pMem)
{
LIMITED_METHOD_CONTRACT;
@@ -912,10 +911,6 @@ EventArgsMarshalingInfo::EventArgsMarshalingInfo()
}
CONTRACTL_END;
- // Create on-demand as we don't want to create the factories in NGEN time
- m_pNCCEventArgsFactory = NULL;
- m_pPCEventArgsFactory = NULL;
-
// Load the System.Collections.Specialized.NotifyCollectionChangedEventArgs class.
SString qualifiedNCCEventArgsTypeName(SString::Utf8, NCCEVENTARGS_ASM_QUAL_TYPE_NAME);
m_hndSystemNCCEventArgsType = TypeName::GetTypeFromAsmQualifiedName(qualifiedNCCEventArgsTypeName.GetUnicode(), FALSE);
@@ -953,25 +948,7 @@ EventArgsMarshalingInfo::EventArgsMarshalingInfo()
EventArgsMarshalingInfo::~EventArgsMarshalingInfo()
{
- CONTRACTL
- {
- NOTHROW;
- GC_TRIGGERS;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- if (m_pNCCEventArgsFactory)
- {
- SafeRelease(m_pNCCEventArgsFactory);
- m_pNCCEventArgsFactory = NULL;
- }
-
- if (m_pPCEventArgsFactory)
- {
- SafeRelease(m_pPCEventArgsFactory);
- m_pPCEventArgsFactory = NULL;
- }
+ LIMITED_METHOD_CONTRACT;
}
void *UriMarshalingInfo::operator new(size_t size, LoaderHeap *pHeap)
diff --git a/src/vm/mlinfo.h b/src/vm/mlinfo.h
index d1b46065e4..b27dcc01c3 100644
--- a/src/vm/mlinfo.h
+++ b/src/vm/mlinfo.h
@@ -225,58 +225,6 @@ public:
return m_hndSystemPCEventArgsType;
}
- ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgsFactory *GetNCCEventArgsFactory()
- {
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS; // For potential COOP->PREEMP->COOP switch
- MODE_ANY;
- PRECONDITION(!GetAppDomain()->IsCompilationDomain());
- }
- CONTRACTL_END;
-
- if (m_pNCCEventArgsFactory.Load() == NULL)
- {
- GCX_PREEMP();
- SafeComHolderPreemp<ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgsFactory> pNCCEventArgsFactory;
-
- IfFailThrow(clr::winrt::GetActivationFactory(g_WinRTNotifyCollectionChangedEventArgsNameW, (ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgsFactory **)&pNCCEventArgsFactory));
- _ASSERTE_MSG(pNCCEventArgsFactory, "Got NULL NCCEventArgs factory!");
-
- if (InterlockedCompareExchangeT(&m_pNCCEventArgsFactory, (ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgsFactory *)pNCCEventArgsFactory, NULL) == NULL)
- pNCCEventArgsFactory.SuppressRelease();
- }
-
- return m_pNCCEventArgsFactory;
- }
-
- ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgsFactory *GetPCEventArgsFactory()
- {
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS; // For potential COOP->PREEMP->COOP switch
- MODE_ANY;
- PRECONDITION(!GetAppDomain()->IsCompilationDomain());
- }
- CONTRACTL_END;
-
- if (m_pPCEventArgsFactory.Load() == NULL)
- {
- GCX_PREEMP();
- SafeComHolderPreemp<ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgsFactory> pPCEventArgsFactory;
-
- IfFailThrow(clr::winrt::GetActivationFactory(g_WinRTPropertyChangedEventArgsNameW, (ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgsFactory **)&pPCEventArgsFactory));
- _ASSERTE_MSG(pPCEventArgsFactory, "Got NULL PCEventArgs factory!");
-
- if (InterlockedCompareExchangeT(&m_pPCEventArgsFactory, (ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgsFactory *)pPCEventArgsFactory, NULL) == NULL)
- pPCEventArgsFactory.SuppressRelease();
- }
-
- return m_pPCEventArgsFactory;
- }
-
MethodDesc *GetSystemNCCEventArgsToWinRTNCCEventArgsMD()
{
LIMITED_METHOD_CONTRACT;
@@ -310,9 +258,6 @@ private:
MethodDesc *m_pWinRTNCCEventArgsToSystemNCCEventArgsMD;
MethodDesc *m_pSystemPCEventArgsToWinRTPCEventArgsMD;
MethodDesc *m_pWinRTPCEventArgsToSystemPCEventArgsMD;
-
- VolatilePtr<ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgsFactory> m_pNCCEventArgsFactory;
- VolatilePtr<ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgsFactory> m_pPCEventArgsFactory;
};
class UriMarshalingInfo
diff --git a/src/vm/stubhelpers.cpp b/src/vm/stubhelpers.cpp
index d43c065362..7475d98061 100644
--- a/src/vm/stubhelpers.cpp
+++ b/src/vm/stubhelpers.cpp
@@ -807,63 +807,6 @@ FCIMPL2(IUnknown*, StubHelpers::UriMarshaler__CreateNativeUriInstance, WCHAR* pR
}
FCIMPLEND
-ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgs* QCALLTYPE
-StubHelpers::EventArgsMarshaler__CreateNativeNCCEventArgsInstance
-(int action, ABI::Windows::UI::Xaml::Interop::IBindableVector *newItem, ABI::Windows::UI::Xaml::Interop::IBindableVector *oldItem, int newIndex, int oldIndex)
-{
- QCALL_CONTRACT;
-
- ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgs *pArgsRC = NULL;
-
- BEGIN_QCALL;
-
- EventArgsMarshalingInfo *marshalingInfo = GetAppDomain()->GetMarshalingData()->GetEventArgsMarshalingInfo();
- ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgsFactory *pFactory = marshalingInfo->GetNCCEventArgsFactory();
-
- SafeComHolderPreemp<IInspectable> pInner;
- HRESULT hr;
- hr = pFactory->CreateInstanceWithAllParameters(
- (ABI::Windows::UI::Xaml::Interop::NotifyCollectionChangedAction)action,
- (ABI::Windows::UI::Xaml::Interop::IBindableVector *)newItem,
- (ABI::Windows::UI::Xaml::Interop::IBindableVector *)oldItem,
- newIndex,
- oldIndex,
- NULL,
- &pInner,
- &pArgsRC);
- IfFailThrow(hr);
-
- END_QCALL;
-
- return pArgsRC;
-}
-
-ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgs* QCALLTYPE
- StubHelpers::EventArgsMarshaler__CreateNativePCEventArgsInstance(HSTRING name)
-{
- QCALL_CONTRACT;
-
- ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgs *pArgsRC = NULL;
-
- BEGIN_QCALL;
-
- EventArgsMarshalingInfo *marshalingInfo = GetAppDomain()->GetMarshalingData()->GetEventArgsMarshalingInfo();
- ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgsFactory *pFactory = marshalingInfo->GetPCEventArgsFactory();
-
- SafeComHolderPreemp<IInspectable> pInner;
- HRESULT hr;
- hr = pFactory->CreateInstance(
- name,
- NULL,
- &pInner,
- &pArgsRC);
- IfFailThrow(hr);
-
- END_QCALL;
-
- return pArgsRC;
-}
-
// A helper to convert an IP to object using special flags.
FCIMPL1(Object *, StubHelpers::InterfaceMarshaler__ConvertToManagedWithoutUnboxing, IUnknown *pNative)
{
diff --git a/src/vm/stubhelpers.h b/src/vm/stubhelpers.h
index 4c4bc8b71c..560e0b3e9b 100644
--- a/src/vm/stubhelpers.h
+++ b/src/vm/stubhelpers.h
@@ -74,12 +74,6 @@ public:
static FCDECL1(StringObject*, UriMarshaler__GetRawUriFromNative, ABI::Windows::Foundation::IUriRuntimeClass* pIUriRC);
static FCDECL2(IUnknown*, UriMarshaler__CreateNativeUriInstance, __in_ecount(strLen) CLR_CHAR* pRawUriObj, UINT strLen);
- static ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgs* QCALLTYPE
- EventArgsMarshaler__CreateNativeNCCEventArgsInstance
- (int action, ABI::Windows::UI::Xaml::Interop::IBindableVector *newItem, ABI::Windows::UI::Xaml::Interop::IBindableVector *oldItem, int newIndex, int oldIndex);
-
- static ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgs* QCALLTYPE EventArgsMarshaler__CreateNativePCEventArgsInstance(HSTRING name);
-
static FCDECL1(MethodDesc *, GetDelegateInvokeMethod, DelegateObject *pThisUNSAFE);
static FCDECL2(IInspectable *, GetWinRTFactoryReturnValue, Object *pThisUNSAFE, PCODE pCtorEntry);
static FCDECL2(IInspectable *, GetOuterInspectable, Object *pThisUNSAFE, MethodDesc *pCtorMD);