Skip to content

Commit

Permalink
Update to .NET 8 and 9
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed Nov 18, 2024
1 parent a911300 commit a5a8552
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 48 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- uses: aarnott/[email protected]
with:
setAllVars: true

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1.7.2
uses: actions/setup-dotnet@v4
with:
version: 3.1.100
dotnet-version: |
8.0.x
9.0.x
- name: dotnet build
run: dotnet build BedrockFramework.sln -c Release
Expand Down
7 changes: 5 additions & 2 deletions BedrockFramework.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29112.163
# Visual Studio Version 17
VisualStudioVersion = 17.12.35410.144 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientApplication", "samples\ClientApplication\ClientApplication.csproj", "{44A257ED-D3A7-4170-BE67-4392F2A6FE18}"
EndProject
Expand All @@ -20,6 +20,9 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EA6E96E9-C7CC-4051-8E3A-28236CE32CFD}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
global.json = global.json
nuget.config = nuget.config
version.json = version.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bedrock.Framework.Experimental", "src\Bedrock.Framework.Experimental\Bedrock.Framework.Experimental.csproj", "{B77439AE-01C0-4877-AF91-180D521F6E55}"
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
</PropertyGroup>
<ItemGroup Condition="$(IsPackable) == 'true'">
<PackageReference Include="Nerdbank.GitVersioning">
<Version>3.3.37</Version>
<Version>3.6.146</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "9.0.100"
}
}
6 changes: 3 additions & 3 deletions samples/ClientApplication/ClientApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -14,8 +14,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="6.0.5" />
<PackageReference Include="MQTTnet.AspNetCore" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.0" />
<PackageReference Include="MQTTnet.AspNetCore" Version="4.3.7.1207" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions samples/ClientApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private static async Task EchoServerWithTls(ServiceProvider serviceProvider)
o.TargetHost = "foo";
};

options.LocalCertificate = new X509Certificate2("testcert.pfx", "testcert");
options.LocalCertificate = X509CertificateLoader.LoadPkcs12FromFile("testcert.pfx", "testcert");

// NOTE: Do not do this in a production environment
options.AllowAnyRemoteCertificate();
Expand Down Expand Up @@ -360,7 +360,7 @@ private static async Task DockerDaemon(IServiceProvider serviceProvider)
.UseConnectionLogging()
.Build();

await using var connection = await client.ConnectAsync(new NamedPipeEndPoint("docker_engine"));
await using var connection = await client.ConnectAsync(new Bedrock.Framework.NamedPipeEndPoint("docker_engine"));

// Use the HTTP/1.1 protocol
var httpProtocol = new HttpClientProtocol(connection);
Expand Down
19 changes: 12 additions & 7 deletions samples/ServerApplication/MqttApplication.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using MQTTnet.Adapter;
using MQTTnet.AspNetCore;
using MQTTnet.Packets;
using MQTTnet.Protocol;

namespace ServerApplication
{
public class MqttApplication : MqttConnectionHandler
public class MqttApplication : ConnectionHandler
{
private MqttConnectionHandler _mqttHandler = new();

public MqttApplication()
{
ClientHandler = OnClientConnectedAsync;
_mqttHandler.ClientHandler = OnClientConnectedAsync;
}

public override async Task OnConnectedAsync(ConnectionContext connection)
{
await _mqttHandler.OnConnectedAsync(connection);
}

private async Task OnClientConnectedAsync(IMqttChannelAdapter adapter)
Expand Down Expand Up @@ -43,8 +49,7 @@ await adapter.SendPacketAsync(new MqttConnAckPacket
case MqttSubscribePacket mqttSubscribePacket:
var ack = new MqttSubAckPacket
{
PacketIdentifier = mqttSubscribePacket.PacketIdentifier,
ReturnCodes = new List<MqttSubscribeReturnCode> { MqttSubscribeReturnCode.SuccessMaximumQoS0 }
PacketIdentifier = mqttSubscribePacket.PacketIdentifier
};
ack.ReasonCodes.Add(MqttSubscribeReasonCode.GrantedQoS0);

Expand Down
2 changes: 1 addition & 1 deletion samples/ServerApplication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static async Task Main(string[] args)
sockets.Listen(IPAddress.Loopback, 5004,
builder => builder.UseServerTls(options =>
{
options.LocalCertificate = new X509Certificate2("testcert.pfx", "testcert");
options.LocalCertificate = X509CertificateLoader.LoadPkcs12FromFile("testcert.pfx", "testcert");

// NOTE: Do not do this in a production environment
options.AllowAnyRemoteCertificate();
Expand Down
4 changes: 2 additions & 2 deletions samples/ServerApplication/ServerApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<Content Include="..\Certs\testcert.pfx" Link="testcert.pfx" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MQTTnet.AspNetCore" Version="3.1.2" />
<PackageReference Include="MQTTnet.AspNetCore" Version="4.3.7.1207" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageDescription>Experimental protocols and transports for Bedrock.Framework.</PackageDescription>
<Authors>David Fowler</Authors>
Expand All @@ -18,20 +18,21 @@
</ItemGroup>

<Choose>
<When Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<When Condition="'$(TargetFramework)' == 'net8.0'">
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Connections.Client" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Connections.Client" Version="8.0.11" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Connections.Client" Version="6.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Http.Connections.Client" Version="9.0.0" />
</ItemGroup>
</Otherwise>
</Choose>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageReference Update="Nerdbank.GitVersioning" Version="3.6.146" />
</ItemGroup>

<ItemGroup>
Expand Down
20 changes: 15 additions & 5 deletions src/Bedrock.Framework/Bedrock.Framework.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<PackageDescription>High performance, low level networking APIs for building custom severs and clients.</PackageDescription>
<Authors>David Fowler</Authors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -11,11 +11,21 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.IO.Pipelines" Version="6.0.3" />
</ItemGroup>
<Choose>
<When Condition="'$(TargetFramework)' == 'net8.0'">
<ItemGroup>
<PackageReference Include="System.IO.Pipelines" Version="8.0.0" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="System.IO.Pipelines" Version="9.0.0" />
</ItemGroup>
</Otherwise>
</Choose>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageReference Update="Nerdbank.GitVersioning" Version="3.6.146" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,5 @@ public class WebSocketFrameException : Exception
/// </summary>
/// <param name="message">The message containing the description of the frame error.</param>
public WebSocketFrameException(string message) : base(message) { }

/// <summary>
/// Creates an instance of a WebSocketFrameException.
/// </summary>
/// <param name="info">The info object required to serialize the exception.</param>
/// <param name="context">The streaming context required to serialize the exception.</param>
protected WebSocketFrameException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public unsafe void WriteMessage(WebSocketWriteFrame message, IBufferWriter<byte>
headerSpan[1] |= 0b1000_0000;

var maskingKey = message.Header.MaskingKey;
MemoryMarshal.Write(headerSpan.Slice(maskPosition), ref maskingKey);
MemoryMarshal.Write(headerSpan.Slice(maskPosition), in maskingKey);

if (!message.MaskingComplete)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions tests/Bedrock.Framework.Tests/Bedrock.Framework.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.1-alpha",
"version": "0.2-alpha",
"nugetPackageVersion": {
"semVer": 2
}
Expand Down

0 comments on commit a5a8552

Please sign in to comment.