feat(utilities): SettingsSnapshot.Copy<T> — reflection settings snapshot (no dropped fields)#617
Open
RicherTunes wants to merge 1 commit into
Open
feat(utilities): SettingsSnapshot.Copy<T> — reflection settings snapshot (no dropped fields)#617RicherTunes wants to merge 1 commit into
RicherTunes wants to merge 1 commit into
Conversation
…hot (no dropped fields) Download clients snapshot their settings synchronously before the background download's first await, so the deferred work sees a stable view even if the host repoints live settings mid-download. Hand-written field-by-field copies proved fragile: across plugins a copy silently dropped a field (amazonmusicarr's EnableDrm, tidalarr's SaveSyncedLyrics/UseLRCLIB), so a feature the user enabled was ignored in the background download — and the host-shape settings classes are hard to unit-test, so the drop went unnoticed. SettingsSnapshot.Copy<T>(this) reflection-copies every public read-write instance property into a fresh instance — structurally cannot drop a field; a newly-added setting is captured automatically. Get-only / computed properties are skipped. Lets all five plugins replace their bespoke snapshot copies with one shared, tested helper (find-once -> fix-once-in-Common -> all adopt). TDD: 4 tests (copies-all / independent-of-source / ignores-get-only / null-throws). Declared in PublicAPI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
SettingsSnapshot.Copy<T>(this)— reflection-copies every read-write property of a settings object into a fresh instance for the download-client pre-await snapshot.Why
Hand-written field-by-field snapshot copies silently dropped fields across plugins, disabling features in background downloads (which read the snapshot, not the live settings):
EnableDrm→ native Widevine CDM never activated in real downloads.SaveSyncedLyrics+UseLRCLIB→ background ignored the user's lyric settings.The host-shape settings classes are hard to unit-test, so the drops went unnoticed. Copying by reflection makes the snapshot structurally unable to drop a field — a newly-added setting is captured automatically. Get-only/computed properties are skipped.
Adoption
Lets all five plugins replace their bespoke snapshot copies with one shared, tested helper (find-once → fix-once-in-Common → all adopt). Plugins re-pin to this Common SHA and call
SettingsSnapshot.Copy(this)in their download-client snapshotter once merged.Tests
4 unit tests: copies-all / independent-of-source / ignores-get-only / null-throws.
🤖 Generated with Claude Code