Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove built-in WinRT support from the runtime #36715

Merged
merged 71 commits into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
150b175
Remove WinRT-specific marshalers from the runtime side.
jkoritzinsky Apr 20, 2020
77a50e7
Remove managed WinRT support in System.Private.CoreLib
jkoritzinsky Apr 20, 2020
2166b6b
Block loading WinRT types into .NET.
jkoritzinsky Apr 21, 2020
eb3ca0f
Remove System.Runtime.InteropServices.WindowsRuntime, System.Runtime.…
jkoritzinsky Apr 21, 2020
ff74bba
Remove WinRT-specific code in hr->exception translation.
jkoritzinsky Apr 21, 2020
1e05d67
Remove WinRT stub types.
jkoritzinsky Apr 21, 2020
34f688c
Remove WinRT type redirection barring some vestigal parts in the RCW …
jkoritzinsky Apr 22, 2020
4f54887
Remove last vestiages of projections. Something is causing failures i…
jkoritzinsky Apr 23, 2020
1a7bd15
Just remove this branch that was only relevant in WinRT. It's the cor…
jkoritzinsky Apr 24, 2020
27fe8c4
Don't throw away the return value here, actually use it.
jkoritzinsky Apr 24, 2020
21d7cd5
Remove WinRTTypeNameConverter
jkoritzinsky Apr 24, 2020
cd2eb2f
Remove winrthelpers.h and winrthelpers.cpp. Start putting blocks in f…
jkoritzinsky Apr 24, 2020
6877fd5
Remove old winrthost that we never shipped.
jkoritzinsky Apr 24, 2020
3bdfb39
Remove the WinMD binder and related WinMD utilities.
jkoritzinsky Apr 24, 2020
346b52a
Add back automatic WinRT apartment initialization.
jkoritzinsky Apr 24, 2020
b68881d
Remove unused delay loads.
jkoritzinsky Apr 24, 2020
a143172
Merge branch 'master' of https://github.com/dotnet/runtime into remov…
jkoritzinsky Apr 24, 2020
00951a9
Restore WinRTSupported() to make sure we correctly initialize WinRT t…
jkoritzinsky Apr 28, 2020
d0101e3
Clean up comments and remove much of the winmd-specific assembly/type…
jkoritzinsky Apr 28, 2020
2ccf720
Remove rooting of now-removed types.
jkoritzinsky Apr 28, 2020
d275680
Remove always-false WinRT flags from EEClass and related code.
jkoritzinsky Apr 28, 2020
1de6a16
Remove WinRT-specific CCW flags.
jkoritzinsky Apr 28, 2020
4e0512d
Remove WinRT weak handles support in the runtime.
jkoritzinsky Apr 29, 2020
73687a4
Remove WinRT references in AppDomain and remove dead code from StubHe…
jkoritzinsky Apr 29, 2020
e22706b
Merge branch 'master' of https://github.com/dotnet/runtime into remov…
jkoritzinsky Apr 29, 2020
4fc4fbd
Revert "Remove WinRT weak handles support in the runtime."
jkoritzinsky May 1, 2020
a10f75c
Reduce amount of work before we refuse to load a winmd.
jkoritzinsky May 7, 2020
2c54204
Merge branch 'master' of https://github.com/dotnet/runtime into remov…
jkoritzinsky May 7, 2020
e847ec0
Throw when resolving the assemblyRef entry. Don't even get to the poi…
jkoritzinsky May 7, 2020
b36bec0
Remove more unneeded support for winmds in the assembly loader.
jkoritzinsky May 7, 2020
2325d85
Remove crossgen/ngen-specific winmd code paths and options.
jkoritzinsky May 7, 2020
f93372e
Remove more winmd-specific support in module loading that's unneeded.
jkoritzinsky May 7, 2020
572ac93
Remove references to the Windows namespace and remove some unused res…
jkoritzinsky May 7, 2020
7cc414f
Remove all mentions of winmds outside of ilasm/ildasm.
jkoritzinsky May 7, 2020
d3c8b6d
Remove remaining winrt support in fieldmarshaler support.
jkoritzinsky May 7, 2020
b0aac23
Remove IRestrictedErrorInfo support.
jkoritzinsky May 7, 2020
631a944
Remove delay load for hstring APIs since we no longer use them.
jkoritzinsky May 7, 2020
d5fe9c1
Remove unused interface from private idl.
jkoritzinsky May 7, 2020
7ede7d2
Remove WinRT support from methodtable and marshalling paths.
jkoritzinsky May 7, 2020
bef8fb8
Remove other unused WinRT-only MarshalNative methods.
jkoritzinsky May 7, 2020
104fd75
Remove WinRT mentions from docs, host, and build.
jkoritzinsky May 13, 2020
6b2596a
Remove IInspectable support and the last bit of MethodTable WinRT-rel…
jkoritzinsky May 14, 2020
5942c9a
Remove unused code from stdinterfaces.h
jkoritzinsky May 14, 2020
3ccfcc1
Remove the old reference tracking GC integration for built-in RCWs.
jkoritzinsky May 14, 2020
b398d88
Remove now-unused jupiter refcounts and pegging tracking.
jkoritzinsky May 14, 2020
c929f79
Merge branch 'master' of https://github.com/dotnet/runtime into remov…
jkoritzinsky May 14, 2020
d3c91bd
Remove unused WinRT checks in managed code and remove Activator test …
jkoritzinsky May 14, 2020
0072cfe
Remove now-dead code.
jkoritzinsky May 14, 2020
b8aa672
Remove dead entries.
jkoritzinsky May 14, 2020
360869d
Remove some dead marshaler code.
jkoritzinsky May 14, 2020
cc8781e
Remove more winrt-specific dead code.
jkoritzinsky May 14, 2020
796c1c8
Fix all-up build excluding the fix for dotnet/arcade#5490
jkoritzinsky May 15, 2020
2ec132e
Fix non-Windows build.
jkoritzinsky May 15, 2020
cac2479
Remove WinRT-specific paths from dynamic support.
jkoritzinsky May 18, 2020
fc14826
Remove codepaths in System.Private.CoreLib that either worked via ref…
jkoritzinsky May 18, 2020
476e43a
Fix native test build
jkoritzinsky May 19, 2020
848062a
Fix x86 CoreCLR build.
jkoritzinsky May 19, 2020
1d7b7b4
Fix managed test build.
jkoritzinsky May 19, 2020
d8e100e
Remove unneeded default interface field that was causing crossgen ass…
jkoritzinsky May 19, 2020
3c4f0ce
Fix classifying ComImported constructors.
jkoritzinsky May 19, 2020
0a99b43
Root the System.__ComObject constructor for the IL Linker. Otherwise …
jkoritzinsky May 20, 2020
068fb3c
Don't run the WinRT blocking test off of Windows.
jkoritzinsky May 20, 2020
a26e275
Fix failing tests.
jkoritzinsky May 20, 2020
d24fee5
Fix typo
jkoritzinsky May 20, 2020
cb4a61a
Update the comment for the refcount field.
jkoritzinsky May 21, 2020
39158b4
Merge branch 'master' of https://github.com/dotnet/runtime into remov…
jkoritzinsky May 21, 2020
b3ff1aa
Remove unused flags on ComToClrCall and fix spacing.
jkoritzinsky May 21, 2020
336542e
Add back IAgileObject support in CCWs
jkoritzinsky May 22, 2020
ec476cb
Merge branch 'master' of https://github.com/dotnet/runtime into remov…
jkoritzinsky May 26, 2020
c53ba60
Remove now inapplicable assert instead of incorrectly simplifying it.
jkoritzinsky May 27, 2020
45ad790
Merge branch 'master' of https://github.com/dotnet/runtime into remov…
jkoritzinsky May 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove last vestiages of projections. Something is causing failures i…
…n the old-style IEnumerable projection with VSD, but I'm not sure exactly what.
  • Loading branch information
jkoritzinsky committed Apr 23, 2020
commit 4f54887a6abbacc9dce8ebc255a87e86e3547897
2 changes: 1 addition & 1 deletion src/coreclr/src/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6322,7 +6322,7 @@ BOOL MethodTable::IsLegalNonArrayWinRTType()

// Attributes are not legal
MethodTable *pParentMT = GetParentMethodTable();
if (pParentMT == MscorlibBinder::GetExistingClass(CLASS__ATTRIBUTE))
if (pParentMT == MscorlibBinder::GetClass(CLASS__ATTRIBUTE))
{
return FALSE;
}
Expand Down
196 changes: 5 additions & 191 deletions src/coreclr/src/vm/runtimecallablewrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3089,131 +3089,6 @@ MethodTable *RCW::ComputeVariantMethodTable(MethodTable *pMT)
RETURN NULL;
}

#ifndef CROSSGEN_COMPILE
//-----------------------------------------------------------------
// Determines the interface that should be QI'ed for when the RCW is cast to pItfMT.
RCW::InterfaceRedirectionKind RCW::GetInterfaceForQI(MethodTable *pItfMT, MethodTable **pNewItfMT)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_ANY;
PRECONDITION(CheckPointer(pItfMT));
PRECONDITION(CheckPointer(pNewItfMT));
}
CONTRACTL_END;

