Skip to content

Commit

Permalink
updated to the latest conventions (#1994)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-driscoll committed May 2, 2024
1 parent 6019d4a commit 4fecf0c
Show file tree
Hide file tree
Showing 26 changed files with 98 additions and 182 deletions.
14 changes: 7 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@
<PackageVersion Include="Polly" Version="8.3.1" />
<PackageVersion Include="StronglyTypedId" Version="1.0.0-beta08" />
<PackageVersion Include="Rocket.Surgery.Build.Information" Version="3.3.11" />
<PackageVersion Include="Rocket.Surgery.Conventions" Version="14.0.0-beta.22" />
<PackageVersion Include="Rocket.Surgery.Conventions.Abstractions" Version="14.0.0-beta.22" />
<PackageVersion Include="Rocket.Surgery.CommandLine" Version="14.0.0-beta.22" />
<PackageVersion Include="Rocket.Surgery.Conventions.DependencyModel" Version="14.0.0-beta.22" />
<PackageVersion Include="Rocket.Surgery.Conventions.DryIoc" Version="14.0.0-beta.22" />
<PackageVersion Include="Rocket.Surgery.Conventions" Version="14.0.1-beta.1" />
<PackageVersion Include="Rocket.Surgery.Conventions.Abstractions" Version="14.0.1-beta.1" />
<PackageVersion Include="Rocket.Surgery.CommandLine" Version="14.0.1-beta.1" />
<PackageVersion Include="Rocket.Surgery.Conventions.DependencyModel" Version="14.0.1-beta.1" />
<PackageVersion Include="Rocket.Surgery.Conventions.DryIoc" Version="14.0.1-beta.1" />
<PackageVersion Include="Rocket.Surgery.DependencyInjection.Extensions" Version="12.1.0" />
<PackageVersion Include="Rocket.Surgery.Extensions" Version="12.1.0" />
<PackageVersion Include="Rocket.Surgery.Hosting" Version="14.0.0-beta.22" />
<PackageVersion Include="Rocket.Surgery.WebAssembly.Hosting" Version="14.0.0-beta.22" />
<PackageVersion Include="Rocket.Surgery.Hosting" Version="14.0.1-beta.1" />
<PackageVersion Include="Rocket.Surgery.WebAssembly.Hosting" Version="14.0.1-beta.1" />
<PackageVersion Include="Scrutor" Version="4.2.2" />
<PackageVersion Include="Serilog" Version="3.1.1" />
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.1" />
Expand Down
15 changes: 0 additions & 15 deletions LaunchPad.sln
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.BlazorWasm", "sample
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.BlazorWasm.Tests", "test\Sample.BlazorWasm.Tests\Sample.BlazorWasm.Tests.csproj", "{A2C670CA-EFDD-468E-BEA1-D6D5A97270C4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.LaunchPad.Web.Hosting", "src\Web.Hosting\Rocket.Surgery.LaunchPad.Web.Hosting.csproj", "{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Classic.Restful", "sample\Sample.Classic.Restful\Sample.Classic.Restful.csproj", "{2C09FAF6-434D-442F-94B2-02AB906B477C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Classic.Restful.Tests", "test\Sample.Classic.Restful.Tests\Sample.Classic.Restful.Tests.csproj", "{2EF6A468-3689-4407-8A11-2E3F5DEDAC0A}"
Expand Down Expand Up @@ -706,18 +704,6 @@ Global
{A2C670CA-EFDD-468E-BEA1-D6D5A97270C4}.Release|x64.Build.0 = Release|Any CPU
{A2C670CA-EFDD-468E-BEA1-D6D5A97270C4}.Release|x86.ActiveCfg = Release|Any CPU
{A2C670CA-EFDD-468E-BEA1-D6D5A97270C4}.Release|x86.Build.0 = Release|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Debug|x64.ActiveCfg = Debug|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Debug|x64.Build.0 = Debug|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Debug|x86.ActiveCfg = Debug|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Debug|x86.Build.0 = Debug|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Release|Any CPU.Build.0 = Release|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Release|x64.ActiveCfg = Release|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Release|x64.Build.0 = Release|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Release|x86.ActiveCfg = Release|Any CPU
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF}.Release|x86.Build.0 = Release|Any CPU
{2C09FAF6-434D-442F-94B2-02AB906B477C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C09FAF6-434D-442F-94B2-02AB906B477C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C09FAF6-434D-442F-94B2-02AB906B477C}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -850,7 +836,6 @@ Global
{A64647FF-BCBA-4B13-BC99-CDE23C1D3CE8} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3}
{B786542C-3EE7-4B6C-9C5B-23E5CA4FE07C} = {5D11C19B-E8E4-4CE3-9C8A-1D368578EBCB}
{A2C670CA-EFDD-468E-BEA1-D6D5A97270C4} = {DF33E0FB-9790-4654-B60F-8AB22E0CC3D1}
{10D4A16B-F9F0-4D88-8705-7AB36E20D8EF} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3}
{2C09FAF6-434D-442F-94B2-02AB906B477C} = {5D11C19B-E8E4-4CE3-9C8A-1D368578EBCB}
{2EF6A468-3689-4407-8A11-2E3F5DEDAC0A} = {DF33E0FB-9790-4654-B60F-8AB22E0CC3D1}
{9700269F-7954-49DE-8096-D5A941A2F4D0} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Web.Hosting\Rocket.Surgery.LaunchPad.Web.Hosting.csproj" />
<ProjectReference Include="..\..\src\AspNetCore\Rocket.Surgery.LaunchPad.AspNetCore.csproj" />
<ProjectReference Include="..\Sample.Core\Sample.Core.csproj" />
<PackageReference
Include="Microsoft.Extensions.ApiDescription.Server"
Expand Down
2 changes: 0 additions & 2 deletions sample/Sample.Core/Domain/RocketDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class RocketDbContext(DbContextOptions<RocketDbContext>? options = null)
public DbSet<ReadyRocket> Rockets { get; set; } = null!;
public DbSet<LaunchRecord> LaunchRecords { get; set; } = null!;

#if NET6_0_OR_GREATER
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
configurationBuilder
Expand All @@ -21,7 +20,6 @@ protected override void ConfigureConventions(ModelConfigurationBuilder configura
.Properties<RocketId>()
.HaveConversion<RocketId.EfCoreValueConverter>();
}
#endif
}

