Skip to content

[Experimental Agent] Fix COM ownership and HTML subscription lifetimes/Alternative fix attempt - #15087

Draft
KlausLoeffelmann wants to merge 1 commit into
dotnet:mainfrom
KlausLoeffelmann:fix/com-html-lifetime-ownership
Draft

KlausLoeffelmann wants to merge 1 commit into
dotnet:mainfrom
KlausLoeffelmann:fix/com-html-lifetime-ownership

Conversation

@KlausLoeffelmann

@KlausLoeffelmann KlausLoeffelmann commented Sep 12, 2026

Copy link
Copy Markdown
Member

This is a fix-attempt based on a different, experimental Agent-approach to evaluate quality/plausibility of bug-fixes in an actual, real-world scenario.

Alternative to ** #15059 **


Executing Agent's description:

Balance caller-owned conversion, activation, and connection-point references so native teardown does not leave a site or event sink rooting its managed host. Adapt the necessary browser/HTML prerequisites from Jeremy Kuhne's #15059 without importing unrelated changes.

Observe HTML window unload independently of application subscriptions, preserve actual delegate/proxy multiplicity, and tear down the correct window's subscriptions while allowing other frames to remain active. Keep ordinary event disconnection separate from final attached-event cleanup, and complete owned-resource cleanup on reentrant/error paths. Keep removal non-creating after teardown, reject revoked registrations before native-identity dictionary comparisons, and preserve nonthrowing subscription behavior for windows that lack the optional event connection point.

Honor successful SetData ownership transfer without reading or releasing a medium the recipient may already have freed. Cover native reference balance, continued usability, event delivery, navigation, and failure paths. Explain the ownership invariants and failure mechanisms at the changes.

Leave the generated-COM GIT strategy/cache redesign for separate work.

Microsoft Reviewers: Open in CodeFlow

Balance caller-owned conversion, activation, and connection-point references
so native teardown does not leave a site or event sink rooting its managed
host. Adapt the necessary browser/HTML prerequisites from Jeremy Kuhne's
dotnet#15059 without importing unrelated changes.

Observe HTML window unload independently of application subscriptions,
preserve actual delegate/proxy multiplicity, and tear down the correct
window's subscriptions while allowing other frames to remain active.
Keep ordinary event disconnection separate from final attached-event
cleanup, and complete owned-resource cleanup on reentrant/error paths.
Keep removal non-creating after teardown, reject revoked registrations before
native-identity dictionary comparisons, and preserve nonthrowing subscription
behavior for windows that lack the optional event connection point.

Honor successful SetData ownership transfer without reading or releasing
a medium the recipient may already have freed. Cover native reference
balance, continued usability, event delivery, navigation, and failure paths.
Explain the ownership invariants and failure mechanisms at the changes.

Leave the generated-COM GIT strategy/cache redesign for separate work.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e87f9293-79ef-46bf-b22b-a6eee74d2a2c
@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.18459%. Comparing base (a7c35d1) to head (3a471ee).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #15087         +/-   ##
===================================================
- Coverage   37.24166%   37.18459%   -0.05708%     
===================================================
  Files            246         246                 
  Lines           9774        9789         +15     
  Branches        1029        1031          +2     
===================================================
  Hits            3640        3640                 
- Misses          5970        5985         +15     
  Partials         164         164                 
Flag Coverage Δ
Debug 37.18459% <0.00000%> (-0.05708%) ⬇️
production 39.29724% <0.00000%> (-0.06802%) ⬇️
test 20.64923% <ø> (ø)
unit 39.29724% <0.00000%> (-0.06802%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dotnet-policy-service dotnet-policy-service Bot added the draft draft PR label Sep 12, 2026
JeremyKuhne added a commit to JeremyKuhne/winforms that referenced this pull request Sep 15, 2026
Integrate the ownership and lifecycle design from dotnet#15087,
authored by Klaus Loffelmann with Copilot. Observe unload independently of
application subscriptions, preserve native registration multiplicity, make
teardown reentrant, and honor successful STGMEDIUM ownership transfer.

Preserve this PR's accessibility, COM factory, VB6 shutdown, bitmap, and
additional ownership coverage. Add direct SetData transfer tests for both
current .NET and .NET Framework.

Co-authored-by: Klaus Loffelmann <klloeffe@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

draft draft PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants