Skip to content

Commit 6855da8

Browse files
firejeff01claude
andcommitted
fix: GitHubUpdateChecker JSON property naming mismatch
GitHub REST API uses snake_case (tag_name, html_url, browser_download_url) but the deserializer used JsonNamingPolicy.CamelCase which expected tagName/htmlUrl. All properties deserialized to null, release.TagName was empty, and CheckAsync always returned IsUpdateAvailable=false — the update banner has never actually fired since F-008 added the checker. Replace the policy with explicit JsonPropertyName attributes on each property in GitHubRelease and GitHubAsset records. Verified against the live API: latest release tag is now parsed and IsUpdateAvailable is true when the installed version is older. Note: users still running pre-fix builds will not see the banner; one manual MSI install of the next release is required to roll the fix out. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 010ecae commit 6855da8

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/Tender.Desktop/Services/GitHubUpdateChecker.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Net.Http;
22
using System.Reflection;
33
using System.Text.Json;
4+
using System.Text.Json.Serialization;
45

56
namespace Tender.Desktop.Services;
67

@@ -10,10 +11,10 @@ public sealed class GitHubUpdateChecker : IUpdateChecker
1011
private const string Owner = "firejeff01";
1112
private const string Repo = "tender";
1213

13-
private static readonly JsonSerializerOptions JsonOptions = new()
14-
{
15-
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
16-
};
14+
// GitHub REST API 用 snake_case(tag_name、html_url、browser_download_url)。
15+
// 早期 .CamelCase 是 bug:對應出來的 JSON key 是 tagName/htmlUrl,全部反序列化成 null,
16+
// 導致 update checker 一直回傳「無更新」。改用顯式 JsonPropertyName 屬性對映。
17+
private static readonly JsonSerializerOptions JsonOptions = new();
1718

1819
public async Task<UpdateInfo> CheckAsync(CancellationToken ct = default)
1920
{
@@ -87,16 +88,28 @@ private static Version GetCurrentVersion()
8788

8889
private sealed record GitHubRelease
8990
{
91+
[JsonPropertyName("tag_name")]
9092
public string? TagName { get; init; }
93+
94+
[JsonPropertyName("name")]
9195
public string? Name { get; init; }
96+
97+
[JsonPropertyName("body")]
9298
public string? Body { get; init; }
99+
100+
[JsonPropertyName("html_url")]
93101
public string? HtmlUrl { get; init; }
102+
103+
[JsonPropertyName("assets")]
94104
public List<GitHubAsset>? Assets { get; init; }
95105
}
96106

97107
private sealed record GitHubAsset
98108
{
109+
[JsonPropertyName("name")]
99110
public string? Name { get; init; }
111+
112+
[JsonPropertyName("browser_download_url")]
100113
public string? BrowserDownloadUrl { get; init; }
101114
}
102115
}

0 commit comments

Comments
 (0)