Skip to content

fix(api)!: return concrete type from DisposeWith - #168

Merged
ChrisPulman merged 1 commit into
mainfrom
CP_disposewith-generic-return
Aug 19, 2026
Merged

fix(api)!: return concrete type from DisposeWith#168
ChrisPulman merged 1 commit into
mainfrom
CP_disposewith-generic-return

Conversation

@ChrisPulman

@ChrisPulman ChrisPulman commented Aug 19, 2026

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

A breaking API fix that makes the MultipleDisposable overload of DisposeWith preserve the receiver's concrete disposable type.

Closes #152

What is the new behavior?

DisposeWith<T>(T disposable, MultipleDisposable disposables) validates the disposable collection, adds the original item, and returns the same T. The parameterless and action overloads retain their existing IDisposable receiver metadata. Lean and Reactive API baselines are updated for every tracked target framework, with TUnit coverage for concrete-type preservation, identity, disposal tracking, and null validation.

What is the current behavior?

The MultipleDisposable overload returns IDisposable, losing the receiver's concrete type, and silently accepts a null collection. Compiled consumers of that overload target the old non-generic metadata signature and must recompile for this change.

Checklist

  • Tests have been added or updated (for bug fixes / features)
  • Docs have been added or updated (for bug fixes / features)
  • Changes target the main branch
  • PR title follows Conventional Commits

Additional information

Validation:

  • Lean and Reactive net10.0 builds passed with zero warnings and errors.
  • Lean and Reactive net462 builds passed with zero warnings and errors.
  • Focused TUnit tests passed: lean 2/2; Reactive 12/12.
  • Targeted Cobertura/Mtpunittest MCP review confirms the generic DisposeWith body is covered.
  • git diff --check passed.

BREAKING CHANGE: DisposeWith(IDisposable, MultipleDisposable) is replaced by DisposeWith<T>(T, MultipleDisposable). Already compiled consumers must recompile. The parameterless and action overloads preserve their existing metadata.

Implementation:
- make the MultipleDisposable overload generic and return the original concrete disposable
- preserve the existing IDisposable receiver metadata for the parameterless and action overloads
- validate the disposable collection before registration

API and tests:
- update lean and Reactive public API baselines for every tracked target framework
- add TUnit coverage for concrete-type preservation, identity, disposal tracking, and null validation

BREAKING CHANGE: DisposeWith(IDisposable, MultipleDisposable) is replaced by DisposeWith<T>(T, MultipleDisposable), so compiled consumers must recompile.
@ChrisPulman
ChrisPulman marked this pull request as ready for review August 19, 2026 00:17
@ChrisPulman
ChrisPulman enabled auto-merge (squash) August 19, 2026 00:30
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.14%. Comparing base (72918bd) to head (124c0da).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #168      +/-   ##
==========================================
- Coverage   98.14%   98.14%   -0.01%     
==========================================
  Files         703      703              
  Lines       21733    21734       +1     
  Branches     2679     2678       -1     
==========================================
  Hits        21330    21330              
  Misses        199      199              
- Partials      204      205       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@ChrisPulman
ChrisPulman merged commit 91eca8f into main Aug 19, 2026
11 checks passed
@ChrisPulman
ChrisPulman deleted the CP_disposewith-generic-return branch August 19, 2026 00:46
@sonarqubecloud

Copy link
Copy Markdown

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.

[Bug]: LinqExtensions.DisposeWith(T this, MultipleDisposable disposables) returns IDisposable rather than T

2 participants