Skip to content

Commit

Permalink
Merge pull request #774 from neozhu/dotnet9rc2
Browse files Browse the repository at this point in the history
[Feat] .NET9 Support
  • Loading branch information
neozhu authored Nov 13, 2024
2 parents 804af81 + 0a9662e commit 44852e5
Show file tree
Hide file tree
Showing 142 changed files with 840 additions and 9,376 deletions.
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

0 comments on commit 44852e5

Please sign in to comment.