Skip to content

Commit

Permalink
Upgrade .net from 7.0.2 to 7.0.3
Browse files Browse the repository at this point in the history
Upgrade FluentValidation from 11.0.4 to 11.5.1
Upgrade MediatR from 11.1.0 to 12.0.0
Upgrade EntityFramework from 7.0.2 to 7.0.3
Upgrade FluentAssertions from 6.9.0 to 6.10.0
  • Loading branch information
Lanz86 authored and jasontaylordev committed Feb 24, 2023
1 parent e5eb97b commit f19bd21
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 53 deletions.
5 changes: 2 additions & 3 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.4.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.5.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace CleanArchitecture.Application.Common.Behaviours;

public class AuthorizationBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : IRequest<TResponse>
public class AuthorizationBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : notnull
{
private readonly ICurrentUserService _currentUserService;
private readonly IIdentityService _identityService;
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Common/Behaviours/PerformanceBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace CleanArchitecture.Application.Common.Behaviours;

public class PerformanceBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : IRequest<TResponse>
public class PerformanceBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : notnull
{
private readonly Stopwatch _timer;
private readonly ILogger<TRequest> _logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace CleanArchitecture.Application.Common.Behaviours;

public class UnhandledExceptionBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : IRequest<TResponse>
public class UnhandledExceptionBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : notnull
{
private readonly ILogger<TRequest> _logger;

Expand Down
2 changes: 1 addition & 1 deletion src/Application/Common/Behaviours/ValidationBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace CleanArchitecture.Application.Common.Behaviours;

public class ValidationBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
where TRequest : IRequest<TResponse>
where TRequest : notnull
{
private readonly IEnumerable<IValidator<TRequest>> _validators;

Expand Down
14 changes: 9 additions & 5 deletions src/Application/ConfigureServices.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Reflection;
using CleanArchitecture.Application.Common.Behaviours;
using CleanArchitecture.Application.Common.Exceptions;
using FluentValidation;
using MediatR;

Expand All @@ -11,11 +12,14 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection
{
services.AddAutoMapper(Assembly.GetExecutingAssembly());
services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
services.AddMediatR(Assembly.GetExecutingAssembly());
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(UnhandledExceptionBehaviour<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(AuthorizationBehaviour<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehaviour<,>));
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(PerformanceBehaviour<,>));
services.AddMediatR(cfg => {
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(UnhandledExceptionBehaviour<,>));
cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(AuthorizationBehaviour<,>));
cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(ValidationBehaviour<,>));
cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(PerformanceBehaviour<,>));
});

return services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public DeleteTodoItemCommandHandler(IApplicationDbContext context)
_context = context;
}

