Skip to content

Commit

Permalink
#339 Migration to .NET 9
Browse files Browse the repository at this point in the history
  • Loading branch information
nkz-soft committed Dec 12, 2024
1 parent 2be7175 commit 18ac682
Show file tree
Hide file tree
Showing 34 changed files with 549 additions and 566 deletions.
12 changes: 11 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

csharp_style_namespace_declarations = file_scoped
csharp_using_directive_placement = inside_namespace

csharp_style_var_for_built_in_types = true
csharp_style_var_when_type_is_apparent = true
csharp_style_var_elsewhere = true

dotnet_style_prefer_conditional_expression_over_return = false

csharp_style_prefer_primary_constructors = false

# Space preferences
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
Expand All @@ -154,7 +165,6 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false


##################################################################################
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/
##################################################################################
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-by-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Restore Dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-by-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Restore Dependencies
Expand Down
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -30,7 +30,7 @@
</PropertyGroup>

<PropertyGroup>
<NoWarn>$(NoWarn);NETSDK1206;xUnit1028;CS1591</NoWarn>
<NoWarn>$(NoWarn);NU1902;NU1903;NU1904;NETSDK1206;xUnit1028;CS1591</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
82 changes: 41 additions & 41 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,84 +8,84 @@
<PackageVersion Include="EasyCaching.Core" Version="1.9.2" />
<PackageVersion Include="EasyCaching.Redis" Version="1.9.2" />
<PackageVersion Include="EasyCaching.Serialization.MessagePack" Version="1.9.0" />
<PackageVersion Include="FluentValidation" Version="11.10.0" />
<PackageVersion Include="FluentValidation" Version="11.11.0" />
<PackageVersion Include="HotChocolate.Abstractions" Version="14.1.0" />
<PackageVersion Include="HotChocolate.Diagnostics" Version="14.0.0" />
<PackageVersion Include="HotChocolate.AspNetCore" Version="14.1.0" />
<PackageVersion Include="HotChocolate.Data" Version="14.1.0" />
<PackageVersion Include="HotChocolate.Data.EntityFramework" Version="14.1.0" />
<PackageVersion Include="HotChocolate.Diagnostics" Version="14.2.0" />
<PackageVersion Include="HotChocolate.AspNetCore" Version="14.2.0" />
<PackageVersion Include="HotChocolate.Data" Version="14.2.0" />
<PackageVersion Include="HotChocolate.Data.EntityFramework" Version="14.2.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageVersion Include="NKZSoft.FluentValidation.Options" Version="1.2.1" />
<PackageVersion Include="Npgsql.OpenTelemetry" Version="8.0.4" />
<PackageVersion Include="NKZSoft.FluentValidation.Options" Version="1.2.2" />
<PackageVersion Include="Npgsql.OpenTelemetry" Version="9.0.2" />
<PackageVersion Include="OpenTelemetry" Version="1.10.0" />
<PackageVersion Include="OpenTelemetry.Api" Version="1.10.0" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.10.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.10.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.10.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.10.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta.12" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.10.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.MassTransit" Version="1.0.0-beta.3" />
<PackageVersion Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.0.0-rc9.14" />
<PackageVersion Include="StackExchange.Redis" Version="2.8.16" />
<PackageVersion Include="System.ServiceModel.Primitives" Version="8.0.0" />
<PackageVersion Include="StackExchange.Redis" Version="2.8.22" />
<PackageVersion Include="System.ServiceModel.Primitives" Version="8.1.0" />
<PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" />
<PackageVersion Include="AspNetCore.HealthChecks.Rabbitmq" Version="8.0.2" />
<PackageVersion Include="Microsoft.NETCore.Platforms" Version="7.0.4" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.10" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.10" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational.Design" Version="1.1.6" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.8" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.8" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.0" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.2" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
<PackageVersion Include="EFCoreSecondLevelCacheInterceptor" Version="4.8.4" />
<PackageVersion Include="EFCoreSecondLevelCacheInterceptor" Version="4.9.0" />
<PackageVersion Include="AspNetCore.HealthChecks.NpgSql" Version="8.0.2" />
<PackageVersion Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
<PackageVersion Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.10" />
<PackageVersion Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.0" />
<PackageVersion Include="Ardalis.GuardClauses" Version="5.0.0" />
<PackageVersion Include="Ardalis.Specification" Version="8.0.0" />
<PackageVersion Include="Scrutor" Version="5.0.1" />
<PackageVersion Include="Scrutor" Version="5.0.2" />
<PackageVersion Include="MediatR" Version="12.4.1" />
<PackageVersion Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.1.0" />
<PackageVersion Include="MassTransit" Version="8.3.0" />
<PackageVersion Include="MassTransit.AspNetCore" Version="7.3.1" />
<PackageVersion Include="MassTransit.Extensions.DependencyInjection" Version="7.3.1" />
<PackageVersion Include="MassTransit.RabbitMQ" Version="8.3.0" />
<PackageVersion Include="FluentResults" Version="3.16.0" />
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="11.10.0" />
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="11.11.0" />
<PackageVersion Include="Mapster" Version="7.4.0" />
<PackageVersion Include="Mapster.Async" Version="2.0.1" />
<PackageVersion Include="Mapster.DependencyInjection" Version="1.0.1" />
<PackageVersion Include="Google.Protobuf" Version="3.28.3" />
<PackageVersion Include="protobuf-net" Version="3.2.30" />
<PackageVersion Include="Google.Protobuf" Version="3.29.1" />
<PackageVersion Include="protobuf-net" Version="3.2.45" />
<PackageVersion Include="protobuf-net.Grpc.AspNetCore" Version="1.2.2" />
<PackageVersion Include="protobuf-net.Grpc.AspNetCore.Reflection" Version="1.2.2" />
<PackageVersion Include="protobuf-net.Reflection" Version="3.2.12" />
<PackageVersion Include="Grpc.Net.ClientFactory" Version="2.66.0" />
<PackageVersion Include="Serilog" Version="4.1.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Grpc.Net.ClientFactory" Version="2.67.0" />
<PackageVersion Include="Serilog" Version="4.2.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.0" />
<PackageVersion Include="Serilog.Extensions.Hosting" Version="9.0.0" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.3" />
<PackageVersion Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageVersion Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.10" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="Xunit.Extensions.Ordering" Version="1.4.5" />
<PackageVersion Include="Xunit.DependencyInjection" Version="9.4.0" />
<PackageVersion Include="Xunit.DependencyInjection" Version="9.7.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -95,13 +95,13 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="FluentAssertions" Version="6.12.2" />
<PackageVersion Include="FluentAssertions" Version="7.0.0" />
<PackageVersion Include="Respawn" Version="6.2.1" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Testcontainers" Version="4.0.0" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="3.10.0" />
<PackageVersion Include="Testcontainers.RabbitMq" Version="4.0.0" />
<PackageVersion Include="Testcontainers.Redis" Version="3.10.0" />
<PackageVersion Include="Testcontainers" Version="4.1.0" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.1.0" />
<PackageVersion Include="Testcontainers.RabbitMq" Version="4.1.0" />
<PackageVersion Include="Testcontainers.Redis" Version="4.1.0" />
<PackageVersion Include="Shouldly" Version="4.2.1" />
<PackageVersion Include="RestSharp" Version="112.1.0" />
<PackageVersion Include="NKZSoft.Service.Configuration.MassTransit.RabbitMq" Version="1.2.0" />
Expand All @@ -114,7 +114,7 @@
<PackageVersion Include="Roslynator.CodeAnalysis.Analyzers" Version="4.12.9" />
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.12.9" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.12.19" />
<PackageVersion Include="AsyncAwaitBestPractices" Version="8.0.0" />
<PackageVersion Include="AsyncAwaitBestPractices" Version="9.0.0" />
<PackageVersion Include="SerilogAnalyzer" Version="0.15.0" />
<PackageVersion Include="CSharpGuidelinesAnalyzer" Version="3.8.5" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace NKZSoft.Template.Application.Common.Behaviours;