// We don't want to be redirecting interfaces if the underlying COM object is not a WinRT type
if (SupportsIInspectable())
{
MethodTable *pNewItfMT1;
MethodTable *pNewItfMT2;
InterfaceRedirectionKind redirectionKind = GetInterfacesForQI(pItfMT, &pNewItfMT1, &pNewItfMT2);

//
// IEnumerable may need three QI attempts:
// 1. IEnumerable/IDispatch+DISPID_NEWENUM
// 2. IBindableIterable
// 3. IIterable<T> for a T
//
// Is this 3rd attempt on IEnumerable (non-generic)?
if (redirectionKind == InterfaceRedirection_Other_RetryOnFailure &&
pItfMT != *pNewItfMT && *pNewItfMT != NULL &&
pItfMT == MscorlibBinder::GetExistingClass(CLASS__IENUMERABLE))
{
return InterfaceRedirection_UnresolvedIEnumerable;
}

if ((redirectionKind != InterfaceRedirection_IEnumerable_RetryOnFailure &&
redirectionKind != InterfaceRedirection_Other_RetryOnFailure) || *pNewItfMT == NULL)
{
// First attempt - use pNewItfMT1
*pNewItfMT = pNewItfMT1;
return redirectionKind;
}
else
{
// Second attempt - use pNewItfMT2
*pNewItfMT = pNewItfMT2;

if (redirectionKind == InterfaceRedirection_IEnumerable_RetryOnFailure)
return InterfaceRedirection_IEnumerable;

// Get ready for the 3rd attmpt if 2nd attempt fails
// This only happens for non-generic IEnumerable
if (pItfMT == MscorlibBinder::GetExistingClass(CLASS__IENUMERABLE))
return InterfaceRedirection_IEnumerable_RetryOnFailure;

return InterfaceRedirection_IEnumerable;
}
}

*pNewItfMT = pItfMT;
return InterfaceRedirection_None;
}
#endif // !CROSSGEN_COMPILE

// static
RCW::InterfaceRedirectionKind RCW::GetInterfacesForQI(MethodTable *pItfMT, MethodTable **ppNewItfMT1, MethodTable **ppNewItfMT2)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_ANY;
PRECONDITION(CheckPointer(pItfMT));
PRECONDITION(CheckPointer(ppNewItfMT1));
PRECONDITION(CheckPointer(ppNewItfMT2));
}
CONTRACTL_END;

RCWPerTypeData *pData = pItfMT->GetRCWPerTypeData();
if (pData == NULL)
{
#ifdef _DEBUG
// verify that if the per-type data is NULL, the type has indeed no redirection
MethodTable *pNewItfMT1;
MethodTable *pNewItfMT2;
_ASSERTE(ComputeInterfacesForQI(pItfMT, &pNewItfMT1, &pNewItfMT2) == InterfaceRedirection_None);
#endif // _DEBUG

*ppNewItfMT1 = pItfMT;
*ppNewItfMT2 = NULL;
return InterfaceRedirection_None;
}
else
{
if ((pData->m_dwFlags & RCWPerTypeData::RedirectionInfoInited) == 0)
{
pData->m_RedirectionKind = ComputeInterfacesForQI(pItfMT, &pData->m_pMTForQI1, &pData->m_pMTForQI2);
FastInterlockOr(&pData->m_dwFlags, RCWPerTypeData::RedirectionInfoInited);
}

*ppNewItfMT1 = pData->m_pMTForQI1;
*ppNewItfMT2 = pData->m_pMTForQI2;
return pData->m_RedirectionKind;
}
}

// static
RCW::InterfaceRedirectionKind RCW::ComputeInterfacesForQI(MethodTable *pItfMT, MethodTable **ppNewItfMT1, MethodTable **ppNewItfMT2)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_ANY;
PRECONDITION(CheckPointer(pItfMT));
PRECONDITION(CheckPointer(ppNewItfMT1));
PRECONDITION(CheckPointer(ppNewItfMT2));
}
CONTRACTL_END;