public async Task<Unit> Handle(DeleteTodoItemCommand request, CancellationToken cancellationToken)
public async Task Handle(DeleteTodoItemCommand request, CancellationToken cancellationToken)
{
var entity = await _context.TodoItems
.FindAsync(new object[] { request.Id }, cancellationToken);
Expand All @@ -32,7 +32,6 @@ public async Task<Unit> Handle(DeleteTodoItemCommand request, CancellationToken
entity.AddDomainEvent(new TodoItemDeletedEvent(entity));

await _context.SaveChangesAsync(cancellationToken);

return Unit.Value;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public UpdateTodoItemCommandHandler(IApplicationDbContext context)
_context = context;
}

public async Task<Unit> Handle(UpdateTodoItemCommand request, CancellationToken cancellationToken)
public async Task Handle(UpdateTodoItemCommand request, CancellationToken cancellationToken)
{
var entity = await _context.TodoItems
.FindAsync(new object[] { request.Id }, cancellationToken);
Expand All @@ -37,7 +37,5 @@ public async Task<Unit> Handle(UpdateTodoItemCommand request, CancellationToken
entity.Done = request.Done;

await _context.SaveChangesAsync(cancellationToken);

return Unit.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public UpdateTodoItemDetailCommandHandler(IApplicationDbContext context)
_context = context;
}

public async Task<Unit> Handle(UpdateTodoItemDetailCommand request, CancellationToken cancellationToken)
public async Task Handle(UpdateTodoItemDetailCommand request, CancellationToken cancellationToken)
{
var entity = await _context.TodoItems
.FindAsync(new object[] { request.Id }, cancellationToken);
Expand All @@ -41,7 +41,5 @@ public async Task<Unit> Handle(UpdateTodoItemDetailCommand request, Cancellation
entity.Note = request.Note;

await _context.SaveChangesAsync(cancellationToken);

return Unit.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public DeleteTodoListCommandHandler(IApplicationDbContext context)
_context = context;
}

public async Task<Unit> Handle(DeleteTodoListCommand request, CancellationToken cancellationToken)
public async Task Handle(DeleteTodoListCommand request, CancellationToken cancellationToken)
{
var entity = await _context.TodoLists
.Where(l => l.Id == request.Id)
Expand All @@ -31,7 +31,5 @@ public async Task<Unit> Handle(DeleteTodoListCommand request, CancellationToken
_context.TodoLists.Remove(entity);

await _context.SaveChangesAsync(cancellationToken);

return Unit.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ public PurgeTodoListsCommandHandler(IApplicationDbContext context)
_context = context;
}

public async Task<Unit> Handle(PurgeTodoListsCommand request, CancellationToken cancellationToken)
public async Task Handle(PurgeTodoListsCommand request, CancellationToken cancellationToken)
{
_context.TodoLists.RemoveRange(_context.TodoLists);

await _context.SaveChangesAsync(cancellationToken);

return Unit.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public UpdateTodoListCommandHandler(IApplicationDbContext context)
_context = context;
}

public async Task<Unit> Handle(UpdateTodoListCommand request, CancellationToken cancellationToken)
public async Task Handle(UpdateTodoListCommand request, CancellationToken cancellationToken)
{
var entity = await _context.TodoLists
.FindAsync(new object[] { request.Id }, cancellationToken);
Expand All @@ -35,6 +35,5 @@ public async Task<Unit> Handle(UpdateTodoListCommand request, CancellationToken

await _context.SaveChangesAsync(cancellationToken);

return Unit.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ namespace CleanArchitecture.Application.WeatherForecasts.Queries.GetWeatherForec

public record GetWeatherForecastsQuery : IRequest<IEnumerable<WeatherForecast>>;

public class GetWeatherForecastsQueryHandler : RequestHandler<GetWeatherForecastsQuery, IEnumerable<WeatherForecast>>
public class GetWeatherForecastsQueryHandler : IRequestHandler<GetWeatherForecastsQuery, IEnumerable<WeatherForecast>>
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

protected override IEnumerable<WeatherForecast> Handle(GetWeatherForecastsQuery request)
public async Task<IEnumerable<WeatherForecast>> Handle(GetWeatherForecastsQuery request, CancellationToken cancellationToken)
{
var rng = new Random();

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MediatR" Version="11.1.0" />
<PackageReference Include="MediatR" Version="12.0.0" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

<ItemGroup>
<PackageReference Include="CsvHelper" Version="30.0.1" />
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer" Version="7.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 9 additions & 9 deletions src/WebUI/WebUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@

<ItemGroup>
<PackageReference Include="FluentValidation.AspNetCore" Version="11.2.2" />
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.2" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2">
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer" Version="7.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.3" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="7.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="7.0.3" />
<PackageReference Include="NSwag.AspNetCore" Version="13.18.2" />
<PackageReference Include="NSwag.MSBuild" Version="13.18.2">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.9.0" />
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="Respawn" Version="6.0.0" />
</ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions tests/Application.IntegrationTests/Testing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ public static async Task<TResponse> SendAsync<TResponse>(IRequest<TResponse> req
return await mediator.Send(request);
}

public static async Task SendAsync(IBaseRequest request)
{
using var scope = _scopeFactory.CreateScope();

var mediator = scope.ServiceProvider.GetRequiredService<ISender>();

await mediator.Send(request);
}

public static string? GetCurrentUserId()
{
return _currentUserId;
Expand Down
4 changes: 2 additions & 2 deletions tests/Application.UnitTests/Application.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.9.0" />
<PackageReference Include="FluentAssertions" Version="6.10.0" />
<PackageReference Include="Moq" Version="4.18.4" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions tests/Domain.UnitTests/Domain.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.9.0" />
<PackageReference Include="FluentAssertions" Version="6.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit f19bd21

Please sign in to comment.