Skip to content

Releases

v5.1.0

Choose a tag to compare

@github-actions github-actions released this 06 Dec 05:40
163a887

Added

  • CollectionDiff.Compute returns the items one collection adds to and removes from another as a CollectionDiff<T>, whose Added and Removed count duplicates and ignore order, under the default or a given IEqualityComparer<T>. WatchDiffsAsync, an extension member on ICollectionDataSource<T>, yields the current items as added and then the items each change added and removed, for await foreach, and skips a change that adds and removes nothing, such as a reorder (#100, ADR-1033).
  • Providers and polling sources record metrics and traces on the meter and activity source NCode.LiveCollections, whose names LiveCollectionsTelemetry.MeterName and LiveCollectionsTelemetry.ActivitySourceName hold. The histogram ncode.livecollections.provider.rebuild.duration measures each build of a provider's collection in seconds, with error.type when the build throws, and ncode.livecollections.polling.refresh.duration measures each refresh of a polling source, with its ncode.livecollections.polling.refresh.trigger (timer or on_demand), its ncode.livecollections.polling.refresh.outcome (changed, unchanged or failed) and error.type when it fails; the spans ncode.livecollections.provider.rebuild and ncode.livecollections.polling.refresh mirror them. They record to the IMeterFactory that DefaultCollectionProviderFactory(IMeterFactory) and DefaultCollectionDataSourceFactory(TimeProvider, IMeterFactory) take, which the container picks when the host registers one, or to the one that the MeterFactory property of CollectionProviderOptions or PeriodicPollingCollectionDataSourceOptions names, and record nothing without one; docs/metrics.md lists each, and the collect metrics and traces guide shows how to turn them on (#103, ADR-1035).

Changed

  • Package validation compares each package with the published 5.0.0 package.
  • The samples in the readmes and on the documentation site subscribe with OnChange, which keeps following a source that signals from several threads at once, instead of ChangeToken.OnChange, which can stop following it (#177, ADR-1039).
  • The documentation site builds with NCodeGroup/docs v0.19.0, which installs its packages with pnpm, and node build/site.mjs tells someone without a toolchain clone to run pnpm install --frozen-lockfile in it (#174).
  • Updated from project-template v0.175.0 to v0.181.0: agent workflow commands, prompts, skills and agents, the template's scripts and decision records. A maintainer's word in a session authorizes protected paths in a filter run (ADR-0094), and a web frontend uses TypeScript, React and MUI and a documentation site Astro Starlight (ADR-0095).
  • ./build/dod.ps1 checks the Markdown links in a Markdown stage, as CI's Markdown checks job does, when Node.js is on PATH, so ./build/gate.ps1 runs no Markdown link stage of its own and no longer fails without Node.js, and AGENTS.md says to put Node.js on PATH first, with nvs use 26 where nvs manages it (#160).
  • The NuGet descriptions and readmes of both packages name what each offers. NCode.LiveCollections names every data source, static, observable, mutable, change-token, composite and periodic polling, the Transform, SelectItems, WhereItems, ConcatSources and Debounce sources derived from another, the consumer helpers, the collection diffs, and metrics and traces. NCode.LiveCollections.Abstractions names the data source contracts, the factory contracts and the options, the MeterFactory options for metrics and traces included (#166).
  • AGENTS.md records that epic #94's breaking stories shipped together as 5.0.0, and that a story that only adds carries a Release: line with the next minor version once the major before it has shipped, and none while a new major waits for its last breaking story (#164).

v5.0.0

Choose a tag to compare

@github-actions github-actions released this 06 Dec 02:58
f387556

Added

  • Decision records ADR-1028 to ADR-1037 settle the design of the mutable and change-token data sources, the derived sources and Debounce, the consumer helpers and item-level diffs, on-demand polling refresh, change detection and backoff, metrics and traces, and the DI helper that registers providers (#95).
  • MutableCollectionDataSource<T>, which ICollectionDataSourceFactory.CreateMutable creates as an IMutableCollectionDataSource<T>, holds an immutable snapshot of a list your code pushes into from any thread: Replace, Update, Add, AddRange, Remove and Clear each swap it under the source's lock and signal once, so a batch of edits is one provider rebuild. A call that changes nothing, such as Remove of an absent item, signals nothing, and the source never disposes its items (#96, ADR-1028).
  • ChangeTokenCollectionDataSource<T>, which ICollectionDataSourceFactory.CreateChangeToken creates, loads its items from a function on the first read and reloads them each time its producer's IChangeToken signals, such as IConfiguration.GetReloadToken() or IFileProvider.Watch(...). A failed reload keeps the last items and goes to the optional handleException; without one, or when it throws, the source stops reloading (#96, ADR-1029).
  • Transform, SelectItems, WhereItems and ConcatSources, extension members on ICollectionDataSource<T> in CollectionDataSourceTransformExtensions, derive a live data source from any data source or provider: they reshape the whole collection, map or filter its items, or concatenate several sources. Each returns an IDisposableCollectionDataSource<T> that rebuilds an immutable snapshot once per signal of its source and owns its source unless owns is false, so disposing the last link of a chain disposes the whole chain (#97, ADR-1030).
  • Debounce, an extension member on ICollectionDataSource<T> in CollectionDataSourceDebounceExtensions, wraps any data source or provider in one that signals once after its source has been quiet for quietPeriod, timed on the TimeProvider it is given, so a burst of edits is one provider rebuild. When the quiet period ends it reads its source once and hands out that snapshot until the next burst settles, a read that throws keeps the last snapshot and signals nothing, a quiet period outside 1 to 4,294,967,294 milliseconds throws ArgumentOutOfRangeException, and it owns its source unless owns is false (#98, ADR-1031).
  • IRefreshableCollectionDataSource<T>, in NCode.LiveCollections.Abstractions, is a disposable data source whose RefreshAsync refreshes it at once, such as right after a write. PeriodicPollingCollectionDataSource<TItem, TState> implements it: a call waits for a refresh that is running, then runs one of its own, and never overlaps the timer's; a Changed result signals before the call returns; an exception from the refresh goes to the caller, never to the exception handler, and polling goes on; the caller's token cancels the wait and the refresh, and after disposal the call throws ObjectDisposedException (#101, ADR-1034).
  • RefreshCollectionResults.ChangedIfDifferent, in NCode.LiveCollections.PeriodicPolling, returns Unchanged when a poll's items equal the current ones in the same order, under the default or a given IEqualityComparer<TItem>, and Changed otherwise, so a refresh that returns the same items rebuilds nothing downstream (#101, ADR-1034).
  • AddCollectionProvider<TItem, TCollection> and AddKeyedCollectionProvider<TItem, TCollection>, extension members on IServiceCollection, register a collection provider in one call as a singleton that the given factory builds, optionally under a service key that the factory also gets, and add the library's services that are missing, as AddLiveCollections() does. Every call adds a registration and the last one wins a single resolution, the provider is registered as no other service type, and the container disposes it with Dispose() or DisposeAsync(), as the container itself is disposed (#104, ADR-1037).
  • WaitForChangeAsync, OnChange and WatchAsync let a consumer react to changes without ChangeToken.OnChange plumbing. WaitForChangeAsync completes on the next change of any data source, provider or ISupportChangeToken, and also when the source is disposed while it waits. OnChange calls a callback with the new collection on each change until its subscription is disposed, and keeps following a source that signals from several threads at once. WatchAsync yields the current collection and then the latest one after each change, for await foreach, without queueing intermediate collections. On a provider, OnChange and WatchAsync hand over the provider's own collection type (#99, ADR-1032, ADR-1040).
  • PeriodicPollingCollectionDataSourceOptions, in NCode.LiveCollections.Abstractions, holds a polling source's optional settings. Its MaxBackoffDelay makes a source whose exception handler returns back off after a failed timer refresh: the n-th failure in a row waits a random time from half to all of the smaller of MaxBackoffDelay and the refresh interval doubled n times, so the first wait is one to two intervals, and after the next refresh that succeeds the timer ticks again one interval later. It is null by default, which keeps the fixed period, and must be at least twice the refresh interval and at most 4,294,967,294 ms. RefreshAsync runs at once during a wait and neither counts as a failure nor resets it (#102, ADR-1036).

Changed

  • ./build/gate.ps1 runs the Markdown check that CI's Markdown checks job runs, node .template/check-markdown.mjs, through build/Assert-MarkdownLinks.ps1, which fails when Node.js isn't on PATH, and the dev container installs Node.js (#158).
  • AGENTS.md records that a breaking change ships in a new major version, with several breaking stories shipping together as one, and that a public method or constructor with overloads takes no optional parameter (#158).
  • Breaking: ICollectionDataSourceFactory gains CreateMutable, with and without items, and CreateChangeToken, so a class that implements it must add them; DefaultCollectionDataSourceFactory does (#96, ADR-1028, ADR-1029).
  • Package validation compares each package with the published 4.0.0 package.
  • Breaking: ICollectionDataSourceFactory.CreatePeriodicPolling returns IRefreshableCollectionDataSource<TItem>, so a class that implements the factory changes the method's return type, as DefaultCollectionDataSourceFactory does, and code built against an earlier version is recompiled (#101, ADR-1034).
  • Breaking: Disposing a provider or a built-in data source signals the change token it handed out once, after it has released everything else, so a consumer waiting on the token learns that the source is gone instead of waiting for its own cancellation token. A change callback that runs on that signal and reads Collection or calls GetChangeToken() gets ObjectDisposedException, which the source drops, and a subscription made with ChangeToken.OnChange ends without calling its consumer; a callback that must tell the disposal apart from a change catches that exception. StaticCollectionDataSource<T>'s token never signals, disposal included. ISupportChangeToken's docs and the custom data source samples show a source of your own cancelling its token before it disposes it ...
Read more

v4.0.0

Choose a tag to compare

@github-actions github-actions released this 05 Dec 17:13
a0d15a2

Added

  • CollectionProviderOptions and CompositeCollectionDataSourceOptions<T> hold the optional settings of a provider and a composite: AdditionalChangeTokenProducers, which make it rebuild on a signal besides its data sources', such as a configuration reload, and the composite's CombineFunc. ICollectionProviderFactory.Create, ICollectionDataSourceFactory.CreateComposite and the CollectionProvider<TItem, TCollection> constructors each have an overload that takes them last, after owns, so these options no longer need a class derived from BaseCollectionProvider or a composite built with new. A later setting is a new property of an options type (#117, ADR-1024).

Changed

  • Breaking: ICollectionProvider<TItem, TCollection> is an IDisposableCollectionDataSource<TItem>, so every provider, whatever its collection type, ImmutableArray<T> and other struct collections included, passes straight to another provider or a composite as a data source. A class that implements ICollectionProvider<TItem, TCollection> itself must add ICollectionDataSource<TItem>.Collection, returning the same items as its Collection; BaseCollectionProvider already does. An owning outer provider disposes an inner provider like any other source it owns: pass owns: false, or give the outer provider CreateComposite([inner], owns: false), to keep the inner provider's lifetime your own (#116, ADR-1023).
  • Breaking: ICollectionProviderFactory and ICollectionDataSourceFactory gain the overloads of Create and CreateComposite without owns and with options, so a class that implements either interface must add them. The methods and constructors that had an optional owns parameter take it as a plain parameter, beside an overload without it that passes the same default, so a caller's code compiles and runs as before (#117, ADR-1024).
  • Breaking: every built-in source hands out a snapshot that never changes after it is returned and is safe to read from any thread, as ICollectionDataSource<T>.Collection promises. ObservableCollectionDataSource<T>.Collection returns an immutable copy of the items, taken on each change before the change token signals, instead of the ObservableCollection<T>, which its caller keeps to edit it or read it live. CompositeCollectionDataSource<T> enumerates what CombineFunc returns once per build into an immutable copy, instead of handing out a query that reads its sources again on each enumeration, and a provider over several sources hands its collection factory an immutable concatenation of their items, so a factory that returns its items as given, items => items, hands out a snapshot too (#118, ADR-1025).
  • Breaking: CollectionProvider<TItem, TCollection>, DefaultCollectionDataSourceFactory and DefaultCollectionProviderFactory are sealed. A class derived from CollectionProvider derives from BaseCollectionProvider<TItem, TCollection> instead and overrides CreateCollection, and one derived from a default factory implements ICollectionDataSourceFactory or ICollectionProviderFactory (#120, ADR-1026).
  • Breaking: NullChangeToken.Singleton is typed IChangeToken, and NullChangeToken has no public constructor, so Singleton is its one instance: replace new NullChangeToken() with NullChangeToken.Singleton (#120, ADR-1026).
  • Updated from project-template v0.173.0 to v0.175.0: agent workflow commands, prompts, skills and agents, the template's scripts and decision records. Every command and prompt, except execute-step, and the planner, reviewer and orchestrator agents file what a run taught as issues: problems with the template's shipped text go to the repository the new template-feedback line of AGENTS.md's Landing section names, and lessons about this project go where follow-ups sends them (ADR-0092); a plan's follow-up whose files are in another repository is filed there (ADR-0093); and the update names a package's Description or PackageTags only when the build lost it (ADR-0158).
  • Breaking: owns has one meaning and one default: whether a provider or a composite disposes the data sources it is given, and every overload or constructor without it passes true. A provider over several sources, CreateComposite and new CompositeCollectionDataSource<T>(...), whose Owns defaults to true, dispose their sources by default, as a provider over one source does; pass owns: false for sources the DI container or the caller still uses. BaseCollectionProvider's constructors take owns through overloads instead of an optional parameter, so a derived class that calls base(dataSources) owns them. The change departs from the template's ADR-0136 deprecate-then-remove rule and ships in 4.0.0 with the other breaking changes of epic #105 (#121, ADR-1027).
  • Breaking: A static or observable source disposes its items only when disposeItems is true. disposeItems replaces the owns parameter of their constructors, CreateStatic and CreateObservable, and defaults to false, so wrapping a caller's ObservableCollection<T> never disposes the caller's items; pass disposeItems: true where the source owns them (#121, ADR-1027).

Removed

  • Breaking: AsDataSource() and its CollectionProviderExtensions class are removed: pass the provider itself where a data source is wanted. The change departs from the template's ADR-0136 deprecate-then-remove rule, as ADR-1002 and ADR-1022 did, and ships in 4.0.0 with the other breaking changes of epic #105 (#116, ADR-1023).
  • Breaking: INullChangeToken and its registration by AddLiveCollections() are removed: use IChangeToken, and NullChangeToken.Singleton where a token that never signals is wanted, instead of resolving one from the container. The change departs from the template's ADR-0136 deprecate-then-remove rule and ships in 4.0.0 with the other breaking changes of epic #105 (#120, ADR-1026).

v3.0.1

Choose a tag to compare

@github-actions github-actions released this 05 Dec 08:06
0271a39

Fixed

  • Disposing a provider or a data source from a UI or other context-bound thread no longer resumes its continuations on that thread: every await in the libraries uses ConfigureAwait(false), and the build enforces it with CA2007 (#119).

v3.0.0

Choose a tag to compare

@github-actions github-actions released this 05 Dec 07:36
ce0805f

Changed

  • Breaking: Providers and the built-in data sources are both IDisposable and IAsyncDisposable, so a provider in a DI container that is disposed synchronously, such as with using var serviceProvider = services.BuildServiceProvider();, no longer throws. ICollectionProvider<TItem, TCollection> gains IDisposable, so a class that implements it must add Dispose(); BaseCollectionProvider gains Dispose() and a virtual DisposeCore(), so a subclass that overrides DisposeAsyncCore() must also override DisposeCore(), or its own resources are released by DisposeAsync() only. IAsyncDisposableCollectionDataSource<T> is removed, and IDisposableCollectionDataSource<T> is both IDisposable and IAsyncDisposable: CreateStatic, CreateComposite and CreatePeriodicPolling return it, as CreateObservable does, so register a created source with services.AddSingleton<ICollectionDataSource<T>>(dataSource). Dispose() never waits: the polling source cancels its loop and returns, and an owned source that is only IAsyncDisposable is disposed by DisposeAsync() alone, since Dispose() disposes everything else and then throws InvalidOperationException for it. DisposeAsync() disposes what it did before (#115, ADR-1022). The change departs from the template's ADR-0136 deprecate-then-remove rule, as ADR-1002 did, so the release is 3.0.0.

v2.0.10

Choose a tag to compare

@github-actions github-actions released this 05 Dec 06:54
a542088

Changed

  • A provider over several data sources subscribes to each of them directly instead of through an internal composite, so a signal swaps the provider's change token once, and the providers, the composite, the observable source and the polling source share one internal implementation of the change-signalling pattern (#114, ADR-1021).

v2.0.9

Choose a tag to compare

@github-actions github-actions released this 05 Dec 06:11
f0c75c9

Fixed

  • The Collection property of a CompositeCollectionDataSource<T> no longer returns null when the composite is disposed on another thread during the read, and a provider or composite whose CreateCollection or CombineFunc disposes it during the first build no longer caches the built collection: Collection throws ObjectDisposedException, as documented (#113, ADR-1020).

v2.0.8

Choose a tag to compare

@github-actions github-actions released this 05 Dec 05:41
69f2fea

Fixed

  • An exception thrown by a consumer's change callback, such as a provider's CreateCollection, a composite's CombineFunc or a callback registered on a change token, no longer reaches the code that edited an ObservableCollection<T> or the source that signalled a composite or a provider: the source drops it and every other consumer still receives the change (#112, ADR-1019).

v2.0.7

Choose a tag to compare

@github-actions github-actions released this 05 Dec 05:12
18dd913

Fixed

  • Breaking: An owning static or observable data source disposes each item that implements IDisposable at run time, whatever the item type T is declared as: items typed as object, as an interface without IDisposable or as a struct are disposed, and items that don't implement it are skipped. StaticCollectionDataSource<T> is marked disposed whether or not it owns its items, and its Collection throws ObjectDisposedException afterwards, as the other sources' do (#111, ADR-1018).

v2.0.6

Choose a tag to compare

@github-actions github-actions released this 05 Dec 04:41
0070f17

Fixed

  • Disposing a polling source no longer passes a cancellation to the exception handler when the refresh cancels through a token linked to the one it receives: any OperationCanceledException the refresh throws while polling is being stopped ends polling quietly, while one thrown at any other time, such as an HttpClient timeout, still reaches the handler (#110).