*ppNewItfMT1 = pItfMT;
return InterfaceRedirection_None;
}

#ifndef CROSSGEN_COMPILE
//-----------------------------------------------------------------
// Returns a known working IEnumerable<T>::GetEnumerator to be used in lieu of the non-generic
Expand Down Expand Up @@ -3353,25 +3228,6 @@ MethodDesc *RCW::ComputeGetEnumeratorMethodForTypeInternal(MethodTable *pMT)
return pMD;
}


//-----------------------------------------------------------------
// Notifies the RCW of an interface that is known to be supported by the COM object.
// pItfMT is the type which the object directly supports, originalInst is the instantiation
// that we asked for. I.e. we know that the object supports pItfMT<originalInst> via
// variance because the QI for IID(pItfMT) succeeded.
void RCW::SetSupportedInterface(MethodTable *pItfMT, Instantiation originalInst)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;

_ASSERTE(false);
}

// Performs QI for the given interface, optionally instantiating it with the given generic args.
HRESULT RCW::CallQueryInterface(MethodTable *pMT, Instantiation inst, IID *piid, IUnknown **ppUnk)
{
Expand All @@ -3384,53 +3240,22 @@ HRESULT RCW::CallQueryInterface(MethodTable *pMT, Instantiation inst, IID *piid,
CONTRACTL_END;

HRESULT hr;
MethodTable *pCastToMT = pMT;
MethodTable *pCOMItfMT = NULL;
InterfaceRedirectionKind redirection = InterfaceRedirection_None;

if (!inst.IsEmpty())
{
pMT = TypeHandle(pMT).Instantiate(inst).GetMethodTable();
}

do
{
redirection = GetInterfaceForQI(pMT, &pCOMItfMT);

if (redirection == InterfaceRedirection_UnresolvedIEnumerable)
{
// We just say no in this case. If we threw an exception, we would make the "as" operator
// throwing which would be ECMA violation.
return E_NOINTERFACE;
}

// To avoid throwing BadImageFormatException later in ComputeGuidForGenericTypes we must fail early if this is a generic type and not a legal WinRT type.
if (pCOMItfMT->SupportsGenericInterop(TypeHandle::Interop_NativeToManaged, MethodTable::modeProjected) && !pCOMItfMT->IsLegalNonArrayWinRTType())
{
return E_NOINTERFACE;
}
else
{
// Retrieve the IID of the interface.
pCOMItfMT->GetGuid(piid, TRUE);
}

// QI for the interface.
hr = SafeQueryInterfaceRemoteAware(*piid, ppUnk);
}
while (hr == E_NOINTERFACE && // Terminate the loop if the QI failed for some other reasons (for example, context transition failure)
(redirection == InterfaceRedirection_IEnumerable_RetryOnFailure || redirection == InterfaceRedirection_Other_RetryOnFailure));
pMT->GetGuid(piid, TRUE);
hr = SafeQueryInterfaceRemoteAware(*piid, ppUnk);

if (SUCCEEDED(hr))
{
if (redirection == InterfaceRedirection_IEnumerable)
if (pMT == MscorlibBinder::GetClass(CLASS__IENUMERABLE))
{
// remember the first IEnumerable<T> interface we successfully QI'ed for
SetGetEnumeratorMethod(pMT);
}

// remember successful QI's for interesting interfaces passing the original instantiation so we know that variance was involved
SetSupportedInterface(pCOMItfMT, pCastToMT->GetInstantiation());
}

return hr;
Expand Down Expand Up @@ -3996,12 +3821,7 @@ bool RCW::SupportsMngStdInterface(MethodTable *pItfMT)
// COM object implements IDispatch and has a member with DISPID_NEWENUM.
if (pItfMT == MscorlibBinder::GetExistingClass(CLASS__IENUMERABLE))
{
SafeComHolder<IDispatch> pDisp = NULL;
if (!AppX::IsAppXProcess())
{
// Get the IDispatch on the current thread.
pDisp = GetIDispatch();
}
SafeComHolder<IDispatch> pDisp = GetIDispatch();
if (pDisp)
{
DISPPARAMS DispParams = {0, 0, NULL, NULL};
Expand Down Expand Up @@ -4290,13 +4110,7 @@ void ComObject::ThrowInvalidCastException(OBJECTREF *pObj, MethodTable *pCastToM
pRCW.Init(*pObj);

// Retrieve the IID of the interface.
MethodTable *pCOMItfMT = NULL;
if (pRCW->GetInterfaceForQI(thCastTo.GetMethodTable(), &pCOMItfMT) == RCW::InterfaceRedirection_UnresolvedIEnumerable)
{
// A special exception message for the case where we are unable to figure out the
// redirected interface because we haven't seen a cast to a generic IEnumerable yet.
COMPlusThrow(kInvalidCastException, IDS_EE_WINRT_IENUMERABLE_BAD_CAST);
}
MethodTable *pCOMItfMT = thCastTo.GetMethodTable();

if (pCOMItfMT->IsProjectedFromWinRT())
{
Expand Down
29 changes: 1 addition & 28 deletions src/coreclr/src/vm/runtimecallablewrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,26 +479,11 @@ struct RCW

#endif // #ifndef DACCESS_COMPILE

enum InterfaceRedirectionKind
{
InterfaceRedirection_None,
InterfaceRedirection_IEnumerable, // IEnumerable`1 - based interface
InterfaceRedirection_IEnumerable_RetryOnFailure, // IEnumerable`1 - based interface, retry on QI failure
InterfaceRedirection_UnresolvedIEnumerable, // unknown IEnumerable`1 instantiation
InterfaceRedirection_Other, // other interface
InterfaceRedirection_Other_RetryOnFailure, // non-generic redirected interface
};

// Returns an interface with variance corresponding to pMT or NULL if pMT does not support variance.
static MethodTable *GetVariantMethodTable(MethodTable *pMT);
static MethodTable *ComputeVariantMethodTable(MethodTable *pMT);

// Determines the interface that should be QI'ed for when the RCW is cast to pItfMT.
// Returns the kind of interface redirection that has been performed.
InterfaceRedirectionKind GetInterfaceForQI(MethodTable *pItfMT, MethodTable **pNewItfMT);
static InterfaceRedirectionKind GetInterfacesForQI(MethodTable *pItfMT, MethodTable **ppNewItfMT1, MethodTable **ppNewItfMT2);
static InterfaceRedirectionKind ComputeInterfacesForQI(MethodTable *pItfMT, MethodTable **ppNewItfMT1, MethodTable **ppNewItfMT2);

// Performs QI for the given interface, optionally instantiating it with the given generic args.
HRESULT CallQueryInterface(MethodTable *pMT, Instantiation inst, IID *piid, IUnknown **ppUnk);

Expand All @@ -521,9 +506,6 @@ struct RCW
// Get the GetEnumerator method for IEnumerable<T> or IIterable<T>
static MethodDesc *ComputeGetEnumeratorMethodForTypeInternal(MethodTable *pMT);

// Notifies the RCW of an interface that is known to be supported by the COM object.
void SetSupportedInterface(MethodTable *pItfMT, Instantiation originalInst);

//-----------------------------------------------------------------
// Retrieve correct COM IP for the current apartment.
// use the cache /update the cache
Expand Down Expand Up @@ -1082,23 +1064,14 @@ struct RCWPerTypeData
// Corresponding type with variance or NULL if the type does not exhibit variant behavior.
MethodTable *m_pVariantMT;

// Types that should be used for QI. m_pMTForQI1 is tried first; if it fails and m_pMTForQI2
// is not NULL, QI for m_pMTForQI2 is performed. We need two types to supports ambiguous casts
// to ICollection<KeyValuePair<K, V>>.
MethodTable *m_pMTForQI1;
MethodTable *m_pMTForQI2;

// The corresponding IEnumerator<T>::GetEnumerator instantiation or NULL if the type does not
// act like IEnumerable.
MethodDesc *m_pGetEnumeratorMethod;

// The kind of redirection performed by QI'ing for m_pMTForQI1.
RCW::InterfaceRedirectionKind m_RedirectionKind;

enum
{
VariantTypeInited = 0x01, // m_pVariantMT is set
RedirectionInfoInited = 0x02, // m_pMTForQI1, m_pMTForQI2, and m_RedirectionKind are set
//unused = 0x02,
GetEnumeratorInited = 0x04, // m_pGetEnumeratorMethod is set
// unused = 0x08,
// unused = 0x10,
Expand Down