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:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user