Repository navigation
Releases
Releases · NCodeGroup/NCode.Disposables
v9.0.0
Changed
- Breaking:
SharedReference.Create(value, onRelease)andAsyncSharedReference.Create(value, onRelease)throwArgumentNullExceptionfor anullvalue or release callback,SharedReference.Create(value),AsyncSharedReference.Create(value),AsSharedReference()andAsAsyncSharedReference()for anullresource, and theSharedReferenceOwner<T>andAsyncSharedReferenceOwner<T>constructors for anullrelease callback; the owner constructors keep accepting anullvalue. Before, anullrelease callback or resource threwNullReferenceExceptiononly when the last lease was released, andCreate(value, onRelease)handed anullvalue to the release callback; pass the value and the release callback to share. (#89, ADR-1008) - Breaking: The
DisposableCollectionandAsyncDisposableCollectionconstructors, and so theCollectionandCollectionIgnoringExceptionsfactories ofDisposableandAsyncDisposable, throwArgumentExceptionfor an initial collection that holds anullitem, whichAddalready rejects, instead of keeping it; leavenullout of the items. (#89, ADR-1008) - Package validation compares each package with the published 8.0.1 package.
docs/assurance-case.mdstates the library's security requirements, its threat model and trust boundary, the secure design principles it applies and the weaknesses it counters, with the tests behind them.
v8.0.1
Added
- The documentation site at https://disposables.ncode.io/: a quick start, a picker that finds the disposable for a situation, a guide for each task with its pitfalls, the rules behind them, a behavior reference of every disposable and an API map of every public member. Every C# sample on it is a test that compiles and runs on each pull request. (ADR-1009, ADR-1010)
Changed
- Package validation compares each package with the published 8.0.0 package.
- The package's project website on nuget.org is the documentation site, and both READMEs link to it. (ADR-1013)
v8.0.0
Changed
- Breaking:
AsyncDisposable.Adapt,AsyncDisposable.AdaptRepeatableand theAsyncDisposableAdapterconstructor throwArgumentNullExceptionfor anulldisposable instead of returning an adapter that disposes nothing; pass the resource to adapt. (#76, ADR-1008)
Removed
- Breaking:
IDisposableAggregate,IAsyncDisposableAggregate,IDisposableCollectionandIAsyncDisposableCollection, obsolete since 7.0.0 (NCDISP002), are deleted: useDisposableAggregate,AsyncDisposableAggregate,DisposableCollectionandAsyncDisposableCollection, which the factories return. (#69, ADR-1005) - Breaking: The 19 members whose
boolpicks a behavior, obsolete since 7.1.0 (NCDISP003), are deleted:idempotentonDisposable.Create,AsyncDisposable.Create,AsyncDisposable.Adaptand theDisposableAction,AsyncDisposableActionandAsyncDisposableAdapterconstructors,asynconDisposable.Contextand theDisposableContextconstructor, andignoreExceptionsonDisposable.Collection,AsyncDisposable.Collection, theDisposableCollectionandAsyncDisposableCollectionconstructors,DisposeAllandDisposeAllAsync. Call the overload without the flag for the default behavior, orCreateRepeatable,AdaptRepeatable,PostingContext,CollectionIgnoringExceptions,DisposeAllIgnoringExceptions()orDisposeAllIgnoringExceptionsAsync()for the other one. (#75, ADR-1007)
v7.1.0
Added
Disposable.CreateRepeatable,AsyncDisposable.CreateRepeatableandAsyncDisposable.AdaptRepeatablerun the action or dispose the resource on every call,Disposable.PostingContextdisposes through the context'sPost, andDisposable.CollectionIgnoringExceptions,AsyncDisposable.CollectionIgnoringExceptions,DisposeAllIgnoringExceptions()andDisposeAllIgnoringExceptionsAsync()ignore the exceptions items throw; the constructors and overloads without a flag, such asnew DisposableAction(action),Disposable.Context(disposable, context)andDisposeAll(), pick the default behavior. (#68, ADR-1007)
Changed
- The project template is v0.113.3, whose
build/Update-PublicApi.ps1andbuild/dod.ps1find the projects when they run from a plan's worktree under.claude/worktrees/. (#70) - The tests create every mock from one
MockRepositoryper test class, which verifies each expected call when the test ends. (#67)
Deprecated
- The
boolparameters that pick a behavior reportNCDISP003:idempotentonDisposable.Create,AsyncDisposable.Create,AsyncDisposable.Adaptand theDisposableAction,AsyncDisposableActionandAsyncDisposableAdapterconstructors,asynconDisposable.Contextand theDisposableContextconstructor, andignoreExceptionsonDisposable.Collection,AsyncDisposable.Collection, theDisposableCollectionandAsyncDisposableCollectionconstructors,DisposeAllandDisposeAllAsync. Use the members named for each behavior, because the next major version deletes these overloads. (#68, ADR-1007)
Fixed
Disposeon a context fromDisposable.PostingContext, or fromDisposable.Contextwithasync: true, callsOperationCompletedand rethrows when the context'sPostthrows, so the context's count of operations stays balanced. (#71)
v7.0.0
Added
DisposableSerialandAsyncDisposableSerial, fromDisposable.SerialandAsyncDisposable.Serial, hold one resource and dispose it when another replaces it. (#65, ADR-1004)DisposableSingleAssignmentandAsyncDisposableSingleAssignment, fromDisposable.SingleAssignmentandAsyncDisposable.SingleAssignment, take one resource once; a second assignment throwsInvalidOperationException. (#65, ADR-1004)DisposableGuard<T>andAsyncDisposableGuard<T>, fromDisposable.GuardandAsyncDisposable.Guard, dispose a resource unlessRelease()hands its ownership on. (#65)DisposableCancellationandAsyncDisposableCancellation, fromDisposable.CancellationandAsyncDisposable.Cancellation, cancel aCancellationTokenSourcewhen disposed, and dispose one they created. (#65)IDisposalStatus.IsDisposed, which every disposable that keeps state implements, andDisposableFlag, fromDisposable.Flag(), which only records its disposal. (#65, ADR-1005)AsyncDisposable.Createoverloads that pass one to eight arguments to aFunc<…, ValueTask>,AsyncDisposable.Context, which disposes on aSynchronizationContextand waits for it, and parameterlessAggregate()andSerial()factories. (#65, ADR-1005)ValueDisposable<TState>andAsyncValueDisposable<TState>, fromDisposable.CreateValueandAsyncDisposable.CreateValue, run a delegate on dispose without allocating. (#65, ADR-1006)- Lock scopes:
SemaphoreSlim.Lock()andLockAsync(), andReaderWriterLockSlim.ReadLock(),UpgradeableReadLock()andWriteLock(), return aValueDisposable<T>that releases the lock. (#65, ADR-1006) AsyncDisposableAggregate.SetDisposableAsyncandAsyncDisposableCollection.AddAsync, which dispose the resource when the holder is already disposed. (#65, ADR-1004)
Changed
- Package validation compares each package with the published 6.0.0 package.
- Each release is tagged and published as its pull request merges:
.github/workflows/tag-release.ymlsigns the tag with gitsign, publishes the GitHub release from the version's changelog section and startspublish.yml, which still waits for a maintainer to approve thenugetenvironment.SECURITY.mdsays how to verify a release tag. (ADR-0016) - Breaking: The
DisposableandAsyncDisposablefactories return the concrete sealed types, such asDisposableAction,DisposableAggregateandDisposableCollection, so recompile against 7.0.0; avarthat later takes anotherIDisposableneeds the typeIDisposable. (#65, ADR-1005) - Breaking: A disposed aggregate's
Disposableproperty returnsnullinstead of throwingObjectDisposedException, andDisposableAggregate's setter disposes the resource it is given;AsyncDisposableAggregate's setter still throws, so callSetDisposableAsync. (#65, ADR-1004) - Breaking:
DisposableCollection.Addon a disposed collection disposes the item instead of keeping it, andAsyncDisposableCollection.AddthrowsObjectDisposedException; callAddAsyncto dispose the item instead. (#65, ADR-1004) DisposableCollectionandAsyncDisposableCollectionare safe to use from several threads: every member takes one lock, and enumeration walks a snapshot. (#65)- The library awaits with
ConfigureAwait(false), so its continuations never resume on the caller'sSynchronizationContext, and CA2007 enforces it. (#65)
Deprecated
v6.0.0
Added
- Public API tracking: each release's public surface is recorded in
PublicAPI.Shipped.txt, and the changes since the last release inPublicAPI.Unshipped.txt, so the build fails on a public API change neither file records. - Each pack is validated against NCode.Disposables 5.3.0, the last version on nuget.org, through
PackageValidationBaselineVersion, so a change that would break 5.3.0's public API fails the pack. (#37, ADR-0147) - The changelog has a section for every release from 1.0.0 to 5.3.0, from their release notes. (#27)
src/NCode.Disposables/README.mdis the package readme nuget.org shows: installation, the main samples, and absolute links to the full guide, the API overview, the changelog and the security policy.- Every C# sample in the READMEs is a compiled test in
tests/NCode.Disposables.Tests/ReadmeSamplesTests.csthat MarkdownSnippets copies into the READMEs, and./build/gate.ps1, which CI and the Landing section'sgaterun, fails when a README differs from its test, then runs./build/dod.ps1. (ADR-1000) - The
AsAsyncSharedReference()extension puts anIAsyncDisposablebehind a reference count and returns its firstAsyncSharedReferenceLease<T>, also for a type that implementsIDisposabletoo, such as aStream. (#55, ADR-1002)
Changed
AssemblyVersionis6.0.0.0for every 6.x release and moves only with the major version, set byassemblyVersioninversion.json, so a later 6.x assembly replaces an earlier one without a binding redirect.SharedReferenceOwnerthrows throughObjectDisposedException.ThrowIf; the exception type and object name are unchanged.- Updated the project from project-template v0.41.0 to v0.61.2: stricter analyzers, shared build settings, a Definition of Done script and CI updates.
- Updated the project from project-template v0.61.2 to v0.112.2: package versions now come from
version.jsonthrough Nerdbank.GitVersioning, the CI workflow checks out the full history and builds a release with-p:PublicRelease=true, the Commit attribution check andcommit-msghook are gone, and the project gains a code of conduct, governance, roadmap, architecture and assurance documents, a coverage and reproducible-build toolkit, and the Scorecard workflow. (#28) - The solution file is
NCode.Disposables.slnx, the XML solution format current .NET SDKs create, in place ofNCode.Disposables.sln, and the ReSharper and Rider settings layer moves with it toNCode.Disposables.slnx.DotSettings.dotnet buildanddotnet testat the repository root work as before. - The package carries its description and tags again:
Directory.Build.propsimportssrc/NCode.Disposables/project.props, and the project files no longer repeat settings the project template makes or referenceMicrosoft.SourceLink.GitHub, which the .NET SDK includes. (#36) - Every C# file starts with the two-line SPDX header,
// Copyright © NCode Groupand// SPDX-License-Identifier: Apache-2.0, in place of theCopyright Preambleregion, Rider's file header matches it, and no file starts with a UTF-8 byte order mark. (#39, #36, ADR-0148) - NCode Review v1.5.0 reviews each pull request and approves a clean one; once the NCode Review Approver's key is stored, that approval meets a required approval. Pull requests the workflow commands open start as drafts (
draft: yes). (#38, ADR-0036) ./build/dod.ps1checks the C# formatting with CSharpier, the code and project files are formatted with it, and a C# file without the SPDX header fails the build: the project turned on the template'scsharp_formatanswer. (#39, ADR-0148)- Packages reach nuget.org through
.github/workflows/publish.yml, the project template's publishing workflow, from a published GitHub release: it tests and packs the tagged commit and pushes the packages through nuget.org trusted publishing once a maintainer approves the protectednugetenvironment, so no long-lived NuGet API key is stored. Each release also gets its packages, a signed build provenance file and an SBOM, attached byrelease-provenance.yml, andraise-baseline.ymlopens the change that raises the package validation baseline. (#44, ADR-0135) README.mdis a guide to every type, in the layout of the other NCode Group projects: a tested sample for each disposable, the shared references, the async adapter and the extensions, their errors and edge cases, an API overview, thread safety, and NuGet, CI, target framework, license and OpenSSF Scorecard badges. Its hand-kept release notes are gone; CHANGELOG.md covers every release.- The package description reads "Building blocks for IDisposable and IAsyncDisposable in .NET", followed by what the library does, without the Markdown backticks nuget.org showed as text.
- Updated the project from project-template v0.112.2 to v0.113.1: Claude Code's project settings no longer ask before a command that mentions
.envorsecrets/, the release workflows and the template's scripts accept a version only in ASCII digits after a lowercasev, and the template's Best Practices record is ADR-0037, renumbered from ADR-0153. docs/architecture.mddescribes the components, the factories, the disposables, the shared references and the extensions, as a diagram and a table. (#56)
Removed
- Breaking:
AsyncDisposableExtensions.AsSharedReference()is deleted: callAsAsyncSharedReference()for anAsyncSharedReferenceLease<T>that disposes withDisposeAsync.AsSharedReference()isDisposableExtensions.AsSharedReference()alone, so on a type that implements bothIDisposableandIAsyncDisposable, such as aMemoryStream, it compiles and returns aSharedReferenceLease<T>that disposes withDispose. No release marks it obsolete first: 5.3.0, the last release, ships it without[Obsolete], so code built against 5.3.0 gets noNCDISP001warning before the deletion. (#59, #55, ADR-1002) - Breaking: The
net8.0target framework: the package targetsnet10.0alone, since .NET 8 left Microsoft support on 2026-11-10. Apps on .NET 8 or 9 stay on 5.3.0. (ADR-1003) .github/workflows/main.yml: its build and test jobs repeatedci.yml'sbuild-and-teston every push and pull request, andpublish.ymlreplaces its publish job. (#43, #44)
Fixed
DisposeAll(ignoreExceptions: true)ignores the failures of the items disposed after an item that implements onlyIAsyncDisposable; theInvalidOperationExceptionfor that item is still thrown. (#53)Disposable.Collection(...).Dispose()andDisposeAll()dispose an item that implements bothIDisposableandIAsyncDisposable, such as aStreamor aDbConnection, throughIDisposable.Disposeinstead of throwingInvalidOperationException, whichDisposeAll()throws only for an item that implementsIAsyncDisposablealone. Its message readsThe collection contains an item that implements IAsyncDisposable but not IDisposable; dispose it with DisposeAllAsync.(#54, ADR-1001)- The XML docs of
DisposableCollectionandAsyncDisposableCollectionsay thatAdd,Remove,Clearand enumeration take no lock, andDisposable.Collection's docs say that several failures are thrown together as anAggregateException.
v5.3.0
v5.2.1
Minor resharper cleanup
Allow creating of async shared references without requiring async callsite
v5.1.0 Allow creating of async shared references without requiring async cal…