Skip to content

Commit

Permalink
Automatically linting code
Browse files Browse the repository at this point in the history
  • Loading branch information
rsg-bot authored Aug 27, 2024
1 parent 2df39b3 commit b1349df
Show file tree
Hide file tree
Showing 52 changed files with 801 additions and 584 deletions.
7 changes: 5 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<ItemGroup>
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.7.0" />
Expand Down Expand Up @@ -162,5 +162,8 @@
<PackageVersion Include="Verify.NewtonsoftJson" Version="1.1.0" />
<PackageVersion Include="Verify.SourceGenerators" Version="2.3.0" />
</ItemGroup>
<Import Project="$(MSBuildThisFileDirectory)/Directory.Packages.support.props" Condition="Exists('$(MSBuildThisFileDirectory)/Directory.Packages.support.props')" />
<Import
Project="$(MSBuildThisFileDirectory)/Directory.Packages.support.props"
Condition="Exists('$(MSBuildThisFileDirectory)/Directory.Packages.support.props')"
/>
</Project>
15 changes: 9 additions & 6 deletions sample/Sample.BlazorServer/Pages/Rockets/Edit.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@ namespace Sample.BlazorServer.Pages.Rockets;

public partial class Edit : ComponentBase
{
[Parameter] public RocketId Id { get; set; }
[Parameter]
public RocketId Id { get; set; }

public EditRocket.Request Model { get; set; } = new();

[Inject] private NavigationManager NavigationManager { get; set; } = null!;
[Inject]
private NavigationManager NavigationManager { get; set; } = null!;

[Inject] private IMediator Mediator { get; set; } = null!;
[Inject]
private IMediator Mediator { get; set; } = null!;

protected override async Task OnInitializedAsync()
{
Model = EditRocket.MapRequest(await Mediator.Send(new GetRocket.Request { Id = Id }));
Model = EditRocket.MapRequest(await Mediator.Send(new GetRocket.Request { Id = Id, }));
}

public async Task Save()
{
await Mediator.Send(Model with { Id = Id });
await Mediator.Send(Model with { Id = Id, });
NavigationManager.NavigateTo("/rockets");
}
}
}
3 changes: 2 additions & 1 deletion sample/Sample.Core/Models/LaunchRecordModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ internal static partial class ModelMapper
{
[MapperIgnoreSource(nameof(LaunchRecord.RocketId))]
public static partial LaunchRecordModel Map(LaunchRecord launchRecord);

public static partial IQueryable<LaunchRecordModel> ProjectTo(IQueryable<LaunchRecord> rocket);
}
}
5 changes: 1 addition & 4 deletions sample/Sample.Core/Models/ModelMapper.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using Riok.Mapperly.Abstractions;
using Rocket.Surgery.LaunchPad.Mapping.Profiles;
using Sample.Core.Domain;

namespace Sample.Core.Models;

[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
[UseStaticMapper(typeof(StandardMapper))]
[UseStaticMapper(typeof(NodaTimeMapper))]
internal static partial class ModelMapper
{
}
internal static partial class ModelMapper { }
6 changes: 3 additions & 3 deletions sample/Sample.Core/Models/RocketModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
using Rocket.Surgery.LaunchPad.Mapping.Profiles;
using Sample.Core.Domain;
using StronglyTypedIds;

Expand Down Expand Up @@ -36,7 +35,8 @@ public record RocketModel

internal static partial class ModelMapper
{
[MapProperty(nameof(@ReadyRocket.SerialNumber), nameof(@RocketModel.Sn))]
[MapProperty(nameof(ReadyRocket.SerialNumber), nameof(RocketModel.Sn))]
public static partial RocketModel Map(ReadyRocket rocket);

public static partial IQueryable<RocketModel> ProjectTo(IQueryable<ReadyRocket> rocket);
}
}
13 changes: 10 additions & 3 deletions sample/Sample.Core/Models/StandardMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ namespace Sample.Core;
[Mapper]
internal static partial class StandardMapper
{
public static long LongToDouble(double value) => Convert.ToInt64(value);
public static double DoubleToLong(long value) => Convert.ToDouble(value);
}
public static long LongToDouble(double value)
{
return Convert.ToInt64(value);
}

