Skip to content

ComWrappers support #5163

Closed
Closed
@kant2002

Description

@kant2002

I want to raise questions about plans for adding ComWrappers support in WinForms.
This make WinForms application IL trimming friendly. For me that would be big win for NativeAOT, but I understand that this is not priority.
Work in .NET repository started dotnet/runtime#54636 and I think similar approach to some degree can happens here.

I initially try to find simplest interfaces where this can be tested, but everything so intermixed with ActiveX support, so I do not know where to start.
So far easiest targets to get started is following

  • IPicture, IStream, IPersistStream.
  • IClassFactory2
  • IMallocSpy

Each these interfaces has their own challenges

IPicture, IStream, IPersistStream

Initially can be implemented for Cursor class only. IPicture used a lot in ActiveX code and that part is extremely problematic and maybe require usage of IDynamicCastable or similar complicated approach. Also probably it will require OleCreatePictureIndirect split of implementation on two parts, one for ComWrappers, second is for ComWrappers, and that would be for some time, since ActiveX seems impenetrable target for now.

IClassFactory2

This is very limited in usage and can be used for probing ground how to start make ActiveX support friendly for ComWrappers. Interface in itself not a problem, but CreateInstanceLic return object instance which as far as I understand, should be universal RCW. I personally may go with temporary using existing COM infrastructure, using Marshal.GetObjectForIUnknown until better solution arise.

IMallocSpy

This interface used only for tests, so not a big win in terms of implementation. Maybe good candidate to prepare tests for world without no built-in COM.

Testing

As mentioned in PR for System.Drawing.Common, they have to support .NET Core 3.1 and this requires a bit of changes in testing. I'm not sure how applicable this concerns for this repo, and how do you manage older .NET Core. Require discussion too.

Also a lot of tests rely on the built-in COM infrastructure so this is also should be factored somehow.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions