code style cleanup

This commit is contained in:
Aaron Po
2026-06-20 13:55:17 -04:00
parent 07aedcb866
commit 254431928f
167 changed files with 3711 additions and 3522 deletions

View File

@@ -1,12 +1,13 @@
using FluentValidation;
using FluentValidation.Results;
using MediatR;
namespace Shared.Application.Behaviors;
/// <summary>
/// MediatR pipeline behavior that runs all registered FluentValidation validators for a
/// request before invoking its handler, short-circuiting with a <see cref="ValidationException"/>
/// when any validator reports failures.
/// MediatR pipeline behavior that runs all registered FluentValidation validators for a
/// request before invoking its handler, short-circuiting with a <see cref="ValidationException" />
/// when any validator reports failures.
/// </summary>
public class ValidationBehavior<TRequest, TResponse>(IEnumerable<IValidator<TRequest>> validators)
: IPipelineBehavior<TRequest, TResponse>
@@ -18,27 +19,21 @@ public class ValidationBehavior<TRequest, TResponse>(IEnumerable<IValidator<TReq
CancellationToken cancellationToken
)
{
if (!validators.Any())
{
return await next();
}
if (!validators.Any()) return await next();
var context = new ValidationContext<TRequest>(request);
ValidationContext<TRequest> context = new(request);
var failures = (
await Task.WhenAll(
validators.Select(v => v.ValidateAsync(context, cancellationToken))
List<ValidationFailure> failures = (
await Task.WhenAll(
validators.Select(v => v.ValidateAsync(context, cancellationToken))
)
)
)
.SelectMany(result => result.Errors)
.Where(failure => failure != null)
.ToList();
if (failures.Count > 0)
{
throw new ValidationException(failures);
}
if (failures.Count > 0) throw new ValidationException(failures);
return await next();
}
}
}

View File

@@ -3,11 +3,11 @@ using MediatR;
namespace Shared.Application.Emails;
/// <summary>
/// Cross-slice command sent by Features.Auth and handled by Features.Emails to dispatch a
/// registration confirmation email, without either slice taking a project reference on the other.
/// Cross-slice command sent by Features.Auth and handled by Features.Emails to dispatch a
/// registration confirmation email, without either slice taking a project reference on the other.
/// </summary>
public record SendRegistrationEmailCommand(
string FirstName,
string Email,
string ConfirmationToken
) : IRequest;
) : IRequest;

View File

@@ -3,11 +3,11 @@ using MediatR;
namespace Shared.Application.Emails;
/// <summary>
/// Cross-slice command sent by Features.Auth and handled by Features.Emails to dispatch a
/// fresh confirmation-link email, without either slice taking a project reference on the other.
/// Cross-slice command sent by Features.Auth and handled by Features.Emails to dispatch a
/// fresh confirmation-link email, without either slice taking a project reference on the other.
/// </summary>
public record SendResendConfirmationEmailCommand(
string FirstName,
string Email,
string ConfirmationToken
) : IRequest;
) : IRequest;

View File

@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Shared.Application</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Shared.Application</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="12.4.1" />
<PackageReference Include="FluentValidation" Version="11.3.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="12.4.1"/>
<PackageReference Include="FluentValidation" Version="11.3.0"/>
</ItemGroup>
</Project>