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..ff8f8cd12 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 9b398267a..5f28e8c3a 100644 --- a/frameworks/effinitive/meta.json +++ b/frameworks/effinitive/meta.json @@ -12,6 +12,7 @@ "pipelined", "limited-conn", "json", + "json-comp", "upload", "api-4", "api-16",