Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rocket Surgery Extensions to 13.0.0-beta.36 #2481

Merged
merged 14 commits into from
Jan 15, 2025
2 changes: 1 addition & 1 deletion .github/workflows/close-milestone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
default-label: ':sparkles: mysterious'
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: 📲 Install GitReleaseManager
uses: gittools/actions/gitreleasemanager/[email protected].2
uses: gittools/actions/gitreleasemanager/[email protected].1
with:
versionSpec: '0.18.0'
- name: Get Repo and Owner
Expand Down
5 changes: 3 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<PackageVersion Include="Serilog.Sinks.Spectre" Version="0.5.0" />
<PackageVersion Include="Serilog.Sinks.Trace" Version="4.0.0" />
<PackageVersion Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.2.0" />
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
<PackageVersion Include="xunit.analyzers" Version="1.19.0" />
<PackageVersion Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageVersion Include="JetBrains.dotCover.CommandLineTools" Version="2024.3.3" />
Expand Down Expand Up @@ -120,8 +121,8 @@
<PackageVersion Include="Rocket.Surgery.Conventions.DryIoc" Version="14.0.1-beta.45" />
<PackageVersion Include="Rocket.Surgery.Conventions.Serilog" Version="14.0.1-beta.45" />
<PackageVersion Include="Rocket.Surgery.CommandLine" Version="14.0.1-beta.45" />
<PackageVersion Include="Rocket.Surgery.DependencyInjection.Extensions" Version="13.0.0-beta.34" />
<PackageVersion Include="Rocket.Surgery.Extensions" Version="13.0.0-beta.34" />
<PackageVersion Include="Rocket.Surgery.DependencyInjection.Extensions" Version="13.0.0-beta.36" />
<PackageVersion Include="Rocket.Surgery.Extensions" Version="13.0.0-beta.36" />
<PackageVersion Include="Rocket.Surgery.Hosting" Version="14.0.1-beta.45" />
<PackageVersion Include="Rocket.Surgery.WebAssembly.Hosting" Version="14.0.1-beta.45" />
<PackageVersion Include="Scrutor" Version="5.1.1" />
Expand Down
5 changes: 4 additions & 1 deletion sample/Sample.BlazorServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@

await app.RunAsync();

public partial class Program;
namespace Sample.BlazorServer
{
public partial class Program;
}
63 changes: 33 additions & 30 deletions sample/Sample.BlazorWasm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,46 @@

await ( await builder.ConfigureRocketSurgery() ).RunAsync();

public static class TestHandler
namespace Sample.BlazorWasm
{
public record Request : IRequest<Response>
public static class TestHandler
{
public string FirstName { get; set; } = null!;
public string LastName { get; set; } = null!;
}
public record Request : IRequest<Response>
{
public string FirstName { get; set; } = null!;
public string LastName { get; set; } = null!;
}

public record Response(string FullName);
public record Response(string FullName);

[UsedImplicitly]
private class RequestValidator : AbstractValidator<Request>
{
public RequestValidator()
[UsedImplicitly]
private class RequestValidator : AbstractValidator<Request>
{
RuleFor(x => x.FirstName)
.NotEmpty()
.MinimumLength(1)
.MaximumLength(20);
RuleFor(x => x.LastName)
.NotEmpty()
.MinimumLength(1)
.MaximumLength(50);
public RequestValidator()
{
RuleFor(x => x.FirstName)
.NotEmpty()
.MinimumLength(1)
.MaximumLength(20);
RuleFor(x => x.LastName)
.NotEmpty()
.MinimumLength(1)
.MaximumLength(50);
}
}
}

[UsedImplicitly]
private class ResponseValidator : AbstractValidator<Response>
{
public ResponseValidator() => RuleFor(z => z.FullName).NotEmpty();
}
[UsedImplicitly]
private class ResponseValidator : AbstractValidator<Response>
{
public ResponseValidator() => RuleFor(z => z.FullName).NotEmpty();
}

[UsedImplicitly]
private class Handler : IRequestHandler<Request, Response>
{
public Task<Response> Handle(Request request, CancellationToken cancellationToken) => Task.FromResult(
new Response(request.FirstName + " " + request.LastName)
);
[UsedImplicitly]
private class Handler : IRequestHandler<Request, Response>
{
public Task<Response> Handle(Request request, CancellationToken cancellationToken) => Task.FromResult(
new Response(request.FirstName + " " + request.LastName)
);
}
}
}
5 changes: 4 additions & 1 deletion sample/Sample.Classic.Restful/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@