using Exceptions;
using Template.Common.Extensions;

public sealed class ValidationBehaviour<TRequest, TResponse>(IEnumerable<IValidator<TRequest>> validators)
: IPipelineBehavior<TRequest, TResponse>
Expand Down
2 changes: 1 addition & 1 deletion src/NKZSoft.Template.Application/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.DependencyInjection.Extensions;
global using NKZSoft.Template.Application.TodoItems.Specifications;
global using NKZSoft.Template.Common;
global using NKZSoft.Template.Common.Extensions;

global using NKZSoft.Template.Domain.AggregatesModel.ToDoAggregates.Entities;
global using NKZSoft.Template.Domain.Events;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

internal sealed class ToDoItemSpecification : Specification<ToDoItem>
{
private static readonly FrozenDictionary<string, Expression<Func<ToDoItem, object>>> SortExpressions =
private static readonly FrozenDictionary<string, Expression<Func<ToDoItem, object>>> _sortExpressions =
new Dictionary<string, Expression<Func<ToDoItem, object>>>(StringComparer.OrdinalIgnoreCase)
{
{ nameof(ToDoItemFilter.Id), item => item.Id },
Expand Down Expand Up @@ -81,7 +81,7 @@ private static ISpecificationBuilder<ToDoItem> Sort(ISpecificationBuilder<ToDoIt
private static ISpecificationBuilder<ToDoItem> Sort(ISpecificationBuilder<ToDoItem> specificationBuilder,
SortDescriptor sort)
{
if (SortExpressions.TryGetValue(sort.Field, out var se))
if (_sortExpressions.TryGetValue(sort.Field, out var se))
{
return sort.Direction == EnumSortDirection.Desc
? specificationBuilder.OrderByDescending(se!)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace NKZSoft.Template.Common;
namespace NKZSoft.Template.Common.Extensions;

public static class GuardClausesExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace NKZSoft.Template.EFCore.Caching.Redis.Extensions;

using Common;
using Configuration;

public static class ServiceCollectionExtensions
Expand Down
1 change: 1 addition & 0 deletions src/NKZSoft.Template.EFCore.Caching.Redis/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
global using Microsoft.Extensions.Options;
global using NKZSoft.FluentValidation.Options;
global using StackExchange.Redis;
global using NKZSoft.Template.Common.Extensions;
2 changes: 1 addition & 1 deletion src/NKZSoft.Template.Infrastructure.Core/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
global using System.Diagnostics.CodeAnalysis;
global using Microsoft.Extensions.DependencyInjection;
global using NKZSoft.Template.Application.Common.Interfaces;
global using NKZSoft.Template.Common;
global using NKZSoft.Template.Common.Extensions;
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using NKZSoft.Template.Persistence.PostgreSQL.Common;
using NKZSoft.Template.Persistence.PostgreSQL.Extensions;

namespace NKZSoft.Template.Persistence.PostgreSQL;
namespace NKZSoft.Template.Persistence.PostgreSQL;
using Common;
using Extensions;

public class ApplicationDbContext : DbContext, IApplicationDbContext
{
private ICurrentUserService _currentUserService = null!;
private IDateTime _dateTime = null!;
private IMediator _mediator = null!;
#pragma warning disable IDE0032
private IDbInitializer _dbInitializer = null!;

#pragma warning restore IDE0032
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static IServiceCollection ConfigureDbContextFactory(this IServiceCollect
private static DbContextOptionsBuilder EnableDbLogging(this DbContextOptionsBuilder builder) => builder
.LogTo(
msg => Log.Logger.Information("{Msg}",msg),
new[] { DbLoggerCategory.Database.Name })
[DbLoggerCategory.Database.Name,])
.EnableDetailedErrors()
.EnableSensitiveDataLogging();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
global using Microsoft.Extensions.Options;
global using NKZSoft.FluentValidation.Options;
global using NKZSoft.Template.Application.Common.Interfaces;
global using NKZSoft.Template.Common;
global using NKZSoft.Template.Common.Extensions;
global using NKZSoft.Template.Domain.AggregatesModel.ToDoAggregates.Entities;
global using NKZSoft.Template.Domain.Common;
global using Npgsql;
Expand Down
Loading

0 comments on commit 18ac682

Please sign in to comment.