Repository navigation
Reject a preference debounce a timer cannot wait for when it is configured [patch] - #44
Merged
Merged
Conversation
…gured [patch] Preferences stored any debounce, and nothing used it until the first click on a persisted toggle, when Timer.Change threw ArgumentOutOfRangeException out of the tray's click handler, after the toggle's setter had already run. Preferences now throws ArgumentOutOfRangeException (param debounce) for a negative value, Timeout.InfiniteTimeSpan, or more than the ~49.7 days a timer can wait. Infinite is refused because it means "write only at exit", and an exit by SIGTERM does not flush (#21). Fixes #36 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011eecgtNA1yFm2UXzPrxvEg
|
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.



Fixes #36
What changed
TrayAppBuilder.Preferences(..., debounce:)stored any value it was given. Nothing used it until the first click on a persisted toggle. At that pointDebouncedPreferenceStore.SetcalledTimer.Change, which threwArgumentOutOfRangeExceptionout of the tray's click handler, after the toggle's setter had already run. The error only showed up in tray mode, so tests never caught it.Preferencesnow throwsArgumentOutOfRangeException(ParamName == "debounce") when the tool is configured, for:Timeout.InfiniteTimeSpan. Decision: refused, because it means "write only at exit", and an exit by SIGTERM doesn't flush (In tray mode, SIGTERM and Ctrl+C kill the process without running OnStop or flushing a pending preference save #21), so nothing would ever be saved;uint.MaxValue - 1ms (about 49.7 days), the most a timer can wait. This limit is exposed internally asTrayAppBuilder.MaxPreferenceDebounce.Zero and
null(half a second) are still accepted. The XML doc gains an<exception>entry, and the README API table states the range.Tests
Preferences_WithADebounceATimerCannotWaitFor_Throwscovers -1000 ms, -1 ms and 60 days.Preferences_WithAnInfiniteDebounce_Throws.Preferences_WithZeroOrNoDebounce_IsAcceptedchecks thatPreferenceDebounceis 0, and 500 ms when no value is given.Preferences_WithTheLongestDebounce_IsAcceptedAndATimerTakesItpasses the maximum through to a realDebouncedPreferenceStore.Set, which proves the limit is the timer's own.This PR is independent of #43 (#38). Both branch from
main.🤖 Generated with Claude Code
https://claude.ai/code/session_011eecgtNA1yFm2UXzPrxvEg
Generated by Claude Code