public class StronglyTypedIdValueConverterSelector(ValueConverterSelectorDependencies dependencies) : ValueConverterSelector(dependencies)
Expand Down
6 changes: 1 addition & 5 deletions sample/Sample.Graphql/Sample.Graphql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ProjectReference Include="..\..\src\AspNetCore\Rocket.Surgery.LaunchPad.AspNetCore.csproj" />
<ProjectReference Include="..\..\src\HotChocolate\Rocket.Surgery.LaunchPad.HotChocolate.csproj" />
<ProjectReference Include="..\..\src\Spatial\Rocket.Surgery.LaunchPad.Spatial.csproj" />
<ProjectReference Include="..\..\src\Web.Hosting\Rocket.Surgery.LaunchPad.Web.Hosting.csproj" />
<ProjectReference Include="..\..\src\AspNetCore\Rocket.Surgery.LaunchPad.AspNetCore.csproj" />
<ProjectReference Include="..\..\src\Serilog\Rocket.Surgery.LaunchPad.Serilog.csproj" />
<ProjectReference Include="..\Sample.Core\Sample.Core.csproj" />
<PackageReference Include="HotChocolate.Data.AutoMapper" />
Expand All @@ -23,8 +23,4 @@

</ItemGroup>

<ItemGroup>
<Folder Include="Properties" />
</ItemGroup>

