From b7f18c337da367446017d3318afe085b2a833b7d Mon Sep 17 00:00:00 2001 From: HenryBartosch Date: Thu, 4 Jun 2026 08:50:10 +0200 Subject: [PATCH 1/2] Refactor JsonEndpoint to return byte[] and update ProcessedItem properties initialization --- frameworks/effinitive/app/Models.cs | 6 ++++-- frameworks/effinitive/app/Tests/Json.cs | 10 +++++++--- frameworks/effinitive/app/effinitive-arena.csproj | 2 +- frameworks/effinitive/meta.json | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/frameworks/effinitive/app/Models.cs b/frameworks/effinitive/app/Models.cs index 1b7eeb599..b5fbb0ce0 100644 --- a/frameworks/effinitive/app/Models.cs +++ b/frameworks/effinitive/app/Models.cs @@ -34,8 +34,10 @@ public sealed class ProcessedItem public double Price { get; set; } public int Quantity { get; set; } public bool Active { get; set; } - public List Tags { get; set; } = []; - public RatingInfo Rating { get; set; } = new(); + // Suppress default-init: these are always set in the endpoint loop so + // the default [] / new() would be immediately discarded (wasted alloc). + public List Tags { get; set; } = null!; + public RatingInfo Rating { get; set; } = null!; public double Total { get; set; } } diff --git a/frameworks/effinitive/app/Tests/Json.cs b/frameworks/effinitive/app/Tests/Json.cs index 3fad33232..50e779ce7 100644 --- a/frameworks/effinitive/app/Tests/Json.cs +++ b/frameworks/effinitive/app/Tests/Json.cs @@ -4,7 +4,9 @@ namespace effinitive.Tests; -public class JsonEndpoint : NoRequestEndpointBase> +// Returns byte[] so SerializeResponse short-circuits into the pre-serialized path, +// bypassing reflection-based JsonSerializerOptions entirely. +public class JsonEndpoint : NoRequestEndpointBase { protected override string Method => "GET"; protected override string Route => "/json/{count}"; @@ -24,7 +26,7 @@ private static DatasetItem[] LoadItems() return [.. items]; } - public override ValueTask> HandleAsync(CancellationToken ct) + public override ValueTask HandleAsync(CancellationToken ct) { var query = HttpContext?.Query ?? QueryCollection.Empty; int count = int.TryParse(HttpContext?.RouteValues?["count"]?.ToString(), out var c) ? c : AllItems.Length; @@ -44,6 +46,8 @@ public override ValueTask> HandleAsync(CancellationTo }; } - return ValueTask.FromResult(new ResponseDto(processed, take)); + var dto = new ResponseDto(processed, take); + return ValueTask.FromResult( + JsonSerializer.SerializeToUtf8Bytes(dto, AppJsonContext.Default.ResponseDtoProcessedItem)); } } diff --git a/frameworks/effinitive/app/effinitive-arena.csproj b/frameworks/effinitive/app/effinitive-arena.csproj index 91d77a275..463cde0de 100644 --- a/frameworks/effinitive/app/effinitive-arena.csproj +++ b/frameworks/effinitive/app/effinitive-arena.csproj @@ -11,7 +11,7 @@ - + diff --git a/frameworks/effinitive/meta.json b/frameworks/effinitive/meta.json index 47581a7d5..3210763f0 100644 --- a/frameworks/effinitive/meta.json +++ b/frameworks/effinitive/meta.json @@ -11,6 +11,7 @@ "pipelined", "limited-conn", "json", + "json-comp", "upload", "api-4", "api-16", From 4172789ee2da671c40cafcb367fb720fede4938f Mon Sep 17 00:00:00 2001 From: HBartosch <162106117+HBartosch@users.noreply.github.com> Date: Wed, 10 Jun 2026 09:31:10 +0200 Subject: [PATCH 2/2] Update effinitive-arena.csproj --- frameworks/effinitive/app/effinitive-arena.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/effinitive/app/effinitive-arena.csproj b/frameworks/effinitive/app/effinitive-arena.csproj index 463cde0de..ff8f8cd12 100644 --- a/frameworks/effinitive/app/effinitive-arena.csproj +++ b/frameworks/effinitive/app/effinitive-arena.csproj @@ -11,7 +11,7 @@ - +