Skip to content

Disable ctor calls on classes marked with ComImport when COM interop feature isn't enabled.#115009

Merged
AaronRobinsonMSFT merged 6 commits into
dotnet:mainfrom
AaronRobinsonMSFT:runtime_114933
Apr 26, 2025
Merged

Disable ctor calls on classes marked with ComImport when COM interop feature isn't enabled.#115009
AaronRobinsonMSFT merged 6 commits into
dotnet:mainfrom
AaronRobinsonMSFT:runtime_114933

Conversation

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

Fixes #114933

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

/cc @dotnet/interop-contrib

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 disables COM interop constructor calls in builds that do not support COM interop by wrapping related code in FEATURE_COMINTEROP conditionals.

  • Wraps COM interop-specific logic in a preprocessor conditional
  • Removes inline conditional checks inside the COM interop block
Comments suppressed due to low confidence (1)

src/coreclr/vm/ecall.cpp:339

  • It would be beneficial to add or update unit tests to verify that COM interop constructor calls are properly disabled in builds without COM interop support.
#ifdef FEATURE_COMINTEROP

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Comment thread src/coreclr/vm/ecall.cpp
Comment thread src/coreclr/vm/ecall.cpp Outdated
@jkotas

jkotas commented Apr 24, 2025

Copy link
Copy Markdown
Member

SecurityException: ECall methods must be packaged into a system module.

This is confusing error to give when somebody tries to use built-in COM on non-Windows. Can we throw IDS_EE_ERROR_COM instead?

@AaronRobinsonMSFT AaronRobinsonMSFT changed the title Disable COM interop ctor calls when COM interop feature isn't supported. Disable ctor calls on classes marked with ComImport when COM interop feature isn't enabled. Apr 24, 2025

@jkotas jkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it worth it to add a regression test for PrepareMethod?

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

Is it worth it to add a regression test for PrepareMethod?

Yeah, I thought about it. I'm not sure how useful it is in practice, but I added one none the less.

…/Runtime/CompilerServices/RuntimeHelpersTests.cs

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

/ba-g WASM reliability

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit 68a1b4a into dotnet:main Apr 26, 2025
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the runtime_114933 branch April 26, 2025 10:37
@github-actions github-actions Bot locked and limited conversation to collaborators May 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assert failure: pMD->IsCtor()

3 participants