await app.RunAsync();

public partial class Program;
namespace Sample.Classic.Restful
{
public partial class Program;
}
45 changes: 25 additions & 20 deletions sample/Sample.Command/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Rocket.Surgery.Conventions;
using Rocket.Surgery.Hosting;

using Sample.Command;

using Spectre.Console.Cli;

var builder = Host.CreateApplicationBuilder(args);
Expand All @@ -28,33 +30,36 @@
);
await host.RunAsync();

public class InstanceThing
namespace Sample.Command
{
public string From => "DryIoc";
}
public class InstanceThing
{
public string From => "DryIoc";
}

public class Dump(IConfiguration configuration, ILogger<Dump> logger, InstanceThing instanceThing)
: Command<AppSettings>
{
public override int Execute([NotNull] CommandContext context, [NotNull] AppSettings settings)
public class Dump(IConfiguration configuration, ILogger<Dump> logger, InstanceThing instanceThing)
: Command<AppSettings>
{
// ReSharper disable once TemplateIsNotCompileTimeConstantProblem
logger.LogInformation(instanceThing.From);
foreach (var item in configuration.AsEnumerable().Reverse())
public override int Execute([NotNull] CommandContext context, [NotNull] AppSettings settings)
{
logger.LogInformation("{Key}: {Value}", item.Key, item.Value ?? "");
}
// ReSharper disable once TemplateIsNotCompileTimeConstantProblem
logger.LogInformation(instanceThing.From);
foreach (var item in configuration.AsEnumerable().Reverse())
{
logger.LogInformation("{Key}: {Value}", item.Key, item.Value ?? "");
}

return 1;
return 1;
}
}
}

public class DefaultCommand(ILogger<DefaultCommand> logger) : Command<AppSettings>
{
public override int Execute([NotNull] CommandContext context, [NotNull] AppSettings settings)
public class DefaultCommand(ILogger<DefaultCommand> logger) : Command<AppSettings>
{
Console.WriteLine("Hello World!");
logger.LogInformation("Test");
return 1;
public override int Execute([NotNull] CommandContext context, [NotNull] AppSettings settings)
{
Console.WriteLine("Hello World!");
logger.LogInformation("Test");
return 1;
}
}
}
6 changes: 3 additions & 3 deletions sample/Sample.Core/Models/ModelMapper.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Riok.Mapperly.Abstractions;
using Rocket.Surgery.LaunchPad.Mapping.Profiles;
using Riok.Mapperly.Abstractions;
using NodaTimeMapper = Rocket.Surgery.LaunchPad.Mapping.NodaTimeMapper;

namespace Sample.Core.Models;

[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
[UseStaticMapper(typeof(StandardMapper))]
[UseStaticMapper(typeof(NodaTimeMapper))]
internal static partial class ModelMapper { }
internal static partial class ModelMapper { }
16 changes: 5 additions & 11 deletions sample/Sample.Core/Models/StandardMapper.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
using Riok.Mapperly.Abstractions;
using Riok.Mapperly.Abstractions;

namespace Sample.Core;
namespace Sample.Core.Models;

[Mapper]
internal static partial class StandardMapper
{
public static long LongToDouble(double value)
{
return Convert.ToInt64(value);
}
public static long LongToDouble(double value) => Convert.ToInt64(value);

public static double DoubleToLong(long value)
{
return Convert.ToDouble(value);
}
}
public static double DoubleToLong(long value) => Convert.ToDouble(value);
}
25 changes: 14 additions & 11 deletions sample/Sample.Core/Operations/LaunchRecords/CreateLaunchRecord.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
using FluentValidation;
using FluentValidation;

