Skip to content

Add interface-selecting ComWrappers overloads - #134354

Merged
AaronRobinsonMSFT merged 8 commits into
mainfrom
copilot/add-trygetcominstance-ux-improvement
Sep 26, 2026
Merged

AaronRobinsonMSFT merged 8 commits into
mainfrom
copilot/add-trygetcominstance-ux-improvement

Conversation

Copilot AI commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Adds the approved convenience overloads for obtaining a specific COM interface without manually composing wrapper creation, QueryInterface, and temporary-reference cleanup.

  • APIs: Add an in Guid interfaceId overload to ComWrappers and a generic overload to StrategyBasedComWrappers, using AOT-friendly interface metadata.
  • Semantics: Cache the wrapper before querying, retain it on query failure, and return a caller-owned interface reference. Unsupported interfaces throw InvalidCastException.
  • Documentation and coverage: Add XML documentation, reference declarations, platform-not-supported support, and tests for interface selection, reference ownership, cache retention, repeated queries, and custom strategies.
nint ifoo = wrappers.GetOrCreateComInterfaceForObject<IFoo>(
    foo, CreateComInterfaceFlags.None);
// Release ifoo when finished.

@azure-pipelines

azure-pipelines Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@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.

Co-authored-by: AaronRobinsonMSFT <30635565+AaronRobinsonMSFT@users.noreply.github.com>
Copilot AI changed the title [WIP] Add TryGetComInstance method to ComWrappers for better UX Add interface-selecting ComWrappers overloads Sep 21, 2026
Co-authored-by: AaronRobinsonMSFT <30635565+AaronRobinsonMSFT@users.noreply.github.com>
Co-authored-by: AaronRobinsonMSFT <30635565+AaronRobinsonMSFT@users.noreply.github.com>
Co-authored-by: AaronRobinsonMSFT <30635565+AaronRobinsonMSFT@users.noreply.github.com>
@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

@jkoritzinsky PTAL

Co-authored-by: AaronRobinsonMSFT <30635565+AaronRobinsonMSFT@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 24, 2026 15:06

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.

Copilot review overview

🔵 Needs a closer look

Query failures must consistently produce InvalidCastException as documented and tested.

Review effort: Lite
Findings: None

Copilot AI review requested due to automatic review settings September 24, 2026 15:56

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.

Copilot review overview

🔵 Needs a closer look

The changes require final human review because they are too complex or risky for automated approval.

Review effort: Lite
Findings: None

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

/cc @jkoritzinsky

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

/ba-g Unrelated failure.

@AaronRobinsonMSFT
AaronRobinsonMSFT merged commit e18128a into main Sep 26, 2026
153 of 155 checks passed
@AaronRobinsonMSFT
AaronRobinsonMSFT deleted the copilot/add-trygetcominstance-ux-improvement branch September 26, 2026 01:29
@github-project-automation github-project-automation Bot moved this to Done in AppModel Sep 26, 2026
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

Suggestion ComWrappers.TryGetComInstance() to improve UX

4 participants