Skip to content

Revert free-threaded assert in FreeThreadedStrategy#130981

Merged
AaronRobinsonMSFT merged 1 commit into
dotnet:mainfrom
AaronRobinsonMSFT:revert_assert
Jul 17, 2026
Merged

Revert free-threaded assert in FreeThreadedStrategy#130981
AaronRobinsonMSFT merged 1 commit into
dotnet:mainfrom
AaronRobinsonMSFT:revert_assert

Conversation

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

Reverts the DEBUG-only free-threaded assert added to FreeThreadedStrategy in #130906. The assert was overly strict: FreeThreadedStrategy is also valid for apartment-affinitized COM objects when the current thread already has the correct apartment type, so the agility probe produced false assert failures.

Also clarifies documentation on StrategyBasedComWrappers.DefaultIUnknownStrategy and adds a class comment on FreeThreadedStrategy describing these use cases.

Closes #130961.

Note

This PR description was generated with assistance from GitHub Copilot.

Update documentation for the DefaultIUnknownStrategy member.
Add comment on FreeThreadedStrategy on use cases.
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 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/interop-contrib
See info in area-owners.md if you want to be subscribed.

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 adjusts the COM marshalling strategy docs and implementation by removing a DEBUG-only “free-threaded” (agility) assert from FreeThreadedStrategy and clarifying when StrategyBasedComWrappers.DefaultIUnknownStrategy is intended to be used.

Changes:

  • Removed the DEBUG-only agility probe/assert from FreeThreadedStrategy.
  • Added an explanatory class comment on FreeThreadedStrategy.
  • Updated the XML remarks for StrategyBasedComWrappers.DefaultIUnknownStrategy to broaden/clarify the intended use.
Show a summary per file
File Description
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/StrategyBasedComWrappers.cs Updates the public remarks for the default IIUnknownStrategy.
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/FreeThreadedStrategy.cs Removes DEBUG-only agility assertion logic and adds clarifying commentary.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 3

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

Did preview 7 snap between #130906 and this?

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

Did preview 7 snap between #130906 and this?

It is possible. I'll track that down.

@AaronRobinsonMSFT
AaronRobinsonMSFT enabled auto-merge (squash) July 17, 2026 18:47
@AaronRobinsonMSFT
AaronRobinsonMSFT merged commit 12a9b3b into dotnet:main Jul 17, 2026
103 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Jul 17, 2026
@AaronRobinsonMSFT
AaronRobinsonMSFT deleted the revert_assert branch July 17, 2026 21:23
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Test failure: A COM object used through FreeThreadedStrategy is not free threaded (agile).

5 participants