Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 13 additions & 13 deletions src/SampleProject.API/SampleProject.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<UserSecretsId>54e8eb06-aaa1-4fff-9f05-3ced1cb623c2</UserSecretsId>
<LangVersion>7.2</LangVersion>
<LangVersion>12.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp2.2\SampleProject.API.xml</DocumentationFile>
Expand All @@ -24,18 +24,18 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Autofac.Extras.CommonServiceLocator" Version="5.0.0" />
<PackageReference Include="Dapper" Version="2.0.30" />
<PackageReference Include="FluentValidation" Version="8.6.1" />
<PackageReference Include="Hellang.Middleware.ProblemDetails" Version="3.1.0" />
<PackageReference Include="MediatR" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.0" />
<PackageReference Include="Quartz" Version="3.0.7" />
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="Autofac.Extras.CommonServiceLocator" Version="6.1.0" />
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="FluentValidation" Version="11.11.0" />
<PackageReference Include="Hellang.Middleware.ProblemDetails" Version="6.5.1" />
<PackageReference Include="MediatR" Version="12.4.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
<PackageReference Include="Quartz" Version="3.13.1" />
<PackageReference Include="Serilog.Formatting.Compact" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public CommandValidationBehavior(IList<IValidator<TRequest>> validators)
this._validators = validators;
}

public Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate<TResponse> next)
public Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
{
var errors = _validators
.Select(v => v.Validate(request))
Expand All @@ -41,5 +41,6 @@ public Task<TResponse> Handle(TRequest request, CancellationToken cancellationTo

return next();
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ public RemoveCustomerOrderCommandHandler(ICustomerRepository customerRepository)
this._customerRepository = customerRepository;
}

public async Task<Unit> 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;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.30" />
<PackageReference Include="FluentValidation" Version="8.6.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="FluentValidation" Version="11.11.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/SampleProject.Domain/SampleProject.Domain.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>7.2</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MediatR" Version="8.0.0" />
<PackageReference Include="MediatR" Version="12.4.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ public LoggingCommandHandlerDecorator(
_executionContextAccessor = executionContextAccessor;
_decorated = decorated;
}
public async Task<Unit> 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 (
Expand All @@ -48,11 +49,11 @@ public async Task<Unit> 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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServiceFactory>(ctx =>
{
var c = ctx.Resolve<IComponentContext>();
return t => c.Resolve(t);
});

builder.RegisterGeneric(typeof(CommandValidationBehavior<,>)).As(typeof(IPipelineBehavior<,>));
}

Expand All @@ -69,7 +63,7 @@ public ScopedContravariantRegistrationSource(params Type[] types)

public IEnumerable<IComponentRegistration> RegistrationsFor(
Service service,
Func<Service, IEnumerable<IComponentRegistration>> registrationAccessor)
Func<Service, IEnumerable<ServiceRegistration>> registrationAccessor)
{
var components = _source.RegistrationsFor(service, registrationAccessor);
foreach (var c in components)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public UnitOfWorkCommandHandlerDecorator(
_ordersContext = ordersContext;
}

public async Task<Unit> Handle(T command, CancellationToken cancellationToken)
public async Task Handle(T command, CancellationToken cancellationToken)
{
await this._decorated.Handle(command, cancellationToken);

Expand All @@ -45,8 +45,6 @@ await _ordersContext.InternalCommands.FirstOrDefaultAsync(x => x.Id == command.I
}

await this._unitOfWork.CommitAsync(cancellationToken);

return Unit.Value;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>7.2</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Autofac.Extras.CommonServiceLocator" Version="5.0.0" />
<PackageReference Include="Dapper" Version="2.0.30" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Quartz" Version="3.0.7" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Autofac" Version="8.1.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="Autofac.Extras.CommonServiceLocator" Version="6.1.0" />
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Quartz" Version="3.13.1" />
<PackageReference Include="Serilog" Version="4.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
using System.Threading.Tasks;
using NUnit.Framework;
using SampleProject.Application.Customers.GetCustomerDetails;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.30" />
<PackageReference Include="NSubstitute" Version="4.2.1" />
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.5.1" />
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="nunit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/Tests/SampleProject.UnitTests/SampleProject.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NSubstitute" Version="4.2.1" />
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="nunit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
</ItemGroup>

<ItemGroup>
Expand Down