public static double DoubleToLong(long value)
{
return Convert.ToDouble(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@

namespace Sample.Core.Operations.LaunchRecords;

[PublicAPI, Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Source)]
[PublicAPI]
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Source)]
[UseStaticMapper(typeof(NodaTimeMapper))]
[UseStaticMapper(typeof(ModelMapper))]
[UseStaticMapper(typeof(StandardMapper))]
public static partial class CreateLaunchRecord
{
private static partial LaunchRecord Map(Request request);

/// <summary>
/// Create a launch record
/// </summary>
Expand Down Expand Up @@ -83,8 +86,6 @@ public Validator()
}
}

private static partial LaunchRecord Map(Request request);

private class Handler(RocketDbContext dbContext) : IRequestHandler<Request, Response>
{
public async Task<Response> Handle(Request request, CancellationToken cancellationToken)
Expand All @@ -105,4 +106,4 @@ public async Task<Response> Handle(Request request, CancellationToken cancellati
};
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

namespace Sample.Core.Operations.LaunchRecords;

[PublicAPI, Mapper]
[PublicAPI]
[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
public static partial class DeleteLaunchRecord
{
Expand Down Expand Up @@ -50,4 +51,4 @@ public async Task Handle(Request request, CancellationToken cancellationToken)
await dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
}
}
}
}
48 changes: 29 additions & 19 deletions sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,27 @@

namespace Sample.Core.Operations.LaunchRecords;

[PublicAPI, Mapper]
[PublicAPI]
[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
[UseStaticMapper(typeof(ModelMapper))]
[UseStaticMapper(typeof(StandardMapper))]
public static partial class EditLaunchRecord
{
[MapperIgnoreTarget(nameof(LaunchRecord.Rocket))]
private static partial LaunchRecord Map(Request request);

[MapperIgnoreSource(nameof(LaunchRecord.Rocket))]
private static partial Request Map(LaunchRecord model);

[MapperIgnoreTarget(nameof(LaunchRecord.Rocket))]
private static partial void Map(Request request, LaunchRecord record);

private static Request Map(PatchRequest request, LaunchRecord record)
{
return request.ApplyChanges(Map(record));
}

/// <summary>
/// The launch record update request
/// </summary>
Expand Down Expand Up @@ -93,28 +108,23 @@ public Validator()
}
}

[MapperIgnoreTarget(nameof(@LaunchRecord.Rocket))]
private static partial LaunchRecord Map(Request request);

[MapperIgnoreSource(nameof(@LaunchRecord.Rocket))]
private static partial Request Map(LaunchRecord model);

[MapperIgnoreTarget(nameof(@LaunchRecord.Rocket))]
private static partial void Map(Request request, LaunchRecord record);
private static Request Map(PatchRequest request, LaunchRecord record) => request.ApplyChanges(Map(record));

