Files
decePubClient/ClientJsonContext.cs
T
thepraandClaude Opus 5.5 dca046e27d
Build / Build (push) Successful in 32s
The client's JSON comes from generated metadata only
PrivaPub's own types are read through the shared ClientModels context, and a type without generated metadata no longer
falls back to reflection silently: it fails at once in development and on the pasture, and is reported on the console
elsewhere. Startup outside production checks that every PrivaPub and Mastodon type the client knows has its metadata.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
2026-11-10 07:28:09 +01:00

32 lines
1.4 KiB
C#

using System.Text.Json.Serialization;
using decePubClient.Models;
namespace decePubClient;
/// <summary>
/// Source-generated JSON metadata for the client's own types, used first by SUtility.DefaultSerializer (HTTP) and by
/// Blazored.LocalStorage (Program.cs); PrivaPub.ClientModels' types come from ClientModelsJsonContext. A type missing
/// from both fails in Development and the pasture, and is reported on the console elsewhere. Names stay camelCase:
/// wwwroot/js/theme.js reads PublicCacheData.pageSettings straight from localStorage.
/// </summary>
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
IgnoreReadOnlyProperties = true)]
[JsonSerializable(typeof(PublicCacheData))]
[JsonSerializable(typeof(PageSettings))]
[JsonSerializable(typeof(AuthData))]
[JsonSerializable(typeof(FeedFilter))]
[JsonSerializable(typeof(PublicActionNotices))]
[JsonSerializable(typeof(ServerInfo))]
[JsonSerializable(typeof(List<ServerInfo>))]
[JsonSerializable(typeof(CustomEmojiCache))]
[JsonSerializable(typeof(PushDevice))]
[JsonSerializable(typeof(UploadMedia))]
[JsonSerializable(typeof(ValidationErrors))]
// recover/valid takes the code as a JSON string ([FromBody] string) and answers a JSON bool
[JsonSerializable(typeof(string))]
[JsonSerializable(typeof(bool))]
public partial class ClientJsonContext : JsonSerializerContext
{
}