Skip to content

Commit ccae4f1

Browse files
authored
Merge branch 'TechEmpower:master' into master
2 parents 21e02d5 + 21c41f9 commit ccae4f1

File tree

297 files changed

+10081
-5463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

297 files changed

+10081
-5463
lines changed

frameworks/CSharp/fastendpoints/Benchmarks/Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<NoWarn>CA2016;IDE1006</NoWarn>
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
namespace Benchmarks.Endpoints;
22

3-
public sealed class JsonEndpoint : Endpoint<EmptyRequest, object>
3+
sealed class JsonEndpoint : Ep.NoReq.Res<object>
44
{
55
public override void Configure()
66
{
77
Get("/json");
88
AllowAnonymous();
99
}
1010

11-
public override Task HandleAsync(EmptyRequest _, CancellationToken __)
11+
public override Task HandleAsync(CancellationToken ct)
1212
{
1313
HttpContext.Response.ContentLength = 27;
14+
1415
return SendAsync(new { message = "Hello, World!" });
1516
}
1617
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
namespace Benchmarks.Endpoints;
22

3-
public sealed class PlainTextEndpoint : Endpoint<EmptyRequest, EmptyResponse>
3+
sealed class PlainTextEndpoint : Ep.NoReq.Res<byte[]>
44
{
5-
private static readonly byte[] payload = System.Text.Encoding.UTF8.GetBytes("Hello, World!");
5+
static readonly byte[] _payload = "Hello, World!"u8.ToArray();
66

77
public override void Configure()
88
{
99
Get("/plaintext");
1010
AllowAnonymous();
1111
}
1212

13-
public override Task HandleAsync(EmptyRequest _, CancellationToken __)
13+
public override Task HandleAsync(CancellationToken ct)
1414
{
1515
HttpContext.Response.StatusCode = StatusCodes.Status200OK;
1616
HttpContext.Response.ContentType = "text/plain";
17-
HttpContext.Response.ContentLength = payload.Length;
18-
return HttpContext.Response.Body.WriteAsync(payload, 0, payload.Length);
17+
HttpContext.Response.ContentLength = _payload.Length;
18+
19+
return HttpContext.Response.Body.WriteAsync(_payload, 0, _payload.Length);
1920
}
2021
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
global using FastEndpoints;
22

3-
var builder = WebApplication.CreateBuilder();
4-
builder.Logging.ClearProviders();
5-
builder.Services.AddFastEndpoints();
3+
var bld = WebApplication.CreateBuilder();
4+
bld.Logging.ClearProviders();
5+
bld.Services.AddFastEndpoints();
66

7-
var app = builder.Build();
7+
var app = bld.Build();
88
app.UseFastEndpoints();
9-
app.Run("http://0.0.0.0:8080");
9+
app.Run("http://0.0.0.0:8080");

frameworks/CSharp/fastendpoints/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ This includes tests for plaintext and json serialization.
55

66
**Language**
77

8-
* C# 12.0
8+
* C# 13.0
99

1010
**Platforms**
1111

12-
* .NET 8 (Windows and Linux)
12+
* .NET 9 (Windows and Linux)
1313

1414
**Web Servers**
1515

@@ -18,7 +18,7 @@ This includes tests for plaintext and json serialization.
1818
**Web Stack**
1919

2020
* [FastEndpoints](https://fast-endpoints.com/)
21-
* ASP.NET 8
21+
* ASP.NET 9
2222

2323
## Paths & Source for Tests
2424

frameworks/CSharp/fastendpoints/fastendpoints.dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
22
WORKDIR /app
33
COPY Benchmarks .
44
RUN dotnet publish -c Release -o out
55

6-
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
6+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
7+
ENV DOTNET_GCDynamicAdaptationMode=0
8+
ENV DOTNET_ReadyToRun=0
9+
ENV DOTNET_HillClimbing_Disable=1
10+
711
WORKDIR /app
812
COPY --from=build /app/out ./
913

frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,21 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<None Remove="Resources\Fortunes.html"/>
20-
<None Remove="Resources\Template.html"/>
19+
<None Remove="Resources\Fortunes.html" />
20+
<None Remove="Resources\Template.html" />
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<EmbeddedResource Include="Resources\Template.html"/>
24+
<EmbeddedResource Include="Resources\Template.html" />
2525
</ItemGroup>
2626

2727
<ItemGroup>
2828

29-
<PackageReference Include="GenHTTP.Core.Kestrel" Version="9.0.0" />
30-
<PackageReference Include="GenHTTP.Modules.Razor" Version="8.6.0" />
31-
<PackageReference Include="GenHTTP.Modules.Webservices" Version="9.0.0" />
29+
<PackageReference Include="GenHTTP.Core" Version="9.6.2" />
30+
<PackageReference Include="GenHTTP.Modules.Webservices" Version="9.6.2" />
3231

33-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
34-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.0" />
32+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
33+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
3534

3635
</ItemGroup>
3736

frameworks/CSharp/genhttp/Benchmarks/Program.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
using Benchmarks.Tests;
22
using Benchmarks.Utilities;
3-
using GenHTTP.Engine.Kestrel;
3+
4+
using GenHTTP.Engine.Internal;
5+
46
using GenHTTP.Modules.IO;
57
using GenHTTP.Modules.Layouting;
68
using GenHTTP.Modules.Webservices;
79

810
var tests = Layout.Create()
911
.Add("plaintext", Content.From(Resource.FromString("Hello, World!")))
12+
.Add("json", new JsonHandler())
1013
.Add("fortunes", new FortuneHandler())
11-
.AddService<JsonResource>("json")
1214
.AddService<DbResource>("db")
1315
.AddService<QueryResource>("queries")
1416
.AddService<UpdateResource>("updates")
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Text.Json;
2+
3+
using GenHTTP.Api.Content;
4+
using GenHTTP.Api.Protocol;
5+
6+
using GenHTTP.Modules.Conversion.Serializers.Json;
7+
8+
namespace Benchmarks.Tests;
9+
10+
public sealed class JsonResult
11+
{
12+
13+
public string Message { get; set; }
14+
}
15+
16+
public sealed class JsonHandler : IHandler
17+
{
18+
private static readonly FlexibleContentType _ContentType = new(ContentType.ApplicationJson, "utf-8");
19+
20+
private static readonly JsonSerializerOptions _Options = new();
21+
22+
public ValueTask PrepareAsync() => new();
23+
24+
public ValueTask<IResponse> HandleAsync(IRequest request)
25+
{
26+
var result = new JsonResult()
27+
{
28+
Message = "Hello, World!"
29+
};
30+
31+
var response = request.Respond()
32+
.Content(new JsonContent(result, _Options))
33+
.Type(_ContentType)
34+
.Build();
35+
36+
return new(response);
37+
}
38+
39+
}

frameworks/CSharp/genhttp/Benchmarks/Tests/JsonResource.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)