Skip to content

Pass through ComWrappers based objects to COM type descriptor #89887

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

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;

namespace System.ComponentModel
Expand Down Expand Up @@ -1541,6 +1542,17 @@ private static TypeDescriptionNode NodeFor(object instance, bool createDelegator
{
type = ComObjectType;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
&& ComWrappers.TryGetComInstance(instance, out nint unknown))
{
// ComObjectType uses the Windows Forms provided ComNativeDescriptor. It currently has hard Win32
// API dependencies. Even though ComWrappers work with other platforms, restricting to Windows until
// such time that the ComNativeDescriptor can handle basic COM types on other platforms.
//
// Tracked with https://github.com/dotnet/winforms/issues/9291
Marshal.Release(unknown);
type = ComObjectType;
}

if (createDelegator)
{
Expand Down