Skip to content

Conversation

@AaronRobinsonMSFT
Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT commented Nov 7, 2025

Fixes #121252

Update tests to activate correctly.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors COM interop code in two key ways: simplifying COM object instantiation in tests and improving the implementation of exception handling for COM HRESULTs.

  • Removes redundant explicit casts when instantiating COM objects via the CoClass pattern
  • Adds diagnostic logging to test execution with Console.WriteLine(nameof(...))
  • Refactors GetCOMHRExceptionObject to use a new direct native helper method instead of the RuntimeMethodHandle.FromIntPtr pathway

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tests/Interop/COM/NETClients/Primitives/StringTests.cs Removed redundant cast in COM object instantiation and added diagnostic logging
src/tests/Interop/COM/NETClients/Primitives/NumericTests.cs Removed redundant cast in COM object instantiation and added diagnostic logging
src/tests/Interop/COM/NETClients/Primitives/ErrorTests.cs Removed redundant cast in COM object instantiation and added diagnostic logging
src/tests/Interop/COM/NETClients/Primitives/ColorTests.cs Removed redundant cast in COM object instantiation and added diagnostic logging
src/tests/Interop/COM/NETClients/Primitives/CallViaReflectionTests.cs Removed redundant cast in COM object instantiation
src/tests/Interop/COM/NETClients/Primitives/ArrayTests.cs Removed redundant cast in COM object instantiation and added diagnostic logging
src/tests/Interop/COM/NETClients/MiscTypes/Program.cs Removed redundant casts in COM object instantiation
src/tests/Interop/COM/NETClients/Licensing/Program.cs Removed redundant casts in COM object instantiation
src/tests/Interop/COM/NETClients/IInspectable/Program.cs Removed redundant cast in COM object instantiation
src/tests/Interop/COM/NETClients/IDispatch/Program.cs Removed redundant casts in COM object instantiation
src/tests/Interop/COM/NETClients/Events/Program.cs Removed redundant casts in COM object instantiation
src/tests/Interop/COM/NETClients/ComDisabled/Program.cs Removed redundant cast in COM object instantiation
src/coreclr/vm/stubhelpers.h Added declaration for new helper method GetComInterfaceFromMethodDesc
src/coreclr/vm/stubhelpers.cpp Implemented new helper method to extract interface MethodTable from a method descriptor
src/coreclr/vm/ecalllist.h Registered the new helper method as an FCFunc
src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs Refactored GetCOMHRExceptionObject to use new direct native helper instead of RuntimeMethodHandle pathway

@AaronRobinsonMSFT
Copy link
Member Author

/ba-g Unrelated timeouts

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit 5bceb81 into dotnet:main Nov 10, 2025
97 of 111 checks passed
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the runtime_121252 branch November 10, 2025 23:00
@AaronRobinsonMSFT
Copy link
Member Author

/backport to release/10.0

@github-actions
Copy link
Contributor

Started backporting to release/10.0 (link to workflow run)

steveisok pushed a commit that referenced this pull request Nov 11, 2025
…1512)

Backport of #121431 to release/10.0

/cc @AaronRobinsonMSFT

## Customer Impact

- [x] Customer reported
- [ ] Found internally

How a COM server is activated can obscure how we determine the `IID` of
a COM interface method. This matters in scenarios involving
`ISupportErrorInfo`. A user reported this in
#121252.

## Regression

- [x] Yes
- [ ] No

This is a regression from .NET 9. It was introduced in
#117690.

## Testing

Tests were updated to validate this behavior.

## Risk

Low. This only impacts COM scenarios involving `ISupportErrorInfo`.

---------

Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InterfaceSupportsErrorInfo called with CLSID instead of an IID

3 participants