fix: correct ReleaseNotes deserialization for AutoUpdater (fixes #1039) (#1061)

* fix: correct ReleaseNotes deserialization for AutoUpdater (fixes #1039)

- TypeScript normalize() now maps string releaseNotes to { note } objects
  and also handles arrays of strings (both cases were broken in PR #1041)
- Added ReleaseNotesConverter (JsonConverter<ReleaseNoteInfo[]>) as defensive
  C# layer that handles all shapes: null, string, string[], object[]
- Added [JsonConverter] attribute on UpdateInfo.ReleaseNotes
- Added unit tests (no Electron required) covering all four input shapes

* chore: sync generated autoUpdater.js and .map with updated TypeScript source

* refactor: address Copilot PR review comments

- Fix namespace: ElectronNET.Converter -> ElectronNET.API.Converter
- Replace JsonDocument.ParseValue() with JsonSerializer.Deserialize<ReleaseNoteInfo>()
  for cleaner, allocation-free object array parsing
- Fix Write(): empty ReleaseNoteInfo[] now serializes as [] instead of null
- Use Array.Empty<ReleaseNoteInfo>() in UpdateInfo default initializer
- Add tests: Serialize_WithEmptyReleaseNotes and Serialize_WithNullReleaseNotes
This commit is contained in:
Gregor Biswanger
2026-05-09 18:17:59 +02:00
committed by GitHub
parent 30b7b1d251
commit d7e1a09880
6 changed files with 223 additions and 5 deletions

View File

@@ -1,4 +1,8 @@
namespace ElectronNET.API.Entities
using System;
using System.Text.Json.Serialization;
using ElectronNET.API.Converter;
namespace ElectronNET.API.Entities
{
/// <summary>
///
@@ -24,7 +28,8 @@
/// <summary>
/// Gets or sets the release notes.
/// </summary>
public ReleaseNoteInfo[] ReleaseNotes { get; set; } = new ReleaseNoteInfo[0];
[JsonConverter(typeof(ReleaseNotesConverter))]
public ReleaseNoteInfo[] ReleaseNotes { get; set; } = Array.Empty<ReleaseNoteInfo>();
/// <summary>
/// Gets or sets the release date.