Skip to content

Keep ExportProvider self-export off the activation fast path - #799

Merged
Andrew Arnott (AArnott) merged 2 commits into
mainfrom
aarnott-fix-exportprovider-self-export-disposal
Sep 23, 2026
Merged

Andrew Arnott (AArnott) merged 2 commits into
mainfrom
aarnott-fix-exportprovider-self-export-disposal

Conversation

@AArnott

Copy link
Copy Markdown
Member

GetExportedValue<ExportProvider>() started failing container disposal after the export-lookup fast path in #772.

That path treated the synthesized ExportProvider export as a normal part and tracked its non-owning wrapper. Disposing the container then called Dispose() on the wrapper, which throws InvalidOperationException ("This instance is an import and cannot be directly disposed."). An empty container is enough to reproduce it.

The fast path now declines that synthesized export, so the call falls back to the existing GetExport path. Callers still receive the non-owning wrapper, and disposing that wrapper directly still throws. Only container disposal is restored to the pre-#772 behavior.

GetExportedValue<ExportProvider>() was tracking the synthesized non-owning wrapper as a normal part, so disposing the container tried to dispose that wrapper and threw.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 23, 2026 03:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved review issues remain, and disposal regression coverage is included.

Review effort: Lite
Findings: None

What changed in this PR

Fixes container disposal failures caused by the synthesized ExportProvider wrapper entering the activation fast path.

Changes:

  • Falls back to normal export resolution for ExportProvider.
  • Adds disposal regression tests for synchronous, asynchronous, and joinable containers.
File Description
test/​Microsoft.VisualStudio.Composition.Tests/​DisposablePartsTests.cs Verifies wrapper and container disposal behavior.
src/​Microsoft.VisualStudio.Composition/​RuntimeExportProviderFactory+RuntimeExportProvider.cs Excludes the synthesized wrapper from fast-path lifecycle tracking.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/Microsoft.VisualStudio.Composition.Tests/DisposablePartsTests.cs Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 23, 2026 15:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved issues were identified.

Review effort: Lite
Findings: None

@AArnott
Andrew Arnott (AArnott) merged commit 0371ac1 into main Sep 23, 2026
10 checks passed
@AArnott
Andrew Arnott (AArnott) deleted the aarnott-fix-exportprovider-self-export-disposal branch September 23, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants