Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] .NET9 Support #774

Merged
merged 49 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
60c5d81
migration to dotnet 9 rc.2
neozhu Oct 9, 2024
7666415
fix workflows
neozhu Oct 9, 2024
9020405
Update Domain.csproj
neozhu Oct 9, 2024
c8f88f5
Update dotnet.yml
neozhu Oct 9, 2024
1dbf7e7
commit
neozhu Oct 10, 2024
f592b62
Merge branch 'main' into dotnet9rc2
neozhu Oct 10, 2024
b8b732e
Updated: Development Requirements in the README
Bram1903 Oct 11, 2024
85f36d7
Merge branch 'main' into dotnet9rc2
neozhu Oct 11, 2024
2b0302f
Merge branch 'main' into dotnet9rc2
Bram1903 Oct 17, 2024
e0f8a8a
Updated: Dependencies
Bram1903 Oct 17, 2024
2122764
Merge branch 'main' into dotnet9rc2
neozhu Oct 19, 2024
751f7f6
merge from main
neozhu Oct 19, 2024
e89773a
Merge branch 'main' into dotnet9rc2
neozhu Oct 19, 2024
8c42aec
Merge branch 'main' into dotnet9rc2
neozhu Oct 20, 2024
2f3359a
Merge branch 'main' into dotnet9rc2
Bram1903 Oct 28, 2024
fdb93f0
Fixed: Merge Issue
Bram1903 Oct 28, 2024
bb0635d
Fixed: Build Error
Bram1903 Oct 28, 2024
fe3402d
Fixed: MudBlazor v8.0.0-preview.2 compatibility
Bram1903 Oct 28, 2024
ea3f11e
Merge branch 'main' into dotnet9rc2
neozhu Nov 1, 2024
ae92c20
clear
neozhu Nov 1, 2024
d00b4f4
Merge branch 'main' into dotnet9rc2
neozhu Nov 1, 2024
cf7bd6a
Merge branch 'main' into dotnet9rc2
neozhu Nov 2, 2024
40e617d
Merge branch 'main' into dotnet9rc2
neozhu Nov 3, 2024
b3e4d85
Merge branch 'main' into dotnet9rc2
neozhu Nov 3, 2024
c4e2de9
add blazor-error-boundary
neozhu Nov 4, 2024
eb95f34
Merge branch 'main' into dotnet9rc2
neozhu Nov 6, 2024
b5dcd53
migration
neozhu Nov 6, 2024
e15e36f
Merge branch 'dotnet9rc2' of https://github.com/neozhu/CleanArchitect…
neozhu Nov 6, 2024
edf2552
Merge branch 'main' into dotnet9rc2
neozhu Nov 8, 2024
ab04c6e
Merge branch 'main' into dotnet9rc2
neozhu Nov 9, 2024
8d668ea
Update Application.csproj
neozhu Nov 9, 2024
5612cf4
"TargetFramework": "net9"
neozhu Nov 9, 2024
69cafa9
fixed input font-size
neozhu Nov 9, 2024
ac90f37
Update SerilogExtensions.cs
neozhu Nov 9, 2024
a24d9b0
Update UserSessionCircuitHandler.cs
neozhu Nov 9, 2024
1f5df04
Update SerilogExtensions.cs
neozhu Nov 9, 2024
fdac12f
Update Infrastructure.csproj
neozhu Nov 10, 2024
a48285d
Update DependencyInjection.cs
neozhu Nov 10, 2024
278b6dc
clean
neozhu Nov 11, 2024
1fb4910
remove LazyCache replace with FusionCache
neozhu Nov 11, 2024
a7789ee
Update Application.csproj
neozhu Nov 11, 2024
f0a1a64
recreate migration for SQLite
neozhu Nov 11, 2024
baf732b
fix
neozhu Nov 11, 2024
9275e50
Update Logs.razor
neozhu Nov 11, 2024
b5611d4
Circuit handler to capture users
neozhu Nov 12, 2024
d7c64b1
clear code
neozhu Nov 12, 2024
54a3e58
test code generate
neozhu Nov 12, 2024
789d6b7
@Assets
neozhu Nov 12, 2024
0a9662e
upgrade to dotnet 9
neozhu Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-version: 9.0.x


- name: Restore dependencies
run: dotnet restore CleanArchitecture.Blazor.sln
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x

- name: Restore dependencies
run: dotnet restore CleanArchitecture.Blazor.sln
- name: Build
Expand Down
1 change: 1 addition & 0 deletions CleanArchitecture.Blazor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
CleanArchitecture.Blazor.nuspec = CleanArchitecture.Blazor.nuspec
README.md = README.md
Dockerfile = Dockerfile
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{21DC0B96-ED87-4130-BA8D-E8CF73903344}"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
# apt update and install fonts
RUN echo "deb http://deb.debian.org/debian/ bookworm main contrib" > /etc/apt/sources.list && \
echo "deb-src http://deb.debian.org/debian/ bookworm main contrib" >> /etc/apt/sources.list && \
Expand Down Expand Up @@ -33,7 +33,7 @@ EXPOSE 443



FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/Migrators/Migrators.MSSQL/Migrators.MSSQL.csproj", "src/Migrators/Migrators.MSSQL/"]
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ Explore the application's features and design through screenshots and a video wa

To get started with development, ensure you have the following tools and environments set up:

- Microsoft Visual Studio Community 2022 (64-bit)
- Docker
- .NET 8.0
- Unit Test Framework

- [.NET 9.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)
- [Microsoft Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) or [Rider](https://www.jetbrains.com/rider/)
- [Docker](https://www.docker.com/)




## Authentication Setup
Expand Down
11 changes: 9 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.8'
version: '3.8'

services:
dashboard:
Expand All @@ -16,6 +16,13 @@ services:
- SmtpClientOptions__Port=
- SmtpClientOptions__User=
- SmtpClientOptions__Password=
- SmtpClientOptions__DefaultFromEmail=
- Authentication__Microsoft__ClientId=
- Authentication__Microsoft__ClientSecret=
- Authentication__Google__ClientId=
- Authentication__Google__ClientSecret=
- ASPNETCORE_HTTP_PORTS=80
- ASPNETCORE_HTTPS_PORTS=443
- ASPNETCORE_URLS=https://+:443;http://+:80
#- ASPNETCORE_Kestrel__Certificates__Default__Password=Password@123
#- ASPNETCORE_Kestrel__Certificates__Default__Path=/root/.aspnet/https/CleanArchitecture.Blazor.Server.UI.pfx
Expand All @@ -30,7 +37,7 @@ services:
restart: on-failure

sqldb:
image: "mcr.microsoft.com/mssql/server:2019-latest"
image: "mcr.microsoft.com/mssql/server:2022-latest"
environment:
- "SA_PASSWORD=Password@123"
- "ACCEPT_EULA=Y"
Expand Down
19 changes: 8 additions & 11 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>CleanArchitecture.Blazor.Application</RootNamespace>
<AssemblyName>CleanArchitecture.Blazor.Application</AssemblyName>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>default</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.5.0-beta.105" />
<PackageReference Include="Ardalis.Specification" Version="8.0.0" />
<PackageReference Include="Ardalis.Specification.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="ClosedXML" Version="0.104.1" />
Expand All @@ -17,17 +17,14 @@
<PackageReference Include="jcamp.FluentEmail.Razor" Version="3.8.0" />
<PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.10.0" />
<PackageReference Include="LazyCache" Version="2.4.0" />
<PackageReference Include="LazyCache.AspNetCore" Version="2.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.10" />
<PackageReference Include="Riok.Mapperly" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Riok.Mapperly" Version="4.1.1-next.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.8" />
<PackageReference Include="Hangfire.Core" Version="1.8.15" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.15" />
<PackageReference Include="Hangfire.InMemory" Version="1.0.0" />
<PackageReference Include="ZiggyCreatures.FusionCache" Version="1.4.1" />
<PackageReference Include="ActualLab.Fusion" Version="9.5.59" />
<PackageReference Include="ZiggyCreatures.FusionCache" Version="2.0.0-preview-1" />
<PackageReference Include="ActualLab.Fusion" Version="9.5.59" />
<PackageReference Include="ActualLab.Fusion.Blazor" Version="9.5.59" />
<PackageReference Include="ActualLab.Generators" Version="9.5.59" />
</ItemGroup>
Expand Down
41 changes: 41 additions & 0 deletions src/Application/Common/FusionCache/FusionCacheFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Microsoft.Extensions.DependencyInjection;
using ZiggyCreatures.Caching.Fusion;

namespace CleanArchitecture.Blazor.Application.Common.FusionCache;
public static class FusionCacheFactory
{
private static IServiceProvider? _serviceProvider;

public static void Configure(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}

public static IFusionCache GetCache()
{
if (_serviceProvider == null)
throw new InvalidOperationException("Service provider not configured.");

return _serviceProvider.GetRequiredService<IFusionCache>();
}
public static void ClearCache()
{
if (_serviceProvider == null)
throw new InvalidOperationException("Service provider not configured.");
var cache = _serviceProvider.GetRequiredService<IFusionCache>();
cache.Clear();
}
public static void RemoveByTags(IEnumerable<string>? tags)
{
if (_serviceProvider == null)
throw new InvalidOperationException("Service provider not configured.");
var cache = _serviceProvider.GetRequiredService<IFusionCache>();
if(tags is not null && tags.Any())
{
foreach(var tag in tags)
{
cache.RemoveByTag(tag);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace CleanArchitecture.Blazor.Application.Common.Interfaces.Caching;
public interface ICacheInvalidatorRequest<TResponse> : IRequest<TResponse>
{
string CacheKey => string.Empty;
CancellationTokenSource? SharedExpiryTokenSource { get; }
IEnumerable<string>? Tags { get; }
}

public interface IFusionCacheRefreshRequest<TResponse> : IRequest<TResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace CleanArchitecture.Blazor.Application.Common.Interfaces.Caching;
public interface ICacheableRequest<TResponse> : IRequest<TResponse>
{
string CacheKey => string.Empty;
MemoryCacheEntryOptions? Options { get; }
IEnumerable<string>? Tags { get; }
}

public interface IFusionCacheRequest<TResponse> : IRequest<TResponse>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Org.BouncyCastle.Bcpg;

namespace CleanArchitecture.Blazor.Application.Common.Interfaces.Identity;
namespace CleanArchitecture.Blazor.Application.Common.Interfaces.Identity;

/// <summary>
/// Interface to access the current user's session information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace CleanArchitecture.Blazor.Application.Common.Interfaces.Identity;
using System.Security.Claims;

namespace CleanArchitecture.Blazor.Application.Common.Interfaces.Identity;

/// <summary>
/// Interface for setting and clearing the current user context.
Expand All @@ -8,8 +10,8 @@ public interface ICurrentUserContextSetter
/// <summary>
/// Sets the current user context with the provided session information.
/// </summary>
/// <param name="sessionInfo">The session information of the current user.</param>
void SetCurrentUser(SessionInfo sessionInfo);
/// <param name="user">The session information of the current user.</param>
void SetCurrentUser(ClaimsPrincipal user);

/// <summary>
/// Clears the current user context.
Expand Down
21 changes: 0 additions & 21 deletions src/Application/Common/Mappings/MappingExtensions.cs

This file was deleted.

8 changes: 5 additions & 3 deletions src/Application/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using CleanArchitecture.Blazor.Application.Pipeline;
using CleanArchitecture.Blazor.Application.Pipeline.PreProcessors;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace CleanArchitecture.Blazor.Application;

Expand All @@ -20,14 +21,15 @@ public static IServiceCollection AddApplication(this IServiceCollection services
config.NotificationPublisher = new ParallelNoWaitPublisher();
config.AddRequestPreProcessor(typeof(IRequestPreProcessor<>), typeof(ValidationPreProcessor<>));
config.AddOpenBehavior(typeof(PerformanceBehaviour<,>));
config.AddOpenBehavior(typeof(MemoryCacheBehaviour<,>));
config.AddOpenBehavior(typeof(FusionCacheBehaviour<,>));
config.AddOpenBehavior(typeof(CacheInvalidationBehaviour<,>));

});

services.AddLazyCache();
services.AddScoped<UserProfileStateService>();
return services;
}
public static void InitializeCacheFactory(this IHost host)
{
FusionCacheFactory.Configure(host.Services);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,16 @@ namespace CleanArchitecture.Blazor.Application.Features.AuditTrails.Caching;
public static class AuditTrailsCacheKey
{
public const string GetAllCacheKey = "all-audittrails";
private static readonly TimeSpan RefreshInterval = TimeSpan.FromSeconds(30);
private static readonly object _tokenLock = new();
private static CancellationTokenSource _tokenSource = new(RefreshInterval);


public static MemoryCacheEntryOptions MemoryCacheEntryOptions =>
new MemoryCacheEntryOptions().AddExpirationToken(new CancellationChangeToken(GetOrCreateTokenSource().Token));

public static string GetPaginationCacheKey(string parameters)
{
return $"AuditTrailsWithPaginationQuery,{parameters}";
}

public static CancellationTokenSource GetOrCreateTokenSource()
{
lock (_tokenLock)
{
if (_tokenSource.IsCancellationRequested)
{
_tokenSource.Dispose();
_tokenSource = new CancellationTokenSource(RefreshInterval);
}
return _tokenSource;
}
}

public static IEnumerable<string>? Tags => new string[] { "audittrail" };
public static void Refresh()
{
lock (_tokenLock)
{
if (!_tokenSource.IsCancellationRequested)
{
_tokenSource.Cancel();
_tokenSource.Dispose();
_tokenSource = new CancellationTokenSource(RefreshInterval);
}
}
FusionCacheFactory.RemoveByTags(Tags);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AuditTrailsWithPaginationQuery : AuditTrailAdvancedFilter, ICacheab
{
public AuditTrailAdvancedSpecification Specification => new(this);
public string CacheKey => AuditTrailsCacheKey.GetPaginationCacheKey($"{this}");
public MemoryCacheEntryOptions? Options => AuditTrailsCacheKey.MemoryCacheEntryOptions;
public IEnumerable<string>? Tags => AuditTrailsCacheKey.Tags;

public override string ToString()
{
Expand Down
Loading
Loading