Skip to content

Commit ed54185

Browse files
committed
Update to .NET 7
1 parent e6eee12 commit ed54185

31 files changed

+113
-169
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
3+
<TargetFramework>net7.0</TargetFramework>
44
<OutputType>Exe</OutputType>
55
<ImplicitUsings>enable</ImplicitUsings>
6+
<TieredPGO>true</TieredPGO>
67
</PropertyGroup>
78

89
<ItemGroup>
@@ -13,10 +14,10 @@
1314
</ItemGroup>
1415

1516
<ItemGroup>
16-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
1718

1819
<PackageReference Include="Dapper" Version="2.0.123" />
19-
<PackageReference Include="MySqlConnector" Version="2.0.0" />
20-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0" />
20+
<PackageReference Include="MySqlConnector" Version="2.2.0" />
21+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.0" />
2122
</ItemGroup>
2223
</Project>

frameworks/CSharp/aspnetcore/PlatformBenchmarks/AsciiString.cs

-57
This file was deleted.

frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Fortunes.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ namespace PlatformBenchmarks
1212
{
1313
public partial class BenchmarkApplication
1414
{
15-
private readonly static AsciiString _fortunesPreamble =
16-
_http11OK +
17-
_headerServer + _crlf +
18-
_headerContentTypeHtml + _crlf +
19-
_headerContentLength;
15+
private static ReadOnlySpan<byte> _fortunesPreamble =>
16+
"HTTP/1.1 200 OK\r\n"u8 +
17+
"Server: K"u8 + "\r\n"u8 +
18+
"Content-Type: text/html; charset=UTF-8"u8 + "\r\n"u8 +
19+
"Content-Length: "u8;
2020

2121
private async Task Fortunes(PipeWriter pipeWriter)
2222
{

frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Json.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public partial class BenchmarkApplication
1010
{
1111
private readonly static uint _jsonPayloadSize = (uint)JsonSerializer.SerializeToUtf8Bytes(new JsonMessage { message = "Hello, World!" }, SerializerContext.JsonMessage).Length;
1212

13-
private readonly static AsciiString _jsonPreamble =
14-
_http11OK +
15-
_headerServer + _crlf +
16-
_headerContentTypeJson + _crlf +
17-
_headerContentLength + _jsonPayloadSize.ToString();
13+
private static ReadOnlySpan<byte> _jsonPreamble =>
14+
"HTTP/1.1 200 OK\r\n"u8 +
15+
"Server: K"u8 + "\r\n"u8 +
16+
"Content-Type: application/json"u8 + "\r\n"u8 +
17+
"Content-Length: 27"u8;
1818

1919
private static void Json(ref BufferWriter<WriterAdapter> writer, IBufferWriter<byte> bodyWriter)
2020
{

frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.Plaintext.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ namespace PlatformBenchmarks;
55

66
public partial class BenchmarkApplication
77
{
8-
private readonly static AsciiString _plaintextPreamble =
9-
_http11OK +
10-
_headerServer + _crlf +
11-
_headerContentTypeText + _crlf +
12-
_headerContentLength + _plainTextBody.Length.ToString();
8+
private static ReadOnlySpan<byte> _plaintextPreamble =>
9+
"HTTP/1.1 200 OK\r\n"u8 +
10+
"Server: K\r\n"u8 +
11+
"Content-Type: text/plain\r\n"u8 +
12+
"Content-Length: 13"u8;
1313

1414
private static void PlainText(ref BufferWriter<WriterAdapter> writer)
1515
{

frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs

+39-39
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,27 @@ namespace PlatformBenchmarks;
1414

1515
public partial class BenchmarkApplication
1616
{
17-
private readonly static AsciiString _applicationName = "Kestrel Platform-Level Application";
18-
public static AsciiString ApplicationName => _applicationName;
19-
20-
private readonly static AsciiString _crlf = "\r\n";
21-
private readonly static AsciiString _eoh = "\r\n\r\n"; // End Of Headers
22-
private readonly static AsciiString _http11OK = "HTTP/1.1 200 OK\r\n";
23-
private readonly static AsciiString _http11NotFound = "HTTP/1.1 404 Not Found\r\n";
24-
private readonly static AsciiString _headerServer = "Server: K";
25-
private readonly static AsciiString _headerContentLength = "Content-Length: ";
26-
private readonly static AsciiString _headerContentLengthZero = "Content-Length: 0";
27-
private readonly static AsciiString _headerContentTypeText = "Content-Type: text/plain";
28-
private readonly static AsciiString _headerContentTypeJson = "Content-Type: application/json";
29-
private readonly static AsciiString _headerContentTypeHtml = "Content-Type: text/html; charset=UTF-8";
30-
31-
private readonly static AsciiString _dbPreamble =
32-
_http11OK +
33-
_headerServer + _crlf +
34-
_headerContentTypeJson + _crlf +
35-
_headerContentLength;
36-
37-
private readonly static AsciiString _plainTextBody = "Hello, World!";
17+
private static ReadOnlySpan<byte> _applicationName => "Kestrel Platform-Level Application"u8;
18+
public static ReadOnlySpan<byte> ApplicationName => _applicationName;
19+
20+
private static ReadOnlySpan<byte> _crlf => "\r\n"u8;
21+
private static ReadOnlySpan<byte> _eoh => "\r\n\r\n"u8; // End Of Headers
22+
private static ReadOnlySpan<byte> _http11OK => "HTTP/1.1 200 OK\r\n"u8;
23+
private static ReadOnlySpan<byte> _http11NotFound => "HTTP/1.1 404 Not Found\r\n"u8;
24+
private static ReadOnlySpan<byte> _headerServer => "Server: K"u8;
25+
private static ReadOnlySpan<byte> _headerContentLength => "Content-Length: "u8;
26+
private static ReadOnlySpan<byte> _headerContentLengthZero => "Content-Length: 0"u8;
27+
private static ReadOnlySpan<byte> _headerContentTypeText => "Content-Type: text/plain"u8;
28+
private static ReadOnlySpan<byte> _headerContentTypeJson => "Content-Type: application/json"u8;
29+
private static ReadOnlySpan<byte> _headerContentTypeHtml => "Content-Type: text/html; charset=UTF-8"u8;
30+
31+
private static ReadOnlySpan<byte> _dbPreamble =>
32+
"HTTP/1.1 200 OK\r\n"u8 +
33+
"Server: K\r\n"u8 +
34+
"Content-Type: application/json\r\n"u8 +
35+
"Content-Length: "u8;
36+
37+
private static ReadOnlySpan<byte> _plainTextBody => "Hello, World!"u8;
3838

3939
private static readonly JsonContext SerializerContext = JsonContext.Default;
4040

@@ -46,12 +46,12 @@ private sealed partial class JsonContext : JsonSerializerContext
4646
{
4747
}
4848

49-
private readonly static AsciiString _fortunesTableStart = "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>";
50-
private readonly static AsciiString _fortunesRowStart = "<tr><td>";
51-
private readonly static AsciiString _fortunesColumn = "</td><td>";
52-
private readonly static AsciiString _fortunesRowEnd = "</td></tr>";
53-
private readonly static AsciiString _fortunesTableEnd = "</table></body></html>";
54-
private readonly static AsciiString _contentLengthGap = new string(' ', 4);
49+
private static ReadOnlySpan<byte> _fortunesTableStart => "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>"u8;
50+
private static ReadOnlySpan<byte> _fortunesRowStart => "<tr><td>"u8;
51+
private static ReadOnlySpan<byte> _fortunesColumn => "</td><td>"u8;
52+
private static ReadOnlySpan<byte> _fortunesRowEnd => "</td></tr>"u8;
53+
private static ReadOnlySpan<byte> _fortunesTableEnd => "</table></body></html>"u8;
54+
private static ReadOnlySpan<byte> _contentLengthGap => " "u8;
5555

5656
#if DATABASE
5757
public static RawDb Db { get; set; }
@@ -62,13 +62,13 @@ private sealed partial class JsonContext : JsonSerializerContext
6262

6363
public static class Paths
6464
{
65-
public readonly static AsciiString Json = "/json";
66-
public readonly static AsciiString Plaintext = "/plaintext";
67-
public readonly static AsciiString SingleQuery = "/db";
68-
public readonly static AsciiString Fortunes = "/fortunes";
69-
public readonly static AsciiString Updates = "/updates/";
70-
public readonly static AsciiString MultipleQueries = "/queries/";
71-
public readonly static AsciiString Caching = "/cached-worlds/";
65+
public static ReadOnlySpan<byte> Json => "/json"u8;
66+
public static ReadOnlySpan<byte> Plaintext => "/plaintext"u8;
67+
public static ReadOnlySpan<byte> SingleQuery => "/db"u8;
68+
public static ReadOnlySpan<byte> Fortunes => "/fortunes"u8;
69+
public static ReadOnlySpan<byte> Updates => "/updates/"u8;
70+
public static ReadOnlySpan<byte> MultipleQueries => "/queries/"u8;
71+
public static ReadOnlySpan<byte> Caching => "/cached-worlds/"u8;
7272
}
7373

7474
private RequestType _requestType;
@@ -169,11 +169,11 @@ private static Task Default(PipeWriter pipeWriter)
169169
return Task.CompletedTask;
170170
}
171171
#endif
172-
private readonly static AsciiString _defaultPreamble =
173-
_http11NotFound +
174-
_headerServer + _crlf +
175-
_headerContentTypeText + _crlf +
176-
_headerContentLengthZero;
172+
private static ReadOnlySpan<byte> _defaultPreamble =>
173+
"HTTP/1.1 200 OK\r\n"u8 +
174+
"Server: K"u8 + "\r\n"u8 +
175+
"Content-Type: text/plain"u8 +
176+
"Content-Length: 0"u8;
177177

178178
private static void Default(ref BufferWriter<WriterAdapter> writer)
179179
{

frameworks/CSharp/aspnetcore/PlatformBenchmarks/Data/CachedWorld.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ public sealed class CachedWorld
99

1010
public int RandomNumber { get; set; }
1111

12-
public static implicit operator CachedWorld(World world) => new CachedWorld { Id = world.Id, RandomNumber = world.RandomNumber };
12+
public static implicit operator CachedWorld(World world) => new() { Id = world.Id, RandomNumber = world.RandomNumber };
1313
}

frameworks/CSharp/aspnetcore/PlatformBenchmarks/DateHeader.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ private static void SetDateValues(DateTimeOffset value)
5757
throw new Exception("date time format failed");
5858
}
5959
Debug.Assert(written == dateTimeRLength);
60-
var temp = s_headerBytesMaster;
61-
s_headerBytesMaster = s_headerBytesScratch;
62-
s_headerBytesScratch = temp;
60+
(s_headerBytesScratch, s_headerBytesMaster) = (s_headerBytesMaster, s_headerBytesScratch);
6361
}
6462
}
6563
}

frameworks/CSharp/aspnetcore/PlatformBenchmarks/PlatformBenchmarks.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
3+
<TargetFramework>net7.0</TargetFramework>
44
<OutputType>Exe</OutputType>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<ImplicitUsings>enable</ImplicitUsings>
7+
<TieredPGO>true</TieredPGO>
78
</PropertyGroup>
89

910
<PropertyGroup>

frameworks/CSharp/aspnetcore/PlatformBenchmarks/Program.cs

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System.Runtime.InteropServices;
5+
using System.Text;
56

67
namespace PlatformBenchmarks;
78

@@ -13,15 +14,15 @@ public static async Task Main(string[] args)
1314
{
1415
Args = args;
1516

16-
Console.WriteLine(BenchmarkApplication.ApplicationName);
17+
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.ApplicationName));
1718
#if !DATABASE
18-
Console.WriteLine(BenchmarkApplication.Paths.Plaintext);
19-
Console.WriteLine(BenchmarkApplication.Paths.Json);
19+
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Plaintext));
20+
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Json));
2021
#else
21-
Console.WriteLine(BenchmarkApplication.Paths.Fortunes);
22-
Console.WriteLine(BenchmarkApplication.Paths.SingleQuery);
23-
Console.WriteLine(BenchmarkApplication.Paths.Updates);
24-
Console.WriteLine(BenchmarkApplication.Paths.MultipleQueries);
22+
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Fortunes));
23+
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.SingleQuery));
24+
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.Updates));
25+
Console.WriteLine(Encoding.UTF8.GetString(BenchmarkApplication.Paths.MultipleQueries));
2526
#endif
2627
DateHeader.SyncDateTimer();
2728

