瀏覽代碼

upgrade `fastendpoints` to v3.1 and match with `aspcore-mvc` (#7033)

* upgrade `fastendpoints` to v3.1.0 and match with `aspcore-mvc`

* change fastendpoints package patch version

* disable default logging providers
Dĵ ΝιΓΞΗΛψΚ 3 年之前
父節點
當前提交
203a651725

+ 1 - 1
frameworks/CSharp/fastendpoints/Benchmarks/Benchmarks.csproj

@@ -8,7 +8,7 @@
     </PropertyGroup>
 
     <ItemGroup>
-        <PackageReference Include="FastEndpoints" Version="2.17.0" />
+        <PackageReference Include="FastEndpoints" Version="3.1.*" />
     </ItemGroup>
 
 </Project>

+ 3 - 8
frameworks/CSharp/fastendpoints/Benchmarks/Endpoints/JsonEndpoint.cs

@@ -1,11 +1,6 @@
 namespace Benchmarks.Endpoints;
 
-public class Response
-{
-    public string message => "Hello, World!";
-}
-
-public class JsonEndpoint : Endpoint<EmptyRequest, Response>
+public class JsonEndpoint : Endpoint<object, object>
 {
     public override void Configure()
     {
@@ -13,9 +8,9 @@ public class JsonEndpoint : Endpoint<EmptyRequest, Response>
         AllowAnonymous();
     }
 
-    public override Task HandleAsync(EmptyRequest r, CancellationToken ct)
+    public override Task HandleAsync(object _, CancellationToken __)
     {
         HttpContext.Response.ContentLength = 27;
-        return SendAsync(Response);
+        return SendAsync(new { message = "Hello, World!" });
     }
 }

+ 6 - 3
frameworks/CSharp/fastendpoints/Benchmarks/Endpoints/PlainTextEndpoint.cs

@@ -1,6 +1,6 @@
 namespace Benchmarks.Endpoints;
 
-public class PlainTextEndpoint : Endpoint<EmptyRequest, object>
+public class PlainTextEndpoint : Endpoint<object, object>
 {
     private static readonly byte[] payload = System.Text.Encoding.UTF8.GetBytes("Hello, World!");
 
@@ -10,8 +10,11 @@ public class PlainTextEndpoint : Endpoint<EmptyRequest, object>
         AllowAnonymous();
     }
 
-    public override Task HandleAsync(EmptyRequest r, CancellationToken ct)
+    public override Task HandleAsync(object _, CancellationToken __)
     {
-        return SendBytesAsync(payload, contentType: "text/plain");
+        HttpContext.Response.StatusCode = StatusCodes.Status200OK;
+        HttpContext.Response.ContentType = "text/plain";
+        HttpContext.Response.ContentLength = payload.Length;
+        return HttpContext.Response.Body.WriteAsync(payload, 0, payload.Length);
     }
 }

+ 2 - 2
frameworks/CSharp/fastendpoints/Benchmarks/Program.cs

@@ -1,9 +1,9 @@
 global using FastEndpoints;
 
 var builder = WebApplication.CreateBuilder();
+builder.Logging.ClearProviders();
 builder.Services.AddFastEndpoints();
 
 var app = builder.Build();
-app.UseAuthorization();
 app.UseFastEndpoints();
-app.Run();
+app.Run();

+ 1 - 1
frameworks/CSharp/fastendpoints/benchmark_config.json

@@ -19,7 +19,7 @@
         "database_os": "Linux",
         "display_name": "FastEndpoints",
         "notes": "",
-        "versus": "aspcore"
+        "versus": "aspcore-mvc"
       }
     }
   ]

+ 1 - 1
frameworks/CSharp/fastendpoints/config.toml

@@ -12,4 +12,4 @@ os = "Linux"
 orm = "Raw"
 platform = ".NET"
 webserver = "Kestrel"
-versus = "aspcore"
+versus = "aspcore-mvc"