From 8312c7e5deb98c60fbcc8a4fa3cc515b7777002a Mon Sep 17 00:00:00 2001 From: Rami Date: Wed, 10 Dec 2025 12:18:23 -0800 Subject: [PATCH 1/2] Updated `UseSignalRHubSpecification` to use async I/O for writing the SignalR spec JSON Fixes #155 --- examples/Server/Server.csproj | 2 +- .../Templates/CoreTemplate.cs | 8 ++++---- .../Templates/SpecificationTemplate.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/Server/Server.csproj b/examples/Server/Server.csproj index 7ad1139..c91467b 100644 --- a/examples/Server/Server.csproj +++ b/examples/Server/Server.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - ddffc1a4-3fbf-4f69-b764-7989d00717e9 + true diff --git a/src/TypedSignalR.Client.DevTools.Specification/Templates/CoreTemplate.cs b/src/TypedSignalR.Client.DevTools.Specification/Templates/CoreTemplate.cs index f6a64b1..458be7f 100644 --- a/src/TypedSignalR.Client.DevTools.Specification/Templates/CoreTemplate.cs +++ b/src/TypedSignalR.Client.DevTools.Specification/Templates/CoreTemplate.cs @@ -24,17 +24,17 @@ internal static partial class EndpointRouteBuilderExtensions public static void UseSignalRHubSpecification(this IEndpointRouteBuilder endpointRouteBuilder) { // Actually, it does not use middleware. - endpointRouteBuilder.MapGet(""/signalr-dev/spec.json"", (HttpContext context) => + endpointRouteBuilder.MapGet(""/signalr-dev/spec.json"", async (HttpContext context) => { context.Response.StatusCode = StatusCodes.Status200OK; context.Response.ContentType = ""application/json""; - context.Response.BodyWriter.Write(GetSpecJsonBytes()); - context.Response.BodyWriter.Complete(); + ReadOnlyMemory jsonBytes = GetSpecJsonBytes(); + await context.Response.Body.WriteAsync(jsonBytes); }); } - private static partial ReadOnlySpan GetSpecJsonBytes(); + private static partial ReadOnlyMemory GetSpecJsonBytes(); } "; } diff --git a/src/TypedSignalR.Client.DevTools.Specification/Templates/SpecificationTemplate.cs b/src/TypedSignalR.Client.DevTools.Specification/Templates/SpecificationTemplate.cs index be77edc..4d0fddc 100644 --- a/src/TypedSignalR.Client.DevTools.Specification/Templates/SpecificationTemplate.cs +++ b/src/TypedSignalR.Client.DevTools.Specification/Templates/SpecificationTemplate.cs @@ -49,7 +49,7 @@ namespace TypedSignalR.Client.DevTools; internal static partial class EndpointRouteBuilderExtensions {{ - private static partial ReadOnlySpan GetSpecJsonBytes() => new byte[] {{ {str} }}; + private static partial ReadOnlyMemory GetSpecJsonBytes() => new byte[] {{ {str} }}; }}"; } } From 609500b1e4b3395c2ed68b1bb3ba538f539a7f8f Mon Sep 17 00:00:00 2001 From: Rami Date: Mon, 5 Jan 2026 20:54:40 -0800 Subject: [PATCH 2/2] Reverted changes in Server.csproj. Used var for jsonBytes variable. --- examples/Server/Server.csproj | 2 +- .../Templates/CoreTemplate.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Server/Server.csproj b/examples/Server/Server.csproj index c91467b..7ad1139 100644 --- a/examples/Server/Server.csproj +++ b/examples/Server/Server.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - true + ddffc1a4-3fbf-4f69-b764-7989d00717e9 diff --git a/src/TypedSignalR.Client.DevTools.Specification/Templates/CoreTemplate.cs b/src/TypedSignalR.Client.DevTools.Specification/Templates/CoreTemplate.cs index 458be7f..8552790 100644 --- a/src/TypedSignalR.Client.DevTools.Specification/Templates/CoreTemplate.cs +++ b/src/TypedSignalR.Client.DevTools.Specification/Templates/CoreTemplate.cs @@ -29,7 +29,7 @@ public static void UseSignalRHubSpecification(this IEndpointRouteBuilder endpoin context.Response.StatusCode = StatusCodes.Status200OK; context.Response.ContentType = ""application/json""; - ReadOnlyMemory jsonBytes = GetSpecJsonBytes(); + var jsonBytes = GetSpecJsonBytes(); await context.Response.Body.WriteAsync(jsonBytes); }); }