</Project>
2 changes: 0 additions & 2 deletions sample/Sample.Pages/Sample.Pages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\AspNetCore\Rocket.Surgery.LaunchPad.AspNetCore.csproj" />
<ProjectReference Include="..\..\src\Hosting\Rocket.Surgery.LaunchPad.Hosting.csproj" />
<ProjectReference Include="..\..\src\Web.Hosting\Rocket.Surgery.LaunchPad.Web.Hosting.csproj" />
<ProjectReference Include="..\Sample.Core\Sample.Core.csproj" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion sample/Sample.Restful/Sample.Restful.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Web.Hosting\Rocket.Surgery.LaunchPad.Web.Hosting.csproj" />
<ProjectReference Include="..\..\src\AspNetCore\Rocket.Surgery.LaunchPad.AspNetCore.csproj" />
<ProjectReference Include="..\Sample.Core\Sample.Core.csproj" />
<PackageReference Include="Humanizer.Core" />
<PackageReference
Expand Down
6 changes: 2 additions & 4 deletions src/Analyzers/GraphqlMutationActionBodyGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,8 @@ ExpressionSyntax requestExpression
methodSymbol
.Parameters.SelectMany(
p => p.Type.AllInterfaces.Select(
static i => i is INamedTypeSymbol
{
MetadataName: "IOptionalTracking`1", TypeArguments: [var requestType,],
}
static i => i is
{ MetadataName: "IOptionalTracking`1", TypeArguments: [var requestType,], }
? requestType
: null
),
Expand Down
1 change: 1 addition & 0 deletions src/AspNetCore/Rocket.Surgery.LaunchPad.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Foundation\Rocket.Surgery.LaunchPad.Foundation.csproj" />
<ProjectReference Include="..\Hosting\Rocket.Surgery.LaunchPad.Hosting.csproj" />
<PackageReference Include="FluentValidation.AspNetCore" />
<PackageReference Include="Rocket.Surgery.Build.Information" />
<PackageReference Include="Serilog.AspNetCore" />
Expand Down
13 changes: 2 additions & 11 deletions src/Foundation/FoundationOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using NodaTime.TimeZones;

namespace Rocket.Surgery.LaunchPad.Foundation;
Expand All @@ -10,14 +9,6 @@ namespace Rocket.Surgery.LaunchPad.Foundation;
[PublicAPI]
public class FoundationOptions
{
/// <summary>
/// The executing assembly
/// </summary>
/// <remarks>
/// Useful so that applications and conventions can know the "true" executing assembly when running in an environment like azure functions
/// </remarks>
public Assembly? EntryAssembly { get; set; }

/// <summary>
/// The NodaTime timezone source
/// </summary>
Expand All @@ -37,4 +28,4 @@ public class FoundationOptions
/// Validation options are registered as health checks instead of throwing and stopping application startup
/// </summary>
public bool? RegisterValidationOptionsAsHealthChecks { get; set; }
}
}
15 changes: 6 additions & 9 deletions src/HotChocolate/AssemblyInfoQuery.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using System.Reflection;
using HotChocolate.Resolvers;
using HotChocolate.Types;
using Microsoft.Extensions.DependencyInjection;
using Rocket.Surgery.LaunchPad.Foundation;

namespace Rocket.Surgery.LaunchPad.HotChocolate;