frameworks/CSharp/aspnetcore/aspcore-ado-my.dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
22
WORKDIR /app
33
COPY PlatformBenchmarks .
44
RUN dotnet publish -c Release -o out /p:DatabaseProvider=MySqlConnector
55

6-
FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
6+
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
77
ENV ASPNETCORE_URLS http://+:8080
88

99
# Full PGO

frameworks/CSharp/aspnetcore/aspcore-ado-pg-up.dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
22
WORKDIR /app
33
COPY PlatformBenchmarks .
44
RUN dotnet publish -c Release -o out /p:DatabaseProvider=Npgsql
55

6-
FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
6+
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
77
ENV ASPNETCORE_URLS http://+:8080
88

99
# Full PGO

frameworks/CSharp/aspnetcore/aspcore-ado-pg.dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
22
WORKDIR /app
33
COPY PlatformBenchmarks .
44
RUN dotnet publish -c Release -o out /p:DatabaseProvider=Npgsql
55

6-
FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
6+
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
77
ENV ASPNETCORE_URLS http://+:8080
88

99
# Full PGO

frameworks/CSharp/aspnetcore/aspcore-mvc-ado-my.dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
22
WORKDIR /app
33
COPY Benchmarks .
44
RUN dotnet publish -c Release -o out
55

6-
FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
6+
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
77
ENV ASPNETCORE_URLS http://+:8080
88

