Skip to content

Commit ceab0bb

Browse files
committed
feat: .NET 6 support / update Fusion to v2.0.70
1 parent eeed368 commit ceab0bb

File tree

166 files changed

+3618
-3671
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+3618
-3671
lines changed

Dockerfile

+14-13
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ ENTRYPOINT ["sh", "start.sh"]
1616

1717
# Samples
1818

19-
FROM mcr.microsoft.com/dotnet/sdk:5.0 as build
19+
FROM mcr.microsoft.com/dotnet/sdk:6.0 as build
2020
RUN apt-get update \
2121
&& apt-get install -y --allow-unauthenticated \
2222
libc6-dev \
2323
libgdiplus \
2424
libx11-dev \
2525
&& apt-get clean \
26-
&& rm -rf /var/lib/apt/lists/*
26+
&& rm -rf /var/lib/apt/lists/* \
27+
&& dotnet workload install wasm-tools
2728
WORKDIR /samples
2829
COPY ["src/", "src/"]
2930
COPY ["templates/", "templates/"]
@@ -34,52 +35,52 @@ RUN dotnet build -c:Release --no-restore
3435

3536
# Create HelloWorld sample image
3637
FROM build as sample_hello_world
37-
WORKDIR /samples/src/HelloWorld/bin/Debug/net5.0
38+
WORKDIR /samples/src/HelloWorld/bin/Debug/net6.0
3839

3940
# Create HelloCart sample image
4041
FROM build as sample_hello_cart
41-
WORKDIR /samples/src/HelloCart/bin/Debug/net5.0
42+
WORKDIR /samples/src/HelloCart/bin/Debug/net6.0
4243

4344
# Create HelloBlazorServer sample image
4445
FROM build as sample_hello_blazor_server
4546
WORKDIR /samples/src/HelloBlazorServer
46-
ENTRYPOINT ["dotnet", "bin/Debug/net5.0/Samples.HelloBlazorServer.dll"]
47+
ENTRYPOINT ["dotnet", "bin/Debug/net6.0/Samples.HelloBlazorServer.dll"]
4748

4849
# Create HelloBlazorHybrid sample image
4950
FROM build as sample_hello_blazor_hybrid
5051
WORKDIR /samples/src/HelloBlazorHybrid/Server
51-
ENTRYPOINT ["dotnet", "bin/Debug/net5.0/Samples.HelloBlazorHybrid.Server.dll"]
52+
ENTRYPOINT ["dotnet", "bin/Debug/net6.0/Samples.HelloBlazorHybrid.Server.dll"]
5253

5354
# Create Blazor sample image
5455
FROM build as sample_blazor
5556
WORKDIR /samples/src/Blazor/Server
56-
ENTRYPOINT ["dotnet", "bin/Debug/net5.0/Samples.Blazor.Server.dll"]
57+
ENTRYPOINT ["dotnet", "bin/Debug/net6.0/Samples.Blazor.Server.dll"]
5758

5859
# Create Caching Server sample image
5960
FROM build as sample_caching_server
6061
WORKDIR /samples/src/Caching/Server
61-
ENTRYPOINT ["dotnet", "bin/Release/net5.0/Samples.Caching.Server.dll"]
62+
ENTRYPOINT ["dotnet", "bin/Release/net6.0/Samples.Caching.Server.dll"]
6263

6364
# Create Caching Client sample image
6465
FROM build as sample_caching_client
65-
WORKDIR /samples/src/Caching/Client/bin/Release/net5.0
66+
WORKDIR /samples/src/Caching/Client/bin/Release/net6.0
6667

6768

6869
# Websites
6970

7071
FROM build as publish
7172
WORKDIR /samples
72-
RUN dotnet publish -c:Release -f:net5.0 --no-build --no-restore src/Blazor/Server/Server.csproj
73+
RUN dotnet publish -c:Release --no-build --no-restore src/Blazor/Server/Server.csproj
7374

74-
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim as runtime
75+
FROM mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim as runtime
7576
RUN apt-get update \
7677
&& apt-get install -y --allow-unauthenticated \
7778
libc6-dev \
7879
libgdiplus \
7980
libx11-dev \
8081
&& apt-get clean \
8182
&& rm -rf /var/lib/apt/lists/*
82-
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
83+
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
8384
WORKDIR /samples
8485
COPY --from=publish /samples .
8586

@@ -88,4 +89,4 @@ FROM runtime as sample_blazor_ws
8889
WORKDIR /samples/src/Blazor/Server
8990
ENV Server__GitHubClientId=7d519556dd8207a36355
9091
ENV Server__GitHubClientSecret=8e161ca4799b7e76e1c25429728db6b2430f2057
91-
ENTRYPOINT ["dotnet", "bin/Release/net5.0/publish/Samples.Blazor.Server.dll"]
92+
ENTRYPOINT ["dotnet", "bin/Release/net6.0/publish/Samples.Blazor.Server.dll"]

Run-Sample-Blazor-MultiHost.cmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set ASPNETCORE_ENVIRONMENT=Development
44

55
set ASPNETCORE_URLS=http://localhost:5005/
66
start cmd /C timeout 5 ^& start http://localhost:5005/"
7-
start cmd /C dotnet run --no-launch-profile -f net5.0 -p src/Blazor/Server/Server.csproj
7+
start cmd /C dotnet run --no-launch-profile --project src/Blazor/Server/Server.csproj
88

99
set ASPNETCORE_URLS=http://localhost:5006/
1010
start cmd /C timeout 5 ^& start http://localhost:5006/"
11-
start cmd /C dotnet run --no-launch-profile -f net5.0 -p src/Blazor/Server/Server.csproj
11+
start cmd /C dotnet run --no-launch-profile --project src/Blazor/Server/Server.csproj

Run-Sample-Blazor.cmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ rem The next line is optional - you need it if you want to debug Blazor client
33
set ASPNETCORE_ENVIRONMENT=Development
44

55
start cmd /C timeout 3 ^& start http://localhost:5005/"
6-
start cmd /C timeout 3 ^& dotnet run -f net5.0 -p src/Blazor/ConsoleClient/ConsoleClient.csproj
7-
dotnet run --no-launch-profile -f net5.0 -p src/Blazor/Server/Server.csproj
6+
start cmd /C timeout 3 ^& dotnet run --project src/Blazor/ConsoleClient/ConsoleClient.csproj
7+
dotnet run --no-launch-profile --project src/Blazor/Server/Server.csproj

Run-Sample-Blazor.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
set ASPNETCORE_ENVIRONMENT=Development
44

55
(sleep 3; xdg-open http://localhost:5005/) &
6-
dotnet run --no-launch-profile -f net5.0 -p src/Blazor/Server/Server.csproj
6+
dotnet run --no-launch-profile --project src/Blazor/Server/Server.csproj

Run-Sample-Caching-NetCore31.cmd Run-Sample-Caching-Net50.cmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ docker-compose build db
33
docker-compose up -d db
44
dotnet build -c Release
55

6-
start "Samples.Caching.Server" dotnet run --no-launch-profile -c Release -f netcoreapp3.1 -p src/Caching/Server/Server.csproj
6+
start "Samples.Caching.Server" dotnet run --no-launch-profile -c Release -f net5.0 --project src/Caching/Server/Server.csproj
77
timeout 3
8-
dotnet run -c Release -f netcoreapp3.1 -p src/Caching/Client/Client.csproj
8+
dotnet run -c Release -f net5.0 --project src/Caching/Client/Client.csproj

Run-Sample-Caching-NetCore31.sh Run-Sample-Caching-Net50.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ docker-compose build db
33
docker-compose up -d db
44
dotnet build -c Release
55

6-
dotnet run --no-launch-profile -c Release -f netcoreapp3.1 -p src/Caching/Server/Server.csproj &
6+
dotnet run --no-launch-profile -c Release -f net5.0 --project src/Caching/Server/Server.csproj &
77
sleep 3
8-
dotnet run -c Release -f netcoreapp3.1 -p src/Caching/Client/Client.csproj
8+
dotnet run -c Release -f net5.0 --project src/Caching/Client/Client.csproj

Run-Sample-Caching.cmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ docker-compose build db
33
docker-compose up -d db
44
dotnet build -c Release
55

6-
start "Samples.Caching.Server" dotnet run --no-launch-profile -c Release -f net5.0 -p src/Caching/Server/Server.csproj
6+
start "Samples.Caching.Server" dotnet run --no-launch-profile -c Release -f net6.0 --project src/Caching/Server/Server.csproj
77
timeout 3
8-
dotnet run -c Release -f net5.0 -p src/Caching/Client/Client.csproj
8+
dotnet run -c Release -f net6.0 --project src/Caching/Client/Client.csproj

Run-Sample-Caching.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ docker-compose build db
33
docker-compose up -d db
44
dotnet build -c Release
55

6-
dotnet run --no-launch-profile -c Release -f net5.0 -p src/Caching/Server/Server.csproj &
6+
dotnet run --no-launch-profile -c Release -f net6.0 --project src/Caching/Server/Server.csproj &
77
sleep 3
8-
dotnet run -c Release -f net5.0 -p src/Caching/Client/Client.csproj
8+
dotnet run -c Release -f net6.0 --project src/Caching/Client/Client.csproj

Run-Sample-HelloBlazorHybrid.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ rem The next line is optional - you need it if you want to debug Blazor client
33
set ASPNETCORE_ENVIRONMENT=Development
44

55
start cmd /C timeout 3 ^& start http://localhost:5005/"
6-
dotnet run --no-launch-profile -f net5.0 -p src/HelloBlazorHybrid/Server/Server.csproj
6+
dotnet run --no-launch-profile --project src/HelloBlazorHybrid/Server/Server.csproj

Run-Sample-HelloBlazorHybrid.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
export ASPNETCORE_ENVIRONMENT=Development
44

55
(sleep 3; xdg-open http://localhost:5005/) &
6-
dotnet run --no-launch-profile -f net5.0 -p src/HelloBlazorHybrid/Server/Server.csproj
6+
dotnet run --no-launch-profile --project src/HelloBlazorHybrid/Server/Server.csproj

Run-Sample-HelloBlazorServer.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ rem The next line is optional - you need it if you want to debug Blazor client
33
set ASPNETCORE_ENVIRONMENT=Development
44

55
start cmd /C timeout 3 ^& start http://localhost:5005/"
6-
dotnet run --no-launch-profile -f net5.0 -p src/HelloBlazorServer/HelloBlazorServer.csproj
6+
dotnet run --no-launch-profile --project src/HelloBlazorServer/HelloBlazorServer.csproj

Run-Sample-HelloBlazorServer.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
export ASPNETCORE_ENVIRONMENT=Development
44

55
(sleep 3; xdg-open http://localhost:5005/) &
6-
dotnet run --no-launch-profile -f net5.0 -p src/HelloBlazorServer/HelloBlazorServer.csproj
6+
dotnet run --no-launch-profile --project src/HelloBlazorServer/HelloBlazorServer.csproj

Run-Sample-HelloCart.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@echo off
2-
dotnet run -p src/HelloCart/HelloCart.csproj
2+
dotnet run --project src/HelloCart/HelloCart.csproj

Run-Sample-HelloCart.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
dotnet run -p src/HelloCart/HelloCart.csproj
2+
dotnet run --project src/HelloCart/HelloCart.csproj

Run-Sample-HelloWorld.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@echo off
2-
dotnet run -p src/HelloWorld/HelloWorld.csproj
2+
dotnet run --project src/HelloWorld/HelloWorld.csproj

Run-Sample-HelloWorld.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
dotnet run -p src/HelloWorld/HelloWorld.csproj
2+
dotnet run --project src/HelloWorld/HelloWorld.csproj

docs/tutorial/Internal/IsExternalInit.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.ComponentModel;
22

3-
#if !NET5
3+
#if !NET5_0_OR_GREATER
44

55
// ReSharper disable once CheckNamespace
66
namespace System.Runtime.CompilerServices

docs/tutorial/Tutorial.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Stl.Fusion.Client" Version="1.11.8" />
22-
<PackageReference Include="Stl.Fusion.Server" Version="1.11.8" />
21+
<PackageReference Include="Stl.Fusion.Client" Version="2.0.70" />
22+
<PackageReference Include="Stl.Fusion.Server" Version="2.0.70" />
2323
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20303.1" />
2424
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.3.0-alpha.20303.1" />
2525
</ItemGroup>

src/Blazor/Abstractions/Abstractions.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<Nullable>enable</Nullable>
77
<LangVersion>latest</LangVersion>
88
<RootNamespace>Samples.Blazor.Abstractions</RootNamespace>
99
<AssemblyName>Samples.Blazor.Abstractions</AssemblyName>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="5.0.10" />
14-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
15-
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
16-
<PackageReference Include="Stl.Fusion.Client" Version="1.11.8" />
13+
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="6.0.0" />
14+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
15+
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
16+
<PackageReference Include="Stl.Fusion.Client" Version="2.0.70" />
1717
</ItemGroup>
1818

1919
</Project>

src/Blazor/Abstractions/IChatService.cs

+65-66
Original file line numberDiff line numberDiff line change
@@ -12,82 +12,81 @@
1212
using Stl.Fusion;
1313
using Stl.Fusion.Authentication;
1414

15-
namespace Samples.Blazor.Abstractions
15+
namespace Samples.Blazor.Abstractions;
16+
17+
public class LongKeyedEntity : IHasId<long>
1618
{
17-
public class LongKeyedEntity : IHasId<long>
18-
{
19-
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
20-
public long Id { get; set; }
21-
}
19+
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
20+
public long Id { get; set; }
21+
}
2222

23-
[Index(nameof(UserId))]
24-
[Index(nameof(CreatedAt))]
25-
public class ChatMessage : LongKeyedEntity
26-
{
27-
public long UserId { get; set; }
28-
public DateTime CreatedAt { get; set; }
29-
[Required, MaxLength(4000)]
30-
public string Text { get; set; } = "";
31-
}
23+
[Index(nameof(UserId))]
24+
[Index(nameof(CreatedAt))]
25+
public class ChatMessage : LongKeyedEntity
26+
{
27+
public long UserId { get; set; }
28+
public DateTime CreatedAt { get; set; }
29+
[Required, MaxLength(4000)]
30+
public string Text { get; set; } = "";
31+
}
3232

33-
public class ChatPage
34-
{
35-
[JsonIgnore]
36-
public long? MinMessageId { get; }
37-
[JsonIgnore]
38-
public long? MaxMessageId { get; }
39-
// Must be sorted by ChatMessage.Id
40-
public List<ChatMessage> Messages { get; }
41-
public Dictionary<long, ChatUser> Users { get; }
33+
public class ChatPage
34+
{
35+
[JsonIgnore]
36+
public long? MinMessageId { get; }
37+
[JsonIgnore]
38+
public long? MaxMessageId { get; }
39+
// Must be sorted by ChatMessage.Id
40+
public List<ChatMessage> Messages { get; }
41+
public Dictionary<long, ChatUser> Users { get; }
4242

43-
public ChatPage()
44-
: this(new List<ChatMessage>(), new Dictionary<long, ChatUser>()) { }
45-
[JsonConstructor]
46-
public ChatPage(List<ChatMessage> messages, Dictionary<long, ChatUser> users)
47-
{
48-
Messages = messages;
49-
Users = users;
50-
if (messages.Count > 0) {
51-
MinMessageId = messages.Min(m => m.Id);
52-
MaxMessageId = messages.Max(m => m.Id);
53-
}
43+
public ChatPage()
44+
: this(new List<ChatMessage>(), new Dictionary<long, ChatUser>()) { }
45+
[JsonConstructor]
46+
public ChatPage(List<ChatMessage> messages, Dictionary<long, ChatUser> users)
47+
{
48+
Messages = messages;
49+
Users = users;
50+
if (messages.Count > 0) {
51+
MinMessageId = messages.Min(m => m.Id);
52+
MaxMessageId = messages.Max(m => m.Id);
5453
}
5554
}
55+
}
5656

57-
// Not an entity!
58-
public class ChatUser : LongKeyedEntity
59-
{
60-
public static ChatUser None => new() { Id = -1, Name = "No user found" };
57+
// Not an entity!
58+
public class ChatUser : LongKeyedEntity
59+
{
60+
public static ChatUser None => new() { Id = -1, Name = "No user found" };
6161

62-
[Required, MaxLength(120)]
63-
public string Name { get; set; } = "";
64-
public bool IsValid => Id >= 0;
65-
}
62+
[Required, MaxLength(120)]
63+
public string Name { get; set; } = "";
64+
public bool IsValid => Id >= 0;
65+
}
6666

67-
public interface IChatService
67+
public interface IChatService
68+
{
69+
public record PostCommand(string Text, Session Session) : ISessionCommand<ChatMessage>
6870
{
69-
public record PostCommand(string Text, Session Session) : ISessionCommand<ChatMessage>
70-
{
71-
// Default constructor is needed for JSON deserialization
72-
public PostCommand() : this(null!, Session.Null) { }
73-
}
71+
// Default constructor is needed for JSON deserialization
72+
public PostCommand() : this(null!, Session.Null) { }
73+
}
7474

75-
// Commands
76-
[CommandHandler]
77-
Task<ChatMessage> Post(PostCommand command, CancellationToken cancellationToken = default);
75+
// Commands
76+
[CommandHandler]
77+
Task<ChatMessage> Post(PostCommand command, CancellationToken cancellationToken = default);
7878

79-
// Queries
80-
[ComputeMethod(KeepAliveTime = 11)]
81-
Task<ChatUser> GetCurrentUser(Session session, CancellationToken cancellationToken = default);
82-
[ComputeMethod(KeepAliveTime = 1)]
83-
Task<ChatUser> GetUser(long id, CancellationToken cancellationToken = default);
84-
[ComputeMethod(KeepAliveTime = 61)]
85-
Task<long> GetUserCount(CancellationToken cancellationToken = default);
86-
[ComputeMethod(KeepAliveTime = 61)]
87-
Task<long> GetActiveUserCount(CancellationToken cancellationToken = default);
88-
[ComputeMethod(KeepAliveTime = 11)]
89-
Task<ChatPage> GetChatTail(int length, CancellationToken cancellationToken = default);
90-
[ComputeMethod(KeepAliveTime = 1)]
91-
Task<ChatPage> GetChatPage(long minMessageId, long maxMessageId, CancellationToken cancellationToken = default);
92-
}
79+
// Queries
80+
[ComputeMethod(KeepAliveTime = 11)]
81+
Task<ChatUser> GetCurrentUser(Session session, CancellationToken cancellationToken = default);
82+
[ComputeMethod(KeepAliveTime = 1)]
83+
Task<ChatUser> GetUser(long id, CancellationToken cancellationToken = default);
84+
[ComputeMethod(KeepAliveTime = 61)]
85+
Task<long> GetUserCount(CancellationToken cancellationToken = default);
86+
[ComputeMethod(KeepAliveTime = 61)]
87+
Task<long> GetActiveUserCount(CancellationToken cancellationToken = default);
88+
[ComputeMethod(KeepAliveTime = 11)]
89+
Task<ChatPage> GetChatTail(int length, CancellationToken cancellationToken = default);
90+
[ComputeMethod(KeepAliveTime = 1)]
91+
Task<ChatPage> GetChatPage(long minMessageId, long maxMessageId, CancellationToken cancellationToken = default);
9392
}

0 commit comments

Comments
 (0)