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

ComNativeDescriptor is dependent on Windows #9291

Open
JeremyKuhne opened this issue Jun 14, 2023 · 5 comments
Open

ComNativeDescriptor is dependent on Windows #9291

JeremyKuhne opened this issue Jun 14, 2023 · 5 comments
Labels
Milestone

Comments

@JeremyKuhne
Copy link
Member

We've recently enabled using ComWrappers with the ComNativeDescriptor- this TypeDescriptionProvider is what is used by the .NET runtime TypeDescriptor for COM objects.

ComWrappers supports other platforms (Unix/Mac), but our current implementation is dependent on Windows PInvokes. These are used both in the ComNativeDescriptor code directly and in support code, such as our VARIANT implementation.

We could remove some of these dependencies, but not everything. As a starting point it would probably be good to target COM types that have no complicated types (that is "primitives") exposed as properties (as described in the ITypeInfo for the type).

Converters that have dependencies on Windows APIs (directly, or indirectly through System.Drawing) would need to be conditionalized. It is unclear what would be the right answer for these. Do we skip a property when it has an IPicture or IFont, for example?

Ideally, we would get cross-plat primitive VARIANT handling from the .NET runtime (that would work with AOT/Trimming enabled). The notable Win32 dependency we have is with SafeArray handling. I haven't looked closely at those APIs, so I'm not sure how difficult it would be to manually implement.

Capturing this for the future. This is unlikely to get scheduled in the near term.

@JeremyKuhne JeremyKuhne added this to the Future milestone Jun 14, 2023
@JeremyKuhne JeremyKuhne added untriaged The team needs to look at this issue in the next triage area-COM labels Jun 14, 2023
@elachlan
Copy link
Contributor

Is the end goal for this better cross platform support in system.drawing and more shared code between winforms and system.drawing?

@AaronRobinsonMSFT
Copy link
Member

AaronRobinsonMSFT commented Jun 16, 2023

@JeremyKuhne Is there a reason to explore this option? The comprehensive COM support is really the least of the issues with WinForms - the entire GDI+ subsystem would need to be stubbed out. Is focusing on cross-platform even remotely tenable or a goal?

@JeremyKuhne
Copy link
Member Author

@AaronRobinsonMSFT, @elachlan the issue is around the ComNativeDescriptor, not cross plat support for Windows Forms in general. The type descriptor only exposes the members marked as properties and that often does not include anything other than "primitives". Even without System.Drawing support this could still be useful.

I don't think this is high priority and wouldn't do it without strong customer need, but I want to at least capture the details as I'm working on creating a PR in the runtime repo that will only allow through ComWrappers for the Windows platform.

@elachlan
Copy link
Contributor

I can see why you mentioned runtime. It might make sense for it to be handled there.

@merriemcgaw merriemcgaw removed the untriaged The team needs to look at this issue in the next triage label Jun 20, 2023
@elachlan
Copy link
Contributor

Related: dotnet/runtime#29125

JeremyKuhne added a commit to JeremyKuhne/runtime that referenced this issue Aug 2, 2023
WinForms hosts the the COM type descriptor. It has been updated to work with ComWrappers based objects- adding the check for them in TypeDescriptor.

There are hard dependencies on Windows in the current implementation. We can potentially update to conditionalize these. dotnet/winforms#9291 tracks.

There is no automated test as it would require adding a dependency upstream to WinForms.
ericstj pushed a commit to dotnet/runtime that referenced this issue Aug 3, 2023
WinForms hosts the the COM type descriptor. It has been updated to work with ComWrappers based objects- adding the check for them in TypeDescriptor.

There are hard dependencies on Windows in the current implementation. We can potentially update to conditionalize these. dotnet/winforms#9291 tracks.

There is no automated test as it would require adding a dependency upstream to WinForms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants