diff --git a/frameworks/CSharp/watson/Benchmarks/Benchmarks.csproj b/frameworks/CSharp/watson/Benchmarks/Benchmarks.csproj index f199ceb3b59..01a0483b2d4 100644 --- a/frameworks/CSharp/watson/Benchmarks/Benchmarks.csproj +++ b/frameworks/CSharp/watson/Benchmarks/Benchmarks.csproj @@ -2,8 +2,8 @@ - net5.0 - 9.0 + net9.0 + 13.0 EmbedIO Benchmarks Test suite to be executed with TechEmpower FrameworkBenchmarks. @@ -17,8 +17,8 @@ - - + + \ No newline at end of file diff --git a/frameworks/CSharp/watson/Benchmarks/Program.cs b/frameworks/CSharp/watson/Benchmarks/Program.cs index 99e4d5922e4..d15cdbd5db1 100644 --- a/frameworks/CSharp/watson/Benchmarks/Program.cs +++ b/frameworks/CSharp/watson/Benchmarks/Program.cs @@ -1,11 +1,10 @@ using System; -using System.Linq; -using System.Net; using System.Text.Json; using System.Threading; using System.Threading.Tasks; using WatsonWebserver; +using WatsonWebserver.Core; namespace Benchmarks { @@ -23,7 +22,7 @@ public class JsonResult public static class Program { - private static readonly ManualResetEvent _WaitEvent = new ManualResetEvent(false); + private static readonly ManualResetEvent WaitEvent = new(false); public static async Task Main(string[] args) { @@ -33,21 +32,23 @@ public static async Task Main(string[] args) var host = "tfb-server"; #endif - using var server = new Server(host, 8080, false, DefaultRoute); + var settings = new WebserverSettings(host, 8080, false); - server.Routes.Static.Add(HttpMethod.GET, "/plaintext", PlaintextRoute); - server.Routes.Static.Add(HttpMethod.GET, "/json", JsonRoute); + using var server = new Webserver(settings, DefaultRoute); + + server.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/plaintext", PlaintextRoute); + server.Routes.PreAuthentication.Static.Add(HttpMethod.GET, "/json", JsonRoute); try { AppDomain.CurrentDomain.ProcessExit += (_, __) => { - _WaitEvent.Set(); + WaitEvent.Set(); }; await server.StartAsync(); - _WaitEvent.WaitOne(); + WaitEvent.WaitOne(); return 0; } @@ -59,22 +60,21 @@ public static async Task Main(string[] args) } } - static async Task DefaultRoute(HttpContext ctx) + static async Task DefaultRoute(HttpContextBase ctx) { ctx.Response.StatusCode = 404; - ctx.Response.StatusDescription = "Not Found"; await ctx.Response.Send("Not found."); } - static async Task PlaintextRoute(HttpContext ctx) + static async Task PlaintextRoute(HttpContextBase ctx) { ctx.Response.Headers.Add("Content-Type", "text/plain; charset=UTF-8"); await ctx.Response.Send("Hello, World!"); } - static async Task JsonRoute(HttpContext ctx) + static async Task JsonRoute(HttpContextBase ctx) { var response = new JsonResult() { Message = "Hello, World!" }; var serialized = JsonSerializer.Serialize(response); diff --git a/frameworks/CSharp/watson/README.md b/frameworks/CSharp/watson/README.md index 549fa94b793..5ee00dc66d7 100644 --- a/frameworks/CSharp/watson/README.md +++ b/frameworks/CSharp/watson/README.md @@ -6,11 +6,11 @@ See the [project website](https://github.com/jchristn/WatsonWebserver) for more **Language** -* C# 9.0 +* C# 13.0 **Platforms** -* .NET 5 +* .NET 9 **Web Servers** diff --git a/frameworks/CSharp/watson/benchmark_config.json b/frameworks/CSharp/watson/benchmark_config.json index d6f8c86dece..6017f614566 100644 --- a/frameworks/CSharp/watson/benchmark_config.json +++ b/frameworks/CSharp/watson/benchmark_config.json @@ -16,8 +16,7 @@ "os": "Linux", "database_os": "Linux", "display_name": "Watson Webserver", - "notes": "", - "tags": ["broken"] + "notes": "" } }] } diff --git a/frameworks/CSharp/watson/watson.dockerfile b/frameworks/CSharp/watson/watson.dockerfile index 675c16d8841..35e05ff1fc4 100644 --- a/frameworks/CSharp/watson/watson.dockerfile +++ b/frameworks/CSharp/watson/watson.dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build WORKDIR /source # copy csproj and restore as distinct layers @@ -7,10 +7,10 @@ RUN dotnet restore -r linux-musl-x64 # copy and publish app and libraries COPY Benchmarks/ . -RUN dotnet publish -c release -o /app -r linux-musl-x64 +RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-contained # final stage/image -FROM mcr.microsoft.com/dotnet/runtime-deps:5.0-alpine +FROM mcr.microsoft.com/dotnet/runtime-deps:9.0-alpine WORKDIR /app COPY --from=build /app .