From b1349dfdd8b1085743aeb07515755dd4b7ae3eb0 Mon Sep 17 00:00:00 2001
From: Rocket Understudy <33589210+rsg-bot@users.noreply.github.com>
Date: Tue, 27 Aug 2024 19:53:40 -0400
Subject: [PATCH] Automatically linting code
---
Directory.Packages.props | 7 +-
.../Pages/Rockets/Edit.razor.cs | 15 +-
.../Sample.Core/Models/LaunchRecordModel.cs | 3 +-
sample/Sample.Core/Models/ModelMapper.cs | 5 +-
sample/Sample.Core/Models/RocketModel.cs | 6 +-
sample/Sample.Core/Models/StandardMapper.cs | 13 +-
.../LaunchRecords/CreateLaunchRecord.cs | 9 +-
.../LaunchRecords/DeleteLaunchRecord.cs | 5 +-
.../LaunchRecords/EditLaunchRecord.cs | 48 +++---
.../LaunchRecords/GetLaunchRecord.cs | 5 +-
.../LaunchRecords/ListLaunchRecords.cs | 8 +-
.../Operations/Rockets/CreateRocket.cs | 10 +-
.../Operations/Rockets/DeleteRocket.cs | 5 +-
.../Operations/Rockets/EditRocket.cs | 41 +++--
.../Operations/Rockets/GetRocket.cs | 9 +-
.../Rockets/GetRocketLaunchRecord.cs | 5 +-
.../Rockets/GetRocketLaunchRecords.cs | 5 +-
.../Operations/Rockets/ListRockets.cs | 5 +-
sample/Sample.Core/Properties/Mapping.cs | 7 +-
.../Services/LaunchRecordsService.cs | 30 ++--
sample/Sample.Grpc/Services/RocketsService.cs | 31 ++--
.../Sample.Grpc/WellKnownGrpcTypesMapper.cs | 87 +++++++---
.../Sample.Pages/Pages/Rockets/Edit.cshtml.cs | 7 +-
.../Conventions/SystemTextJsonConvention.cs | 2 +-
.../NewtonsoftJsonMapper.cs | 94 ++++++----
src/Mapping/DateTimeMapper.cs | 41 +++--
src/Mapping/NodaTimeDateTimeMapper.cs | 98 +++++++----
src/Mapping/NodaTimeMapper.cs | 161 +++++++++++-------
src/Mapping/SystemTextJsonMapper.cs | 115 +++++++------
.../Rocket.Surgery.LaunchPad.Mapping.targets | 8 +-
test/Directory.Build.targets | 49 +++---
.../Extensions.Tests/Mapping/DurationTests.cs | 20 ++-
.../Mapping/Helpers/MapperDataAttribute.cs | 6 +-
.../Mapping/Helpers/MapperTestBase.cs | 15 +-
.../Mapping/Helpers/MethodResult.cs | 47 ++---
test/Extensions.Tests/Mapping/InstantTests.cs | 36 ++--
.../Mapping/JsonElementConverterTests.cs | 75 ++++----
.../Mapping/LocalDateTests.cs | 37 ++--
.../Mapping/LocalDateTimeTests.cs | 32 ++--
.../Mapping/LocalTimeTests.cs | 36 ++--
.../Mapping/OffsetDateTimeTests.cs | 35 ++--
test/Extensions.Tests/Mapping/OffsetTests.cs | 31 ++--
test/Extensions.Tests/Mapping/PeriodTests.cs | 32 ++--
test/Extensions.Tests/ModuleInitializer.cs | 2 +-
.../FoundationTests.cs | 2 +-
.../FoundationTests.cs | 8 +-
.../ClassicFoundationTests.cs | 12 +-
test/Sample.Core.Tests/FoundationTests.cs | 8 +-
test/Sample.Graphql.Tests/FoundationTests.cs | 3 +-
test/Sample.Grpc.Tests/FoundationTests.cs | 3 +-
test/Sample.Pages.Tests/FoundationTests.cs | 2 +-
test/Sample.Restful.Tests/FoundationTests.cs | 9 +-
52 files changed, 801 insertions(+), 584 deletions(-)
diff --git a/Directory.Packages.props b/Directory.Packages.props
index ad5fcd1ee..a064fa720 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -1,4 +1,4 @@
-
+
@@ -162,5 +162,8 @@
-
+
diff --git a/sample/Sample.BlazorServer/Pages/Rockets/Edit.razor.cs b/sample/Sample.BlazorServer/Pages/Rockets/Edit.razor.cs
index e29c4a070..e44b14bf7 100644
--- a/sample/Sample.BlazorServer/Pages/Rockets/Edit.razor.cs
+++ b/sample/Sample.BlazorServer/Pages/Rockets/Edit.razor.cs
@@ -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");
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Models/LaunchRecordModel.cs b/sample/Sample.Core/Models/LaunchRecordModel.cs
index 805a1e5d9..f43d9a7b7 100644
--- a/sample/Sample.Core/Models/LaunchRecordModel.cs
+++ b/sample/Sample.Core/Models/LaunchRecordModel.cs
@@ -66,5 +66,6 @@ internal static partial class ModelMapper
{
[MapperIgnoreSource(nameof(LaunchRecord.RocketId))]
public static partial LaunchRecordModel Map(LaunchRecord launchRecord);
+
public static partial IQueryable ProjectTo(IQueryable rocket);
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Models/ModelMapper.cs b/sample/Sample.Core/Models/ModelMapper.cs
index aec212b09..c473d9c77 100644
--- a/sample/Sample.Core/Models/ModelMapper.cs
+++ b/sample/Sample.Core/Models/ModelMapper.cs
@@ -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 { }
\ No newline at end of file
diff --git a/sample/Sample.Core/Models/RocketModel.cs b/sample/Sample.Core/Models/RocketModel.cs
index 7f87b2e4a..575c6174e 100644
--- a/sample/Sample.Core/Models/RocketModel.cs
+++ b/sample/Sample.Core/Models/RocketModel.cs
@@ -1,5 +1,4 @@
using Riok.Mapperly.Abstractions;
-using Rocket.Surgery.LaunchPad.Mapping.Profiles;
using Sample.Core.Domain;
using StronglyTypedIds;
@@ -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 ProjectTo(IQueryable rocket);
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Models/StandardMapper.cs b/sample/Sample.Core/Models/StandardMapper.cs
index 489f23810..d6ae017ec 100644
--- a/sample/Sample.Core/Models/StandardMapper.cs
+++ b/sample/Sample.Core/Models/StandardMapper.cs
@@ -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);
+ }
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/LaunchRecords/CreateLaunchRecord.cs b/sample/Sample.Core/Operations/LaunchRecords/CreateLaunchRecord.cs
index c90b39b1f..613679ce6 100644
--- a/sample/Sample.Core/Operations/LaunchRecords/CreateLaunchRecord.cs
+++ b/sample/Sample.Core/Operations/LaunchRecords/CreateLaunchRecord.cs
@@ -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);
+
///
/// Create a launch record
///
@@ -83,8 +86,6 @@ public Validator()
}
}
- private static partial LaunchRecord Map(Request request);
-
private class Handler(RocketDbContext dbContext) : IRequestHandler
{
public async Task Handle(Request request, CancellationToken cancellationToken)
@@ -105,4 +106,4 @@ public async Task Handle(Request request, CancellationToken cancellati
};
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/LaunchRecords/DeleteLaunchRecord.cs b/sample/Sample.Core/Operations/LaunchRecords/DeleteLaunchRecord.cs
index 3b2882d57..9fe647542 100644
--- a/sample/Sample.Core/Operations/LaunchRecords/DeleteLaunchRecord.cs
+++ b/sample/Sample.Core/Operations/LaunchRecords/DeleteLaunchRecord.cs
@@ -8,7 +8,8 @@
namespace Sample.Core.Operations.LaunchRecords;
-[PublicAPI, Mapper]
+[PublicAPI]
+[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
public static partial class DeleteLaunchRecord
{
@@ -50,4 +51,4 @@ public async Task Handle(Request request, CancellationToken cancellationToken)
await dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs b/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs
index 083c092f9..ec460961f 100644
--- a/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs
+++ b/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs
@@ -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));
+ }
+
///
/// The launch record update request
///
@@ -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(mediator), IRequestHandler
{
- private async Task 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 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 GetRequest(PatchRequest patchRequest, CancellationToken cancellationToken)
- => Map(patchRequest, await GetLaunchRecord(patchRequest.Id, cancellationToken));
+ {
+ return Map(patchRequest, await GetLaunchRecord(patchRequest.Id, cancellationToken));
+ }
public async Task Handle(Request request, CancellationToken cancellationToken)
{
@@ -127,4 +137,4 @@ public async Task Handle(Request request, CancellationToken c
return ModelMapper.Map(rocket);
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/LaunchRecords/GetLaunchRecord.cs b/sample/Sample.Core/Operations/LaunchRecords/GetLaunchRecord.cs
index ba951a5d6..87eeff864 100644
--- a/sample/Sample.Core/Operations/LaunchRecords/GetLaunchRecord.cs
+++ b/sample/Sample.Core/Operations/LaunchRecords/GetLaunchRecord.cs
@@ -9,7 +9,8 @@
namespace Sample.Core.Operations.LaunchRecords;
-[PublicAPI, Mapper]
+[PublicAPI]
+[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
public static partial class GetLaunchRecord
{
@@ -47,4 +48,4 @@ public async Task Handle(Request request, CancellationToken c
return ModelMapper.Map(rocket);
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/LaunchRecords/ListLaunchRecords.cs b/sample/Sample.Core/Operations/LaunchRecords/ListLaunchRecords.cs
index c53e8b48b..d0e1dd25e 100644
--- a/sample/Sample.Core/Operations/LaunchRecords/ListLaunchRecords.cs
+++ b/sample/Sample.Core/Operations/LaunchRecords/ListLaunchRecords.cs
@@ -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 Project(IQueryable queryable);
+
///
/// The launch record search
///
@@ -23,7 +26,6 @@ public record Request(RocketType? RocketType) : IStreamRequest;
- private static partial IQueryable Project(IQueryable queryable);
private class Handler(RocketDbContext dbContext) : IStreamRequestHandler
{
public IAsyncEnumerable Handle(Request request, CancellationToken cancellationToken)
@@ -37,4 +39,4 @@ public IAsyncEnumerable Handle(Request request, CancellationT
return Project(query).ToAsyncEnumerable();
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/Rockets/CreateRocket.cs b/sample/Sample.Core/Operations/Rockets/CreateRocket.cs
index d537b7a41..0c94d220d 100644
--- a/sample/Sample.Core/Operations/Rockets/CreateRocket.cs
+++ b/sample/Sample.Core/Operations/Rockets/CreateRocket.cs
@@ -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);
+
///
/// The operation to create a new rocket record
///
@@ -56,8 +60,6 @@ public Validator()
}
}
- [MapperRequiredMapping(RequiredMappingStrategy.Source)]
- private static partial ReadyRocket Map(Request request);
private class Handler(RocketDbContext dbContext) : IRequestHandler
{
public async Task Handle(Request request, CancellationToken cancellationToken)
@@ -90,4 +92,4 @@ public async Task Handle(Request request, CancellationToken cancellati
};
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/Rockets/DeleteRocket.cs b/sample/Sample.Core/Operations/Rockets/DeleteRocket.cs
index 9e6b6a24b..9920edf9c 100644
--- a/sample/Sample.Core/Operations/Rockets/DeleteRocket.cs
+++ b/sample/Sample.Core/Operations/Rockets/DeleteRocket.cs
@@ -8,7 +8,8 @@
namespace Sample.Core.Operations.Rockets;
-[PublicAPI, Mapper]
+[PublicAPI]
+[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
public static partial class DeleteRocket
{
@@ -44,4 +45,4 @@ public async Task Handle(Request request, CancellationToken cancellationToken)
await dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/Rockets/EditRocket.cs b/sample/Sample.Core/Operations/Rockets/EditRocket.cs
index da99ca808..828f250d1 100644
--- a/sample/Sample.Core/Operations/Rockets/EditRocket.cs
+++ b/sample/Sample.Core/Operations/Rockets/EditRocket.cs
@@ -8,12 +8,32 @@
namespace Sample.Core.Operations.Rockets;
-[PublicAPI, Mapper]
+[PublicAPI]
+[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
[UseStaticMapper(typeof(ModelMapper))]
[UseStaticMapper(typeof(StandardMapper))]
public static partial class EditRocket
{
+ [MapperRequiredMapping(RequiredMappingStrategy.Target)]
+ public static partial Request MapRequest(ReadyRocket model);
+
+ [MapperRequiredMapping(RequiredMappingStrategy.Target)]
+ [MapProperty(nameof(RocketModel.Sn), nameof(Request.SerialNumber))]
+ public static partial Request MapRequest(RocketModel model);
+
+ [MapperRequiredMapping(RequiredMappingStrategy.Source)]
+ private static partial ReadyRocket Map(Request request);
+
+ [MapperRequiredMapping(RequiredMappingStrategy.Source)]
+ private static partial void Map(Request request, ReadyRocket record);
+
+ [MapperRequiredMapping(RequiredMappingStrategy.Source)]
+ private static Request Map(PatchRequest request, ReadyRocket rocket)
+ {
+ return request.ApplyChanges(MapRequest(rocket));
+ }
+
///
/// The edit operation to update a rocket
///
@@ -62,19 +82,6 @@ public RequestValidator()
}
}
- [MapperRequiredMapping(RequiredMappingStrategy.Source)]
- private static partial ReadyRocket Map(Request request);
- [MapperRequiredMapping(RequiredMappingStrategy.Target)]
- public static partial Request MapRequest(ReadyRocket model);
- [MapperRequiredMapping(RequiredMappingStrategy.Target)]
- [MapProperty(nameof(@RocketModel.Sn), nameof(@Request.SerialNumber))]
- public static partial Request MapRequest(RocketModel model);
- [MapperRequiredMapping(RequiredMappingStrategy.Source)]
- private static partial void Map(Request request, ReadyRocket record);
-
- [MapperRequiredMapping(RequiredMappingStrategy.Source)]
- private static Request Map(PatchRequest request, ReadyRocket rocket) => request.ApplyChanges(MapRequest(rocket));
-
private class RequestHandler(RocketDbContext dbContext, IMediator mediator)
: PatchRequestHandler(mediator), IRequestHandler
{
@@ -87,7 +94,9 @@ private async Task GetRocket(RocketId id, CancellationToken cancell
}
protected override async Task GetRequest(PatchRequest patchRequest, CancellationToken cancellationToken)
- => Map(patchRequest, await GetRocket(patchRequest.Id, cancellationToken));
+ {
+ return Map(patchRequest, await GetRocket(patchRequest.Id, cancellationToken));
+ }
public async Task Handle(Request request, CancellationToken cancellationToken)
{
@@ -101,4 +110,4 @@ public async Task Handle(Request request, CancellationToken cancell
return ModelMapper.Map(rocket);
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/Rockets/GetRocket.cs b/sample/Sample.Core/Operations/Rockets/GetRocket.cs
index a991bd372..af0625453 100644
--- a/sample/Sample.Core/Operations/Rockets/GetRocket.cs
+++ b/sample/Sample.Core/Operations/Rockets/GetRocket.cs
@@ -8,7 +8,8 @@
namespace Sample.Core.Operations.Rockets;
-[PublicAPI, Mapper]
+[PublicAPI]
+[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
public static partial class GetRocket
{
@@ -36,6 +37,8 @@ public Validator()
private class Handler(RocketDbContext dbContext) : IRequestHandler
{
public async Task Handle(Request request, CancellationToken cancellationToken)
- => ModelMapper.Map(await dbContext.Rockets.FindAsync([request.Id,], cancellationToken).ConfigureAwait(false) ?? throw new NotFoundException());
+ {
+ return ModelMapper.Map(await dbContext.Rockets.FindAsync([request.Id,], cancellationToken).ConfigureAwait(false) ?? throw new NotFoundException());
+ }
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecord.cs b/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecord.cs
index bca4de664..fcd3fb5e2 100644
--- a/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecord.cs
+++ b/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecord.cs
@@ -8,7 +8,8 @@
namespace Sample.Core.Operations.Rockets;
-[PublicAPI, Mapper]
+[PublicAPI]
+[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
public static partial class GetRocketLaunchRecord
{
@@ -45,4 +46,4 @@ public async Task Handle(Request request, CancellationToken c
return ModelMapper.Map(await dbContext.LaunchRecords.FindAsync([request.LaunchRecordId,], cancellationToken) ?? throw new NotFoundException());
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecords.cs b/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecords.cs
index f923dab59..9bd52fb72 100644
--- a/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecords.cs
+++ b/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecords.cs
@@ -10,7 +10,8 @@
namespace Sample.Core.Operations.Rockets;
-[PublicAPI, Mapper]
+[PublicAPI]
+[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
public static partial class GetRocketLaunchRecords
{
@@ -46,4 +47,4 @@ public async IAsyncEnumerable Handle(Request request, [Enumer
}
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Operations/Rockets/ListRockets.cs b/sample/Sample.Core/Operations/Rockets/ListRockets.cs
index b9bef3611..aa5a99716 100644
--- a/sample/Sample.Core/Operations/Rockets/ListRockets.cs
+++ b/sample/Sample.Core/Operations/Rockets/ListRockets.cs
@@ -8,7 +8,8 @@
namespace Sample.Core.Operations.Rockets;
-[PublicAPI, Mapper]
+[PublicAPI]
+[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
public static partial class ListRockets
{
@@ -30,4 +31,4 @@ public IAsyncEnumerable Handle(Request request, CancellationToken c
return ModelMapper.ProjectTo(query).AsAsyncEnumerable();
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Core/Properties/Mapping.cs b/sample/Sample.Core/Properties/Mapping.cs
index 525d60072..149e35db1 100644
--- a/sample/Sample.Core/Properties/Mapping.cs
+++ b/sample/Sample.Core/Properties/Mapping.cs
@@ -1,2 +1,7 @@
using Riok.Mapperly.Abstractions;
-[assembly: MapperDefaults(EnumMappingIgnoreCase = true, EnabledConversions = MappingConversionType.All ^ MappingConversionType.ImplicitCast ^ MappingConversionType.ExplicitCast)]
+
+[assembly:
+ MapperDefaults(
+ EnumMappingIgnoreCase = true,
+ EnabledConversions = MappingConversionType.All ^ MappingConversionType.ImplicitCast ^ MappingConversionType.ExplicitCast
+ )]
\ No newline at end of file
diff --git a/sample/Sample.Grpc/Services/LaunchRecordsService.cs b/sample/Sample.Grpc/Services/LaunchRecordsService.cs
index a4b4d8457..089ba2cd3 100644
--- a/sample/Sample.Grpc/Services/LaunchRecordsService.cs
+++ b/sample/Sample.Grpc/Services/LaunchRecordsService.cs
@@ -13,11 +13,23 @@ namespace Sample.Grpc.Services;
[UseStaticMapper(typeof(WellKnownGrpcTypesMapper))]
public partial class LaunchRecordsService(IMediator mediator) : LaunchRecords.LaunchRecordsBase
{
+ public static partial CreateLaunchRecord.Request Map(CreateLaunchRecordRequest request);
+ public static partial CreateLaunchRecordResponse Map(CreateLaunchRecord.Response request);
+ public static partial GetLaunchRecord.Request Map(GetLaunchRecordRequest request);
+ public static partial EditLaunchRecord.Request Map(UpdateLaunchRecordRequest request);
+ public static partial ListLaunchRecords.Request Map(ListLaunchRecordsRequest request);
+ public static partial DeleteLaunchRecord.Request Map(DeleteLaunchRecordRequest request);
+ public static partial LaunchRecordModel Map(Core.Models.LaunchRecordModel request);
+
public override async Task CreateLaunchRecord(CreateLaunchRecordRequest request, ServerCallContext context)
- => Map(await mediator.Send(Map(request), context.CancellationToken));
+ {
+ return Map(await mediator.Send(Map(request), context.CancellationToken));
+ }
public override async Task EditLaunchRecord(UpdateLaunchRecordRequest request, ServerCallContext context)
- => Map(await mediator.Send(Map(request), context.CancellationToken));
+ {
+ return Map(await mediator.Send(Map(request), context.CancellationToken));
+ }
public override async Task DeleteLaunchRecord(DeleteLaunchRecordRequest request, ServerCallContext context)
{
@@ -26,7 +38,9 @@ public override async Task DeleteLaunchRecord(DeleteLaunchRecordRequest r
}
public override async Task GetLaunchRecords(GetLaunchRecordRequest request, ServerCallContext context)
- => Map(await mediator.Send(Map(request), context.CancellationToken));
+ {
+ return Map(await mediator.Send(Map(request), context.CancellationToken));
+ }
public override async Task ListLaunchRecords(
ListLaunchRecordsRequest request,
@@ -40,14 +54,6 @@ ServerCallContext context
}
}
- public static partial CreateLaunchRecord.Request Map(CreateLaunchRecordRequest request);
- public static partial CreateLaunchRecordResponse Map(CreateLaunchRecord.Response request);
- public static partial GetLaunchRecord.Request Map(GetLaunchRecordRequest request);
- public static partial EditLaunchRecord.Request Map(UpdateLaunchRecordRequest request);
- public static partial ListLaunchRecords.Request Map(ListLaunchRecordsRequest request);
- public static partial DeleteLaunchRecord.Request Map(DeleteLaunchRecordRequest request);
- public static partial LaunchRecordModel Map(Core.Models.LaunchRecordModel request);
-
[UsedImplicitly]
private class CreateLaunchRecordRequestValidator : AbstractValidator
{
@@ -119,4 +125,4 @@ public DeleteLaunchRecordRequestValidator()
.NotNull();
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Grpc/Services/RocketsService.cs b/sample/Sample.Grpc/Services/RocketsService.cs
index 3de402ccf..1cf26745b 100644
--- a/sample/Sample.Grpc/Services/RocketsService.cs
+++ b/sample/Sample.Grpc/Services/RocketsService.cs
@@ -4,7 +4,6 @@
using MediatR;
using Riok.Mapperly.Abstractions;
using Rocket.Surgery.LaunchPad.Mapping.Profiles;
-using Sample.Core.Models;
using Sample.Core.Operations.Rockets;
namespace Sample.Grpc.Services;
@@ -14,11 +13,23 @@ namespace Sample.Grpc.Services;
[UseStaticMapper(typeof(WellKnownGrpcTypesMapper))]
public partial class RocketsService(IMediator mediator) : Rockets.RocketsBase
{
+ public static partial CreateRocket.Request Map(CreateRocketRequest request);
+ public static partial CreateRocketResponse Map(CreateRocket.Response request);
+ public static partial GetRocket.Request Map(GetRocketRequest request);
+ public static partial EditRocket.Request Map(UpdateRocketRequest request);
+ public static partial ListRockets.Request Map(ListRocketsRequest request);
+ public static partial DeleteRocket.Request Map(DeleteRocketRequest request);
+ public static partial RocketModel Map(Core.Models.RocketModel request);
+
public override async Task CreateRocket(CreateRocketRequest request, ServerCallContext context)
- => Map(await mediator.Send(Map(request), context.CancellationToken));
+ {
+ return Map(await mediator.Send(Map(request), context.CancellationToken));
+ }
public override async Task EditRocket(UpdateRocketRequest request, ServerCallContext context)
- => Map(await mediator.Send(Map(request), context.CancellationToken));
+ {
+ return Map(await mediator.Send(Map(request), context.CancellationToken));
+ }
public override async Task DeleteRocket(DeleteRocketRequest request, ServerCallContext context)
{
@@ -27,7 +38,9 @@ public override async Task DeleteRocket(DeleteRocketRequest request, Serv
}
public override async Task GetRockets(GetRocketRequest request, ServerCallContext context)
- => Map(await mediator.Send(Map(request), context.CancellationToken));
+ {
+ return Map(await mediator.Send(Map(request), context.CancellationToken));
+ }
public override async Task ListRockets(ListRocketsRequest request, IServerStreamWriter responseStream, ServerCallContext context)
{
@@ -37,14 +50,6 @@ public override async Task ListRockets(ListRocketsRequest request, IServerStream
}
}
- public static partial CreateRocket.Request Map(CreateRocketRequest request);
- public static partial CreateRocketResponse Map(CreateRocket.Response request);
- public static partial GetRocket.Request Map(GetRocketRequest request);
- public static partial EditRocket.Request Map(UpdateRocketRequest request);
- public static partial ListRockets.Request Map(ListRocketsRequest request);
- public static partial DeleteRocket.Request Map(DeleteRocketRequest request);
- public static partial RocketModel Map(Core.Models.RocketModel request);
-
[UsedImplicitly]
private class CreateRocketRequestValidator : AbstractValidator
{
@@ -104,4 +109,4 @@ public DeleteRocketRequestValidator()
.NotNull();
}
}
-}
+}
\ No newline at end of file
diff --git a/sample/Sample.Grpc/WellKnownGrpcTypesMapper.cs b/sample/Sample.Grpc/WellKnownGrpcTypesMapper.cs
index 12425ed57..e3074e2c0 100644
--- a/sample/Sample.Grpc/WellKnownGrpcTypesMapper.cs
+++ b/sample/Sample.Grpc/WellKnownGrpcTypesMapper.cs
@@ -7,42 +7,87 @@
namespace Sample.Grpc;
-[PublicAPI, Mapper]
+[PublicAPI]
+[Mapper]
[UseStaticMapper(typeof(NodaTimeMapper))]
public partial class WellKnownGrpcTypesMapper
{
- public static Instant ConvertToInstant(Timestamp ts) => Instant.FromDateTimeOffset(ts.ToDateTimeOffset());
- public static Timestamp ConvertToTimestamp(Instant ts) => Timestamp.FromDateTimeOffset(ts.ToDateTimeOffset());
+ public static Instant ConvertToInstant(Timestamp ts)
+ {
+ return Instant.FromDateTimeOffset(ts.ToDateTimeOffset());
+ }
- public static Instant? ConvertToNullableInstant(NullableTimestamp ts) =>
- ts.KindCase == NullableTimestamp.KindOneofCase.Data
+ public static Timestamp ConvertToTimestamp(Instant ts)
+ {
+ return Timestamp.FromDateTimeOffset(ts.ToDateTimeOffset());
+ }
+
+ public static Instant? ConvertToNullableInstant(NullableTimestamp ts)
+ {
+ return ts.KindCase == NullableTimestamp.KindOneofCase.Data
? Instant.FromDateTimeOffset(ts.Data.ToDateTimeOffset())
: default;
+ }
+
+ public static NullableTimestamp ConvertFromNullableInstant(Instant? ts)
+ {
+ return ts.HasValue
+ ? new() { Data = Timestamp.FromDateTimeOffset(ts.Value.ToDateTimeOffset()), }
+ : new() { Null = NullValue.NullValue, };
+ }
+
+ public static NullableTimestamp ConvertFromInstant(Instant ts)
+ {
+ return new() { Data = Timestamp.FromDateTimeOffset(ts.ToDateTimeOffset()), };
+ }
- public static NullableTimestamp ConvertFromNullableInstant(Instant? ts) => ts.HasValue
- ? new() { Data = Timestamp.FromDateTimeOffset(ts.Value.ToDateTimeOffset()) }
- : new() { Null = NullValue.NullValue };
+ public static Instant ConvertFromInstant(NullableTimestamp ts)
+ {
+ return Instant.FromDateTimeOffset(ts.Data.ToDateTimeOffset());
+ }
- public static NullableTimestamp ConvertFromInstant(Instant ts) => new() { Data = Timestamp.FromDateTimeOffset(ts.ToDateTimeOffset()) };
- public static Instant ConvertFromInstant(NullableTimestamp ts) => Instant.FromDateTimeOffset(ts.Data.ToDateTimeOffset());
+ public static Duration ConvertToDuration(WktDuration ts)
+ {
+ return Duration.FromTimeSpan(ts.ToTimeSpan());
+ }
- public static Duration ConvertToDuration(WktDuration ts) => Duration.FromTimeSpan(ts.ToTimeSpan());
- public static WktDuration ConvertToWktDuration(Duration ts) => WktDuration.FromTimeSpan(ts.ToTimeSpan());
+ public static WktDuration ConvertToWktDuration(Duration ts)
+ {
+ return WktDuration.FromTimeSpan(ts.ToTimeSpan());
+ }
- public static TimeSpan ConvertToTimeSpan(WktDuration ts) => ts.ToTimeSpan();
- public static WktDuration ConvertToWktDuration(TimeSpan ts) => WktDuration.FromTimeSpan(ts);
+ public static TimeSpan ConvertToTimeSpan(WktDuration ts)
+ {
+ return ts.ToTimeSpan();
+ }
+
+ public static WktDuration ConvertToWktDuration(TimeSpan ts)
+ {
+ return WktDuration.FromTimeSpan(ts);
+ }
public static partial RocketType MapRocketType(Core.Domain.RocketType request);
public static partial Core.Domain.RocketType MapRocketType(RocketType request);
- public static NullableRocketType MapNullableRocketType(Core.Domain.RocketType request) => new() { Data = (RocketType)request };
- public static Core.Domain.RocketType MapNullableRocketType(NullableRocketType request) => (Core.Domain.RocketType)request.Data;
+ public static NullableRocketType MapNullableRocketType(Core.Domain.RocketType request)
+ {
+ return new() { Data = (RocketType)request, };
+ }
+
+ public static Core.Domain.RocketType MapNullableRocketType(NullableRocketType request)
+ {
+ return (Core.Domain.RocketType)request.Data;
+ }
- public static NullableRocketType MapRocketType(Core.Domain.RocketType? request) =>
- request.HasValue ? new() { Data = (RocketType)request.Value } : new() { Null = NullValue.NullValue };
+ public static NullableRocketType MapRocketType(Core.Domain.RocketType? request)
+ {
+ return request.HasValue ? new() { Data = (RocketType)request.Value, } : new() { Null = NullValue.NullValue, };
+ }
- public static Core.Domain.RocketType? MapRocketType(NullableRocketType request) =>
- request.KindCase == NullableRocketType.KindOneofCase.Data
+ public static Core.Domain.RocketType? MapRocketType(NullableRocketType request)
+ {
+ return request.KindCase == NullableRocketType.KindOneofCase.Data
? (Core.Domain.RocketType)request.Data
: default;
-}
+ }
+}
\ No newline at end of file
diff --git a/sample/Sample.Pages/Pages/Rockets/Edit.cshtml.cs b/sample/Sample.Pages/Pages/Rockets/Edit.cshtml.cs
index b62612560..cab4d0261 100644
--- a/sample/Sample.Pages/Pages/Rockets/Edit.cshtml.cs
+++ b/sample/Sample.Pages/Pages/Rockets/Edit.cshtml.cs
@@ -5,7 +5,8 @@ namespace Sample.Pages.Pages.Rockets;
public class RocketEditModel : RocketViewModel
{
- [BindProperty] public EditRocket.Request Model { get; set; } = new();
+ [BindProperty]
+ public EditRocket.Request Model { get; set; } = new();
public override async Task OnGet()
{
@@ -21,7 +22,7 @@ public async Task OnPost()
return Page();
}
- await Send(Model with { Id = Id });
+ await Send(Model with { Id = Id, });
return RedirectToPage("Index");
}
-}
+}
\ No newline at end of file
diff --git a/src/Foundation/Conventions/SystemTextJsonConvention.cs b/src/Foundation/Conventions/SystemTextJsonConvention.cs
index 64754308e..b7acf4c61 100644
--- a/src/Foundation/Conventions/SystemTextJsonConvention.cs
+++ b/src/Foundation/Conventions/SystemTextJsonConvention.cs
@@ -49,4 +49,4 @@ public void Register(IConventionContext context, IConfiguration configuration, I
)
);
}
-}
+}
\ No newline at end of file
diff --git a/src/Mapping.NewtonsoftJson/NewtonsoftJsonMapper.cs b/src/Mapping.NewtonsoftJson/NewtonsoftJsonMapper.cs
index 89bd6b315..4e3ac679c 100644
--- a/src/Mapping.NewtonsoftJson/NewtonsoftJsonMapper.cs
+++ b/src/Mapping.NewtonsoftJson/NewtonsoftJsonMapper.cs
@@ -8,56 +8,84 @@
namespace Rocket.Surgery.LaunchPad.Mapping;
///
-/// Configures methods for handling well-known conversions for Newtonsoft.Json
+/// Configures methods for handling well-known conversions for Newtonsoft.Json
///
-[Mapper, PublicAPI]
+[Mapper]
+[PublicAPI]
public partial class NewtonsoftJsonMapper(IOptionsMonitor jsonSerializerOptions)
{
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// A representation of the , or the default if the is null.
- public JsonElement FromJObject(JObject? source) => source == null ? default : JsonDocument.Parse(WriteToBytes(source)).RootElement.Clone();
+ /// The to convert.
+ ///
+ /// A representation of the , or the default if the is
+ /// null.
+ ///
+ public JsonElement FromJObject(JObject? source)
+ {
+ return source == null ? default : JsonDocument.Parse(WriteToBytes(source)).RootElement.Clone();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// A representation of the , or null if the is undefined.
- public JObject? ToJObject(JsonElement source) => source.ValueKind == JsonValueKind.Undefined
- ? default
- : JObject.Parse(JsonSerializer.Serialize(source, jsonSerializerOptions.CurrentValue));
+ /// The to convert.
+ /// A representation of the , or null if the is undefined.
+ public JObject? ToJObject(JsonElement source)
+ {
+ return source.ValueKind == JsonValueKind.Undefined
+ ? default
+ : JObject.Parse(JsonSerializer.Serialize(source, jsonSerializerOptions.CurrentValue));
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// A representation of the , or the default if the is null.
- public JsonElement FromJArray(JArray? source) => source == default ? default : JsonDocument.Parse(WriteToBytes(source)).RootElement.Clone();
+ /// The to convert.
+ ///
+ /// A representation of the , or the default if the is
+ /// null.
+ ///
+ public JsonElement FromJArray(JArray? source)
+ {
+ return source == default ? default : JsonDocument.Parse(WriteToBytes(source)).RootElement.Clone();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// A representation of the , or null if the is undefined.
- public JArray? ToJArray(JsonElement source) => source.ValueKind == JsonValueKind.Undefined
- ? default
- : JArray.Parse(JsonSerializer.Serialize(source, jsonSerializerOptions.CurrentValue));
+ /// The to convert.
+ /// A representation of the , or null if the is undefined.
+ public JArray? ToJArray(JsonElement source)
+ {
+ return source.ValueKind == JsonValueKind.Undefined
+ ? default
+ : JArray.Parse(JsonSerializer.Serialize(source, jsonSerializerOptions.CurrentValue));
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// A representation of the , or the default if the is null.
- public JsonElement FromJToken(JToken? source) => source == null ? default : JsonDocument.Parse(WriteToBytes(source)).RootElement.Clone();
+ /// The to convert.
+ ///
+ /// A representation of the , or the default if the is
+ /// null.
+ ///
+ public JsonElement FromJToken(JToken? source)
+ {
+ return source == null ? default : JsonDocument.Parse(WriteToBytes(source)).RootElement.Clone();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// A representation of the , or null if the is undefined.
- public JToken? ToJToken(JsonElement source) => source.ValueKind == JsonValueKind.Undefined
- ? default
- : JToken.Parse(JsonSerializer.Serialize(source, jsonSerializerOptions.CurrentValue));
-}
+ /// The to convert.
+ /// A representation of the , or null if the is undefined.
+ public JToken? ToJToken(JsonElement source)
+ {
+ return source.ValueKind == JsonValueKind.Undefined
+ ? default
+ : JToken.Parse(JsonSerializer.Serialize(source, jsonSerializerOptions.CurrentValue));
+ }
+}
\ No newline at end of file
diff --git a/src/Mapping/DateTimeMapper.cs b/src/Mapping/DateTimeMapper.cs
index 9c1b3cd99..5407e11d0 100644
--- a/src/Mapping/DateTimeMapper.cs
+++ b/src/Mapping/DateTimeMapper.cs
@@ -3,29 +3,36 @@
namespace Rocket.Surgery.LaunchPad.Mapping;
///
-/// A mapper used to map between and
+/// A mapper used to map between and
///
///
-/// If you're using this type... you know what you're doing or you're doing it wrong.
+/// If you're using this type... you know what you're doing or you're doing it wrong.
///
-[Mapper, PublicAPI]
+[Mapper]
+[PublicAPI]
public partial class DateTimeMapper
{
///
- /// Converts a to a .
+ /// Converts a to a .
///
///
///
- public static DateTime FromDateTimeOffset(DateTimeOffset source) => source.UtcDateTime;
-///
-/// Converts a to a .
-///
-///
-///
- public static DateTimeOffset ToDateTimeOffset(DateTime source) =>
- source switch
- {
- { Kind: DateTimeKind.Unspecified or DateTimeKind.Local } => new(source.ToUniversalTime(), TimeSpan.Zero),
- { Kind: DateTimeKind.Utc } => new(source, TimeSpan.Zero),
- };
-}
+ public static DateTime FromDateTimeOffset(DateTimeOffset source)
+ {
+ return source.UtcDateTime;
+ }
+
+ ///
+ /// Converts a to a .
+ ///
+ ///
+ ///
+ public static DateTimeOffset ToDateTimeOffset(DateTime source)
+ {
+ return source switch
+ {
+ { Kind: DateTimeKind.Unspecified or DateTimeKind.Local, } => new(source.ToUniversalTime(), TimeSpan.Zero),
+ { Kind: DateTimeKind.Utc, } => new(source, TimeSpan.Zero),
+ };
+ }
+}
\ No newline at end of file
diff --git a/src/Mapping/NodaTimeDateTimeMapper.cs b/src/Mapping/NodaTimeDateTimeMapper.cs
index fcb5388b5..07b083ecb 100644
--- a/src/Mapping/NodaTimeDateTimeMapper.cs
+++ b/src/Mapping/NodaTimeDateTimeMapper.cs
@@ -4,72 +4,96 @@
namespace Rocket.Surgery.LaunchPad.Mapping;
///
-/// A mapper used to map between NodaTime and
+/// A mapper used to map between NodaTime and
///
///
-/// If you're using this type... you know what you're doing or you're doing it wrong.
+/// If you're using this type... you know what you're doing or you're doing it wrong.
///
-[Mapper, PublicAPI]
+[Mapper]
+[PublicAPI]
public partial class NodaTimeDateTimeMapper
{
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static Instant ToInstant(DateTime source) =>
- Instant.FromDateTimeUtc(
+ /// The to convert.
+ /// The equivalent .
+ public static Instant ToInstant(DateTime source)
+ {
+ return Instant.FromDateTimeUtc(
source.Kind == DateTimeKind.Unspecified
? DateTime.SpecifyKind(source, DateTimeKind.Utc)
: source.ToUniversalTime()
);
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static DateTime FromInstant(Instant source) => source.ToDateTimeUtc();
+ /// The to convert.
+ /// The equivalent .
+ public static DateTime FromInstant(Instant source)
+ {
+ return source.ToDateTimeUtc();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static LocalDate ToLocalDate(DateTime source) => LocalDate.FromDateTime(source);
+ /// The to convert.
+ /// The equivalent .
+ public static LocalDate ToLocalDate(DateTime source)
+ {
+ return LocalDate.FromDateTime(source);
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static DateTime FromLocalDate(LocalDate source) => source.AtMidnight().ToDateTimeUnspecified();
+ /// The to convert.
+ /// The equivalent .
+ public static DateTime FromLocalDate(LocalDate source)
+ {
+ return source.AtMidnight().ToDateTimeUnspecified();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static LocalDateTime ToLocalDateTime(DateTime source) => LocalDateTime.FromDateTime(source);
+ /// The to convert.
+ /// The equivalent .
+ public static LocalDateTime ToLocalDateTime(DateTime source)
+ {
+ return LocalDateTime.FromDateTime(source);
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static DateTime FromLocalDateTime(LocalDateTime source) => source.ToDateTimeUnspecified();
+ /// The to convert.
+ /// The equivalent .
+ public static DateTime FromLocalDateTime(LocalDateTime source)
+ {
+ return source.ToDateTimeUnspecified();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static LocalTime ToLocalTime(TimeSpan source) => LocalTime.FromTicksSinceMidnight(source.Ticks);
+ /// The to convert.
+ /// The equivalent .
+ public static LocalTime ToLocalTime(TimeSpan source)
+ {
+ return LocalTime.FromTicksSinceMidnight(source.Ticks);
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static TimeSpan FromLocalTime(LocalTime source) => new(source.TickOfDay);
-}
+ /// The to convert.
+ /// The equivalent .
+ public static TimeSpan FromLocalTime(LocalTime source)
+ {
+ return new(source.TickOfDay);
+ }
+}
\ No newline at end of file
diff --git a/src/Mapping/NodaTimeMapper.cs b/src/Mapping/NodaTimeMapper.cs
index 80e9a6987..89fce7f6f 100644
--- a/src/Mapping/NodaTimeMapper.cs
+++ b/src/Mapping/NodaTimeMapper.cs
@@ -5,106 +5,149 @@
namespace Rocket.Surgery.LaunchPad.Mapping.Profiles;
///
-/// A mapper used to map between NodaTime and , , and
+/// A mapper used to map between NodaTime and , , and
///
-[Mapper, PublicAPI]
+[Mapper]
+[PublicAPI]
public static partial class NodaTimeMapper
{
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static Duration ToDuration(TimeSpan source) => Duration.FromTimeSpan(source);
+ /// The to convert.
+ /// The equivalent .
+ public static Duration ToDuration(TimeSpan source)
+ {
+ return Duration.FromTimeSpan(source);
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static TimeSpan FromDuration(Duration source) => source.ToTimeSpan();
+ /// The to convert.
+ /// The equivalent .
+ public static TimeSpan FromDuration(Duration source)
+ {
+ return source.ToTimeSpan();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static Instant ToInstant(DateTimeOffset source) => Instant.FromDateTimeOffset(source);
+ /// The to convert.
+ /// The equivalent .
+ public static Instant ToInstant(DateTimeOffset source)
+ {
+ return Instant.FromDateTimeOffset(source);
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static DateTimeOffset FromInstant(Instant source) => source.ToDateTimeOffset();
+ /// The to convert.
+ /// The equivalent .
+ public static DateTimeOffset FromInstant(Instant source)
+ {
+ return source.ToDateTimeOffset();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static LocalDate ToLocalDate(DateOnly source) => LocalDate.FromDateOnly(source);
+ /// The to convert.
+ /// The equivalent .
+ public static LocalDate ToLocalDate(DateOnly source)
+ {
+ return LocalDate.FromDateOnly(source);
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static DateOnly FromLocalDate(LocalDate source) => source.ToDateOnly();
+ /// The to convert.
+ /// The equivalent .
+ public static DateOnly FromLocalDate(LocalDate source)
+ {
+ return source.ToDateOnly();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static LocalTime ToLocalTime(TimeOnly source) => LocalTime.FromTimeOnly(source);
+ /// The to convert.
+ /// The equivalent .
+ public static LocalTime ToLocalTime(TimeOnly source)
+ {
+ return LocalTime.FromTimeOnly(source);
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static TimeOnly FromLocalTime(LocalTime source) => source.ToTimeOnly();
+ /// The to convert.
+ /// The equivalent .
+ public static TimeOnly FromLocalTime(LocalTime source)
+ {
+ return source.ToTimeOnly();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static Offset ToOffset(TimeSpan source) => Offset.FromTicks(source.Ticks);
+ /// The to convert.
+ /// The equivalent .
+ public static Offset ToOffset(TimeSpan source)
+ {
+ return Offset.FromTicks(source.Ticks);
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static TimeSpan FromOffset(Offset source) => source.ToTimeSpan();
+ /// The to convert.
+ /// The equivalent .
+ public static TimeSpan FromOffset(Offset source)
+ {
+ return source.ToTimeSpan();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static OffsetDateTime ToOffsetDateTime(DateTimeOffset source) => OffsetDateTime.FromDateTimeOffset(source);
+ /// The to convert.
+ /// The equivalent .
+ public static OffsetDateTime ToOffsetDateTime(DateTimeOffset source)
+ {
+ return OffsetDateTime.FromDateTimeOffset(source);
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static DateTimeOffset FromOffsetDateTime(OffsetDateTime source) => source.ToDateTimeOffset();
+ /// The to convert.
+ /// The equivalent .
+ public static DateTimeOffset FromOffsetDateTime(OffsetDateTime source)
+ {
+ return source.ToDateTimeOffset();
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static Period ToPeriod(string source) => PeriodPattern.Roundtrip.Parse(source).Value;
+ /// The to convert.
+ /// The equivalent .
+ public static Period ToPeriod(string source)
+ {
+ return PeriodPattern.Roundtrip.Parse(source).Value;
+ }
///
- /// Converts a to a .
+ /// Converts a to a .
///
- /// The to convert.
- /// The equivalent .
- public static string FromPeriod(Period source) => source.ToString();
-}
+ /// The to convert.
+ /// The equivalent .
+ public static string FromPeriod(Period source)
+ {
+ return source.ToString();
+ }
+}
\ No newline at end of file
diff --git a/src/Mapping/SystemTextJsonMapper.cs b/src/Mapping/SystemTextJsonMapper.cs
index da8a6256c..6c565da0e 100644
--- a/src/Mapping/SystemTextJsonMapper.cs
+++ b/src/Mapping/SystemTextJsonMapper.cs
@@ -5,107 +5,106 @@
namespace Rocket.Surgery.LaunchPad.Mapping;
///
-/// Configures methods for well-known conversions with STJ
+/// Configures methods for well-known conversions with STJ
///
-/// The to use for serialization.
-[Mapper, PublicAPI]
+/// The to use for serialization.
+[Mapper]
+[PublicAPI]
public partial class SystemTextJsonMapper(IOptionsMonitor options)
{
///
- /// Converts a to a byte array.
+ /// Converts a to a byte array.
///
- /// The to convert.
- /// A byte array representation of the , or null if the is undefined.
+ /// The to convert.
+ /// A byte array representation of the , or null if the is undefined.
[UserMapping]
- public byte[]? JsonElementToByteArray(JsonElement source) =>
- source is { ValueKind: not JsonValueKind.Undefined }
+ public byte[]? JsonElementToByteArray(JsonElement source)
+ {
+ return source is { ValueKind: not JsonValueKind.Undefined, }
? JsonSerializer.SerializeToUtf8Bytes(source, options.CurrentValue)
: null;
+ }
///
- /// Converts a nullable to a byte array.
+ /// Converts a nullable to a byte array.
///
- /// The to convert.
- /// A byte array representation of the , or null if the is undefined.
+ /// The to convert.
+ /// A byte array representation of the , or null if the is undefined.
[UserMapping]
- public byte[]? JsonElementToByteArray(JsonElement? source) =>
- source is { ValueKind: not JsonValueKind.Undefined }
+ public byte[]? JsonElementToByteArray(JsonElement? source)
+ {
+ return source is { ValueKind: not JsonValueKind.Undefined, }
? JsonSerializer.SerializeToUtf8Bytes(source, options.CurrentValue)
: null;
+ }
///
- /// Converts a to a string.
+ /// Converts a to a string.
///
- /// The to convert.
- /// A string representation of the , or null if the is undefined.
+ /// The to convert.
+ /// A string representation of the , or null if the is undefined.
[UserMapping]
- public string? JsonElementToString(JsonElement source) =>
- source is { ValueKind: not JsonValueKind.Undefined }
+ public string? JsonElementToString(JsonElement source)
+ {
+ return source is { ValueKind: not JsonValueKind.Undefined, }
? JsonSerializer.Serialize(source, options.CurrentValue)
: null;
+ }
///
- /// Converts a nullable to a string.
+ /// Converts a nullable to a string.
///
- /// The to convert.
- /// A string representation of the , or null if the is undefined.
+ /// The to convert.
+ /// A string representation of the , or null if the is undefined.
[UserMapping]
- public string? JsonElementToString(JsonElement? source) =>
- source is { ValueKind: not JsonValueKind.Undefined }
+ public string? JsonElementToString(JsonElement? source)
+ {
+ return source is { ValueKind: not JsonValueKind.Undefined, }
? JsonSerializer.Serialize(source.Value, options.CurrentValue)
: null;
+ }
///
- /// Converts a byte array to a .
+ /// Converts a byte array to a .
///
/// The byte array to convert.
- /// A representation of the byte array, or the default if the byte array is null or empty.
+ /// A representation of the byte array, or the default if the byte array is null or empty.
[UserMapping]
- public JsonElement ByteArrayToJsonElement(byte[]? source) =>
- source switch
- {
- null or { Length: 0 } => new(),
- _ => JsonSerializer.Deserialize(source, options.CurrentValue)
- };
+ public JsonElement ByteArrayToJsonElement(byte[]? source)
+ {
+ return source switch { null or { Length: 0, } => new(), _ => JsonSerializer.Deserialize(source, options.CurrentValue), };
+ }
///
- /// Converts a byte array to a .
+ /// Converts a byte array to a .
///
/// The byte array to convert.
- /// A representation of the byte array, or the default if the byte array is null or empty.
+ /// A representation of the byte array, or the default if the byte array is null or empty.
[UserMapping]
- public JsonElement? ByteArrayToNullableJsonElement(byte[]? source) =>
- source switch
- {
- null => null,
- { Length: 0 } => new(),
- _ => JsonSerializer.Deserialize(source, options.CurrentValue)
- };
+ public JsonElement? ByteArrayToNullableJsonElement(byte[]? source)
+ {
+ return source switch { null => null, { Length: 0, } => new(), _ => JsonSerializer.Deserialize(source, options.CurrentValue), };
+ }
///
- /// Converts a string to a .
+ /// Converts a string to a .
///
/// The string to convert.
- /// A representation of the string, or the default if the string is null or empty.
+ /// A representation of the string, or the default if the string is null or empty.
[UserMapping]
- public JsonElement StringToJsonElement(string? source) =>
- source switch
- {
- null or { Length: 0 } => new(),
- _ => JsonSerializer.Deserialize(source, options.CurrentValue)
- };
+ public JsonElement StringToJsonElement(string? source)
+ {
+ return source switch { null or { Length: 0, } => new(), _ => JsonSerializer.Deserialize(source, options.CurrentValue), };
+ }
///
- /// Converts a string to a .
+ /// Converts a string to a .
///
/// The string to convert.
- /// A representation of the string, or the default if the string is null or empty.
+ /// A representation of the string, or the default if the string is null or empty.
[UserMapping]
- public JsonElement? StringToNullableJsonElement(string? source) =>
- source switch
- {
- null => null,
- { Length: 0 } => new(),
- _ => JsonSerializer.Deserialize(source, options.CurrentValue)
- };
-}
+ public JsonElement? StringToNullableJsonElement(string? source)
+ {
+ return source switch { null => null, { Length: 0, } => new(), _ => JsonSerializer.Deserialize(source, options.CurrentValue), };
+ }
+}
\ No newline at end of file
diff --git a/src/Mapping/build/Rocket.Surgery.LaunchPad.Mapping.targets b/src/Mapping/build/Rocket.Surgery.LaunchPad.Mapping.targets
index 3e98108ac..67dd5156c 100644
--- a/src/Mapping/build/Rocket.Surgery.LaunchPad.Mapping.targets
+++ b/src/Mapping/build/Rocket.Surgery.LaunchPad.Mapping.targets
@@ -1,8 +1,8 @@
-
-
-
-
+
+
+
+
diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets
index 46232fca7..ca8ebe08d 100644
--- a/test/Directory.Build.targets
+++ b/test/Directory.Build.targets
@@ -1,31 +1,30 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
diff --git a/test/Extensions.Tests/Mapping/DurationTests.cs b/test/Extensions.Tests/Mapping/DurationTests.cs
index 1ffbcea12..ae53823e4 100644
--- a/test/Extensions.Tests/Mapping/DurationTests.cs
+++ b/test/Extensions.Tests/Mapping/DurationTests.cs
@@ -8,7 +8,16 @@ namespace Extensions.Tests.Mapping;
public partial class DurationTests(ITestOutputHelper testOutputHelper) : MapperTestBase(testOutputHelper)
{
- [Mapper, PublicAPI]
+ [Theory]
+ [MapperData]
+ public Task Maps_All_Methods(MethodResult result)
+ {
+ return VerifyMethod(result, new Mapper(), TimeSpan.FromHours(1), Duration.FromMinutes(44))
+ .UseHashedParameters(result.ToString());
+ }
+
+ [Mapper]
+ [PublicAPI]
[UseStaticMapper(typeof(NodaTimeMapper))]
private partial class Mapper
{
@@ -48,11 +57,4 @@ private class Foo4
{
public TimeSpan? Bar { get; set; }
}
-
- [Theory, MapperData]
- public Task Maps_All_Methods(MethodResult result)
- {
- return VerifyMethod(result, new Mapper(), TimeSpan.FromHours(1), Duration.FromMinutes(44))
- .UseHashedParameters(result.ToString());
- }
-}
+}
\ No newline at end of file
diff --git a/test/Extensions.Tests/Mapping/Helpers/MapperDataAttribute.cs b/test/Extensions.Tests/Mapping/Helpers/MapperDataAttribute.cs
index 5d49be27c..26f695c4e 100644
--- a/test/Extensions.Tests/Mapping/Helpers/MapperDataAttribute.cs
+++ b/test/Extensions.Tests/Mapping/Helpers/MapperDataAttribute.cs
@@ -13,8 +13,8 @@ public override IEnumerable