99
# Full PGO

frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg-up.dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
22
WORKDIR /app
33
COPY Benchmarks .
44
RUN dotnet publish -c Release -o out
55

6-
FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
6+
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
77
ENV ASPNETCORE_URLS http://+:8080
88

99
# Full PGO

frameworks/CSharp/aspnetcore/aspcore-mvc-ado-pg.dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
22
WORKDIR /app
33
COPY Benchmarks .
44
RUN dotnet publish -c Release -o out
55

6-
FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
6+
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
77
ENV ASPNETCORE_URLS http://+:8080
88

99
# Full PGO

frameworks/CSharp/aspnetcore/aspcore-mvc-dap-my.dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
22
WORKDIR /app
33
COPY Benchmarks .
44
RUN dotnet publish -c Release -o out
55

6-
FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
6+
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
77
ENV ASPNETCORE_URLS http://+:8080
88

99
# Full PGO

frameworks/CSharp/aspnetcore/aspcore-mvc-dap-pg-up.dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
22
WORKDIR /app
33
COPY Benchmarks .
44
RUN dotnet publish -c Release -o out
55

6-
FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
6+
FROM mcr.microsoft.com/dotnet/aspnet:7.0.0 AS runtime
77
ENV ASPNETCORE_URLS http://+:8080
88

99
# Full PGO

0 commit comments

Comments
 (0)