perf(runtime): O(1) attribute resolution, precomputed types, coalesced static writes, shared JSON options

This commit is contained in:
Joseph Doherty
2026-08-14 19:57:26 -04:00
parent ee193cd2bb
commit 125055d998
7 changed files with 350 additions and 83 deletions
@@ -27,6 +27,15 @@ public class ExternalSystemClient : IExternalSystemClient
private readonly ILogger<ExternalSystemClient> _logger;
private readonly ExternalSystemGatewayOptions _options;
/// <summary>
/// Shared options for the per-call AuthConfiguration JSON parse in
/// <see cref="TryParseJsonAuth"/> (perf remediation, arch-review WP1.5) — avoids
/// allocating a new <see cref="JsonSerializerOptions"/> (and its internal cached
/// metadata) on every outbound call. Settings preserved exactly.
/// </summary>
private static readonly JsonSerializerOptions AuthJsonOptions =
new() { PropertyNameCaseInsensitive = true };
/// <summary>
/// Initializes a new instance of the ExternalSystemClient.
/// </summary>
@@ -755,7 +764,7 @@ public class ExternalSystemClient : IExternalSystemClient
{
fields = JsonSerializer.Deserialize<Dictionary<string, string?>>(
config,
new JsonSerializerOptions { PropertyNameCaseInsensitive = true })
AuthJsonOptions)
?? new Dictionary<string, string?>(StringComparer.OrdinalIgnoreCase);
// Normalize to case-insensitive so "Header"/"header" both resolve.