Skip to content

Commit 939321d

Browse files
authored
[CSharp] Migrate FastEndpoints to .NET 9 (#9566)
1 parent 1c3638e commit 939321d

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
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

0 commit comments

Comments
 (0)