-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
First round of converting System.Drawing.Common to COMWrappers #54636
Conversation
Using COM Wrappers makes the library trim compatible.
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
|
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
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. |
@ViktorHofer what if this was opt-in per test? A test project could decide to add a configuration for |
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:
|
src/libraries/Common/src/Interop/Windows/Ole32/Interop.IStream.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Windows.COMWrappers.cs
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Windows.COMWrappers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Windows.COMWrappers.cs
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
Moved test infrastructure discussion into #54639. |
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
* 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
src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Windows.COMWrappers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Windows/Ole32/Interop.IStream.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Windows/Ole32/Interop.IStream.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Show resolved
Hide resolved
src/libraries/System.Drawing.Common/src/System/Drawing/DrawingComWrappers.cs
Outdated
Show resolved
Hide resolved
* Rename methods * Use COM naming * Fix method signature to use pointer instead of out. * CheckStatus => ThrowExceptionForHR
Looks like the x86 tests are failing:
Trying to get a repro locally. |
@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. |
This is what I see when trying to debug the .dmp file. @AaronRobinsonMSFT any thoughts?
|
@eerhardt How can I get a hold of that DMP file? |
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 |
Line https://github.com/dotnet/runtime/pull/54636/files#diff-f587d46981bfe7aeb74b6390ab4035ef7355e1c5cfe849583efb14da68c0aa49R288 maybe here should be added AddRef. |
The AddRef happens (in QueryInterface) before the PictureWrapper class is created, here: Notice that x64 passes. It is just failing on x86. |
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 |
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 runtime/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs Line 654 in 57bfe47
be changed to |
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 |
src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Windows.COMWrappers.cs
Outdated
Show resolved
Hide resolved
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. |
This change just remove warning from ILLink and do not make attempt to convert other COM object creation to use ComWrappers Also I have to add target net5.0-windows where ComWrappers would be used. Same concerns regarding testing as in dotnet#54636 Two calls inside OleDbDataAdapter call GetErrorInfo but do not do anything with results. That's probably mistake from previous refactoring. These parts does not touched and left as is. Need advice on that specific parts how to proceed.
Test failures are unrelated. Merging. |
…bugger2 * origin/main: (78 commits) Fix unreached during dump. (dotnet#54861) Fix lowering usage of an unset LSRA field. (dotnet#54731) Fix setting breakpoints on AVX 256 instructions and other 32 byte immediate instructions (dotnet#54786) Add perf_slow yaml (dotnet#54853) Faster type load for scenarios made more common by generic math (dotnet#54588) Make sure we consider buffer length when marshalling back Unicode ByValTStr fields (dotnet#54695) Add YieldProcessor implementation for arm (dotnet#54829) Remove ActiveIssue for dotnet#50968 (dotnet#54831) Enable System.Text.Json tests for Wasm AOT (dotnet#54833) Remove ActiveIssue for dotnet#51723 (dotnet#54830) Fix load exception on generic covariant return type (dotnet#54790) Obsolete X509Certificate2.PrivateKey and PublicKey.Key. (dotnet#54562) First round of converting System.Drawing.Common to COMWrappers (dotnet#54636) Fix alloc-dealloc mismatches (dotnet#54701) Add one-shot ECB methods [Mono] MSBuild Task housekeeping (dotnet#54485) Move iOS/tvOS simulator AOT imports in the Mono workload (dotnet#54821) Remove unnecessary char[] allocation from Uri.GetRelativeSerializationString (dotnet#54799) Reduce overhead of Enumerable.Chunk (dotnet#54782) Fix EnumMemberRefs always returning NULL (dotnet#54805) ...
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