-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Rewrite Type.GetTypeFromProgID in C# #42546
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
Conversation
jkotas
commented
Sep 21, 2020
- Move CoreRT managed implementation of Type.GetTypeFromProgID to CoreCLR
- Delete dead code and unnecessary levels of indirection
- Add tests for Type.GetTypeFromProgID and Type.GetTypeFromCLSID
- Move CoreRT managed implementation of Type.GetTypeFromProgID to CoreCLR - Delete dead code and unnecessary levels of indirection - Add tests for Type.GetTypeFromProgID and Type.GetTypeFromCLSID
#else // FEATURE_COMINTEROP_UNMANAGED_ACTIVATION | ||
internal static Type GetTypeFromProgIDImpl(string progID, string? server, bool throwOnError) | ||
{ | ||
throw new NotImplementedException("CoreCLR_REMOVED -- Unmanaged activation removed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling Type.GetTypeFromProgID
on Unix gives this today:
Unhandled exception. System.NotImplementedException: CoreCLR_REMOVED -- Unmanaged activation removed
at System.RuntimeType.GetTypeFromProgIDImpl(String progID, String server, Boolean throwOnError)
at System.Type.GetTypeFromProgID(String progID)
This change is changing it to nice COM interop not support PlatformNotSupportedException.
Assert.Same(type, Marshal.GetTypeFromCLSID(guid)); | ||
Assert.Same(type, Marshal.GetTypeFromCLSID(TestCLSID)); | ||
|
||
Assert.Same(type, Type.GetTypeFromCLSID(TestCLSID)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We did not have any test coverage for Type.GetTypeFromCLSID and Type.GetTypeFromProgID
if (throwOnError) | ||
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); | ||
|
||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will return null
instead of throwing when throwOnError
is false. It matches what we do in other similar situations.
@@ -1318,171 +1318,6 @@ FCIMPL2(Object*, MarshalNative::GetObjectsForNativeVariants, VARIANT* aSrcNative | |||
} | |||
FCIMPLEND | |||
|
|||
FCIMPL2(void, MarshalNative::DoGetTypeLibGuid, GUID * result, Object* refTlbUNSAFE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code that I have run into along the way
src/coreclr/src/vm/interoputil.h
Outdated
//-------------------------------------------------------------------------- | ||
// GetComClassFromCLSID used by reflection class to setup a Class based on CLSID | ||
void GetComClassFromCLSID(REFCLSID clsid, STRINGREF srefServer, OBJECTREF* pRef); | ||
void GetComClassFromCLSID(REFCLSID clsid, __in_opt PCWSTR wszServer, OBJECTREF* pRef); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__in_opt
is SAL. The SAL2 version is _In_opt_z_
for this one.