Repository navigation
First round of converting System.Drawing.Common to COMWrappers - #54636
Conversation
Using COM Wrappers makes the library trim compatible.
commented
Jun 23, 2021
|
Tagging subscribers to this area: @safern, @tarekgh Issue DetailsUsing COM Wrappers makes the library trim compatible. I also added a trimming test to ensure the method in question works with trimming. @ericstj @ViktorHofer - this is another case where we are splitting ".NET Core 3.1" build with ".NET Current" build. (I had to do that in order to use ComWrappers, because that API came in 5.0.) This means we are going to be missing test coverage for all of these COM interop scenarios for System.Drawing.Common v6.0.0 when running on .NET Core 3.1. cc @kant2002
|
commented
Jun 23, 2021
I agree that is painful and should be fixed by adding support for testing on older .NETCoreApp versions and run them either per rolling build or nightly. We don't have capacity to run them on every PR. |
commented
Jun 23, 2021
|
@ViktorHofer what if this was opt-in per test? A test project could decide to add a configuration for |
commented
Jun 23, 2021
|
cc @michaelgsharp as well, who's been doing a lot of helix work lately. ML.NET has a similar requirement around wanting to run tests against multiple different framework versions. Also, maybe we should move this discussion to an issue. Do we have a good one already? |
The overall issue isn't specific to Windows, we need coverage on as many OSs that a library supports, as possible. The cost that I'm concerned about isn't observable in the amount of build agents but in the number of Helix clients that accept work items. I imagine support for testing on older .NETCoreApp configurations could be implemented in the following way in order:
|
|
Moved test infrastructure discussion into #54639. |
* Use function pointers instead of delegates * Rename Guid to IID * Better interop to closely match the native side * Release any COM pointer that was QueryInterface * Use pointers instead of Marshal.PtrToStructure/StructureToPtr
* No need for a VTable struct, just set each function pointer right into the table * Wrap all managed calls in try-catch and return HResult
* Rename methods * Use COM naming * Fix method signature to use pointer instead of out. * CheckStatus => ThrowExceptionForHR
commented
Jun 24, 2021
|
Looks like the x86 tests are failing: Trying to get a repro locally. |
commented
Jun 24, 2021
|
@ViktorHofer do we have a lot of projects that would run on previous versions of .NET Core? What if we start small and run them on Ubuntu, Windows and macOS on the build agent without using helix? If there aren't may projects that would want to do this, we could get away without using helix and running them on the build agent. |
commented
Jun 25, 2021
This is what I see when trying to debug the .dmp file. @AaronRobinsonMSFT any thoughts? |
commented
Jun 25, 2021
|
@eerhardt How can I get a hold of that DMP file? |
commented
Jun 25, 2021
|
I have it locally, and can send it to you. Or: See https://github.com/dotnet/runtime/blob/main/eng/testing/debug-dump-template.md |
commented
Jun 25, 2021
|
Line https://github.com/dotnet/runtime/pull/54636/files#diff-f587d46981bfe7aeb74b6390ab4035ef7355e1c5cfe849583efb14da68c0aa49R288 maybe here should be added AddRef. |
commented
Jun 25, 2021
The AddRef happens (in QueryInterface) before the PictureWrapper class is created, here: Notice that x64 passes. It is just failing on x86. |
commented
Jun 25, 2021
|
There are also x64 tests failing, and these I can repro on my machine, but not 100% of the time. The test failure is: We are expecting an
runtime/src/libraries/Common/src/System/HResults.cs Lines 78 to 79 in 57bfe47 But |
commented
Jun 25, 2021
I was able to catch some of these in a debugger, and have figured out some more information. The case where it is failing is getting into: runtime/src/coreclr/vm/excep.cpp Lines 3004 to 3008 in 57bfe47
AFAICT, the reason runtime/src/coreclr/vm/marshalnative.cpp Line 647 in 57bfe47 The managed C# code is passing in A naïve question: If I'm calling be changed to |
commented
Jun 25, 2021
|
Yes, COM IErrorInfo is mess. .NET interop assumes that all COM calls set it, but it is not the case in practice.
Changing that would be breaking behavior change. It should be fine to pass in |
commented
Jun 28, 2021
|
The musl library test leg is failing HTTP and sockets tests - unrelated to this change. The CoreClr Pri0 arm64 test failure also look unrelated, but I can’t find a current issue tracking the failures. |
commented
Jun 28, 2021
|
Test failures are unrelated. Merging. |

Using COM Wrappers makes the library trim compatible.
I also added a trimming test to ensure the method in question works with trimming.
@ericstj @ViktorHofer - this is another case where we are splitting ".NET Core 3.1" build with ".NET Current" build. (I had to do that in order to use ComWrappers, because that API came in 5.0.) This means we are going to be missing test coverage for all of these COM interop scenarios for System.Drawing.Common v6.0.0 when running on .NET Core 3.1.
cc @kant2002