/// <summary>
/// Returns assembly information for the given application
/// </summary>
[ExtendObjectType(OperationTypeNames.Query)]
[PublicAPI]
[ExtendObjectType(OperationTypeNames.Query)]
public class AssemblyInfoQuery
{
/// <summary>
Expand All @@ -19,12 +17,11 @@ public class AssemblyInfoQuery
/// <param name="context"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
#pragma warning disable CA1822
#pragma warning disable CA1822
public AssemblyInfo Version(IResolverContext context, CancellationToken cancellationToken)
#pragma warning restore CA1822
#pragma warning restore CA1822
{
return new AssemblyInfo(
context.Services.GetService<FoundationOptions>()?.EntryAssembly ?? Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly()
);
// ReSharper disable once NullableWarningSuppressionIsUsed
return new(Assembly.GetEntryAssembly()!);
}
}
}
67 changes: 35 additions & 32 deletions src/Mapping/Profiles/NodaTimeProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,28 @@ public NodaTimeProfile()
private void CreateMappingsForDurationConverter()
{
CreateMap<decimal, Duration>().ConvertUsing(source => Duration.FromTicks((long)( source * NodaConstants.TicksPerMillisecond )));
CreateMap<decimal?, Duration?>().ConvertUsing(
source => source.HasValue ? Duration.FromTicks((long)( source.Value * NodaConstants.TicksPerMillisecond )) : default(Duration?)
);
CreateMap<decimal?, Duration?>()
.ConvertUsing(
source => source.HasValue ? Duration.FromTicks((long)( source.Value * NodaConstants.TicksPerMillisecond )) : default(Duration?)
);
CreateMap<double, Duration>().ConvertUsing(source => Duration.FromTicks((long)( source * NodaConstants.TicksPerMillisecond )));
CreateMap<double?, Duration?>().ConvertUsing(
source => source.HasValue ? Duration.FromTicks((long)( source.Value * NodaConstants.TicksPerMillisecond )) : default(Duration?)
);
CreateMap<double?, Duration?>()
.ConvertUsing(
source => source.HasValue ? Duration.FromTicks((long)( source.Value * NodaConstants.TicksPerMillisecond )) : default(Duration?)
);
CreateMap<Duration, decimal>().ConvertUsing(source => (decimal)source.BclCompatibleTicks / NodaConstants.TicksPerMillisecond);
CreateMap<Duration, double>().ConvertUsing(source => (double)source.BclCompatibleTicks / NodaConstants.TicksPerMillisecond);
CreateMap<Duration, int>().ConvertUsing(source => (int)( source.BclCompatibleTicks / NodaConstants.TicksPerSecond ));
CreateMap<Duration, long>().ConvertUsing(source => source.BclCompatibleTicks / NodaConstants.TicksPerMillisecond);
CreateMap<Duration, TimeSpan>().ConvertUsing(source => source.ToTimeSpan());
CreateMap<Duration?, decimal?>().ConvertUsing(
source => source.HasValue ? (decimal)source.Value.BclCompatibleTicks / NodaConstants.TicksPerMillisecond : default(decimal?)
);
CreateMap<Duration?, double?>().ConvertUsing(
source => source.HasValue ? (double)source.Value.BclCompatibleTicks / NodaConstants.TicksPerMillisecond : default(double?)
);
CreateMap<Duration?, decimal?>()
.ConvertUsing(
source => source.HasValue ? (decimal)source.Value.BclCompatibleTicks / NodaConstants.TicksPerMillisecond : default(decimal?)
);
CreateMap<Duration?, double?>()
.ConvertUsing(
source => source.HasValue ? (double)source.Value.BclCompatibleTicks / NodaConstants.TicksPerMillisecond : default(double?)
);
CreateMap<Duration?, int?>()
.ConvertUsing(source => source.HasValue ? (int)( source.Value.BclCompatibleTicks / NodaConstants.TicksPerSecond ) : default(int?));
CreateMap<Duration?, long?>()
Expand All @@ -62,27 +66,30 @@ private void CreateMappingsForDurationConverter()
CreateMap<int?, Duration?>()
.ConvertUsing(source => source.HasValue ? Duration.FromTicks(source.Value * NodaConstants.TicksPerSecond) : default(Duration?));
CreateMap<long, Duration>().ConvertUsing(source => Duration.FromTicks(source * NodaConstants.TicksPerMillisecond));
CreateMap<long?, Duration?>().ConvertUsing(
source => source.HasValue ? Duration.FromTicks(source.Value * NodaConstants.TicksPerMillisecond) : default(Duration?)
);
CreateMap<long?, Duration?>()
.ConvertUsing(
source => source.HasValue ? Duration.FromTicks(source.Value * NodaConstants.TicksPerMillisecond) : default(Duration?)
);
CreateMap<TimeSpan, Duration>().ConvertUsing(source => Duration.FromTimeSpan(source));
CreateMap<TimeSpan?, Duration?>().ConvertUsing(source => source.HasValue ? Duration.FromTimeSpan(source.Value) : default(Duration?));
}

