core: keep setting defaults for properties missing from the file
agent-review agent review: fail

With init-only properties, the source-generated reader set a property
missing from settings.json to its default value, not its initializer,
so the file failed validation and every setting fell back to defaults.
Any release that adds a setting would have reset all user settings.
Settings use settable properties now, and the snapshot's version field
too; the other persisted types were checked and keep their defaults.

Refs #1
This commit is contained in:
Florian Schmidt
2026-10-14 21:23:04 +02:00
parent 15c7e684bb
commit 9f33dd8896
5 changed files with 127 additions and 17 deletions
@@ -7,6 +7,16 @@ namespace FinalToken.StreamDeck.Tests;
public sealed class PluginTests
{
[Theory]
[InlineData("{}", "Claude", "SessionPercent", "")]
[InlineData("{\"provider\":\"Codex\"}", "Codex", "SessionPercent", "")]
[InlineData("{\"metric\":\"TokensToday\",\"future\":1}", "Claude", "TokensToday", "")]
public void PartialStatSettingsKeepConstructorDefaults(string json, string provider, string metric, string window)
{
var settings = JsonSerializer.Deserialize(json, PluginJsonContext.Default.StatSettings)!;
Assert.Equal(new StatSettings(provider, metric, window), settings);
Assert.True(settings.IsValid);
}
private static readonly DateTimeOffset Now = new(2026, 10, 14, 12, 0, 0, TimeSpan.Zero);
private static Snapshot Snapshot(PaceState state = PaceState.Ahead) => new()
{