Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions frameworks/effinitive/app/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> 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<string> Tags { get; set; } = null!;
public RatingInfo Rating { get; set; } = null!;
public double Total { get; set; }
}

Expand Down
10 changes: 7 additions & 3 deletions frameworks/effinitive/app/Tests/Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace effinitive.Tests;

public class JsonEndpoint : NoRequestEndpointBase<ResponseDto<ProcessedItem>>
// Returns byte[] so SerializeResponse short-circuits into the pre-serialized path,
// bypassing reflection-based JsonSerializerOptions entirely.
public class JsonEndpoint : NoRequestEndpointBase<byte[]>
{
protected override string Method => "GET";
protected override string Route => "/json/{count}";
Expand All @@ -24,7 +26,7 @@ private static DatasetItem[] LoadItems()
return [.. items];
}

public override ValueTask<ResponseDto<ProcessedItem>> HandleAsync(CancellationToken ct)
public override ValueTask<byte[]> HandleAsync(CancellationToken ct)
{
var query = HttpContext?.Query ?? QueryCollection.Empty;
int count = int.TryParse(HttpContext?.RouteValues?["count"]?.ToString(), out var c) ? c : AllItems.Length;
Expand All @@ -44,6 +46,8 @@ public override ValueTask<ResponseDto<ProcessedItem>> HandleAsync(CancellationTo
};
}

return ValueTask.FromResult(new ResponseDto<ProcessedItem>(processed, take));
var dto = new ResponseDto<ProcessedItem>(processed, take);
return ValueTask.FromResult(
JsonSerializer.SerializeToUtf8Bytes(dto, AppJsonContext.Default.ResponseDtoProcessedItem));
}
}
2 changes: 1 addition & 1 deletion frameworks/effinitive/app/effinitive-arena.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EffinitiveFramework.Core" Version="2.0.0" />
<PackageReference Include="EffinitiveFramework.Core" Version="2.1.1" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.5" />
<PackageReference Include="Npgsql" Version="10.0.2" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions frameworks/effinitive/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"pipelined",
"limited-conn",
"json",
"json-comp",
"upload",
"api-4",
"api-16",
Expand Down
Loading