Skip to content

Commit

Permalink
♻️ Incapsulate validators (#452)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Mackay [SSW] <[email protected]>
  • Loading branch information
AntPolkanov and danielmackay authored Nov 28, 2024
1 parent 869b3da commit 9262725
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
<RootNamespace>SSW.CleanArchitecture.Application</RootNamespace>
<AssemblyName>SSW.CleanArchitecture.Application</AssemblyName>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Ardalis.Specification.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="ErrorOr" Version="2.0.1" />
Expand All @@ -15,4 +17,5 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Application/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static IServiceCollection AddApplication(this IServiceCollection services
{
var applicationAssembly = typeof(DependencyInjection).Assembly;

services.AddValidatorsFromAssembly(applicationAssembly);
services.AddValidatorsFromAssembly(applicationAssembly, includeInternalTypes: true);

services.AddMediatR(config =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task<ErrorOr<Guid>> Handle(CreateHeroCommand request, CancellationT
}
}

public class CreateHeroCommandValidator : AbstractValidator<CreateHeroCommand>
internal sealed class CreateHeroCommandValidator : AbstractValidator<CreateHeroCommand>
{
public CreateHeroCommandValidator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task<ErrorOr<Guid>> Handle(UpdateHeroCommand request, CancellationT
}
}

public class UpdateHeroCommandValidator : AbstractValidator<UpdateHeroCommand>
internal sealed class UpdateHeroCommandValidator : AbstractValidator<UpdateHeroCommand>
{
public UpdateHeroCommandValidator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<ErrorOr<Success>> Handle(AddHeroToTeamCommand request, Cancell
}
}

public class AddHeroToTeamCommandValidator : AbstractValidator<AddHeroToTeamCommand>
internal sealed class AddHeroToTeamCommandValidator : AbstractValidator<AddHeroToTeamCommand>
{
public AddHeroToTeamCommandValidator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task<ErrorOr<Success>> Handle(CompleteMissionCommand request, Cance
}
}

public class CompleteMissionCommandValidator : AbstractValidator<CompleteMissionCommand>
internal sealed class CompleteMissionCommandValidator : AbstractValidator<CompleteMissionCommand>
{
public CompleteMissionCommandValidator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task<ErrorOr<Success>> Handle(CreateTeamCommand request, Cancellati
}
}

public class CreateTeamCommandValidator : AbstractValidator<CreateTeamCommand>
internal sealed class CreateTeamCommandValidator : AbstractValidator<CreateTeamCommand>
{
public CreateTeamCommandValidator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task<ErrorOr<Success>> Handle(ExecuteMissionCommand request, Cancel
}
}

public class ExecuteMissionCommandValidator : AbstractValidator<ExecuteMissionCommand>
internal sealed class ExecuteMissionCommandValidator : AbstractValidator<ExecuteMissionCommand>
{
public ExecuteMissionCommandValidator()
{
Expand Down
2 changes: 0 additions & 2 deletions src/Domain/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Global using directives

global using Ardalis.Specification;
global using static System.ArgumentException;
global using static System.ArgumentNullException;
Expand Down
1 change: 0 additions & 1 deletion src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

<ItemGroup>
<ProjectReference Include="..\Application\Application.csproj" />
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 5 additions & 6 deletions src/WebApi/WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="Application.IntegrationTests" />
</ItemGroup>
Expand All @@ -21,10 +25,5 @@
</PackageReference>
<PackageReference Include="Scalar.AspNetCore" Version="1.2.39" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Application\Application.csproj" />
<ProjectReference Include="..\Domain\Domain.csproj" />
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public async Task<ErrorOr<Success>> Handle(CommandNameCommand request, Cancellat
}
}

public class CommandNameCommandValidator : AbstractValidator<CommandNameCommand>
internal sealed class CommandNameCommandValidator : AbstractValidator<CommandNameCommand>
{
public CommandNameCommandValidator()
{
Expand Down
5 changes: 2 additions & 3 deletions tests/Architecture.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Global using directives

global using FluentAssertions;
global using NetArchTest.Rules;
global using NetArchTest.Rules;
global using Xunit;
1 change: 0 additions & 1 deletion tests/Architecture.Tests/Usings.cs

This file was deleted.

File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tools/AppHost/AppHost.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0-rc.1.24511.1"/>
<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0"/>

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand Down

0 comments on commit 9262725

Please sign in to comment.