using MediatR;

using NodaTime;

using Riok.Mapperly.Abstractions;
using Rocket.Surgery.LaunchPad.Foundation;
using Rocket.Surgery.LaunchPad.Mapping.Profiles;

using Rocket.Surgery.LaunchPad.Mapping;
using Rocket.Surgery.LaunchPad.Primitives;

using Sample.Core.Domain;
using Sample.Core.Models;

Expand All @@ -16,8 +21,6 @@ namespace Sample.Core.Operations.LaunchRecords;
[UseStaticMapper(typeof(StandardMapper))]
public static partial class CreateLaunchRecord
{
private static partial LaunchRecord Map(Request request);

/// <summary>
/// Create a launch record
/// </summary>
Expand All @@ -31,12 +34,12 @@ public record Request : IRequest<Response>
/// <summary>
/// The launch partner
/// </summary>
public string? Partner { get; set; } = null!; // TODO: Make generator that can be used to create a writable view model
public string? Partner { get; set; } // TODO: Make generator that can be used to create a writable view model

/// <summary>
/// The launch partners payload
/// </summary>
public string? Payload { get; set; } = null!; // TODO: Make generator that can be used to create a writable view model
public string? Payload { get; set; } // TODO: Make generator that can be used to create a writable view model

/// <summary>
/// The payload weight
Expand Down Expand Up @@ -92,9 +95,7 @@ public async Task<Response> Handle(Request request, CancellationToken cancellati
{
var record = Map(request);

var rocket = await dbContext.Rockets.FindAsync(new object[] { request.RocketId, }, cancellationToken);
if (rocket == null) throw new RequestFailedException("Rocket not found!");

var rocket = await dbContext.Rockets.FindAsync([request.RocketId], cancellationToken) ?? throw new RequestFailedException("Rocket not found!");
record.Rocket = rocket;

await dbContext.AddAsync(record, cancellationToken).ConfigureAwait(false);
Expand All @@ -106,4 +107,6 @@ public async Task<Response> Handle(Request request, CancellationToken cancellati
};
}
}
}

private static partial LaunchRecord Map(Request request);
}
22 changes: 11 additions & 11 deletions sample/Sample.Core/Operations/LaunchRecords/DeleteLaunchRecord.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using FluentValidation;
using FluentValidation;

using MediatR;

using Riok.Mapperly.Abstractions;
using Rocket.Surgery.LaunchPad.Foundation;
using Rocket.Surgery.LaunchPad.Mapping.Profiles;

using Rocket.Surgery.LaunchPad.Mapping;
using Rocket.Surgery.LaunchPad.Primitives;

using Sample.Core.Domain;
using Sample.Core.Models;

Expand All @@ -22,21 +26,17 @@ public record Request(LaunchRecordId Id) : IRequest;
[UsedImplicitly]
private class Validator : AbstractValidator<Request>
{
public Validator()
{
RuleFor(x => x.Id)
.NotEmpty()
.NotNull();
}
public Validator() => RuleFor(x => x.Id)
.NotEmpty()
.NotNull();
}

[UsedImplicitly]
private class Handler(RocketDbContext dbContext) : IRequestHandler<Request>
{
public async Task Handle(Request request, CancellationToken cancellationToken)
{
var rocket = await dbContext.LaunchRecords.FindAsync(new object[] { request.Id, }, cancellationToken);
if (rocket == null) throw new NotFoundException();
var rocket = await dbContext.LaunchRecords.FindAsync([request.Id], cancellationToken) ?? throw new NotFoundException();

// contrived for testing
if (rocket.Id == new LaunchRecordId(new("bad361de-a6d5-425a-9cf6-f9b2dd236be6")))
Expand Down
Loading
Loading