private class Handler(RocketDbContext dbContext, IMediator mediator)
: PatchRequestHandler<Request, PatchRequest, LaunchRecordModel>(mediator), IRequestHandler<Request, LaunchRecordModel>
{
private async Task<LaunchRecord> GetLaunchRecord(LaunchRecordId id, CancellationToken cancellationToken) => await dbContext
.LaunchRecords
.Include(z => z.Rocket)
.FirstOrDefaultAsync(z => z.Id == id, cancellationToken)
.ConfigureAwait(false)
?? throw new NotFoundException();
private async Task<LaunchRecord> GetLaunchRecord(LaunchRecordId id, CancellationToken cancellationToken)
{
return await dbContext
.LaunchRecords
.Include(z => z.Rocket)
.FirstOrDefaultAsync(z => z.Id == id, cancellationToken)
.ConfigureAwait(false)
?? throw new NotFoundException();
}

protected override async Task<Request> GetRequest(PatchRequest patchRequest, CancellationToken cancellationToken)
=> Map(patchRequest, await GetLaunchRecord(patchRequest.Id, cancellationToken));
{
return Map(patchRequest, await GetLaunchRecord(patchRequest.Id, cancellationToken));
}

public async Task<LaunchRecordModel> Handle(Request request, CancellationToken cancellationToken)
{
Expand All @@ -127,4 +137,4 @@ public async Task<LaunchRecordModel> Handle(Request request, CancellationToken c
return ModelMapper.Map(rocket);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

namespace Sample.Core.Operations.LaunchRecords;

[PublicAPI, Mapper]
[PublicAPI]
[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
public static partial class GetLaunchRecord
{
Expand Down Expand Up @@ -47,4 +48,4 @@ public async Task<LaunchRecordModel> Handle(Request request, CancellationToken c
return ModelMapper.Map(rocket);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@

namespace Sample.Core.Operations.LaunchRecords;

[PublicAPI, Mapper]
[PublicAPI]
[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
[UseStaticMapper(typeof(ModelMapper))]
[UseStaticMapper(typeof(StandardMapper))]
public static partial class ListLaunchRecords
{
private static partial IQueryable<LaunchRecordModel> Project(IQueryable<LaunchRecord> queryable);

/// <summary>
/// The launch record search
/// </summary>
Expand All @@ -23,7 +26,6 @@ public record Request(RocketType? RocketType) : IStreamRequest<LaunchRecordModel

private class Validator : AbstractValidator<Request>;

private static partial IQueryable<LaunchRecordModel> Project(IQueryable<LaunchRecord> queryable);
private class Handler(RocketDbContext dbContext) : IStreamRequestHandler<Request, LaunchRecordModel>
{
public IAsyncEnumerable<LaunchRecordModel> Handle(Request request, CancellationToken cancellationToken)
Expand All @@ -37,4 +39,4 @@ public IAsyncEnumerable<LaunchRecordModel> Handle(Request request, CancellationT
return Project(query).ToAsyncEnumerable();
}
}
}
}
10 changes: 6 additions & 4 deletions sample/Sample.Core/Operations/Rockets/CreateRocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@

namespace Sample.Core.Operations.Rockets;

[PublicAPI, Mapper]
[PublicAPI]
[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
[UseStaticMapper(typeof(ModelMapper))]
[UseStaticMapper(typeof(StandardMapper))]
public static partial class CreateRocket
{
[MapperRequiredMapping(RequiredMappingStrategy.Source)]
private static partial ReadyRocket Map(Request request);

/// <summary>
/// The operation to create a new rocket record
/// </summary>
Expand Down Expand Up @@ -56,8 +60,6 @@ public Validator()
}
}

[MapperRequiredMapping(RequiredMappingStrategy.Source)]
private static partial ReadyRocket Map(Request request);
private class Handler(RocketDbContext dbContext) : IRequestHandler<Request, Response>
{
public async Task<Response> Handle(Request request, CancellationToken cancellationToken)
Expand Down Expand Up @@ -90,4 +92,4 @@ public async Task<Response> Handle(Request request, CancellationToken cancellati
};
}
}
}
}
5 changes: 3 additions & 2 deletions sample/Sample.Core/Operations/Rockets/DeleteRocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

namespace Sample.Core.Operations.Rockets;

[PublicAPI, Mapper]
[PublicAPI]
[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
public static partial class DeleteRocket
{
Expand Down Expand Up @@ -44,4 +45,4 @@ public async Task Handle(Request request, CancellationToken cancellationToken)
await dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
}
}
}
}
Loading

0 comments on commit b1349df

Please sign in to comment.