From b70afb25a09d221c5dc286e35d5562d2ddca1cb4 Mon Sep 17 00:00:00 2001 From: Oskar Gewalli Date: Mon, 18 Nov 2024 19:24:18 +0200 Subject: [PATCH] chore: Upgrade to net8 and upgrade dependencies --- .../SampleProject.API.csproj | 26 +++++++++---------- .../Validation/CommandValidationBehavior.cs | 5 ++-- .../RemoveCustomerOrderCommandHandler.cs | 4 +-- .../SampleProject.Application.csproj | 8 +++--- .../SampleProject.Domain.csproj | 6 ++--- .../Database/SqlConnectionFactory.cs | 2 +- .../Logging/LoggingCommandHandlerDecorator.cs | 9 ++++--- .../Processing/AllConstructorFinder.cs | 2 +- .../Processing/MediatorModule.cs | 8 +----- .../UnitOfWorkCommandHandlerDecorator.cs | 4 +-- .../SampleProject.Infrastructure.csproj | 22 ++++++++-------- .../Customers/CustomersTests.cs | 2 +- .../Orders/OrdersTests.cs | 2 +- .../SampleProject.IntegrationTests.csproj | 14 +++++----- .../SeedWork/TestBase.cs | 2 +- .../SampleProject.UnitTests.csproj | 10 +++---- 16 files changed, 59 insertions(+), 67 deletions(-) diff --git a/src/SampleProject.API/SampleProject.API.csproj b/src/SampleProject.API/SampleProject.API.csproj index 50124f6..cda9a6c 100644 --- a/src/SampleProject.API/SampleProject.API.csproj +++ b/src/SampleProject.API/SampleProject.API.csproj @@ -3,9 +3,9 @@ false - netcoreapp3.1 + net8.0 54e8eb06-aaa1-4fff-9f05-3ced1cb623c2 - 7.2 + 12.0 bin\Debug\netcoreapp2.2\SampleProject.API.xml @@ -24,18 +24,18 @@ - - - - - - - - - - + + + + + + + + + + - + diff --git a/src/SampleProject.Application/Configuration/Validation/CommandValidationBehavior.cs b/src/SampleProject.Application/Configuration/Validation/CommandValidationBehavior.cs index 4542d60..52305e6 100644 --- a/src/SampleProject.Application/Configuration/Validation/CommandValidationBehavior.cs +++ b/src/SampleProject.Application/Configuration/Validation/CommandValidationBehavior.cs @@ -17,7 +17,7 @@ public CommandValidationBehavior(IList> validators) this._validators = validators; } - public Task Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate next) + public Task Handle(TRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) { var errors = _validators .Select(v => v.Validate(request)) @@ -41,5 +41,6 @@ public Task Handle(TRequest request, CancellationToken cancellationTo return next(); } -} + + } } \ No newline at end of file diff --git a/src/SampleProject.Application/Orders/RemoveCustomerOrder/RemoveCustomerOrderCommandHandler.cs b/src/SampleProject.Application/Orders/RemoveCustomerOrder/RemoveCustomerOrderCommandHandler.cs index e804f15..28a3386 100644 --- a/src/SampleProject.Application/Orders/RemoveCustomerOrder/RemoveCustomerOrderCommandHandler.cs +++ b/src/SampleProject.Application/Orders/RemoveCustomerOrder/RemoveCustomerOrderCommandHandler.cs @@ -16,13 +16,11 @@ public RemoveCustomerOrderCommandHandler(ICustomerRepository customerRepository) this._customerRepository = customerRepository; } - public async Task Handle(RemoveCustomerOrderCommand request, CancellationToken cancellationToken) + public async Task Handle(RemoveCustomerOrderCommand request, CancellationToken cancellationToken) { var customer = await this._customerRepository.GetByIdAsync(new CustomerId(request.CustomerId)); customer.RemoveOrder(new OrderId(request.OrderId)); - - return Unit.Value; } } } \ No newline at end of file diff --git a/src/SampleProject.Application/SampleProject.Application.csproj b/src/SampleProject.Application/SampleProject.Application.csproj index d3a2284..7c2303d 100644 --- a/src/SampleProject.Application/SampleProject.Application.csproj +++ b/src/SampleProject.Application/SampleProject.Application.csproj @@ -1,13 +1,13 @@ - netcoreapp3.1 + net8.0 - - - + + + diff --git a/src/SampleProject.Domain/SampleProject.Domain.csproj b/src/SampleProject.Domain/SampleProject.Domain.csproj index c5dd223..1d6b875 100644 --- a/src/SampleProject.Domain/SampleProject.Domain.csproj +++ b/src/SampleProject.Domain/SampleProject.Domain.csproj @@ -1,12 +1,12 @@ - netcoreapp3.1 - 7.2 + net8.0 + 12.0 - + diff --git a/src/SampleProject.Infrastructure/Database/SqlConnectionFactory.cs b/src/SampleProject.Infrastructure/Database/SqlConnectionFactory.cs index 45e28f8..2fe80a5 100644 --- a/src/SampleProject.Infrastructure/Database/SqlConnectionFactory.cs +++ b/src/SampleProject.Infrastructure/Database/SqlConnectionFactory.cs @@ -1,6 +1,6 @@ using System; using System.Data; -using System.Data.SqlClient; +using Microsoft.Data.SqlClient; using SampleProject.Application; using SampleProject.Application.Configuration.Data; diff --git a/src/SampleProject.Infrastructure/Logging/LoggingCommandHandlerDecorator.cs b/src/SampleProject.Infrastructure/Logging/LoggingCommandHandlerDecorator.cs index 33ede03..17d11b6 100644 --- a/src/SampleProject.Infrastructure/Logging/LoggingCommandHandlerDecorator.cs +++ b/src/SampleProject.Infrastructure/Logging/LoggingCommandHandlerDecorator.cs @@ -30,11 +30,12 @@ public LoggingCommandHandlerDecorator( _executionContextAccessor = executionContextAccessor; _decorated = decorated; } - public async Task Handle(T command, CancellationToken cancellationToken) + public async Task Handle(T command, CancellationToken cancellationToken) { if (command is IRecurringCommand) { - return await _decorated.Handle(command, cancellationToken); + await _decorated.Handle(command, cancellationToken); + return; } using ( @@ -48,11 +49,11 @@ public async Task Handle(T command, CancellationToken cancellationToken) "Executing command {Command}", command.GetType().Name); - var result = await _decorated.Handle(command, cancellationToken); + await _decorated.Handle(command, cancellationToken); this._logger.Information("Command {Command} processed successful", command.GetType().Name); - return result; + return; } catch (Exception exception) { diff --git a/src/SampleProject.Infrastructure/Processing/AllConstructorFinder.cs b/src/SampleProject.Infrastructure/Processing/AllConstructorFinder.cs index 110ff04..e436971 100644 --- a/src/SampleProject.Infrastructure/Processing/AllConstructorFinder.cs +++ b/src/SampleProject.Infrastructure/Processing/AllConstructorFinder.cs @@ -17,7 +17,7 @@ public ConstructorInfo[] FindConstructors(Type targetType) var result = Cache.GetOrAdd(targetType, t => t.GetTypeInfo().DeclaredConstructors.ToArray()); - return result.Length > 0 ? result : throw new NoConstructorsFoundException(targetType); + return result.Length > 0 ? result : throw new NoConstructorsFoundException(targetType, this); } } } \ No newline at end of file diff --git a/src/SampleProject.Infrastructure/Processing/MediatorModule.cs b/src/SampleProject.Infrastructure/Processing/MediatorModule.cs index 33efeb2..63291fe 100644 --- a/src/SampleProject.Infrastructure/Processing/MediatorModule.cs +++ b/src/SampleProject.Infrastructure/Processing/MediatorModule.cs @@ -44,12 +44,6 @@ protected override void Load(ContainerBuilder builder) builder.RegisterGeneric(typeof(RequestPostProcessorBehavior<,>)).As(typeof(IPipelineBehavior<,>)); builder.RegisterGeneric(typeof(RequestPreProcessorBehavior<,>)).As(typeof(IPipelineBehavior<,>)); - builder.Register(ctx => - { - var c = ctx.Resolve(); - return t => c.Resolve(t); - }); - builder.RegisterGeneric(typeof(CommandValidationBehavior<,>)).As(typeof(IPipelineBehavior<,>)); } @@ -69,7 +63,7 @@ public ScopedContravariantRegistrationSource(params Type[] types) public IEnumerable RegistrationsFor( Service service, - Func> registrationAccessor) + Func> registrationAccessor) { var components = _source.RegistrationsFor(service, registrationAccessor); foreach (var c in components) diff --git a/src/SampleProject.Infrastructure/Processing/UnitOfWorkCommandHandlerDecorator.cs b/src/SampleProject.Infrastructure/Processing/UnitOfWorkCommandHandlerDecorator.cs index e956ea6..cec3908 100644 --- a/src/SampleProject.Infrastructure/Processing/UnitOfWorkCommandHandlerDecorator.cs +++ b/src/SampleProject.Infrastructure/Processing/UnitOfWorkCommandHandlerDecorator.cs @@ -28,7 +28,7 @@ public UnitOfWorkCommandHandlerDecorator( _ordersContext = ordersContext; } - public async Task Handle(T command, CancellationToken cancellationToken) + public async Task Handle(T command, CancellationToken cancellationToken) { await this._decorated.Handle(command, cancellationToken); @@ -45,8 +45,6 @@ await _ordersContext.InternalCommands.FirstOrDefaultAsync(x => x.Id == command.I } await this._unitOfWork.CommitAsync(cancellationToken); - - return Unit.Value; } } } \ No newline at end of file diff --git a/src/SampleProject.Infrastructure/SampleProject.Infrastructure.csproj b/src/SampleProject.Infrastructure/SampleProject.Infrastructure.csproj index de56fe6..dca4b08 100644 --- a/src/SampleProject.Infrastructure/SampleProject.Infrastructure.csproj +++ b/src/SampleProject.Infrastructure/SampleProject.Infrastructure.csproj @@ -1,20 +1,20 @@ - netcoreapp3.1 - 7.2 + net8.0 + 12.0 - - - - - - - - - + + + + + + + + + diff --git a/src/Tests/SampleProject.IntegrationTests/Customers/CustomersTests.cs b/src/Tests/SampleProject.IntegrationTests/Customers/CustomersTests.cs index 72e6e5e..d1b72df 100644 --- a/src/Tests/SampleProject.IntegrationTests/Customers/CustomersTests.cs +++ b/src/Tests/SampleProject.IntegrationTests/Customers/CustomersTests.cs @@ -1,4 +1,4 @@ -using System.Data.SqlClient; +using Microsoft.Data.SqlClient; using System.Threading.Tasks; using NUnit.Framework; using SampleProject.Application.Customers.GetCustomerDetails; diff --git a/src/Tests/SampleProject.IntegrationTests/Orders/OrdersTests.cs b/src/Tests/SampleProject.IntegrationTests/Orders/OrdersTests.cs index e7acdd8..5fcffa0 100644 --- a/src/Tests/SampleProject.IntegrationTests/Orders/OrdersTests.cs +++ b/src/Tests/SampleProject.IntegrationTests/Orders/OrdersTests.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Data.SqlClient; +using Microsoft.Data.SqlClient; using System.Threading.Tasks; using NUnit.Framework; using SampleProject.Application.Customers.IntegrationHandlers; diff --git a/src/Tests/SampleProject.IntegrationTests/SampleProject.IntegrationTests.csproj b/src/Tests/SampleProject.IntegrationTests/SampleProject.IntegrationTests.csproj index b670852..6d41d8c 100644 --- a/src/Tests/SampleProject.IntegrationTests/SampleProject.IntegrationTests.csproj +++ b/src/Tests/SampleProject.IntegrationTests/SampleProject.IntegrationTests.csproj @@ -1,18 +1,18 @@ - netcoreapp3.1 + net8.0 false - - - - - - + + + + + + diff --git a/src/Tests/SampleProject.IntegrationTests/SeedWork/TestBase.cs b/src/Tests/SampleProject.IntegrationTests/SeedWork/TestBase.cs index 42c797f..94aa649 100644 --- a/src/Tests/SampleProject.IntegrationTests/SeedWork/TestBase.cs +++ b/src/Tests/SampleProject.IntegrationTests/SeedWork/TestBase.cs @@ -1,6 +1,6 @@ using System; using System.Data; -using System.Data.SqlClient; +using Microsoft.Data.SqlClient; using System.Threading.Tasks; using Dapper; using Microsoft.Extensions.DependencyInjection; diff --git a/src/Tests/SampleProject.UnitTests/SampleProject.UnitTests.csproj b/src/Tests/SampleProject.UnitTests/SampleProject.UnitTests.csproj index 9b8840e..2878249 100644 --- a/src/Tests/SampleProject.UnitTests/SampleProject.UnitTests.csproj +++ b/src/Tests/SampleProject.UnitTests/SampleProject.UnitTests.csproj @@ -1,16 +1,16 @@ - netcoreapp3.1 + net8.0 false - - - - + + + +