private void CreateMappingsForInstantConvertor()
{
CreateMap<DateTime, Instant>().ConvertUsing(
source => Instant.FromDateTimeUtc(
source.Kind == DateTimeKind.Unspecified ? DateTime.SpecifyKind(source, DateTimeKind.Utc) : source.ToUniversalTime()
)
);
CreateMap<DateTime?, Instant?>().ConvertUsing(
source => source.HasValue
? Instant.FromDateTimeUtc(
source.Value.Kind == DateTimeKind.Unspecified ? DateTime.SpecifyKind(source.Value, DateTimeKind.Utc) : source.Value.ToUniversalTime()
CreateMap<DateTime, Instant>()
.ConvertUsing(
source => Instant.FromDateTimeUtc(
source.Kind == DateTimeKind.Unspecified ? DateTime.SpecifyKind(source, DateTimeKind.Utc) : source.ToUniversalTime()
)
: default
);
);
CreateMap<DateTime?, Instant?>()
.ConvertUsing(
source => source.HasValue
? Instant.FromDateTimeUtc(
source.Value.Kind == DateTimeKind.Unspecified ? DateTime.SpecifyKind(source.Value, DateTimeKind.Utc) : source.Value.ToUniversalTime()
)
: default
);
CreateMap<DateTimeOffset, Instant>().ConvertUsing(source => Instant.FromDateTimeOffset(source));
CreateMap<DateTimeOffset?, Instant?>().ConvertUsing(source => source.HasValue ? Instant.FromDateTimeOffset(source.Value) : default(Instant?));
CreateMap<Instant, DateTime>().ConvertUsing(source => source.ToDateTimeUtc());
Expand All @@ -97,12 +104,10 @@ private void CreateMappingsForLocalDateConverter()
CreateMap<DateTime?, LocalDate?>().ConvertUsing(source => source.HasValue ? LocalDate.FromDateTime(source.Value) : default(LocalDate?));
CreateMap<LocalDate, DateTime>().ConvertUsing(source => source.AtMidnight().ToDateTimeUnspecified());
CreateMap<LocalDate?, DateTime?>().ConvertUsing(source => source.HasValue ? source.Value.AtMidnight().ToDateTimeUnspecified() : default(DateTime?));
#if NET6_0_OR_GREATER
CreateMap<DateOnly, LocalDate>().ConvertUsing(source => LocalDate.FromDateOnly(source));
CreateMap<DateOnly?, LocalDate?>().ConvertUsing(source => source.HasValue ? LocalDate.FromDateOnly(source.Value) : default(LocalDate?));
CreateMap<LocalDate, DateOnly>().ConvertUsing(source => source.ToDateOnly());
CreateMap<LocalDate?, DateOnly?>().ConvertUsing(source => source.HasValue ? source.Value.ToDateOnly() : default(DateOnly?));
#endif
}

private void CreateMappingsForLocalDateTimeConverter()
Expand All @@ -113,13 +118,11 @@ private void CreateMappingsForLocalDateTimeConverter()

private void CreateMappingsForLocalTimeConverter()
{
#if NET6_0_OR_GREATER
CreateMap<TimeOnly, LocalTime>().ConvertUsing(source => LocalTime.FromTimeOnly(source));
CreateMap<TimeOnly?, LocalTime?>().ConvertUsing(source => source.HasValue ? LocalTime.FromTimeOnly(source.Value) : default(LocalTime?));
CreateMap<LocalTime, TimeOnly>().ConvertUsing(source => source.ToTimeOnly());
CreateMap<LocalTime?, TimeOnly?>().ConvertUsing(source => source.HasValue ? source.Value.ToTimeOnly() : default(TimeOnly?));
#endif
CreateMap<LocalTime, TimeSpan>().ConvertUsing(source => new TimeSpan(source.TickOfDay));
CreateMap<LocalTime, TimeSpan>().ConvertUsing(source => new(source.TickOfDay));
CreateMap<LocalTime?, TimeSpan?>().ConvertUsing(source => source.HasValue ? new TimeSpan(source.Value.TickOfDay) : default(TimeSpan?));
CreateMap<TimeSpan, LocalTime>().ConvertUsing(source => LocalTime.FromTicksSinceMidnight(source.Ticks));
CreateMap<TimeSpan?, LocalTime?>().ConvertUsing(source => source.HasValue ? LocalTime.FromTicksSinceMidnight(source.Value.Ticks) : default(LocalTime?));
Expand Down Expand Up @@ -147,4 +150,4 @@ private void CreateMappingsForPeriodConverter()
CreateMap<Period?, string?>().ConvertUsing(source => source == default ? default : source.ToString());
CreateMap<string?, Period?>().ConvertUsing(source => ( source == default ? default : PeriodPattern.Roundtrip.Parse(source).Value ) ?? default(Period?));
}
}
}
Loading

0 comments on commit 4fecf0c

Please sign in to comment.