Skip to content

Commit 491de73

Browse files
Update aspnetcore Platform to use latest Razor Slices (#9464)
* Update aspnetcore Platform to use latest Razor Slices This allows enabling native AOT too * Update README.md * Update ChunkedPipeWriter.cs * Update Npgsql & seal classes * Update ChunkedPipeWriter.cs
1 parent 01a72bb commit 491de73

15 files changed

+66
-48
lines changed

frameworks/CSharp/aspnetcore/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ See [.NET Core](http://dot.net) and [ASP.NET Core](https://github.com/dotnet/asp
66

77
**Language**
88

9-
* C# 8.0
9+
* C# 13.0
1010

frameworks/CSharp/aspnetcore/benchmark_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"json_url": "/json",
3131
"db_url": "/db",
3232
"query_url": "/queries/",
33+
"fortune_url": "/fortunes",
3334
"update_url": "/updates/",
3435
"cached_query_url": "/cached-worlds/",
3536
"port": 8080,

frameworks/CSharp/aspnetcore/src/Minimal/Minimal.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Npgsql" Version="8.0.5" />
12+
<PackageReference Include="Npgsql" Version="9.0.2" />
1313
<PackageReference Include="Dapper" Version="2.1.35" />
1414
<PackageReference Include="RazorSlices" Version="0.8.1" />
1515
</ItemGroup>

frameworks/CSharp/aspnetcore/src/Mvc/Mvc.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Npgsql" Version="8.0.5" />
13-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.0-rc.2" />
12+
<PackageReference Include="Npgsql" Version="9.0.2" />
13+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
1414
</ItemGroup>
1515

1616
</Project>

frameworks/CSharp/aspnetcore/src/Platform/BenchmarkApplication.Caching.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace PlatformBenchmarks;
88

9-
public partial class BenchmarkApplication
9+
public sealed partial class BenchmarkApplication
1010
{
1111
private static async Task Caching(PipeWriter pipeWriter, int count)
1212
{

frameworks/CSharp/aspnetcore/src/Platform/BenchmarkApplication.Fortunes.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
#if !AOT
4+
using System;
55
using System.IO.Pipelines;
66
using System.Runtime.CompilerServices;
77
using System.Threading.Tasks;
88
using RazorSlices;
99

1010
namespace PlatformBenchmarks;
1111

12-
public partial class BenchmarkApplication
12+
public sealed partial class BenchmarkApplication
1313
{
1414
private async Task FortunesRaw(PipeWriter pipeWriter)
1515
{
@@ -19,7 +19,7 @@ await RawDb.LoadFortunesRows(),
1919
FortunesTemplateFactory);
2020
}
2121

22-
private ValueTask OutputFortunes<TModel>(PipeWriter pipeWriter, TModel model, SliceFactory<TModel> templateFactory)
22+
private ValueTask OutputFortunes<TModel>(PipeWriter pipeWriter, TModel model, Func<TModel, RazorSlice<TModel>> templateFactory)
2323
{
2424
// Render headers
2525
var preamble = """
@@ -39,7 +39,7 @@ private ValueTask OutputFortunes<TModel>(PipeWriter pipeWriter, TModel model, Sl
3939
// Kestrel PipeWriter span size is 4K, headers above already written to first span & template output is ~1350 bytes,
4040
// so 2K chunk size should result in only a single span and chunk being used.
4141
var chunkedWriter = GetChunkedWriter(pipeWriter, chunkSizeHint: 2048);
42-
var renderTask = template.RenderAsync(chunkedWriter, null, HtmlEncoder);
42+
var renderTask = template.RenderAsync(chunkedWriter, HtmlEncoder);
4343

4444
if (renderTask.IsCompletedSuccessfully)
4545
{
@@ -51,18 +51,17 @@ private ValueTask OutputFortunes<TModel>(PipeWriter pipeWriter, TModel model, Sl
5151
return AwaitTemplateRenderTask(renderTask, chunkedWriter, template);
5252
}
5353

54-
private static async ValueTask AwaitTemplateRenderTask(ValueTask renderTask, ChunkedBufferWriter<WriterAdapter> chunkedWriter, RazorSlice template)
54+
private static async ValueTask AwaitTemplateRenderTask(ValueTask renderTask, ChunkedPipeWriter chunkedWriter, RazorSlice template)
5555
{
5656
await renderTask;
5757
EndTemplateRendering(chunkedWriter, template);
5858
}
5959

6060
[MethodImpl(MethodImplOptions.AggressiveInlining)]
61-
private static void EndTemplateRendering(ChunkedBufferWriter<WriterAdapter> chunkedWriter, RazorSlice template)
61+
private static void EndTemplateRendering(ChunkedPipeWriter chunkedWriter, RazorSlice template)
6262
{
63-
chunkedWriter.End();
63+
chunkedWriter.Complete();
6464
ReturnChunkedWriter(chunkedWriter);
6565
template.Dispose();
6666
}
6767
}
68-
#endif

frameworks/CSharp/aspnetcore/src/Platform/BenchmarkApplication.HttpConnection.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace PlatformBenchmarks;
1414

15-
public partial class BenchmarkApplication : IHttpConnection
15+
public sealed partial class BenchmarkApplication : IHttpConnection
1616
{
1717
private State _state;
1818

@@ -193,15 +193,15 @@ private static BufferWriter<WriterAdapter> GetWriter(PipeWriter pipeWriter, int
193193
=> new(new(pipeWriter), sizeHint);
194194

195195
[MethodImpl(MethodImplOptions.AggressiveInlining)]
196-
private static ChunkedBufferWriter<WriterAdapter> GetChunkedWriter(PipeWriter pipeWriter, int chunkSizeHint)
196+
private static ChunkedPipeWriter GetChunkedWriter(PipeWriter pipeWriter, int chunkSizeHint)
197197
{
198198
var writer = ChunkedWriterPool.Get();
199-
writer.SetOutput(new WriterAdapter(pipeWriter), chunkSizeHint);
199+
writer.SetOutput(pipeWriter, chunkSizeHint);
200200
return writer;
201201
}
202202

203203
[MethodImpl(MethodImplOptions.AggressiveInlining)]
204-
private static void ReturnChunkedWriter(ChunkedBufferWriter<WriterAdapter> writer) => ChunkedWriterPool.Return(writer);
204+
private static void ReturnChunkedWriter(ChunkedPipeWriter writer) => ChunkedWriterPool.Return(writer);
205205

206206
private struct WriterAdapter : IBufferWriter<byte>
207207
{

frameworks/CSharp/aspnetcore/src/Platform/BenchmarkApplication.Json.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace PlatformBenchmarks;
1111

12-
public partial class BenchmarkApplication
12+
public sealed partial class BenchmarkApplication
1313
{
1414
private readonly static uint _jsonPayloadSize = (uint)JsonSerializer.SerializeToUtf8Bytes(
1515
new JsonMessage { message = "Hello, World!" },

frameworks/CSharp/aspnetcore/src/Platform/BenchmarkApplication.MultipleQueries.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace PlatformBenchmarks;
1010

11-
public partial class BenchmarkApplication
11+
public sealed partial class BenchmarkApplication
1212
{
1313
private static async Task MultipleQueries(PipeWriter pipeWriter, int count)
1414
{

frameworks/CSharp/aspnetcore/src/Platform/BenchmarkApplication.Plaintext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace PlatformBenchmarks;
99

10-
public partial class BenchmarkApplication
10+
public sealed partial class BenchmarkApplication
1111
{
1212
private static ReadOnlySpan<byte> _plaintextPreamble =>
1313
"HTTP/1.1 200 OK\r\n"u8 +

0 commit comments

Comments
 (0)