diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 8cffa71d6..2e17f84e7 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ "commands": ["reportgenerator"] }, "nuke.globaltool": { - "version": "6.1.1", + "version": "6.1.2", "commands": ["nuke"] }, "codecov.tool": { diff --git a/Directory.Packages.props b/Directory.Packages.props index 1779c836b..93c4e8b49 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -15,7 +15,7 @@ - + @@ -66,6 +66,8 @@ + + @@ -89,11 +91,11 @@ - - - - - + + + + + @@ -140,7 +142,7 @@ - + - - + + + + diff --git a/LaunchPad.sln b/LaunchPad.sln index 77c04d062..933144f0b 100644 --- a/LaunchPad.sln +++ b/LaunchPad.sln @@ -103,14 +103,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Analyzers.Tests", "test\Ana EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.LaunchPad.HotChocolate", "src\HotChocolate\Rocket.Surgery.LaunchPad.HotChocolate.csproj", "{57F109FE-5337-45FA-8A50-F4BD139B0383}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.LaunchPad.Graphql", "src\Graphql\Rocket.Surgery.LaunchPad.Graphql.csproj", "{B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Graphql", "sample\Sample.Graphql\Sample.Graphql.csproj", "{AEFC06BB-A1A4-498F-B93A-0E76D95F662A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Graphql.Tests", "test\Sample.Graphql.Tests\Sample.Graphql.Tests.csproj", "{D6A3919B-8513-4879-853B-E942FFB1757B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate", "src\EntityFramework.HotChocolate\Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate.csproj", "{190EE25F-ECD1-4461-A454-F10185E3A7FD}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.LaunchPad.Mapping", "src\Mapping\Rocket.Surgery.LaunchPad.Mapping.csproj", "{C275559A-F759-4FC4-AAAC-11AE60B7BD45}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rocket.Surgery.LaunchPad.Mapping.NewtonsoftJson", "src\Mapping.NewtonsoftJson\Rocket.Surgery.LaunchPad.Mapping.NewtonsoftJson.csproj", "{4AC6F683-FB5C-47E1-A6F6-3E56DCB54600}" @@ -127,6 +123,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.BlazorWasm.Tests", " 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 Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -599,18 +597,6 @@ Global {57F109FE-5337-45FA-8A50-F4BD139B0383}.Release|x64.Build.0 = Release|Any CPU {57F109FE-5337-45FA-8A50-F4BD139B0383}.Release|x86.ActiveCfg = Release|Any CPU {57F109FE-5337-45FA-8A50-F4BD139B0383}.Release|x86.Build.0 = Release|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Debug|x64.ActiveCfg = Debug|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Debug|x64.Build.0 = Debug|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Debug|x86.ActiveCfg = Debug|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Debug|x86.Build.0 = Debug|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Release|Any CPU.Build.0 = Release|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Release|x64.ActiveCfg = Release|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Release|x64.Build.0 = Release|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Release|x86.ActiveCfg = Release|Any CPU - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA}.Release|x86.Build.0 = Release|Any CPU {AEFC06BB-A1A4-498F-B93A-0E76D95F662A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AEFC06BB-A1A4-498F-B93A-0E76D95F662A}.Debug|Any CPU.Build.0 = Debug|Any CPU {AEFC06BB-A1A4-498F-B93A-0E76D95F662A}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -635,18 +621,6 @@ Global {D6A3919B-8513-4879-853B-E942FFB1757B}.Release|x64.Build.0 = Release|Any CPU {D6A3919B-8513-4879-853B-E942FFB1757B}.Release|x86.ActiveCfg = Release|Any CPU {D6A3919B-8513-4879-853B-E942FFB1757B}.Release|x86.Build.0 = Release|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Debug|x64.ActiveCfg = Debug|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Debug|x64.Build.0 = Debug|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Debug|x86.ActiveCfg = Debug|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Debug|x86.Build.0 = Debug|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Release|Any CPU.Build.0 = Release|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Release|x64.ActiveCfg = Release|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Release|x64.Build.0 = Release|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Release|x86.ActiveCfg = Release|Any CPU - {190EE25F-ECD1-4461-A454-F10185E3A7FD}.Release|x86.Build.0 = Release|Any CPU {C275559A-F759-4FC4-AAAC-11AE60B7BD45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C275559A-F759-4FC4-AAAC-11AE60B7BD45}.Debug|Any CPU.Build.0 = Debug|Any CPU {C275559A-F759-4FC4-AAAC-11AE60B7BD45}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -743,6 +717,18 @@ Global {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 + {2C09FAF6-434D-442F-94B2-02AB906B477C}.Debug|x64.Build.0 = Debug|Any CPU + {2C09FAF6-434D-442F-94B2-02AB906B477C}.Debug|x86.ActiveCfg = Debug|Any CPU + {2C09FAF6-434D-442F-94B2-02AB906B477C}.Debug|x86.Build.0 = Debug|Any CPU + {2C09FAF6-434D-442F-94B2-02AB906B477C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2C09FAF6-434D-442F-94B2-02AB906B477C}.Release|Any CPU.Build.0 = Release|Any CPU + {2C09FAF6-434D-442F-94B2-02AB906B477C}.Release|x64.ActiveCfg = Release|Any CPU + {2C09FAF6-434D-442F-94B2-02AB906B477C}.Release|x64.Build.0 = Release|Any CPU + {2C09FAF6-434D-442F-94B2-02AB906B477C}.Release|x86.ActiveCfg = Release|Any CPU + {2C09FAF6-434D-442F-94B2-02AB906B477C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -790,10 +776,8 @@ Global {CBF9F362-9694-4BB6-930C-1C59B45E189D} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3} {D040AD5E-620B-4AF1-92B3-FB4409C4ECFD} = {DF33E0FB-9790-4654-B60F-8AB22E0CC3D1} {57F109FE-5337-45FA-8A50-F4BD139B0383} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3} - {B6B3D5A8-7DC2-4D80-8704-4C30236BD0BA} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3} {AEFC06BB-A1A4-498F-B93A-0E76D95F662A} = {5D11C19B-E8E4-4CE3-9C8A-1D368578EBCB} {D6A3919B-8513-4879-853B-E942FFB1757B} = {DF33E0FB-9790-4654-B60F-8AB22E0CC3D1} - {190EE25F-ECD1-4461-A454-F10185E3A7FD} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3} {C275559A-F759-4FC4-AAAC-11AE60B7BD45} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3} {4AC6F683-FB5C-47E1-A6F6-3E56DCB54600} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3} {32465135-7CBB-4109-8D06-3A2B9F36ABF0} = {8FFDF555-DB50-45F9-9A2D-6410F39151C3} @@ -802,5 +786,6 @@ Global {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} EndGlobalSection EndGlobal diff --git a/Readme.md b/Readme.md index f979b466e..cf3859571 100644 --- a/Readme.md +++ b/Readme.md @@ -29,11 +29,9 @@ A common set of libraries used to build console and web applications. | Rocket.Surgery.LaunchPad.AspNetCore.Spatial | [![nuget-version-hf0rber6kqsw-badge]![nuget-downloads-hf0rber6kqsw-badge]][nuget-hf0rber6kqsw] | | Rocket.Surgery.LaunchPad.AspNetCore.Testing | [![nuget-version-vmr7vthhrumq-badge]![nuget-downloads-vmr7vthhrumq-badge]][nuget-vmr7vthhrumq] | | Rocket.Surgery.LaunchPad.EntityFramework | [![nuget-version-nutptsm/tbya-badge]![nuget-downloads-nutptsm/tbya-badge]][nuget-nutptsm/tbya] | -| Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate | [![nuget-version-bpcodlgj17qg-badge]![nuget-downloads-bpcodlgj17qg-badge]][nuget-bpcodlgj17qg] | | Rocket.Surgery.LaunchPad.Foundation | [![nuget-version-kb2xyygxvala-badge]![nuget-downloads-kb2xyygxvala-badge]][nuget-kb2xyygxvala] | | Rocket.Surgery.LaunchPad.Foundation.NewtonsoftJson | [![nuget-version-m0yumfedtfoa-badge]![nuget-downloads-m0yumfedtfoa-badge]][nuget-m0yumfedtfoa] | | Rocket.Surgery.LaunchPad.Functions | [![nuget-version-hllqtixjuvag-badge]![nuget-downloads-hllqtixjuvag-badge]][nuget-hllqtixjuvag] | -| Rocket.Surgery.LaunchPad.Graphql | [![nuget-version-zuh73yztcqma-badge]![nuget-downloads-zuh73yztcqma-badge]][nuget-zuh73yztcqma] | | Rocket.Surgery.LaunchPad.Grpc | [![nuget-version-auwnvpy8f+6g-badge]![nuget-downloads-auwnvpy8f+6g-badge]][nuget-auwnvpy8f+6g] | | Rocket.Surgery.LaunchPad.Hosting | [![nuget-version-w/tyeoj0dncw-badge]![nuget-downloads-w/tyeoj0dncw-badge]][nuget-w/tyeoj0dncw] | | Rocket.Surgery.LaunchPad.HotChocolate | [![nuget-version-ozd3tvimwvrq-badge]![nuget-downloads-ozd3tvimwvrq-badge]][nuget-ozd3tvimwvrq] | @@ -88,9 +86,6 @@ TBD [nuget-nutptsm/tbya]: https://www.nuget.org/packages/Rocket.Surgery.LaunchPad.EntityFramework/ [nuget-version-nutptsm/tbya-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.LaunchPad.EntityFramework.svg?color=004880&logo=nuget&style=flat-square "NuGet Version" [nuget-downloads-nutptsm/tbya-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.LaunchPad.EntityFramework.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads" -[nuget-bpcodlgj17qg]: https://www.nuget.org/packages/Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate/ -[nuget-version-bpcodlgj17qg-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate.svg?color=004880&logo=nuget&style=flat-square "NuGet Version" -[nuget-downloads-bpcodlgj17qg-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads" [nuget-kb2xyygxvala]: https://www.nuget.org/packages/Rocket.Surgery.LaunchPad.Foundation/ [nuget-version-kb2xyygxvala-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.LaunchPad.Foundation.svg?color=004880&logo=nuget&style=flat-square "NuGet Version" [nuget-downloads-kb2xyygxvala-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.LaunchPad.Foundation.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads" @@ -100,9 +95,6 @@ TBD [nuget-hllqtixjuvag]: https://www.nuget.org/packages/Rocket.Surgery.LaunchPad.Functions/ [nuget-version-hllqtixjuvag-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.LaunchPad.Functions.svg?color=004880&logo=nuget&style=flat-square "NuGet Version" [nuget-downloads-hllqtixjuvag-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.LaunchPad.Functions.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads" -[nuget-zuh73yztcqma]: https://www.nuget.org/packages/Rocket.Surgery.LaunchPad.Graphql/ -[nuget-version-zuh73yztcqma-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.LaunchPad.Graphql.svg?color=004880&logo=nuget&style=flat-square "NuGet Version" -[nuget-downloads-zuh73yztcqma-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.LaunchPad.Graphql.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads" [nuget-auwnvpy8f+6g]: https://www.nuget.org/packages/Rocket.Surgery.LaunchPad.Grpc/ [nuget-version-auwnvpy8f+6g-badge]: https://img.shields.io/nuget/v/Rocket.Surgery.LaunchPad.Grpc.svg?color=004880&logo=nuget&style=flat-square "NuGet Version" [nuget-downloads-auwnvpy8f+6g-badge]: https://img.shields.io/nuget/dt/Rocket.Surgery.LaunchPad.Grpc.svg?color=004880&logo=nuget&style=flat-square "NuGet Downloads" diff --git a/sample/Sample.BlazorServer/Startup.cs b/sample/Sample.BlazorServer/Startup.cs index 28b9b602b..3a206dddd 100644 --- a/sample/Sample.BlazorServer/Startup.cs +++ b/sample/Sample.BlazorServer/Startup.cs @@ -1,6 +1,5 @@ using Rocket.Surgery.LaunchPad.AspNetCore; using Sample.BlazorServer.Data; -using Serilog; namespace Sample.BlazorServer; @@ -39,14 +38,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseHttpsRedirection(); app.UseStaticFiles(); - // Should this move into an extension method? - app.UseSerilogRequestLogging( - x => - { - x.GetLevel = LaunchPadLogHelpers.DefaultGetLevel; - x.EnrichDiagnosticContext = LaunchPadLogHelpers.DefaultEnrichDiagnosticContext; - } - ); + app.UseLaunchPadRequestLogging(); app.UseMetricsAllMiddleware(); app.UseRouting(); diff --git a/sample/Sample.Classic.Restful/Controllers/LaunchRecordController.cs b/sample/Sample.Classic.Restful/Controllers/LaunchRecordController.cs new file mode 100644 index 000000000..9ea993492 --- /dev/null +++ b/sample/Sample.Classic.Restful/Controllers/LaunchRecordController.cs @@ -0,0 +1,64 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ModelBinding; +using Rocket.Surgery.LaunchPad.AspNetCore; +using Sample.Core.Models; +using Sample.Core.Operations.LaunchRecords; + +namespace Sample.Classic.Restful.Controllers; + +[Route("[controller]")] +public partial class LaunchRecordController : RestfulApiController +{ + /// + /// Search for launch records + /// + /// The search context + /// + [HttpGet] + public partial IAsyncEnumerable ListLaunchRecords(ListLaunchRecords.Request request); + + /// + /// Load details of a specific launch record + /// + /// The request context + /// + [HttpGet("{id:guid}")] + public partial Task> GetLaunchRecord(GetLaunchRecord.Request request); + + /// + /// Create a new launch record + /// + /// The launch record details + /// + [HttpPost] + [Created(nameof(GetLaunchRecord))] + public partial Task> CreateLaunchRecord(CreateLaunchRecord.Request request); + + /// + /// Update a given launch record + /// + /// The id of the launch record + /// The request details + /// + [HttpPut("{id:guid}")] + // ReSharper disable once RouteTemplates.ParameterTypeAndConstraintsMismatch + public partial Task EditLaunchRecord([BindRequired] [FromRoute] LaunchRecordId id, EditLaunchRecord.Request model); + + /// + /// Update a given launch record + /// + /// The id of the launch record + /// The request details + /// + [HttpPatch("{id:guid}")] + // ReSharper disable once RouteTemplates.ParameterTypeAndConstraintsMismatch + public partial Task PatchLaunchRecord([BindRequired] [FromRoute] LaunchRecordId id, EditLaunchRecord.PatchRequest model); + + /// + /// Remove a launch record + /// + /// + /// + [HttpDelete("{id:guid}")] + public partial Task DeleteLaunchRecord(DeleteLaunchRecord.Request request); +} diff --git a/sample/Sample.Classic.Restful/Controllers/RocketController.cs b/sample/Sample.Classic.Restful/Controllers/RocketController.cs new file mode 100644 index 000000000..f36fd982a --- /dev/null +++ b/sample/Sample.Classic.Restful/Controllers/RocketController.cs @@ -0,0 +1,80 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ModelBinding; +using Rocket.Surgery.LaunchPad.AspNetCore; +using Sample.Core.Models; +using Sample.Core.Operations.Rockets; + +namespace Sample.Classic.Restful.Controllers; + +[Route("[controller]")] +public partial class RocketController : RestfulApiController +{ + /// + /// Search for rockets + /// + /// The search context + /// + [HttpGet] + public partial IAsyncEnumerable ListRockets(ListRockets.Request request); + + /// + /// Load details of a specific rocket + /// + /// The request context + /// + [HttpGet("{id:guid}")] + public partial Task> GetRocket(GetRocket.Request request); + + /// + /// Create a new rocket + /// + /// The rocket details + /// + [HttpPost] + [Created(nameof(GetRocket))] + public partial Task> CreateRocket(CreateRocket.Request request); + + /// + /// Update a given rocket + /// + /// The id of the rocket + /// The request details + /// + [HttpPut("{id:guid}")] + // ReSharper disable once RouteTemplates.ParameterTypeAndConstraintsMismatch + public partial Task> EditRocket([BindRequired] [FromRoute] RocketId id, [BindRequired] [FromBody] EditRocket.Request model); + + /// + /// Update a given rocket + /// + /// The id of the rocket + /// The request details + /// + [HttpPatch("{id:guid}")] + // ReSharper disable once RouteTemplates.ParameterTypeAndConstraintsMismatch + public partial Task> PatchRocket([BindRequired] [FromRoute] RocketId id, [BindRequired] [FromBody] EditRocket.PatchRequest model); + + /// + /// Remove a rocket + /// + /// + /// + [HttpDelete("{id:guid}")] + public partial Task RemoveRocket([BindRequired] [FromRoute] DeleteRocket.Request request); + + /// + /// Get the launch records for a given rocket + /// + /// + [HttpGet("{id:guid}/launch-records")] + // ReSharper disable once RouteTemplates.ParameterTypeAndConstraintsMismatch + public partial IAsyncEnumerable GetRocketLaunchRecords(GetRocketLaunchRecords.Request request); + + /// + /// Get a specific launch record for a given rocket + /// + /// + [HttpGet("{id:guid}/launch-records/{launchRecordId:guid}")] + // ReSharper disable once RouteTemplates.ParameterTypeAndConstraintsMismatch + public partial Task> GetRocketLaunchRecord(GetRocketLaunchRecord.Request request); +} diff --git a/sample/Sample.Classic.Restful/Controllers/WeatherForecastController.cs b/sample/Sample.Classic.Restful/Controllers/WeatherForecastController.cs new file mode 100644 index 000000000..f912e06d9 --- /dev/null +++ b/sample/Sample.Classic.Restful/Controllers/WeatherForecastController.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Mvc; +using Rocket.Surgery.LaunchPad.AspNetCore; + +namespace Sample.Classic.Restful.Controllers; + +[Route("[controller]")] +public class WeatherForecastController : RestfulApiController +{ + private static readonly string[] Summaries = + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet] + public IEnumerable Get() + { + var rng = new Random(); + return Enumerable.Range(1, 5).Select( + index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = rng.Next(-20, 55), + Summary = Summaries[rng.Next(Summaries.Length)] + } + ) + .ToArray(); + } +} diff --git a/sample/Sample.Classic.Restful/Program.cs b/sample/Sample.Classic.Restful/Program.cs new file mode 100644 index 000000000..1cfe5b78b --- /dev/null +++ b/sample/Sample.Classic.Restful/Program.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.DependencyModel; +using Rocket.Surgery.Hosting; + +namespace Sample.Classic.Restful; + +/// +/// Startup interop (here for testing only or for 3.1 support) +/// +public static partial class Program +{ + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()) + .LaunchWith(RocketBooster.ForDependencyContext(DependencyContext.Default), z => z.WithConventionsFrom(Imports.GetConventions)); + } +} diff --git a/sample/Sample.Classic.Restful/Properties/launchSettings.json b/sample/Sample.Classic.Restful/Properties/launchSettings.json new file mode 100644 index 000000000..ec6b632d5 --- /dev/null +++ b/sample/Sample.Classic.Restful/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:9140", + "sslPort": 44304 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Sample.Restful": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/sample/Sample.Classic.Restful/Sample.Classic.Restful.csproj b/sample/Sample.Classic.Restful/Sample.Classic.Restful.csproj new file mode 100644 index 000000000..a568acf24 --- /dev/null +++ b/sample/Sample.Classic.Restful/Sample.Classic.Restful.csproj @@ -0,0 +1,22 @@ + + + net6.0 + true + true + true + + + + + + + + + + + + diff --git a/sample/Sample.Classic.Restful/Startup.cs b/sample/Sample.Classic.Restful/Startup.cs new file mode 100644 index 000000000..8ee904fd3 --- /dev/null +++ b/sample/Sample.Classic.Restful/Startup.cs @@ -0,0 +1,67 @@ +using System.Reflection; +using Hellang.Middleware.ProblemDetails; +using Microsoft.OpenApi.Models; +using Rocket.Surgery.LaunchPad.AspNetCore; +using Rocket.Surgery.LaunchPad.AspNetCore.AppMetrics; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Sample.Classic.Restful; + +/// +/// Startup interop (here for testing only or for 3.1 support) +/// +public class Startup +{ + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers().AddControllersAsServices(); + services + .Configure( + c => c.SwaggerDoc( + "v1", + new OpenApiInfo + { + Version = typeof(Startup).GetCustomAttribute()?.Version + ?? typeof(Startup).GetCustomAttribute()?.Version ?? "0.1.0", + Title = "Test Application", + } + ) + ); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.UseProblemDetails(); + app.UseHttpsRedirection(); + + app.UseLaunchPadRequestLogging(); + app.UseMetricsAllMiddleware(); + + app.UseRouting(); + + app + .UseSwaggerUI() + .UseReDoc(); + + app.UseAuthorization(); + + app.UseEndpoints( + endpoints => + { + endpoints.MapControllers(); + + endpoints.MapSwagger(); + endpoints.MapAppMetrics(); + } + ); + } +} diff --git a/sample/Sample.Classic.Restful/WeatherForecast.cs b/sample/Sample.Classic.Restful/WeatherForecast.cs new file mode 100644 index 000000000..0cdf7b80e --- /dev/null +++ b/sample/Sample.Classic.Restful/WeatherForecast.cs @@ -0,0 +1,12 @@ +namespace Sample.Classic.Restful; + +public class WeatherForecast +{ + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)( TemperatureC / 0.5556 ); + + public string? Summary { get; set; } +} diff --git a/sample/Sample.Classic.Restful/appsettings.Development.yml b/sample/Sample.Classic.Restful/appsettings.Development.yml new file mode 100644 index 000000000..881ec6e17 --- /dev/null +++ b/sample/Sample.Classic.Restful/appsettings.Development.yml @@ -0,0 +1,8 @@ +Serilog: + MinimumLevel: + Default: Debug + Override: + Microsoft: 'Information' + Microsoft.AspNetCore.Hosting.Diagnostics: 'Debug' + Microsoft.Hosting.Lifetime": 'Debug' + System": 'Information' diff --git a/sample/Sample.Classic.Restful/appsettings.yml b/sample/Sample.Classic.Restful/appsettings.yml new file mode 100644 index 000000000..fecfd222f --- /dev/null +++ b/sample/Sample.Classic.Restful/appsettings.yml @@ -0,0 +1,17 @@ +Serilog: + MinimumLevel: + Default: 'Information' + Override: + Microsoft: 'Warning' + Microsoft.AspNetCore.Hosting.Diagnostics: 'Information' + Microsoft.Hosting.Lifetime: 'Information' + System: 'Warning' +AllowedHosts: '*' +Metrics: + Enabled: true + Tracking: + ApdexTrackingEnabled: true + ApdexTSeconds: 0.1 + IgnoredHttpStatusCodes: [404] + IgnoredRoutesRegexPatterns: [] + OAuth2TrackingEnabled: true diff --git a/sample/Sample.Command/Program.cs b/sample/Sample.Command/Program.cs index bcea8e8ce..c28aa43ff 100644 --- a/sample/Sample.Command/Program.cs +++ b/sample/Sample.Command/Program.cs @@ -46,6 +46,7 @@ public Dump(IConfiguration configuration, ILogger logger, InstanceThing in public override int Execute([NotNull] CommandContext context, [NotNull] AppSettings settings) { + // ReSharper disable once TemplateIsNotCompileTimeConstantProblem _logger.LogInformation(_instanceThing.From); foreach (var item in _configuration.AsEnumerable().Reverse()) { diff --git a/sample/Sample.Core/DataConvention.cs b/sample/Sample.Core/DataConvention.cs index 6f0609ebf..69857bafe 100644 --- a/sample/Sample.Core/DataConvention.cs +++ b/sample/Sample.Core/DataConvention.cs @@ -5,17 +5,15 @@ using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Sample.Core; using Sample.Core.Domain; #if NET using Microsoft.Extensions.DependencyInjection.Extensions; #endif -[assembly: Convention(typeof(DataConvention))] - namespace Sample.Core; [LiveConvention] +[ExportConvention] internal class DataConvention : IServiceConvention { public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services) diff --git a/sample/Sample.Core/DataGenerationConvention.cs b/sample/Sample.Core/DataGenerationConvention.cs index 941a56f74..af70a431c 100644 --- a/sample/Sample.Core/DataGenerationConvention.cs +++ b/sample/Sample.Core/DataGenerationConvention.cs @@ -5,14 +5,12 @@ using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; using Rocket.Surgery.DependencyInjection; -using Sample.Core; using Sample.Core.Domain; -[assembly: Convention(typeof(DataGenerationConvention))] - namespace Sample.Core; [LiveConvention] +[ExportConvention] public class DataGenerationConvention : IServiceConvention { public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services) diff --git a/sample/Sample.Core/Domain/RocketDbContext.cs b/sample/Sample.Core/Domain/RocketDbContext.cs index 3da3b531f..fca1a493f 100644 --- a/sample/Sample.Core/Domain/RocketDbContext.cs +++ b/sample/Sample.Core/Domain/RocketDbContext.cs @@ -30,7 +30,8 @@ protected override void ConfigureConventions(ModelConfigurationBuilder configura public class StronglyTypedIdValueConverterSelector : ValueConverterSelector { - private static Type UnwrapNullableType(Type type) + [return: NotNullIfNotNull("type")] + private static Type? UnwrapNullableType(Type? type) { if (type is null) { @@ -48,7 +49,7 @@ public StronglyTypedIdValueConverterSelector(ValueConverterSelectorDependencies { } - public override IEnumerable Select(Type modelClrType, Type providerClrType = null) + public override IEnumerable Select(Type modelClrType, Type? providerClrType = null) { var baseConverters = base.Select(modelClrType, providerClrType); foreach (var converter in baseConverters) @@ -63,18 +64,18 @@ public override IEnumerable Select(Type modelClrType, Type p // 'null' means 'get any value converters for the modelClrType' if (underlyingProviderType is null || underlyingProviderType == typeof(Guid)) { - // Try and get a nested class with the expected name. + // Try and get a nested class with the expected name. var converterType = underlyingModelType.GetNestedType("EfCoreValueConverter"); if (converterType != null) { yield return _converters.GetOrAdd( ( underlyingModelType, typeof(Guid) ), - k => + _ => { // Create an instance of the converter whenever it's requested. Func factory = - info => (ValueConverter)Activator.CreateInstance(converterType, info.MappingHints); + info => (ValueConverter)Activator.CreateInstance(converterType, info.MappingHints)!; // Build the info for our strongly-typed ID => Guid converter return new ValueConverterInfo(modelClrType, typeof(Guid), factory); diff --git a/sample/Sample.Core/Models/LaunchRecordModel.cs b/sample/Sample.Core/Models/LaunchRecordModel.cs index 9e45f8146..9a765f85e 100644 --- a/sample/Sample.Core/Models/LaunchRecordModel.cs +++ b/sample/Sample.Core/Models/LaunchRecordModel.cs @@ -8,6 +8,7 @@ namespace Sample.Core.Models; /// /// Unique Id of a launch record /// +#pragma warning disable CA1036 [StronglyTypedId( StronglyTypedIdBackingType.Guid, StronglyTypedIdConverter.SystemTextJson | StronglyTypedIdConverter.EfCoreValueConverter | StronglyTypedIdConverter.TypeConverter @@ -15,6 +16,7 @@ namespace Sample.Core.Models; public partial struct LaunchRecordId { } +#pragma warning restore CA1036 /// /// The launch record details diff --git a/sample/Sample.Core/Models/RocketModel.cs b/sample/Sample.Core/Models/RocketModel.cs index 52fdef8cb..1a2e31f0e 100644 --- a/sample/Sample.Core/Models/RocketModel.cs +++ b/sample/Sample.Core/Models/RocketModel.cs @@ -7,6 +7,7 @@ namespace Sample.Core.Models; /// /// Unique Id of a rocket /// +#pragma warning disable CA1036 [StronglyTypedId( StronglyTypedIdBackingType.Guid, StronglyTypedIdConverter.SystemTextJson | StronglyTypedIdConverter.EfCoreValueConverter | StronglyTypedIdConverter.TypeConverter @@ -14,6 +15,7 @@ namespace Sample.Core.Models; public partial struct RocketId { } +#pragma warning restore CA1036 /// /// The details of a given rocket diff --git a/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs b/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs index 80d845fb4..185317406 100644 --- a/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs +++ b/sample/Sample.Core/Operations/LaunchRecords/EditLaunchRecord.cs @@ -6,7 +6,6 @@ using Rocket.Surgery.LaunchPad.Foundation; using Sample.Core.Domain; using Sample.Core.Models; -using Sample.Core.Operations.Rockets; namespace Sample.Core.Operations.LaunchRecords; diff --git a/sample/Sample.Core/Operations/Rockets/EditRocket.cs b/sample/Sample.Core/Operations/Rockets/EditRocket.cs index 69c7c4019..fb236a7c1 100644 --- a/sample/Sample.Core/Operations/Rockets/EditRocket.cs +++ b/sample/Sample.Core/Operations/Rockets/EditRocket.cs @@ -104,6 +104,10 @@ protected override async Task GetRequest(PatchRequest patchRequest, Can public async Task Handle(Request request, CancellationToken cancellationToken) { var rocket = await GetRocket(request.Id, cancellationToken); + if (rocket == null) + { + throw new NotFoundException(); + } _mapper.Map(request, rocket); _dbContext.Update(rocket); diff --git a/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecord.cs b/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecord.cs index f6b3f13f0..094ce6479 100644 --- a/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecord.cs +++ b/sample/Sample.Core/Operations/Rockets/GetRocketLaunchRecord.cs @@ -55,7 +55,7 @@ public async Task Handle(Request request, CancellationToken c throw new NotFoundException(); } - var launchRecord = _dbContext.LaunchRecords.FindAsync(new object[] { request.LaunchRecordId }, cancellationToken); + var launchRecord = await _dbContext.LaunchRecords.FindAsync(new object[] { request.LaunchRecordId }, cancellationToken); if (launchRecord == null) { throw new NotFoundException(); diff --git a/sample/Sample.Function/LocalServices.cs b/sample/Sample.Function/LocalServices.cs index 1fcf2828a..922df4e3c 100644 --- a/sample/Sample.Function/LocalServices.cs +++ b/sample/Sample.Function/LocalServices.cs @@ -2,12 +2,11 @@ using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Sample_Function; - -[assembly: Convention(typeof(LocalServices))] namespace Sample_Function; +[PublicAPI] +[ExportConvention] public class LocalServices : IServiceConvention { public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services) diff --git a/sample/Sample.Function/TestFunction.cs b/sample/Sample.Function/TestFunction.cs index 11aeb983c..e16038f06 100644 --- a/sample/Sample.Function/TestFunction.cs +++ b/sample/Sample.Function/TestFunction.cs @@ -23,7 +23,7 @@ public async Task Run( ILogger log ) { - log.LogInformation("C# HTTP trigger function processed a request."); + log.LogInformation("C# HTTP trigger function processed a request"); string? name = req.Query["name"]; diff --git a/sample/Sample.Graphql/ConfigureLaunchRecordType.cs b/sample/Sample.Graphql/ConfigureLaunchRecordType.cs deleted file mode 100644 index 09b08f08e..000000000 --- a/sample/Sample.Graphql/ConfigureLaunchRecordType.cs +++ /dev/null @@ -1,50 +0,0 @@ -using HotChocolate.Data.Sorting; -using HotChocolate.Types; -using HotChocolate.Types.Pagination; -using Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate; -using Sample.Core.Domain; -using Sample.Core.Models; - -namespace Sample.Graphql; - -public class ConfigureLaunchRecordType : ConfigureEntityFrameworkEntityQueryType -{ - public override void Configure(IObjectFieldDescriptor fieldDescriptor) - { - fieldDescriptor - .UsePaging( - typeof(ObjectType), - options: new PagingOptions - { - DefaultPageSize = 10, - IncludeTotalCount = true, - MaxPageSize = 20 - } - ) - .UseOffsetPaging( - typeof(ObjectType), - options: new PagingOptions - { - DefaultPageSize = 10, - IncludeTotalCount = true, - MaxPageSize = 20 - } - ) -// .UseProjection() - .UseFiltering(x => x.Ignore(x => x.ActualLaunchDate)) - .UseSorting(); - } - - private class LaunchRecordSort : SortInputType - { - protected override void Configure(ISortInputTypeDescriptor descriptor) - { - descriptor.BindFieldsExplicitly(); - descriptor.Field(z => z.Partner); - descriptor.Field(z => z.Payload); - descriptor.Field(z => z.PayloadWeightKg); - descriptor.Field(z => z.ActualLaunchDate); - descriptor.Field(z => z.ScheduledLaunchDate); - } - } -} diff --git a/sample/Sample.Graphql/ConfigureReadyRocketType.cs b/sample/Sample.Graphql/ConfigureReadyRocketType.cs deleted file mode 100644 index cc82a985d..000000000 --- a/sample/Sample.Graphql/ConfigureReadyRocketType.cs +++ /dev/null @@ -1,38 +0,0 @@ -using HotChocolate.Data.Sorting; -using HotChocolate.Types; -using HotChocolate.Types.Pagination; -using Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate; -using Sample.Core.Domain; -using Sample.Core.Models; - -namespace Sample.Graphql; - -public class ConfigureReadyRocketType : ConfigureEntityFrameworkEntityQueryType -{ - public override void Configure(IObjectFieldDescriptor fieldDescriptor) - { - fieldDescriptor - .UsePaging( - typeof(ObjectType), - options: new PagingOptions - { - DefaultPageSize = 10, - IncludeTotalCount = true, - MaxPageSize = 20 - } - ) - .UseProjection() - .UseFiltering() - .UseSorting(); - } - - private class RocketSort : SortInputType - { - protected override void Configure(ISortInputTypeDescriptor descriptor) - { - descriptor.BindFieldsExplicitly(); - descriptor.Field(z => z.Type); - descriptor.Field(z => z.Sn); - } - } -} diff --git a/sample/Sample.Graphql/Program.cs b/sample/Sample.Graphql/Program.cs index 275f50693..19192a926 100644 --- a/sample/Sample.Graphql/Program.cs +++ b/sample/Sample.Graphql/Program.cs @@ -1,7 +1,6 @@ using Microsoft.Extensions.DependencyModel; using Rocket.Surgery.Conventions; using Rocket.Surgery.Hosting; -using Rocket.Surgery.LaunchPad.HotChocolate; namespace Sample.Graphql; diff --git a/sample/Sample.Graphql/Sample.Graphql.csproj b/sample/Sample.Graphql/Sample.Graphql.csproj index ac16dc6ae..ef42644c0 100644 --- a/sample/Sample.Graphql/Sample.Graphql.csproj +++ b/sample/Sample.Graphql/Sample.Graphql.csproj @@ -8,12 +8,12 @@ - - + + diff --git a/sample/Sample.Graphql/Startup.cs b/sample/Sample.Graphql/Startup.cs index 24a9444c2..dd95cd22c 100644 --- a/sample/Sample.Graphql/Startup.cs +++ b/sample/Sample.Graphql/Startup.cs @@ -1,25 +1,15 @@ -using System.Collections.Concurrent; -using System.Diagnostics; -using System.Linq.Expressions; -using System.Reflection; -using HotChocolate; -using HotChocolate.Configuration; +using System.Linq.Expressions; using HotChocolate.Data.Filters; using HotChocolate.Data.Sorting; -using HotChocolate.Types; -using HotChocolate.Types.Descriptors; -using HotChocolate.Types.Descriptors.Definitions; using HotChocolate.Types.Pagination; using HotChocolate.Utilities; using MediatR; using Rocket.Surgery.LaunchPad.AspNetCore; -using Rocket.Surgery.LaunchPad.Foundation; using Rocket.Surgery.LaunchPad.HotChocolate; using Sample.Core.Domain; using Sample.Core.Models; using Sample.Core.Operations.LaunchRecords; using Sample.Core.Operations.Rockets; -using Serilog; namespace Sample.Graphql; @@ -55,14 +45,7 @@ public void ConfigureServices(IServiceCollection services) // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - // Should this move into an extension method? - app.UseSerilogRequestLogging( - x => - { - x.GetLevel = LaunchPadLogHelpers.DefaultGetLevel; - x.EnrichDiagnosticContext = LaunchPadLogHelpers.DefaultEnrichDiagnosticContext; - } - ); + app.UseLaunchPadRequestLogging(); app.UseMetricsAllMiddleware(); app.UseRouting(); @@ -131,25 +114,41 @@ public partial record EditLaunchRecordPatchRequest : IOptionalTracking CreateRocket([Service] IMediator mediator, CancellationToken cancellationToken, CreateRocket.Request request) + public Task CreateRocket( + [Service] IMediator mediator, + CreateRocket.Request request, + CancellationToken cancellationToken + ) { return mediator.Send(request, cancellationToken); } [UseServiceScope] - public Task EditRocket([Service] IMediator mediator, CancellationToken cancellationToken, EditRocket.Request request) + public Task EditRocket( + [Service] IMediator mediator, + EditRocket.Request request, + CancellationToken cancellationToken + ) { return mediator.Send(request, cancellationToken); } [UseServiceScope] - public Task PatchRocket([Service] IMediator mediator, CancellationToken cancellationToken, EditRocketPatchRequest request) + public Task PatchRocket( + [Service] IMediator mediator, + EditRocketPatchRequest request, + CancellationToken cancellationToken + ) { return mediator.Send(request.Create(), cancellationToken); } [UseServiceScope] - public Task DeleteRocket([Service] IMediator mediator, CancellationToken cancellationToken, DeleteRocket.Request request) + public Task DeleteRocket( + [Service] IMediator mediator, + DeleteRocket.Request request, + CancellationToken cancellationToken + ) { return mediator.Send(request, cancellationToken); } @@ -160,26 +159,40 @@ public class LaunchRecordMutation { [UseServiceScope] public Task CreateLaunchRecord( - [Service] IMediator mediator, CancellationToken cancellationToken, CreateLaunchRecord.Request request + [Service] IMediator mediator, + CreateLaunchRecord.Request request, + CancellationToken cancellationToken ) { return mediator.Send(request, cancellationToken); } [UseServiceScope] - public Task EditLaunchRecord([Service] IMediator mediator, CancellationToken cancellationToken, EditLaunchRecord.Request request) + public Task EditLaunchRecord( + [Service] IMediator mediator, + EditLaunchRecord.Request request, + CancellationToken cancellationToken + ) { return mediator.Send(request, cancellationToken); } [UseServiceScope] - public Task PatchLaunchRecord([Service] IMediator mediator, CancellationToken cancellationToken, EditLaunchRecordPatchRequest request) + public Task PatchLaunchRecord( + [Service] IMediator mediator, + EditLaunchRecordPatchRequest request, + CancellationToken cancellationToken + ) { return mediator.Send(request.Create(), cancellationToken); } [UseServiceScope] - public Task DeleteLaunchRecord([Service] IMediator mediator, CancellationToken cancellationToken, DeleteLaunchRecord.Request request) + public Task DeleteLaunchRecord( + [Service] IMediator mediator, + DeleteLaunchRecord.Request request, + CancellationToken cancellationToken + ) { return mediator.Send(request, cancellationToken); } @@ -191,7 +204,7 @@ public class QueryType : ObjectTypeExtension protected override void Configure(IObjectTypeDescriptor descriptor) { descriptor - .Field(t => t.GetLaunchRecords(default)) + .Field(t => t.GetLaunchRecords(default!)) .UsePaging>>( options: new PagingOptions { @@ -212,7 +225,7 @@ protected override void Configure(IObjectTypeDescriptor descriptor) .UseFiltering() .UseSorting(); descriptor - .Field(t => t.GetRockets(default)) + .Field(t => t.GetRockets(default!)) .UsePaging>>( options: new PagingOptions { diff --git a/sample/Sample.Grpc/Startup.cs b/sample/Sample.Grpc/Startup.cs index 44506a0e3..e55f54c75 100644 --- a/sample/Sample.Grpc/Startup.cs +++ b/sample/Sample.Grpc/Startup.cs @@ -1,6 +1,5 @@ using Rocket.Surgery.LaunchPad.AspNetCore; using Sample.Grpc.Services; -using Serilog; namespace Sample.Grpc; @@ -15,14 +14,7 @@ public void ConfigureServices(IServiceCollection services) // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - // Should this move into an extension method? - app.UseSerilogRequestLogging( - x => - { - x.GetLevel = LaunchPadLogHelpers.DefaultGetLevel; - x.EnrichDiagnosticContext = LaunchPadLogHelpers.DefaultEnrichDiagnosticContext; - } - ); + app.UseLaunchPadRequestLogging(); app.UseMetricsAllMiddleware(); app.UseRouting(); diff --git a/sample/Sample.Pages/Startup.cs b/sample/Sample.Pages/Startup.cs index 4cc9ea7e9..253aa06ae 100644 --- a/sample/Sample.Pages/Startup.cs +++ b/sample/Sample.Pages/Startup.cs @@ -1,5 +1,4 @@ using Rocket.Surgery.LaunchPad.AspNetCore; -using Serilog; namespace Sample.Pages; @@ -41,14 +40,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseHttpsRedirection(); app.UseStaticFiles(); - // Should this move into an extension method? - app.UseSerilogRequestLogging( - x => - { - x.GetLevel = LaunchPadLogHelpers.DefaultGetLevel; - x.EnrichDiagnosticContext = LaunchPadLogHelpers.DefaultEnrichDiagnosticContext; - } - ); + app.UseLaunchPadRequestLogging(); app.UseMetricsAllMiddleware(); app.UseRouting(); diff --git a/sample/Sample.Restful.Client/Test1.cs b/sample/Sample.Restful.Client/Test1.cs index d350cc396..4db4ff3f8 100644 --- a/sample/Sample.Restful.Client/Test1.cs +++ b/sample/Sample.Restful.Client/Test1.cs @@ -4,6 +4,7 @@ namespace Sample.Restful.Client; public partial class RocketClient { + // ReSharper disable once UnusedParameterInPartialMethod partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings) { // This is required for patching to work as expected diff --git a/sample/Sample.Restful/Program.cs b/sample/Sample.Restful/Program.cs index f5ec9ae91..6ee6e3212 100644 --- a/sample/Sample.Restful/Program.cs +++ b/sample/Sample.Restful/Program.cs @@ -1,7 +1,5 @@ using System.Reflection; using Hellang.Middleware.ProblemDetails; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; using Microsoft.OpenApi.Models; using Rocket.Surgery.LaunchPad.AspNetCore; using Rocket.Surgery.LaunchPad.AspNetCore.AppMetrics; diff --git a/sample/Sample.Worker/Worker.cs b/sample/Sample.Worker/Worker.cs index e6ffab8fd..1451fe3ca 100644 --- a/sample/Sample.Worker/Worker.cs +++ b/sample/Sample.Worker/Worker.cs @@ -19,7 +19,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { - var items = await _mediator.Invoke(m => m.CreateStream(new ListRockets.Request(null), stoppingToken)).ToListAsync(); + var items = await _mediator.Invoke(m => m.CreateStream(new ListRockets.Request(null), stoppingToken)) + .ToListAsync(stoppingToken); _logger.LogInformation("Items: {@Items}", items); await Task.Delay(1000, stoppingToken).ConfigureAwait(false); } diff --git a/src/Analyzers/Composition/RestfulApiMethodBuilder.cs b/src/Analyzers/Composition/RestfulApiMethodBuilder.cs index 5ea2fc637..e771fac05 100644 --- a/src/Analyzers/Composition/RestfulApiMethodBuilder.cs +++ b/src/Analyzers/Composition/RestfulApiMethodBuilder.cs @@ -269,6 +269,4 @@ bool IRestfulApiMethodMatcher.IsMatch(ActionModel actionModel) } } -internal record ActionModel(Compilation Compilation, string ActionName, IMethodSymbol ActionMethod) -{ -} +internal record ActionModel(Compilation Compilation, string ActionName, IMethodSymbol ActionMethod); diff --git a/src/Analyzers/Composition/RestfulApiParameterMatcher.cs b/src/Analyzers/Composition/RestfulApiParameterMatcher.cs index 93ed8eda1..eb92c7082 100644 --- a/src/Analyzers/Composition/RestfulApiParameterMatcher.cs +++ b/src/Analyzers/Composition/RestfulApiParameterMatcher.cs @@ -68,9 +68,9 @@ static bool CheckType(ITypeSymbol symbol, INamedTypeSymbol type) return NameMatch switch { - ApiConventionNameMatchBehavior.Exact => Names.Any(name => parameter.Name!.Equals(name, StringComparison.OrdinalIgnoreCase)), - ApiConventionNameMatchBehavior.Prefix => Names.Any(name => parameter.Name!.StartsWith(name, StringComparison.OrdinalIgnoreCase)), - ApiConventionNameMatchBehavior.Suffix => Names.Any(name => parameter.Name!.EndsWith(name, StringComparison.OrdinalIgnoreCase)), + ApiConventionNameMatchBehavior.Exact => Names.Any(name => parameter.Name.Equals(name, StringComparison.OrdinalIgnoreCase)), + ApiConventionNameMatchBehavior.Prefix => Names.Any(name => parameter.Name.StartsWith(name, StringComparison.OrdinalIgnoreCase)), + ApiConventionNameMatchBehavior.Suffix => Names.Any(name => parameter.Name.EndsWith(name, StringComparison.OrdinalIgnoreCase)), _ => true }; } diff --git a/src/Analyzers/ControllerActionBodyGenerator.cs b/src/Analyzers/ControllerActionBodyGenerator.cs index e0e03799e..67da0cda6 100644 --- a/src/Analyzers/ControllerActionBodyGenerator.cs +++ b/src/Analyzers/ControllerActionBodyGenerator.cs @@ -53,7 +53,6 @@ private static string Pascalize(string input) var parameterType = (INamedTypeSymbol)parameter.Type; var isUnit = parameterType.AllInterfaces.Any(z => z.MetadataName == "IRequest"); var isUnitResult = symbol.ReturnType is INamedTypeSymbol { Arity: 1 } nts && nts.TypeArguments[0].MetadataName == "ActionResult"; - var isRecord = parameterType.IsRecord; var isStream = symbol.ReturnType.MetadataName == "IAsyncEnumerable`1"; var newSyntax = syntax @@ -80,7 +79,7 @@ private static string Pascalize(string input) var declaredParam = newSyntax.ParameterList.Parameters.Single(z => z.Identifier.Text == parameter.Name); var parameterProperties = parameterType.MemberNames .Join( - otherParams, z => z, z => z.Name, (memberName, symbol) => ( memberName, symbol ), + otherParams, z => z, z => z.Name, (memberName, s) => ( memberName, symbol: s ), StringComparer.OrdinalIgnoreCase ) .ToArray(); @@ -243,10 +242,10 @@ private static string Pascalize(string input) Key: "StatusCode", Value: { Kind: TypedConstantKind.Primitive, Value: int } } ) - .Select(z => (int)z.Value.Value!); + .Select(c => (int)c.Value.Value!); var constructorArguments = z - .ConstructorArguments.Where(z => z is { Kind: TypedConstantKind.Primitive, Value: int }) - .Select(z => (int)z.Value!); + .ConstructorArguments.Where(c => c is { Kind: TypedConstantKind.Primitive, Value: int }) + .Select(c => (int)c.Value!); return namedArguments.Concat(constructorArguments); } @@ -373,7 +372,7 @@ static ImmutableArray availableRouteParameters( (MethodDeclarationSyntax method, IMethodSymbol symbol, IRestfulApiMethodMatcher? matcher, IParameterSymbol? request) relatedMember ) { - var parameterNames = relatedMember.symbol.Parameters.Remove(relatedMember.request).Select(z => z.Name); + var parameterNames = relatedMember.symbol.Parameters.Remove(relatedMember.request!).Select(z => z.Name); parameterNames = parameterNames.Concat( relatedMember.request?.Type.GetMembers() .Where(z => z is IPropertySymbol { IsImplicitlyDeclared: false } ps && ps.Name != "EqualityContract") @@ -626,7 +625,7 @@ private void GenerateMethods( var streamRequest = methodSymbol.Parameters.FirstOrDefault( p => p.Type.AllInterfaces.Any(i => i.MetadataName == "IStreamRequest`1") ); - return ( method, symbol: methodSymbol!, matcher, request: request ?? streamRequest ); + return ( method, symbol: methodSymbol, matcher, request: request ?? streamRequest ); } ) .Where(z => z is { symbol: { }, method: { } }) @@ -713,15 +712,20 @@ public void Initialize(IncrementalGeneratorInitializationContext context) namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } }" ); diff --git a/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs b/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs index 3b8574d74..2edd2c96d 100644 --- a/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs +++ b/src/Analyzers/GraphqlOptionalPropertyTrackingGenerator.cs @@ -2,7 +2,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Diagnostics; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Rocket.Surgery.LaunchPad.Analyzers; @@ -45,7 +44,14 @@ INamedTypeSymbol targetSymbol .WithMembers(List()) .WithAttributeLists(List()) .WithConstraintClauses(List()) - .WithBaseList(null); + .WithBaseList(null) + .WithAttributeLists( + SingletonList( + AttributeList( + SingletonSeparatedList(Attribute(ParseName("System.Runtime.CompilerServices.CompilerGenerated"))) + ) + ) + ); var writeableProperties = targetSymbol.GetMembers() @@ -259,7 +265,6 @@ private static MemberDeclarationSyntax[] GenerateTrackingProperties(IPropertySym { var type = GenericName(Identifier("HotChocolate.Optional")) .WithTypeArgumentList(TypeArgumentList(SingletonSeparatedList(typeSyntax))); - var fieldName = $"_{propertySymbol.Name}"; return new MemberDeclarationSyntax[] { PropertyDeclaration(type, Identifier(propertySymbol.Name)) @@ -300,7 +305,7 @@ node is (ClassDeclarationSyntax or RecordDeclarationSyntax) and TypeDeclarationS ) ) .Select( - (tuple, token) => + (tuple, _) => { var interfaceSymbol = tuple.symbol .Interfaces.FirstOrDefault( diff --git a/src/Analyzers/InheritFromGenerator.cs b/src/Analyzers/InheritFromGenerator.cs index 320247ef9..c4772d92a 100644 --- a/src/Analyzers/InheritFromGenerator.cs +++ b/src/Analyzers/InheritFromGenerator.cs @@ -32,7 +32,14 @@ AttributeData[] attributes .WithMembers(List()) .WithAttributeLists(List()) .WithConstraintClauses(List()) - .WithBaseList(null); + .WithBaseList(null) + .WithAttributeLists( + SingletonList( + AttributeList( + SingletonSeparatedList(Attribute(ParseName("System.Runtime.CompilerServices.CompilerGenerated"))) + ) + ) + ); foreach (var attribute in attributes) { diff --git a/src/Analyzers/PropertyTrackingGenerator.cs b/src/Analyzers/PropertyTrackingGenerator.cs index f727b2a07..bb7794383 100644 --- a/src/Analyzers/PropertyTrackingGenerator.cs +++ b/src/Analyzers/PropertyTrackingGenerator.cs @@ -2,7 +2,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Diagnostics; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; namespace Rocket.Surgery.LaunchPad.Analyzers; @@ -45,7 +44,14 @@ INamedTypeSymbol targetSymbol .WithMembers(List()) .WithAttributeLists(List()) .WithConstraintClauses(List()) - .WithBaseList(null); + .WithBaseList(null) + .WithAttributeLists( + SingletonList( + AttributeList( + SingletonSeparatedList(Attribute(ParseName("System.Runtime.CompilerServices.CompilerGenerated"))) + ) + ) + ); var writeableProperties = targetSymbol.GetMembers() @@ -347,7 +353,7 @@ node is (ClassDeclarationSyntax or RecordDeclarationSyntax) and TypeDeclarationS ) ) .Select( - (tuple, token) => + (tuple, _) => { var interfaceSymbol = tuple.symbol .Interfaces.FirstOrDefault( diff --git a/src/AppMetrics/Conventions/AppMetricsConvention.cs b/src/AppMetrics/Conventions/AppMetricsConvention.cs index c22fa9a92..1cf8a58b4 100644 --- a/src/AppMetrics/Conventions/AppMetricsConvention.cs +++ b/src/AppMetrics/Conventions/AppMetricsConvention.cs @@ -4,15 +4,14 @@ using Microsoft.Extensions.Hosting; using Rocket.Surgery.Conventions; using Rocket.Surgery.Hosting; -using Rocket.Surgery.LaunchPad.AppMetrics.Conventions; - -[assembly: Convention(typeof(AppMetricsConvention))] namespace Rocket.Surgery.LaunchPad.AppMetrics.Conventions; /// /// Convention for activating app metrics /// +[PublicAPI] +[ExportConvention] public class AppMetricsConvention : IHostingConvention { /// diff --git a/src/AspNetCore.AppMetrics/Conventions/AppMetricsAspNetCoreConvention.cs b/src/AspNetCore.AppMetrics/Conventions/AppMetricsAspNetCoreConvention.cs index 08c6f558f..8200f0851 100644 --- a/src/AspNetCore.AppMetrics/Conventions/AppMetricsAspNetCoreConvention.cs +++ b/src/AspNetCore.AppMetrics/Conventions/AppMetricsAspNetCoreConvention.cs @@ -3,15 +3,14 @@ using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.LaunchPad.AspNetCore.AppMetrics.Conventions; - -[assembly: Convention(typeof(AppMetricsAspNetCoreConvention))] namespace Rocket.Surgery.LaunchPad.AspNetCore.AppMetrics.Conventions; /// /// Convention for activating App Metrics with Asp.Net Core /// +[PublicAPI] +[ExportConvention] public class AppMetricsAspNetCoreConvention : IServiceConvention { /// diff --git a/src/AspNetCore.NewtonsoftJson/Conventions/NewtonsoftJsonConvention.cs b/src/AspNetCore.NewtonsoftJson/Conventions/NewtonsoftJsonConvention.cs index 125db4c7e..93efa2955 100644 --- a/src/AspNetCore.NewtonsoftJson/Conventions/NewtonsoftJsonConvention.cs +++ b/src/AspNetCore.NewtonsoftJson/Conventions/NewtonsoftJsonConvention.cs @@ -4,11 +4,8 @@ using Newtonsoft.Json; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.LaunchPad.AspNetCore.Conventions; using Rocket.Surgery.LaunchPad.Foundation; -[assembly: Convention(typeof(NewtonsoftJsonConvention))] - namespace Rocket.Surgery.LaunchPad.AspNetCore.Conventions; /// @@ -18,6 +15,7 @@ namespace Rocket.Surgery.LaunchPad.AspNetCore.Conventions; /// /// [PublicAPI] +[ExportConvention] public class NewtonsoftJsonConvention : IServiceConvention { private readonly FoundationOptions _options; diff --git a/src/AspNetCore.Spatial/Conventions/AspNetCoreSpatialConvention.cs b/src/AspNetCore.Spatial/Conventions/AspNetCoreSpatialConvention.cs index f77139201..8cee33ac6 100644 --- a/src/AspNetCore.Spatial/Conventions/AspNetCoreSpatialConvention.cs +++ b/src/AspNetCore.Spatial/Conventions/AspNetCoreSpatialConvention.cs @@ -2,17 +2,16 @@ using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.LaunchPad.AspNetCore.Conventions; using Rocket.Surgery.LaunchPad.AspNetCore.OpenApi; using Swashbuckle.AspNetCore.SwaggerGen; -[assembly: Convention(typeof(AspNetCoreSpatialConvention))] - namespace Rocket.Surgery.LaunchPad.AspNetCore.Conventions; /// /// Convention to register spatial types /// +[PublicAPI] +[ExportConvention] public class AspNetCoreSpatialConvention : IServiceConvention { /// diff --git a/src/AspNetCore.Testing/ConventionTestWebHost.cs b/src/AspNetCore.Testing/ConventionTestWebHost.cs index dac94acf3..6ad43435d 100644 --- a/src/AspNetCore.Testing/ConventionTestWebHost.cs +++ b/src/AspNetCore.Testing/ConventionTestWebHost.cs @@ -1,17 +1,13 @@ using System.Diagnostics; using System.Reactive.Disposables; -using System.Reflection; using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.DependencyModel; using Microsoft.Extensions.Hosting; using NodaTime; using NodaTime.Testing; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.Conventions.Testing; using Rocket.Surgery.Hosting; using Serilog; using Serilog.Extensions.Logging; @@ -19,41 +15,19 @@ namespace Rocket.Surgery.LaunchPad.AspNetCore.Testing; -[ExportConvention] -public class HostingConvention : IHostingConvention, IServiceConvention -{ - public void Register(IConventionContext context, IHostBuilder builder) - { - } - - public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services) - { - } -} - internal sealed class HostingListener : IObserver, IObserver>, IDisposable { private static readonly AsyncLocal _currentListener = new(); - private readonly List> _hostBuilderActions = new(); private readonly CompositeDisposable _disposable = new(); + private ConventionTestHostOptions _options = new(); - public void Attach() + public void Attach(ConventionTestHostOptions? options) { + _options = options ?? _options; _currentListener.Value = this; _disposable.Add(DiagnosticListener.AllListeners.Subscribe(this)); } - /// - /// Add additional configuration to the Host - /// - /// - /// - public HostingListener ConfigureHostBuilder(Action action) - { - _hostBuilderActions.Add(action); - return this; - } - public void Dispose() { _disposable.Dispose(); @@ -92,19 +66,39 @@ public void OnNext(KeyValuePair value) if (value.Key == "HostBuilding") { - var builder = (IHostBuilder)value.Value!; - builder.ConfigureRocketSurgery( - z => + _options.SetupHostBuilder((IHostBuilder)value.Value!); + } + } +} + +internal class ConventionTestHostOptions +{ + private readonly List> _hostBuilderActions = new(); + + public void SetupHostBuilder(IHostBuilder hostBuilder) + { + hostBuilder.ConfigureRocketSurgery( + z => + { + z.Set(HostType.UnitTest); + z.IncludeConvention(typeof(HostingListener).Assembly); + foreach (var item in _hostBuilderActions) { - z.Set(HostType.UnitTest); - z.IncludeConvention(typeof(HostingListener).Assembly); - foreach (var item in _hostBuilderActions) - { - item(z); - } + item(z); } - ); - } + } + ); + } + + /// + /// Add additional configuration to the Host + /// + /// + /// + public ConventionTestHostOptions ConfigureHostBuilder(Action action) + { + _hostBuilderActions.Add(action); + return this; } } @@ -116,19 +110,34 @@ public void OnNext(KeyValuePair value) public class ConventionTestWebHost : WebApplicationFactory where TEntryPoint : class { - private HostingListener _listener = new HostingListener(); + private readonly ConventionTestHostOptions _options = new(); + private HostingListener _listener = new(); + /// public ConventionTestWebHost() { ConfigureClock(); } + /// protected override IHost CreateHost(IHostBuilder builder) { - _listener.Attach(); + _listener.Attach(_options); return base.CreateHost(builder); } + /// + protected override IHostBuilder? CreateHostBuilder() + { + var hostBuilder = base.CreateHostBuilder(); + if (hostBuilder is { }) + { + _options.SetupHostBuilder(hostBuilder); + } + + return hostBuilder; + } + /// /// Configure the default /// @@ -204,7 +213,7 @@ public ConventionTestWebHost ConfigureLoggerFactory(ILoggerFactory /// public ConventionTestWebHost ConfigureHostBuilder(Action action) { - _listener.ConfigureHostBuilder(action); + _options.ConfigureHostBuilder(action); return this; } } diff --git a/src/AspNetCore/AspNetCoreOptions.cs b/src/AspNetCore/AspNetCoreOptions.cs new file mode 100644 index 000000000..cbc2e26ac --- /dev/null +++ b/src/AspNetCore/AspNetCoreOptions.cs @@ -0,0 +1,14 @@ +using System.Reflection; + +namespace Rocket.Surgery.LaunchPad.AspNetCore; + +/// +/// Options for launchpad and aspnet core. +/// +public class AspNetCoreOptions +{ + /// + /// Defines a filter to exclude assembly parts from the application. + /// + public Func AssemblyPartFilter { get; set; } = _ => true; +} diff --git a/src/AspNetCore/Composition/RestfulApiActionModelConvention.cs b/src/AspNetCore/Composition/RestfulApiActionModelConvention.cs index 5b5cfe37f..1ba62a395 100644 --- a/src/AspNetCore/Composition/RestfulApiActionModelConvention.cs +++ b/src/AspNetCore/Composition/RestfulApiActionModelConvention.cs @@ -34,11 +34,11 @@ internal class RestfulApiActionModelConvention : IActionModelConvention, ISchema private static void ExtractParameterDetails(ActionModel action) { var requestParameter = action.Parameters.FirstOrDefault( - z => z.ParameterInfo?.ParameterType.GetInterfaces().Any( + z => z.ParameterInfo.ParameterType.GetInterfaces().Any( i => i.IsGenericType && ( typeof(IRequest<>) == i.GetGenericTypeDefinition() || typeof(IStreamRequest<>) == i.GetGenericTypeDefinition() ) - ) == true + ) ) ; if (requestParameter is null) return; @@ -179,7 +179,7 @@ public void Apply(OpenApiSchema schema, SchemaFilterContext context) if (_propertiesToHideFromOpenApi.TryGetValue(context.Type, out var propertiesToRemove)) { foreach (var property in propertiesToRemove - .Join(schema.Properties, z => z, z => z.Key, (a, b) => b.Key, StringComparer.OrdinalIgnoreCase) + .Join(schema.Properties, z => z, z => z.Key, (_, b) => b.Key, StringComparer.OrdinalIgnoreCase) .ToArray()) { schema.Properties.Remove(property); diff --git a/src/AspNetCore/Conventions/AspNetCoreConvention.cs b/src/AspNetCore/Conventions/AspNetCoreConvention.cs index 86e83eeca..4198f0153 100644 --- a/src/AspNetCore/Conventions/AspNetCoreConvention.cs +++ b/src/AspNetCore/Conventions/AspNetCoreConvention.cs @@ -1,6 +1,4 @@ using System.Reflection; -using FluentValidation; -using FluentValidation.AspNetCore; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.Extensions.Configuration; @@ -80,6 +78,17 @@ private static IEnumerable GetAssemblyClosure(Assembly assembly) } } + private readonly AspNetCoreOptions _options; + + /// + /// Builds the aspnet core convention + /// + /// + public AspNetCoreConvention(AspNetCoreOptions? options = null) + { + _options = options ?? new AspNetCoreOptions(); + } + /// /// Registers the specified context. /// @@ -104,6 +113,7 @@ public void Register(IConventionContext context, IConfiguration configuration, I GetServiceFromCollection(services)!, context.AssemblyCandidateFinder .GetCandidateAssemblies("Rocket.Surgery.LaunchPad.AspNetCore") + .Where(_options.AssemblyPartFilter) .SelectMany(GetApplicationPartAssemblies) ); diff --git a/src/AspNetCore/Conventions/FluentValidationConvention.cs b/src/AspNetCore/Conventions/FluentValidationConvention.cs index 7dd61a15d..bbe73d3a9 100644 --- a/src/AspNetCore/Conventions/FluentValidationConvention.cs +++ b/src/AspNetCore/Conventions/FluentValidationConvention.cs @@ -1,25 +1,16 @@ -using System.Net; -using System.Reflection; -using FluentValidation; +using System.Reflection; using FluentValidation.AspNetCore; -using FluentValidation.Results; using FluentValidation.Validators; -using Hellang.Middleware.ProblemDetails; using MicroElements.Swashbuckle.FluentValidation; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Options; using Microsoft.OpenApi.Any; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; using Rocket.Surgery.Extensions; using Rocket.Surgery.LaunchPad.AspNetCore.Validation; -using Rocket.Surgery.LaunchPad.Foundation; using Rocket.Surgery.LaunchPad.Foundation.Validation; -using ProblemDetailsException = Rocket.Surgery.LaunchPad.Foundation.ProblemDetailsException; namespace Rocket.Surgery.LaunchPad.AspNetCore.Conventions; diff --git a/src/AspNetCore/Conventions/ProblemDetailsConvention.cs b/src/AspNetCore/Conventions/ProblemDetailsConvention.cs index e75e9b164..fe761a650 100644 --- a/src/AspNetCore/Conventions/ProblemDetailsConvention.cs +++ b/src/AspNetCore/Conventions/ProblemDetailsConvention.cs @@ -33,10 +33,10 @@ public void Register(IConventionContext context, IConfiguration configuration, I .AddProblemDetailsConventions(); services.AddOptions() - .Configure(options => options.SuppressModelStateInvalidFilter = true); + .Configure(static options => options.SuppressModelStateInvalidFilter = true); services.AddOptions() .Configure>( - (builder, apiBehaviorOptions) => + static (builder, apiBehaviorOptions) => { var currentIncludeExceptionDetails = builder.IncludeExceptionDetails; builder.IncludeExceptionDetails = (httpContext, exception) => @@ -58,16 +58,16 @@ public void Register(IConventionContext context, IConfiguration configuration, I // builder.MapToProblemDetailsDataException(StatusCodes.Status400BadRequest); // builder.MapToProblemDetailsDataException(StatusCodes.Status403Forbidden); builder.Map( - exception => new FluentValidationProblemDetails(exception.Errors) + static exception => new FluentValidationProblemDetails(exception.Errors) { Status = StatusCodes.Status422UnprocessableEntity } ); builder.Map( - (context, ex) => ex is not IProblemDetailsData && context.Items[typeof(ValidationResult)] is ValidationResult, - (context, _) => + static (ctx, ex) => ex is not IProblemDetailsData && ctx.Items[typeof(ValidationResult)] is ValidationResult, + static (ctx, _) => { - var result = context.Items[typeof(ValidationResult)] as ValidationResult; + var result = ctx.Items[typeof(ValidationResult)] as ValidationResult; return new FluentValidationProblemDetails(result!.Errors) { Status = StatusCodes.Status422UnprocessableEntity diff --git a/src/AspNetCore/Filters/NotFoundExceptionFilter.cs b/src/AspNetCore/Filters/NotFoundExceptionFilter.cs index 4b9754ca2..0c330e42f 100644 --- a/src/AspNetCore/Filters/NotFoundExceptionFilter.cs +++ b/src/AspNetCore/Filters/NotFoundExceptionFilter.cs @@ -1,6 +1,4 @@ using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Infrastructure; using Rocket.Surgery.LaunchPad.Foundation; diff --git a/src/AspNetCore/Filters/RequestFailedExceptionFilter.cs b/src/AspNetCore/Filters/RequestFailedExceptionFilter.cs index f681c1019..ed6cffeb5 100644 --- a/src/AspNetCore/Filters/RequestFailedExceptionFilter.cs +++ b/src/AspNetCore/Filters/RequestFailedExceptionFilter.cs @@ -1,6 +1,4 @@ using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Infrastructure; using Rocket.Surgery.LaunchPad.Foundation; diff --git a/src/AspNetCore/OpenApi/StronglyTypedIdSchemaFilter.cs b/src/AspNetCore/OpenApi/StronglyTypedIdSchemaFilter.cs index f1ac9b274..60e606712 100644 --- a/src/AspNetCore/OpenApi/StronglyTypedIdSchemaFilter.cs +++ b/src/AspNetCore/OpenApi/StronglyTypedIdSchemaFilter.cs @@ -4,7 +4,7 @@ namespace Rocket.Surgery.LaunchPad.AspNetCore.OpenApi; -internal class StronglyTypedIdHelpers +internal static class StronglyTypedIdHelpers { public static bool IsStronglyTypedId(Type? type) { diff --git a/src/AspNetCore/RocketSurgeryMvcCoreExtensions.cs b/src/AspNetCore/RocketSurgeryMvcCoreExtensions.cs index 667c0be8a..3c5685087 100644 --- a/src/AspNetCore/RocketSurgeryMvcCoreExtensions.cs +++ b/src/AspNetCore/RocketSurgeryMvcCoreExtensions.cs @@ -1,5 +1,7 @@ +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.Extensions.DependencyInjection; +using Serilog; namespace Rocket.Surgery.LaunchPad.AspNetCore; @@ -28,6 +30,22 @@ public static IMvcCoreBuilder WithMvcCore(this IServiceCollection services) return new ImmutableMvcBuilder(services, true); } + /// + /// Default request logging for serilog with launchpad + /// + /// + /// + public static IApplicationBuilder UseLaunchPadRequestLogging(this IApplicationBuilder app) + { + return app.UseSerilogRequestLogging( + x => + { + x.GetLevel = LaunchPadLogHelpers.DefaultGetLevel; + x.EnrichDiagnosticContext = LaunchPadLogHelpers.DefaultEnrichDiagnosticContext; + } + ); + } + /// /// AddMvc or AddMvcCore can cause breaking changes if called multiple times over the application lifespan. /// This allows us to ensure that we don't upset that state, but get back the expected mvc builder. diff --git a/src/AspNetCore/Validation/ValidatorInterceptor.cs b/src/AspNetCore/Validation/ValidatorInterceptor.cs index 267160fbf..6b6f7573f 100644 --- a/src/AspNetCore/Validation/ValidatorInterceptor.cs +++ b/src/AspNetCore/Validation/ValidatorInterceptor.cs @@ -19,7 +19,7 @@ public ValidationResult AfterAspNetValidation(ActionContext actionContext, IVali { result = new ValidationResult( result.Errors - .Join(includeProperties, z => z.PropertyName, z => z, (a, b) => a, StringComparer.OrdinalIgnoreCase) + .Join(includeProperties, z => z.PropertyName, z => z, (a, _) => a, StringComparer.OrdinalIgnoreCase) ); } diff --git a/src/EntityFramework.HotChocolate/AutoConfigureDbContextConfigureQueryType.cs b/src/EntityFramework.HotChocolate/AutoConfigureDbContextConfigureQueryType.cs deleted file mode 100644 index 559356eb7..000000000 --- a/src/EntityFramework.HotChocolate/AutoConfigureDbContextConfigureQueryType.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System.Linq.Expressions; -using System.Reflection; -using HotChocolate.Resolvers; -using HotChocolate.Types; -using Humanizer; -using Microsoft.EntityFrameworkCore; - -namespace Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate; - -/// -/// Configure the GraphQl values for a given Entity Framework type. -/// -/// -public class ConfigureConfigureEntityFrameworkContextQueryType : ObjectTypeExtension - where TContext : DbContext -{ - private static IObjectFieldDescriptor ConfigureResolve(IObjectFieldDescriptor typeDescriptor, PropertyInfo propertyInfo) - { - var resolverContextProperty = Expression.Parameter(typeof(IPureResolverContext), "ctx"); - var cancellationTokenProperty = Expression.Parameter(typeof(CancellationToken), "ct"); - - var serviceCall = Expression.Call(resolverContextProperty, nameof(IPureResolverContext.Service), new[] { typeof(TContext) }); - var contextProperty = Expression.Property(serviceCall, propertyInfo); - - var method = Expression.Lambda>(contextProperty, resolverContextProperty, cancellationTokenProperty) - .Compile(); - return typeDescriptor - .UseDbContext() - .Resolve(method); - } - - private static IObjectFieldDescriptor ConfigureResolveModel(IObjectFieldDescriptor typeDescriptor, PropertyInfo propertyInfo) - { - var resolverContextProperty = Expression.Parameter(typeof(IResolverContext), "ctx"); - var cancellationTokenProperty = Expression.Parameter(typeof(CancellationToken), "ct"); - - var serviceCall = Expression.Call( - resolverContextProperty, - typeof(IPureResolverContext).GetMethod(nameof(IPureResolverContext.Service), BindingFlags.Public | BindingFlags.Instance)!.MakeGenericMethod( - typeof(TContext) - ) - ); - var contextProperty = Expression.Property(serviceCall, propertyInfo); - - var projectToMethod = typeof(AutoMapperQueryableExtensions).GetMethod( - nameof(AutoMapperQueryableExtensions.ProjectTo), BindingFlags.Static | BindingFlags.Public - ); - var projectTo = Expression.Call(null, projectToMethod!.MakeGenericMethod(typeof(TEntity), typeof(TModel)), contextProperty, resolverContextProperty); - - var method = Expression - .Lambda>>(projectTo, resolverContextProperty, cancellationTokenProperty) - .Compile(); - return typeDescriptor - .UseDbContext() - .Resolve(method); - } - - - private readonly IEnumerable _configureQueryEntities; - - /// - /// The constructor - /// - /// - public ConfigureConfigureEntityFrameworkContextQueryType(IEnumerable configureQueryEntities) - { - _configureQueryEntities = configureQueryEntities; - } - - /// - /// The constructor - /// - /// - public ConfigureConfigureEntityFrameworkContextQueryType(params IConfigureEntityFrameworkEntityQueryType[] configureQueryEntities) - { - _configureQueryEntities = configureQueryEntities; - } - - public Func MapModel { get; set; } - - /// - protected override void Configure(IObjectTypeDescriptor descriptor) - { - descriptor.Name(OperationTypeNames.Query); - var configure = typeof(ConfigureConfigureEntityFrameworkContextQueryType).GetMethod( - nameof(ConfigureResolve), - BindingFlags.NonPublic | BindingFlags.Static - )!; - var configureModel = typeof(ConfigureConfigureEntityFrameworkContextQueryType).GetMethod( - nameof(ConfigureResolveModel), - BindingFlags.NonPublic | BindingFlags.Static - )!; - var sets = typeof(TContext) - .GetProperties() - .Where(z => z.PropertyType.IsGenericType && z.PropertyType.GetGenericTypeDefinition() == typeof(DbSet<>)) - .ToArray(); - - foreach (var set in sets) - { - var field = descriptor.Field(set.Name.Humanize().Pluralize().Dehumanize().Camelize()); - var entityType = set.PropertyType.GetGenericArguments()[0]; - var modelType = MapModel?.Invoke(entityType); - if (modelType == entityType) - { - configure.MakeGenericMethod(set.PropertyType).Invoke(null, new object[] { field, set }); - } - else if (modelType is { }) - { - configureModel.MakeGenericMethod(set.PropertyType.GetGenericArguments()[0], modelType).Invoke(null, new object[] { field, set }); - } - - Configure(field, set); - foreach (var item in _configureQueryEntities.Where(z => z.Match(set))) - { - item.Configure(field); - } - } - } - - /// - /// Allows further customization by the child class. - /// - /// - /// - protected virtual void Configure(IObjectFieldDescriptor fieldDescriptor, PropertyInfo propertyInfo) - { - } -} diff --git a/src/EntityFramework.HotChocolate/ConfigureEntityFrameworkEntityQueryType.cs b/src/EntityFramework.HotChocolate/ConfigureEntityFrameworkEntityQueryType.cs deleted file mode 100644 index 259a3f064..000000000 --- a/src/EntityFramework.HotChocolate/ConfigureEntityFrameworkEntityQueryType.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Reflection; -using HotChocolate.Types; -using Microsoft.EntityFrameworkCore; - -namespace Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate; - -/// -/// Configure the GraphQl values for a given Entity Framework type. -/// -/// -[PublicAPI] -public class ConfigureEntityFrameworkEntityQueryType : ObjectTypeExtension, IConfigureEntityFrameworkEntityQueryType - where TEntity : class -{ - private readonly Action? _action; - - /// - /// The constructor - /// - public ConfigureEntityFrameworkEntityQueryType() - { - } - - /// - /// The constructor - /// - /// - public ConfigureEntityFrameworkEntityQueryType(Action action) - { - _action = action; - } - - /// - /// Allows further customization by the child class. - /// - /// - /// - public virtual void Configure(IObjectFieldDescriptor fieldDescriptor) - { - if (_action == null) - throw new NotImplementedException("Action was not implemented!"); - _action.Invoke(fieldDescriptor); - } - -#pragma warning disable CA1033 - bool IConfigureEntityFrameworkEntityQueryType.Match(PropertyInfo propertyInfo) -#pragma warning restore CA1033 - { - return propertyInfo.PropertyType == typeof(DbSet); - } -} diff --git a/src/EntityFramework.HotChocolate/IConfigureEntityFrameworkEntityQueryType.cs b/src/EntityFramework.HotChocolate/IConfigureEntityFrameworkEntityQueryType.cs deleted file mode 100644 index d19f03cd0..000000000 --- a/src/EntityFramework.HotChocolate/IConfigureEntityFrameworkEntityQueryType.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using HotChocolate.Types; - -namespace Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate; - -/// -/// Interface for configuring entity framework query types with graphql -/// -public interface IConfigureEntityFrameworkEntityQueryType -{ - /// - /// The method used to the configure the field - /// - /// - void Configure(IObjectFieldDescriptor fieldDescriptor); - - /// - /// Determine if the given property is a match or not. - /// - /// - /// - bool Match(PropertyInfo propertyInfo); -} diff --git a/src/EntityFramework.HotChocolate/Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate.csproj b/src/EntityFramework.HotChocolate/Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate.csproj deleted file mode 100644 index d1bc13238..000000000 --- a/src/EntityFramework.HotChocolate/Rocket.Surgery.LaunchPad.EntityFramework.HotChocolate.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - net6.0 - - $(PackageTags) - - - - - - - - - - - diff --git a/src/Foundation.NewtonsoftJson/Conventions/NewtonsoftJsonConvention.cs b/src/Foundation.NewtonsoftJson/Conventions/NewtonsoftJsonConvention.cs index 1f0fe602f..0288e73d6 100644 --- a/src/Foundation.NewtonsoftJson/Conventions/NewtonsoftJsonConvention.cs +++ b/src/Foundation.NewtonsoftJson/Conventions/NewtonsoftJsonConvention.cs @@ -7,17 +7,16 @@ using NodaTime; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.LaunchPad.Foundation.Conventions; using Rocket.Surgery.LaunchPad.Serilog; using Serilog; -[assembly: Convention(typeof(NewtonsoftJsonConvention))] - namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; /// /// Convention for working with Newtonsoft Json /// +[PublicAPI] +[ExportConvention] public class NewtonsoftJsonConvention : IServiceConvention, ISerilogConvention { /// diff --git a/src/Foundation.NewtonsoftJson/NewtonsoftJsonDestructuringPolicy.cs b/src/Foundation.NewtonsoftJson/NewtonsoftJsonDestructuringPolicy.cs index 2fd181db8..fb42ee80e 100644 --- a/src/Foundation.NewtonsoftJson/NewtonsoftJsonDestructuringPolicy.cs +++ b/src/Foundation.NewtonsoftJson/NewtonsoftJsonDestructuringPolicy.cs @@ -19,7 +19,7 @@ private static LogEventPropertyValue Destructure(JArray ja, ILogEventPropertyVal private static LogEventPropertyValue Destructure(JObject jo, ILogEventPropertyValueFactory propertyValueFactory) { - string typeTag = null; + string? typeTag = null; var props = new List(jo.Count); foreach (var prop in jo.Properties()) @@ -55,7 +55,7 @@ private static LogEventPropertyValue DestructureToDictionaryValue(JObject jo, IL return new DictionaryValue(elements); } - public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, out LogEventPropertyValue result) + public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, out LogEventPropertyValue? result) { switch (value) { diff --git a/src/Foundation/Assigned.cs b/src/Foundation/Assigned.cs index 1a8748126..a9c734efa 100644 --- a/src/Foundation/Assigned.cs +++ b/src/Foundation/Assigned.cs @@ -1,4 +1,5 @@ namespace Rocket.Surgery.LaunchPad.Foundation; +#pragma warning disable CA2225 /// /// The Assigned type is used to differentiate between not set and set input values. @@ -55,7 +56,9 @@ public static implicit operator T(Assigned assigned) /// Creates an empty Assigned that provides a default value. /// /// The default value. +#pragma warning disable CA1000 public static Assigned Empty(T? defaultValue = default) +#pragma warning restore CA1000 { return new(defaultValue, false); } @@ -142,8 +145,13 @@ public override int GetHashCode() /// /// true if both values are equal. /// - public bool Equals(Assigned other) + public bool Equals(Assigned? other) { + if (other is null) + { + return !_hasValue; + } + if (!_hasValue && !other._hasValue) { return true; diff --git a/src/Foundation/Conventions/ConfigurationConvention.cs b/src/Foundation/Conventions/ConfigurationConvention.cs index 342bea8fa..7c344c55d 100644 --- a/src/Foundation/Conventions/ConfigurationConvention.cs +++ b/src/Foundation/Conventions/ConfigurationConvention.cs @@ -1,9 +1,6 @@ using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.Setup; using Rocket.Surgery.Extensions.Configuration; -using Rocket.Surgery.LaunchPad.Foundation.Conventions; - -[assembly: Convention(typeof(ConfigurationConvention))] namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; @@ -11,6 +8,7 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; /// Registers json configuration /// [PublicAPI] +[ExportConvention] public class ConfigurationConvention : ISetupConvention { /// diff --git a/src/Foundation/Conventions/DefaultConvention.cs b/src/Foundation/Conventions/DefaultConvention.cs index 0a7d81800..9a49800f0 100644 --- a/src/Foundation/Conventions/DefaultConvention.cs +++ b/src/Foundation/Conventions/DefaultConvention.cs @@ -2,9 +2,6 @@ using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.LaunchPad.Foundation.Conventions; - -[assembly: Convention(typeof(DefaultConvention))] namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; @@ -13,6 +10,8 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public class DefaultConvention : IServiceConvention { /// diff --git a/src/Foundation/Conventions/FluentValidationConvention.cs b/src/Foundation/Conventions/FluentValidationConvention.cs index bdbb65668..fe6bd9088 100644 --- a/src/Foundation/Conventions/FluentValidationConvention.cs +++ b/src/Foundation/Conventions/FluentValidationConvention.cs @@ -6,11 +6,8 @@ using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; using Rocket.Surgery.Conventions.Reflection; -using Rocket.Surgery.LaunchPad.Foundation.Conventions; using Rocket.Surgery.LaunchPad.Foundation.Validation; -[assembly: Convention(typeof(FluentValidationConvention))] - namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; /// @@ -19,6 +16,8 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; /// /// /// +[PublicAPI] +[ExportConvention] [AfterConvention(typeof(MediatRConvention))] public class FluentValidationConvention : IServiceConvention { diff --git a/src/Foundation/Conventions/MediatRConvention.cs b/src/Foundation/Conventions/MediatRConvention.cs index 6e18a40ec..0ce07584d 100644 --- a/src/Foundation/Conventions/MediatRConvention.cs +++ b/src/Foundation/Conventions/MediatRConvention.cs @@ -4,9 +4,6 @@ using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; using Rocket.Surgery.Conventions.Reflection; -using Rocket.Surgery.LaunchPad.Foundation.Conventions; - -[assembly: Convention(typeof(MediatRConvention))] namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; @@ -15,6 +12,8 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public class MediatRConvention : IServiceConvention { private readonly FoundationOptions _options; diff --git a/src/Foundation/Conventions/NodaTimeConvention.cs b/src/Foundation/Conventions/NodaTimeConvention.cs index 4c1e09741..6ad08b5d3 100644 --- a/src/Foundation/Conventions/NodaTimeConvention.cs +++ b/src/Foundation/Conventions/NodaTimeConvention.cs @@ -5,12 +5,9 @@ using NodaTime.TimeZones; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.LaunchPad.Foundation.Conventions; using Rocket.Surgery.LaunchPad.Serilog; using Serilog; -[assembly: Convention(typeof(NodaTimeConvention))] - namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; /// @@ -18,6 +15,7 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; /// /// [PublicAPI] +[ExportConvention] public class NodaTimeConvention : IServiceConvention, ISerilogConvention { private readonly FoundationOptions _options; diff --git a/src/Foundation/Conventions/SystemTextJsonConvention.cs b/src/Foundation/Conventions/SystemTextJsonConvention.cs index 7f15a8aa5..a028e8ead 100644 --- a/src/Foundation/Conventions/SystemTextJsonConvention.cs +++ b/src/Foundation/Conventions/SystemTextJsonConvention.cs @@ -6,12 +6,9 @@ using NodaTime; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.LaunchPad.Foundation.Conventions; using Rocket.Surgery.LaunchPad.Serilog; using Serilog; -[assembly: Convention(typeof(SystemTextJsonConvention))] - namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; /// @@ -19,6 +16,8 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public class SystemTextJsonConvention : IServiceConvention, ISerilogConvention { /// diff --git a/src/Foundation/FluentValidationExtensions.cs b/src/Foundation/FluentValidationExtensions.cs index f5138b2e8..319c8a71d 100644 --- a/src/Foundation/FluentValidationExtensions.cs +++ b/src/Foundation/FluentValidationExtensions.cs @@ -43,25 +43,6 @@ params string[] values return ruleBuilder.SetValidator(new StringInValidator(values, false)); } - /// - /// Uses the polymorphic validator. - /// - /// - /// The type of the t property. - /// The builder. - /// IRuleBuilderOptions{T, TProperty}. - public static IRuleBuilderOptions UsePolymorphicValidator( - this IRuleBuilder builder - ) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.SetAsyncValidator(new PolymorphicPropertyValidator()); - } - /// /// Get a fluent validation validator if defined. /// diff --git a/src/Foundation/NodaTimeDestructuringPolicy.cs b/src/Foundation/NodaTimeDestructuringPolicy.cs index 18ad1ad87..d76c29ee4 100644 --- a/src/Foundation/NodaTimeDestructuringPolicy.cs +++ b/src/Foundation/NodaTimeDestructuringPolicy.cs @@ -1,4 +1,3 @@ -using System.Text.Json; using NodaTime; using NodaTime.Text; using Serilog.Core; @@ -17,7 +16,6 @@ public NodaTimeDestructuringPolicy(IDateTimeZoneProvider provider) public bool TryDestructure(object value, ILogEventPropertyValueFactory _, out LogEventPropertyValue? result) { - ScalarValue a; if (value is Instant instant1) { result = new ScalarValue(InstantPattern.ExtendedIso.Format(instant1)); diff --git a/src/Foundation/PatchRequestHandler.cs b/src/Foundation/PatchRequestHandler.cs index 2e92016c0..b30e24d9c 100644 --- a/src/Foundation/PatchRequestHandler.cs +++ b/src/Foundation/PatchRequestHandler.cs @@ -24,7 +24,7 @@ protected PatchRequestHandler(IMediator mediator) } /// - /// Method used to get , database calls, etc. + /// Method used to get request database calls, etc. /// /// /// diff --git a/src/Foundation/ProblemDetailsException.cs b/src/Foundation/ProblemDetailsException.cs index 9b0d445f5..abee1ed74 100644 --- a/src/Foundation/ProblemDetailsException.cs +++ b/src/Foundation/ProblemDetailsException.cs @@ -8,7 +8,14 @@ namespace Rocket.Surgery.LaunchPad.Foundation; public abstract class ProblemDetailsException : Exception, IProblemDetailsData { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. + /// + private ProblemDetailsException() : this("An problem occurred.") + { + } + + /// + /// Initializes a new instance of the class. /// /// The message that describes the error. protected ProblemDetailsException(string message) : base(message) @@ -16,7 +23,7 @@ protected ProblemDetailsException(string message) : base(message) } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The error message that explains the reason for the exception. /// diff --git a/src/Foundation/RequestFailedException.cs b/src/Foundation/RequestFailedException.cs index 4c1c0a4c2..17a11467b 100644 --- a/src/Foundation/RequestFailedException.cs +++ b/src/Foundation/RequestFailedException.cs @@ -8,7 +8,7 @@ namespace Rocket.Surgery.LaunchPad.Foundation; /// /// [PublicAPI] -public class RequestFailedException : ProblemDetailsException, IProblemDetailsData +public class RequestFailedException : ProblemDetailsException { /// /// Initializes a new instance of the class. diff --git a/src/Foundation/Rocket.Surgery.LaunchPad.Foundation.csproj b/src/Foundation/Rocket.Surgery.LaunchPad.Foundation.csproj index c1ccecbad..702f33944 100644 --- a/src/Foundation/Rocket.Surgery.LaunchPad.Foundation.csproj +++ b/src/Foundation/Rocket.Surgery.LaunchPad.Foundation.csproj @@ -11,6 +11,7 @@ + diff --git a/src/Foundation/Validation/PolymorphicPropertyValidator.cs b/src/Foundation/Validation/PolymorphicPropertyValidator.cs deleted file mode 100644 index bd245f9cb..000000000 --- a/src/Foundation/Validation/PolymorphicPropertyValidator.cs +++ /dev/null @@ -1,27 +0,0 @@ -using FluentValidation; -using FluentValidation.Validators; -using Microsoft.Extensions.DependencyInjection; - -namespace Rocket.Surgery.LaunchPad.Foundation.Validation; - -/// -/// PolymorphicPropertyValidator. -/// -/// -/// -public class PolymorphicPropertyValidator : AsyncPropertyValidator -{ - /// - public override string Name { get; } = "PolymorphicPropertyValidator"; - - /// - public override async Task IsValidAsync(ValidationContext context, TProperty value, CancellationToken cancellation) - { - // bail out if the property is null - if (value is not { }) return true; - - var factory = context.GetServiceProvider().GetService(); - var validator = factory.GetValidator(value.GetType()); - return validator is null || ( await validator.ValidateAsync(context, cancellation).ConfigureAwait(false) ).IsValid; - } -} diff --git a/src/Functions/Conventions/SerilogFunctionsConvention.cs b/src/Functions/Conventions/SerilogFunctionsConvention.cs index 02bf286d6..d56787f7d 100644 --- a/src/Functions/Conventions/SerilogFunctionsConvention.cs +++ b/src/Functions/Conventions/SerilogFunctionsConvention.cs @@ -4,14 +4,11 @@ using Microsoft.Extensions.Logging; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.LaunchPad.Functions.Conventions; using Rocket.Surgery.LaunchPad.Serilog; using Serilog; using Serilog.Extensions.Logging; using ILogger = Serilog.ILogger; -[assembly: Convention(typeof(SerilogFunctionsConvention))] - namespace Rocket.Surgery.LaunchPad.Functions.Conventions; /// @@ -19,6 +16,8 @@ namespace Rocket.Surgery.LaunchPad.Functions.Conventions; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public class SerilogFunctionsConvention : IServiceConvention { private readonly LaunchPadLoggingOptions _options; @@ -108,9 +107,9 @@ public void Register(IConventionContext context, IConfiguration configuration, I } ); - if (context.Get() != null) + if (context.Get() is { } loggerFactory) { - services.AddSingleton(context.Get()); + services.AddSingleton(loggerFactory); } } } diff --git a/src/Graphql/Rocket.Surgery.LaunchPad.Graphql.csproj b/src/Graphql/Rocket.Surgery.LaunchPad.Graphql.csproj deleted file mode 100644 index c95961e47..000000000 --- a/src/Graphql/Rocket.Surgery.LaunchPad.Graphql.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - netcoreapp3.1;net6.0 - - $(PackageTags) - - - - - - - - - - - - - - diff --git a/src/Grpc/Conventions/GrpcConvention.cs b/src/Grpc/Conventions/GrpcConvention.cs index f0f0a5a6f..171cf8cd7 100644 --- a/src/Grpc/Conventions/GrpcConvention.cs +++ b/src/Grpc/Conventions/GrpcConvention.cs @@ -2,12 +2,8 @@ using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.LaunchPad.Foundation; -using Rocket.Surgery.LaunchPad.Grpc.Conventions; using Rocket.Surgery.LaunchPad.Grpc.Validation; -[assembly: Convention(typeof(GrpcConvention))] - namespace Rocket.Surgery.LaunchPad.Grpc.Conventions; /// @@ -17,6 +13,7 @@ namespace Rocket.Surgery.LaunchPad.Grpc.Conventions; /// /// [PublicAPI] +[ExportConvention] public class GrpcConvention : IServiceConvention { /// diff --git a/src/Grpc/Validation/ValidationInterceptor.cs b/src/Grpc/Validation/ValidationInterceptor.cs index 78bf43351..b8a6022a0 100644 --- a/src/Grpc/Validation/ValidationInterceptor.cs +++ b/src/Grpc/Validation/ValidationInterceptor.cs @@ -13,7 +13,7 @@ private static RpcException CreateException(ValidationResult results, string? me validationMetadata.Add("title", "Unprocessable Entity"); validationMetadata.Add("link", "https://tools.ietf.org/html/rfc4918#section-11.2"); if (message is { }) validationMetadata.Add("message", message); - throw new RpcException(new Status(StatusCode.InvalidArgument, message), validationMetadata, message); + throw new RpcException(new Status(StatusCode.InvalidArgument, message ?? ""), validationMetadata, message ?? ""); } private readonly IValidatorErrorMessageHandler _handler; diff --git a/src/Hosting/Conventions/EnvironmentLoggingConvention.cs b/src/Hosting/Conventions/EnvironmentLoggingConvention.cs index 8a2d46d56..832bf7203 100644 --- a/src/Hosting/Conventions/EnvironmentLoggingConvention.cs +++ b/src/Hosting/Conventions/EnvironmentLoggingConvention.cs @@ -1,12 +1,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Rocket.Surgery.Conventions; -using Rocket.Surgery.LaunchPad.Hosting.Conventions; using Rocket.Surgery.LaunchPad.Serilog; using Serilog; -[assembly: Convention(typeof(EnvironmentLoggingConvention))] - namespace Rocket.Surgery.LaunchPad.Hosting.Conventions; /// @@ -14,6 +11,8 @@ namespace Rocket.Surgery.LaunchPad.Hosting.Conventions; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public class EnvironmentLoggingConvention : ISerilogConvention { /// diff --git a/src/Hosting/Conventions/HealthChecksConvention.cs b/src/Hosting/Conventions/HealthChecksConvention.cs new file mode 100644 index 000000000..ed03b64ee --- /dev/null +++ b/src/Hosting/Conventions/HealthChecksConvention.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Rocket.Surgery.Conventions; +using Rocket.Surgery.Conventions.DependencyInjection; +using Rocket.Surgery.LaunchPad.Serilog; + +namespace Rocket.Surgery.LaunchPad.Hosting.Conventions; + +/// +/// EnvironmentLoggingConvention. +/// Implements the +/// +/// +[PublicAPI] +[ExportConvention] +public class HealthChecksConvention : IServiceConvention +{ + /// + public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services) + { + services.AddHealthChecks(); + } +} diff --git a/src/Hosting/Conventions/SerilogConsoleLoggingConvention.cs b/src/Hosting/Conventions/SerilogConsoleLoggingConvention.cs index 397ebf1c0..bf414ecad 100644 --- a/src/Hosting/Conventions/SerilogConsoleLoggingConvention.cs +++ b/src/Hosting/Conventions/SerilogConsoleLoggingConvention.cs @@ -1,13 +1,10 @@ using Microsoft.Extensions.Configuration; using Rocket.Surgery.Conventions; -using Rocket.Surgery.LaunchPad.Hosting.Conventions; using Rocket.Surgery.LaunchPad.Serilog; using Serilog; using Serilog.Events; using Serilog.Sinks.SystemConsole.Themes; -[assembly: Convention(typeof(SerilogConsoleLoggingConvention))] - namespace Rocket.Surgery.LaunchPad.Hosting.Conventions; /// @@ -15,6 +12,8 @@ namespace Rocket.Surgery.LaunchPad.Hosting.Conventions; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public sealed class SerilogConsoleLoggingConvention : ISerilogConvention { private readonly LaunchPadLoggingOptions _options; diff --git a/src/Hosting/Conventions/SerilogDebugLoggingConvention.cs b/src/Hosting/Conventions/SerilogDebugLoggingConvention.cs index 29bcda9a4..f9171b9a3 100644 --- a/src/Hosting/Conventions/SerilogDebugLoggingConvention.cs +++ b/src/Hosting/Conventions/SerilogDebugLoggingConvention.cs @@ -1,12 +1,9 @@ using Microsoft.Extensions.Configuration; using Rocket.Surgery.Conventions; -using Rocket.Surgery.LaunchPad.Hosting.Conventions; using Rocket.Surgery.LaunchPad.Serilog; using Serilog; using Serilog.Events; -[assembly: Convention(typeof(SerilogDebugLoggingConvention))] - namespace Rocket.Surgery.LaunchPad.Hosting.Conventions; /// @@ -14,6 +11,8 @@ namespace Rocket.Surgery.LaunchPad.Hosting.Conventions; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public sealed class SerilogDebugLoggingConvention : ISerilogConvention { private readonly LaunchPadLoggingOptions _options; diff --git a/src/Hosting/Conventions/SerilogHostingConvention.cs b/src/Hosting/Conventions/SerilogHostingConvention.cs index ec795ea91..12038b04e 100644 --- a/src/Hosting/Conventions/SerilogHostingConvention.cs +++ b/src/Hosting/Conventions/SerilogHostingConvention.cs @@ -4,13 +4,10 @@ using Microsoft.Extensions.Logging; using Rocket.Surgery.Conventions; using Rocket.Surgery.Hosting; -using Rocket.Surgery.LaunchPad.Hosting.Conventions; using Rocket.Surgery.LaunchPad.Serilog; using Serilog; using ILogger = Serilog.ILogger; -[assembly: Convention(typeof(SerilogHostingConvention))] - namespace Rocket.Surgery.LaunchPad.Hosting.Conventions; /// @@ -18,6 +15,8 @@ namespace Rocket.Surgery.LaunchPad.Hosting.Conventions; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public class SerilogHostingConvention : IHostingConvention { private readonly LaunchPadLoggingOptions _options; diff --git a/src/Hosting/Rocket.Surgery.LaunchPad.Hosting.csproj b/src/Hosting/Rocket.Surgery.LaunchPad.Hosting.csproj index 88b0f1bd9..13f311083 100644 --- a/src/Hosting/Rocket.Surgery.LaunchPad.Hosting.csproj +++ b/src/Hosting/Rocket.Surgery.LaunchPad.Hosting.csproj @@ -1,7 +1,7 @@  netstandard2.1;net6.0 - + $(PackageTags) @@ -10,6 +10,7 @@ + diff --git a/src/HotChocolate/Conventions/GraphqlConvention.cs b/src/HotChocolate/Conventions/GraphqlConvention.cs index c6975bdd0..75a54c7ef 100644 --- a/src/HotChocolate/Conventions/GraphqlConvention.cs +++ b/src/HotChocolate/Conventions/GraphqlConvention.cs @@ -1,22 +1,19 @@ -using HotChocolate.Types; -using MediatR; +using MediatR; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.Conventions.Reflection; using Rocket.Surgery.LaunchPad.Foundation; -using Rocket.Surgery.LaunchPad.HotChocolate.Conventions; using Rocket.Surgery.LaunchPad.HotChocolate.Types; -[assembly: Convention(typeof(GraphqlConvention))] - namespace Rocket.Surgery.LaunchPad.HotChocolate.Conventions; /// /// The graph ql convention /// +[PublicAPI] +[ExportConvention] [BeforeConvention(typeof(HotChocolateConvention))] public class GraphqlConvention : IServiceConvention { diff --git a/src/HotChocolate/Conventions/HotChocolateConvention.cs b/src/HotChocolate/Conventions/HotChocolateConvention.cs index 7ae9c9e30..ccf5de8cd 100644 --- a/src/HotChocolate/Conventions/HotChocolateConvention.cs +++ b/src/HotChocolate/Conventions/HotChocolateConvention.cs @@ -3,16 +3,15 @@ using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; using Rocket.Surgery.LaunchPad.HotChocolate.Configuration; -using Rocket.Surgery.LaunchPad.HotChocolate.Conventions; using Rocket.Surgery.LaunchPad.HotChocolate.Extensions; -[assembly: Convention(typeof(HotChocolateConvention))] - namespace Rocket.Surgery.LaunchPad.HotChocolate.Conventions; /// /// Hot Chocolate convention /// +[PublicAPI] +[ExportConvention] public class HotChocolateConvention : IServiceConvention { /// diff --git a/src/HotChocolate/GraphqlExtensions.cs b/src/HotChocolate/GraphqlExtensions.cs index 19b53f4b7..138f95a49 100644 --- a/src/HotChocolate/GraphqlExtensions.cs +++ b/src/HotChocolate/GraphqlExtensions.cs @@ -2,10 +2,8 @@ using System.Reflection; using HotChocolate; using HotChocolate.Data.Filters; -using HotChocolate.Data.Sorting; using HotChocolate.Execution.Configuration; using HotChocolate.Types; -using HotChocolate.Types.Descriptors; using HotChocolate.Utilities; using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.LaunchPad.Foundation; diff --git a/src/HotChocolate/Types/VoidType.cs b/src/HotChocolate/Types/VoidType.cs index baccfc9bd..0e6d8ddde 100644 --- a/src/HotChocolate/Types/VoidType.cs +++ b/src/HotChocolate/Types/VoidType.cs @@ -27,7 +27,7 @@ public override bool IsInstanceOfType(IValueNode valueSyntax) /// public override object? ParseLiteral(IValueNode valueSyntax) { - return new object(); + return (object?)new object(); } /// diff --git a/src/Mapping.NewtonsoftJson/AutoMapperNewtonsoftJsonConvention.cs b/src/Mapping.NewtonsoftJson/AutoMapperNewtonsoftJsonConvention.cs index d50a0bc6f..d0ace2847 100644 --- a/src/Mapping.NewtonsoftJson/AutoMapperNewtonsoftJsonConvention.cs +++ b/src/Mapping.NewtonsoftJson/AutoMapperNewtonsoftJsonConvention.cs @@ -2,9 +2,6 @@ using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.LaunchPad.Mapping; - -[assembly: Convention(typeof(AutoMapperNewtonsoftJsonConvention))] namespace Rocket.Surgery.LaunchPad.Mapping; @@ -13,6 +10,8 @@ namespace Rocket.Surgery.LaunchPad.Mapping; /// Implements the /// /// +[PublicAPI] +[ExportConvention] [DependsOnConvention(typeof(AutoMapperConvention))] public class AutoMapperNewtonsoftJsonConvention : IServiceConvention { diff --git a/src/Mapping/AutoMapperConvention.cs b/src/Mapping/AutoMapperConvention.cs index 974e522a3..1ddf010a6 100644 --- a/src/Mapping/AutoMapperConvention.cs +++ b/src/Mapping/AutoMapperConvention.cs @@ -3,9 +3,6 @@ using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; using Rocket.Surgery.Conventions.Reflection; -using Rocket.Surgery.LaunchPad.Mapping; - -[assembly: Convention(typeof(AutoMapperConvention))] namespace Rocket.Surgery.LaunchPad.Mapping; @@ -14,6 +11,8 @@ namespace Rocket.Surgery.LaunchPad.Mapping; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public class AutoMapperConvention : IServiceConvention { private readonly AutoMapperOptions _options; diff --git a/src/Mapping/Profiles/NodaTimeProfile.cs b/src/Mapping/Profiles/NodaTimeProfile.cs index 05d732e0b..e4c5ec707 100644 --- a/src/Mapping/Profiles/NodaTimeProfile.cs +++ b/src/Mapping/Profiles/NodaTimeProfile.cs @@ -1,6 +1,5 @@ using AutoMapper; using NodaTime; -using NodaTime.Extensions; using NodaTime.Text; namespace Rocket.Surgery.LaunchPad.Mapping.Profiles; diff --git a/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs b/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs index ebe5f248c..6b359f890 100644 --- a/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs +++ b/src/Serilog/Conventions/ConfigureOptionsLoggingConvention.cs @@ -2,11 +2,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Rocket.Surgery.Conventions; -using Rocket.Surgery.LaunchPad.Serilog.Conventions; using Serilog; -[assembly: Convention(typeof(ConfigureOptionsLoggingConvention))] - namespace Rocket.Surgery.LaunchPad.Serilog.Conventions; /// @@ -14,6 +11,8 @@ namespace Rocket.Surgery.LaunchPad.Serilog.Conventions; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public class ConfigureOptionsLoggingConvention : ISerilogConvention { /// diff --git a/src/Serilog/Conventions/SerilogEnrichEnvironmentLoggingConvention.cs b/src/Serilog/Conventions/SerilogEnrichEnvironmentLoggingConvention.cs index 61b86db93..aadabbee7 100644 --- a/src/Serilog/Conventions/SerilogEnrichEnvironmentLoggingConvention.cs +++ b/src/Serilog/Conventions/SerilogEnrichEnvironmentLoggingConvention.cs @@ -1,10 +1,7 @@ using Microsoft.Extensions.Configuration; using Rocket.Surgery.Conventions; -using Rocket.Surgery.LaunchPad.Serilog.Conventions; using Serilog; -[assembly: Convention(typeof(SerilogEnrichLoggingConvention))] - namespace Rocket.Surgery.LaunchPad.Serilog.Conventions; /// @@ -12,6 +9,8 @@ namespace Rocket.Surgery.LaunchPad.Serilog.Conventions; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public class SerilogEnrichEnvironmentLoggingConvention : ISerilogConvention { /// diff --git a/src/Serilog/Conventions/SerilogEnrichLoggingConvention.cs b/src/Serilog/Conventions/SerilogEnrichLoggingConvention.cs index 674b77d5c..a39d0dd8b 100644 --- a/src/Serilog/Conventions/SerilogEnrichLoggingConvention.cs +++ b/src/Serilog/Conventions/SerilogEnrichLoggingConvention.cs @@ -1,10 +1,7 @@ using Microsoft.Extensions.Configuration; using Rocket.Surgery.Conventions; -using Rocket.Surgery.LaunchPad.Serilog.Conventions; using Serilog; -[assembly: Convention(typeof(SerilogEnrichLoggingConvention))] - namespace Rocket.Surgery.LaunchPad.Serilog.Conventions; /// @@ -12,6 +9,8 @@ namespace Rocket.Surgery.LaunchPad.Serilog.Conventions; /// Implements the /// /// +[PublicAPI] +[ExportConvention] public class SerilogEnrichLoggingConvention : ISerilogConvention { /// diff --git a/src/Serilog/Conventions/SerilogReadFromConfigurationConvention.cs b/src/Serilog/Conventions/SerilogReadFromConfigurationConvention.cs index f7421bf95..360e8d272 100644 --- a/src/Serilog/Conventions/SerilogReadFromConfigurationConvention.cs +++ b/src/Serilog/Conventions/SerilogReadFromConfigurationConvention.cs @@ -2,12 +2,9 @@ using Microsoft.Extensions.Logging; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.Configuration; -using Rocket.Surgery.LaunchPad.Serilog.Conventions; using Serilog; using Serilog.Extensions.Logging; -[assembly: Convention(typeof(SerilogReadFromConfigurationConvention))] - namespace Rocket.Surgery.LaunchPad.Serilog.Conventions; /// @@ -15,7 +12,9 @@ namespace Rocket.Surgery.LaunchPad.Serilog.Conventions; /// Implements the /// /// +[PublicAPI] [LiveConvention] +[ExportConvention] public class SerilogReadFromConfigurationConvention : ISerilogConvention, IConfigurationConvention { /// diff --git a/src/Spatial.NewtonsoftJson/Conventions/SpactialNewtonsoftJsonConvention.cs b/src/Spatial.NewtonsoftJson/Conventions/SpactialNewtonsoftJsonConvention.cs index d06327b3c..992b0b043 100644 --- a/src/Spatial.NewtonsoftJson/Conventions/SpactialNewtonsoftJsonConvention.cs +++ b/src/Spatial.NewtonsoftJson/Conventions/SpactialNewtonsoftJsonConvention.cs @@ -6,15 +6,14 @@ using Newtonsoft.Json; using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; -using Rocket.Surgery.LaunchPad.Spatial.Conventions; - -[assembly: Convention(typeof(SpatialNewtonsoftJsonConvention))] namespace Rocket.Surgery.LaunchPad.Spatial.Conventions; /// /// Adds support for spatial types into Newtonsoft Json /// +[PublicAPI] +[ExportConvention] public class SpatialNewtonsoftJsonConvention : IServiceConvention { /// diff --git a/src/Spatial/Conventions/SpatialConvention.cs b/src/Spatial/Conventions/SpatialConvention.cs index 800dda9df..6402fa602 100644 --- a/src/Spatial/Conventions/SpatialConvention.cs +++ b/src/Spatial/Conventions/SpatialConvention.cs @@ -7,16 +7,15 @@ using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; using Rocket.Surgery.LaunchPad.Serilog; -using Rocket.Surgery.LaunchPad.Spatial.Conventions; using Serilog; -[assembly: Convention(typeof(SpatialConvention))] - namespace Rocket.Surgery.LaunchPad.Spatial.Conventions; /// /// Adds support for spatial types into STJ /// +[PublicAPI] +[ExportConvention] public class SpatialConvention : IServiceConvention, ISerilogConvention { /// diff --git a/src/Spatial/NetTopologySuiteDestructuringPolicy.cs b/src/Spatial/NetTopologySuiteDestructuringPolicy.cs index 2123e21c2..7055b04e3 100644 --- a/src/Spatial/NetTopologySuiteDestructuringPolicy.cs +++ b/src/Spatial/NetTopologySuiteDestructuringPolicy.cs @@ -1,4 +1,3 @@ -using NetTopologySuite; using NetTopologySuite.Algorithm; using NetTopologySuite.Features; using NetTopologySuite.Geometries; @@ -12,7 +11,7 @@ internal class NetTopologySuiteDestructuringPolicy : IDestructuringPolicy public const string defaultIdPropertyName = "_NetTopologySuite_id"; - internal static LogEventProperty WriteBBox(Envelope value, Geometry? geometry) + internal static LogEventProperty? WriteBBox(Envelope? value, Geometry? geometry) { // if we don't want to write "null" bounding boxes, bail out. if (value == null || value.IsNull) @@ -22,10 +21,6 @@ internal static LogEventProperty WriteBBox(Envelope value, Geometry? geometry) if (geometry is Point) return null; - // if value == null, try to get it from geometry - if (value == null) - value = geometry?.EnvelopeInternal ?? new Envelope(); - return new LogEventProperty( "bbox", value.IsNull diff --git a/src/Testing/FakeClockConvention.cs b/src/Testing/FakeClockConvention.cs index b9b97c096..9783b1428 100644 --- a/src/Testing/FakeClockConvention.cs +++ b/src/Testing/FakeClockConvention.cs @@ -6,16 +6,15 @@ using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.DependencyInjection; using Rocket.Surgery.LaunchPad.Foundation.Conventions; -using Rocket.Surgery.LaunchPad.Testing; - -[assembly: Convention(typeof(FakeClockConvention))] namespace Rocket.Surgery.LaunchPad.Testing; /// /// A fake clock convention used during unit testing /// +[PublicAPI] [UnitTestConvention] +[ExportConvention] [BeforeConvention(typeof(NodaTimeConvention))] public class FakeClockConvention : IServiceConvention { diff --git a/test/Analyzers.Tests/ControllerActionBodyGeneratorTests.cs b/test/Analyzers.Tests/ControllerActionBodyGeneratorTests.cs index ec91e94ae..719382f13 100644 --- a/test/Analyzers.Tests/ControllerActionBodyGeneratorTests.cs +++ b/test/Analyzers.Tests/ControllerActionBodyGeneratorTests.cs @@ -1,12 +1,9 @@ -using System.Security.Cryptography; -using System.Text; using Analyzers.Tests.Helpers; using MediatR; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Rocket.Surgery.LaunchPad.Analyzers; using Rocket.Surgery.LaunchPad.AspNetCore; -using Xunit.Abstractions; namespace Analyzers.Tests; diff --git a/test/Analyzers.Tests/GraphqlOptionalPropertyTrackingGeneratorTests.cs b/test/Analyzers.Tests/GraphqlOptionalPropertyTrackingGeneratorTests.cs index 61250aa42..e989496d3 100644 --- a/test/Analyzers.Tests/GraphqlOptionalPropertyTrackingGeneratorTests.cs +++ b/test/Analyzers.Tests/GraphqlOptionalPropertyTrackingGeneratorTests.cs @@ -148,7 +148,7 @@ public partial record PatchRocket : IOptionalTracking, IRequest(out var output).Should().BeTrue(); + result.TryGetResult(out _).Should().BeTrue(); await Verify(result); } @@ -173,7 +173,7 @@ public partial record PatchRocket : IOptionalTracking, IRequest(out var output).Should().BeTrue(); + result.TryGetResult(out _).Should().BeTrue(); await Verify(result); } @@ -198,7 +198,7 @@ public partial record PatchRocket : IOptionalTracking, IRequest(out var output).Should().BeTrue(); + result.TryGetResult(out _).Should().BeTrue(); await Verify(result); } @@ -224,7 +224,7 @@ public partial record PatchRocketUnderTest : IOptionalTracking } "; var result = await GenerateAsync(source); - result.TryGetResult(out var output).Should().BeTrue(); + result.TryGetResult(out _).Should().BeTrue(); await Verify(result); } diff --git a/test/Analyzers.Tests/Helpers/GenerationTestResult.cs b/test/Analyzers.Tests/Helpers/GenerationTestResult.cs index 3f6ba9958..62a116747 100644 --- a/test/Analyzers.Tests/Helpers/GenerationTestResult.cs +++ b/test/Analyzers.Tests/Helpers/GenerationTestResult.cs @@ -1,9 +1,7 @@ using System.Collections.Immutable; -using FluentAssertions; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.Extensions.Logging; -using Xunit; using Xunit.Sdk; namespace Analyzers.Tests.Helpers; diff --git a/test/Analyzers.Tests/Helpers/GenerationTestResults.cs b/test/Analyzers.Tests/Helpers/GenerationTestResults.cs index ae315ce91..d7bac309d 100644 --- a/test/Analyzers.Tests/Helpers/GenerationTestResults.cs +++ b/test/Analyzers.Tests/Helpers/GenerationTestResults.cs @@ -1,9 +1,6 @@ using System.Collections.Immutable; -using System.Reflection; -using System.Runtime.Loader; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.Emit; namespace Analyzers.Tests.Helpers; @@ -56,8 +53,8 @@ public void AssertCompilationWasSuccessful() { Assert.Empty( InputDiagnostics - .Where(z => !z.GetMessage().Contains("does not contain a definition for")) - .Where(z => !z.GetMessage().Contains("Assuming assembly reference")) + .Where(z => !z.GetMessage().Contains("does not contain a definition for", StringComparison.Ordinal)) + .Where(z => !z.GetMessage().Contains("Assuming assembly reference", StringComparison.Ordinal)) .Where(x => x.Severity >= DiagnosticSeverity.Warning) ); foreach (var result in Results.Values) diff --git a/test/Analyzers.Tests/Helpers/GeneratorTest.cs b/test/Analyzers.Tests/Helpers/GeneratorTest.cs index 9aa39cfb8..5ede8c230 100644 --- a/test/Analyzers.Tests/Helpers/GeneratorTest.cs +++ b/test/Analyzers.Tests/Helpers/GeneratorTest.cs @@ -8,7 +8,6 @@ using Microsoft.Extensions.Logging; using Rocket.Surgery.Conventions; using Rocket.Surgery.Extensions.Testing; -using Xunit.Abstractions; namespace Analyzers.Tests.Helpers; diff --git a/test/Analyzers.Tests/InheritFromGeneratorTests.cs b/test/Analyzers.Tests/InheritFromGeneratorTests.cs index c15668f8a..75c71cfd4 100644 --- a/test/Analyzers.Tests/InheritFromGeneratorTests.cs +++ b/test/Analyzers.Tests/InheritFromGeneratorTests.cs @@ -1,10 +1,8 @@ using Analyzers.Tests.Helpers; -using FluentAssertions; using MediatR; using Microsoft.Extensions.Logging; using Rocket.Surgery.LaunchPad.Analyzers; using Rocket.Surgery.LaunchPad.Foundation; -using Xunit.Abstractions; namespace Analyzers.Tests; @@ -109,33 +107,9 @@ public partial record Request : IRequest public partial record Response {} } } -"; - - var expected = @" -#nullable enable -using System; -using MediatR; -using Rocket.Surgery.LaunchPad.Foundation; - -namespace Sample.Core.Operations.Rockets -{ - public static partial class CreateRocket - { - public partial record Request - { - public string SerialNumber { get; set; } - - public Request With(Model value) => this with {SerialNumber = value.SerialNumber}; - } - } -} -#nullable restore "; var result = await GenerateAsync(source); - result.EnsureDiagnosticSeverity(); - result.AssertGeneratedAsExpected(expected); - await Verify(result); } @@ -171,35 +145,9 @@ public partial record Request : IRequest public partial record Response {} } } -"; - - var expected = @" -#nullable enable -using System; -using MediatR; -using Rocket.Surgery.LaunchPad.Foundation; - -namespace Sample.Core.Operations.Rockets -{ - public static partial class CreateRocket - { - public partial record Request - { - public string SerialNumber { get; set; } - - public Request With(Model value) => this with {SerialNumber = value.SerialNumber}; - public string OtherNumber { get; set; } - - public Request With(Other value) => this with {OtherNumber = value.OtherNumber}; - } - } -} -#nullable restore "; var result = await GenerateAsync(source); - result.EnsureDiagnosticSeverity(); - result.AssertGeneratedAsExpected(expected); await Verify(result); } @@ -230,30 +178,9 @@ public partial record Request : Model, IRequest public partial record Response {} } } -"; - - var expected = @" -#nullable enable -using System; -using MediatR; -using Rocket.Surgery.LaunchPad.Foundation; - -namespace Sample.Core.Operations.Rockets -{ - public static partial class CreateRocket - { - public partial record Request - { - public Request With(Model value) => this with {SerialNumber = value.SerialNumber}; - } - } -} -#nullable restore "; var result = await GenerateAsync(source); - result.EnsureDiagnosticSeverity(); - result.AssertGeneratedAsExpected(expected); await Verify(result); } @@ -284,32 +211,9 @@ public partial class Request : IRequest public partial record Response {} } } -"; - - var expected = @" -#nullable enable -using System; -using MediatR; -using Rocket.Surgery.LaunchPad.Foundation; - -namespace Sample.Core.Operations.Rockets -{ - public static partial class CreateRocket - { - public partial class Request - { - public string SerialNumber { get; set; } - - public Request With(Model value) => new Request{Id = this.Id, SerialNumber = value.SerialNumber}; - } - } -} -#nullable restore "; var result = await GenerateAsync(source); - result.EnsureDiagnosticSeverity(); - result.AssertGeneratedAsExpected(expected); await Verify(result); } diff --git a/test/Analyzers.Tests/ModuleInitializer.cs b/test/Analyzers.Tests/ModuleInitializer.cs index 18fc1f011..eaee47d68 100644 --- a/test/Analyzers.Tests/ModuleInitializer.cs +++ b/test/Analyzers.Tests/ModuleInitializer.cs @@ -3,6 +3,8 @@ using DiffEngine; using Microsoft.CodeAnalysis; +namespace Analyzers.Tests; + public static class ModuleInitializer { [ModuleInitializer] @@ -14,14 +16,18 @@ public static void Init() VerifierSettings.RegisterFileConverter(Convert); VerifierSettings.RegisterFileConverter(Convert); VerifierSettings.DerivePathInfo( - (sourceFile, projectDirectory, type, method) => + (sourceFile, _, type, method) => { - static string GetTypeName(Type type) => type.IsNested ? $"{type.ReflectedType!.Name}.{type.Name}" : type.Name; + static string GetTypeName(Type type) + { + return type.IsNested ? $"{type.ReflectedType!.Name}.{type.Name}" : type.Name; + } var typeName = GetTypeName(type); return new(Path.Combine(Path.GetDirectoryName(sourceFile)!, "snapshots"), typeName, method.Name); - }); + } + ); } private static ConversionResult Convert(GenerationTestResults target, IReadOnlyDictionary context) diff --git a/test/Analyzers.Tests/MutableGeneratorTests.cs b/test/Analyzers.Tests/MutableGeneratorTests.cs index 4708f1ae7..4edbadac7 100644 --- a/test/Analyzers.Tests/MutableGeneratorTests.cs +++ b/test/Analyzers.Tests/MutableGeneratorTests.cs @@ -2,7 +2,6 @@ using Microsoft.Extensions.Logging; using Rocket.Surgery.LaunchPad.Analyzers; using Rocket.Surgery.LaunchPad.Foundation; -using Xunit.Abstractions; namespace Analyzers.Tests; diff --git a/test/Analyzers.Tests/PropertyTrackingGeneratorTests.cs b/test/Analyzers.Tests/PropertyTrackingGeneratorTests.cs index ddd4653bc..cb8195633 100644 --- a/test/Analyzers.Tests/PropertyTrackingGeneratorTests.cs +++ b/test/Analyzers.Tests/PropertyTrackingGeneratorTests.cs @@ -1,7 +1,6 @@ using Analyzers.Tests.Helpers; using DryIoc.ImTools; using MediatR; -using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.Extensions.Logging; using Rocket.Surgery.LaunchPad.Analyzers; using Rocket.Surgery.LaunchPad.Foundation; @@ -238,7 +237,7 @@ public partial record PatchRocket : IPropertyTracking, IRequest(out var output).Should().BeTrue(); + result.TryGetResult(out _).Should().BeTrue(); await Verify(result); } @@ -262,7 +261,7 @@ public partial record PatchRocket : IPropertyTracking, IRequest(out var output).Should().BeTrue(); + result.TryGetResult(out _).Should().BeTrue(); await Verify(result); } diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Error_If_Controller_Is_Not_Partial.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Error_If_Controller_Is_Not_Partial.01.verified.cs.txt index 6552cc842..5c4413b30 100644 --- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Error_If_Controller_Is_Not_Partial.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Error_If_Controller_Is_Not_Partial.01.verified.cs.txt @@ -4,14 +4,19 @@ using System; namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } } \ No newline at end of file diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithAcceptReturnType_sources=.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithAcceptReturnType_sources=.01.verified.cs.txt index 6552cc842..5c4413b30 100644 --- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithAcceptReturnType_sources=.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithAcceptReturnType_sources=.01.verified.cs.txt @@ -4,14 +4,19 @@ using System; namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } } \ No newline at end of file diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithCreatedReturn_sources=.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithCreatedReturn_sources=.01.verified.cs.txt index 6552cc842..5c4413b30 100644 --- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithCreatedReturn_sources=.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithCreatedReturn_sources=.01.verified.cs.txt @@ -4,14 +4,19 @@ using System; namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } } \ No newline at end of file diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters2_sources=.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters2_sources=.01.verified.cs.txt index 6552cc842..5c4413b30 100644 --- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters2_sources=.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters2_sources=.01.verified.cs.txt @@ -4,14 +4,19 @@ using System; namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } } \ No newline at end of file diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters3_sources=.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters3_sources=.01.verified.cs.txt index 6552cc842..5c4413b30 100644 --- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters3_sources=.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters3_sources=.01.verified.cs.txt @@ -4,14 +4,19 @@ using System; namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } } \ No newline at end of file diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters4_sources=.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters4_sources=.01.verified.cs.txt index 6552cc842..5c4413b30 100644 --- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters4_sources=.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters4_sources=.01.verified.cs.txt @@ -4,14 +4,19 @@ using System; namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } } \ No newline at end of file diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=.01.verified.cs.txt index 6552cc842..5c4413b30 100644 --- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodiesWithMultipleParameters_sources=.01.verified.cs.txt @@ -4,14 +4,19 @@ using System; namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } } \ No newline at end of file diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForListAction_sources=.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForListAction_sources=.01.verified.cs.txt index 6552cc842..5c4413b30 100644 --- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForListAction_sources=.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForListAction_sources=.01.verified.cs.txt @@ -4,14 +4,19 @@ using System; namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } } \ No newline at end of file diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForRequest_sources=.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForRequest_sources=.01.verified.cs.txt index 6552cc842..5c4413b30 100644 --- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForRequest_sources=.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyForRequest_sources=.01.verified.cs.txt @@ -4,14 +4,19 @@ using System; namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } } \ No newline at end of file diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterAndAddBindRequired_sources=.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterAndAddBindRequired_sources=.01.verified.cs.txt index 6552cc842..5c4413b30 100644 --- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterAndAddBindRequired_sources=.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameterAndAddBindRequired_sources=.01.verified.cs.txt @@ -4,14 +4,19 @@ using System; namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } } \ No newline at end of file diff --git a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameter_sources=.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameter_sources=.01.verified.cs.txt index 6552cc842..5c4413b30 100644 --- a/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameter_sources=.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/ControllerActionBodyGeneratorTests.Should_Generate_Method_Bodies_key=GenerateBodyWithIdParameter_sources=.01.verified.cs.txt @@ -4,14 +4,19 @@ using System; namespace Rocket.Surgery.LaunchPad.AspNetCore { + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class CreatedAttribute : Attribute + sealed class CreatedAttribute : Attribute { - public CreatedAttribute(string methodName){} + public CreatedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } + + [System.Runtime.CompilerServices.CompilerGenerated] [AttributeUsage(AttributeTargets.Method)] - class AcceptedAttribute : Attribute + sealed class AcceptedAttribute : Attribute { - public AcceptedAttribute(string methodName){} + public AcceptedAttribute(string methodName){ MethodName = methodName; } + public string MethodName { get; } } } \ No newline at end of file diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt index d4a28bcf1..90fba1ffe 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt @@ -3,6 +3,7 @@ using System; using NodaTime; +[System.Runtime.CompilerServices.CompilerGenerated] public partial class PatchGraphRocket { public HotChocolate.Optional SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt index d4a28bcf1..90fba1ffe 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt @@ -3,6 +3,7 @@ using System; using NodaTime; +[System.Runtime.CompilerServices.CompilerGenerated] public partial class PatchGraphRocket { public HotChocolate.Optional SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt index dfeb8ffd9..d429026d5 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt @@ -3,6 +3,7 @@ using System; using NodaTime; +[System.Runtime.CompilerServices.CompilerGenerated] public partial class PatchGraphRocket { public HotChocolate.Optional SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt index dfeb8ffd9..d429026d5 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt @@ -3,6 +3,7 @@ using System; using NodaTime; +[System.Runtime.CompilerServices.CompilerGenerated] public partial class PatchGraphRocket { public HotChocolate.Optional SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt index a65e1a840..4ffdd7128 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt @@ -3,6 +3,7 @@ using System; using NodaTime; +[System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchGraphRocket { public HotChocolate.Optional SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt index a65e1a840..4ffdd7128 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_IPropertyTracking_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt @@ -3,6 +3,7 @@ using System; using NodaTime; +[System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchGraphRocket { public HotChocolate.Optional SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt index d0d244ed3..569669d1d 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=SerialNumber_value=12345.01.verified.cs.txt @@ -3,6 +3,7 @@ using System; using NodaTime; +[System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchGraphRocket { public HotChocolate.Optional Id { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt index d0d244ed3..569669d1d 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Create_property=Type_value=12345.01.verified.cs.txt @@ -3,6 +3,7 @@ using System; using NodaTime; +[System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchGraphRocket { public HotChocolate.Optional Id { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.received.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.received.cs.txt deleted file mode 100644 index cdec108a9..000000000 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.received.cs.txt +++ /dev/null @@ -1,41 +0,0 @@ -//HintName: Rocket.Surgery.LaunchPad.Analyzers/Rocket.Surgery.LaunchPad.Analyzers.GraphqlOptionalPropertyTrackingGenerator/Test1_PatchGraphRocket.cs -#nullable enable -using System; -using NodaTime; - -namespace Sample.Core.Operations.Rockets -{ - public static class PublicClass - { - public partial record PatchGraphRocket - { - public HotChocolate.Optional SerialNumber { get; set; } - - public HotChocolate.Optional Type { get; set; } - - public HotChocolate.Optional PlannedDate { get; set; } - - public global::Sample.Core.Operations.Rockets.Request Create() - { - var value = new global::Sample.Core.Operations.Rockets.Request{Id = Id}; - if (SerialNumber.HasValue) - { - value = value with {SerialNumber = SerialNumber.Value}; - } - - if (Type.HasValue) - { - value = value with {Type = Type.Value ?? default}; - } - - if (PlannedDate.HasValue) - { - value = value with {PlannedDate = PlannedDate.Value ?? default}; - } - - return value; - } - } - } -} -#nullable restore diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt index d787062c1..72d5a5289 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt @@ -7,6 +7,7 @@ namespace Sample.Core.Operations.Rockets { public static class PublicClass { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchGraphRocket { public HotChocolate.Optional SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Builtin_Struct_Property.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Builtin_Struct_Property.01.verified.cs.txt index 076c0155a..5f5d378a0 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Builtin_Struct_Property.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Builtin_Struct_Property.01.verified.cs.txt @@ -5,6 +5,7 @@ using NodaTime; namespace Sample.Core.Operations.Rockets { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchRocket { public HotChocolate.Optional SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.01.received.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.01.received.cs.txt deleted file mode 100644 index 4527a9725..000000000 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.01.received.cs.txt +++ /dev/null @@ -1,38 +0,0 @@ -//HintName: Rocket.Surgery.LaunchPad.Analyzers/Rocket.Surgery.LaunchPad.Analyzers.GraphqlOptionalPropertyTrackingGenerator/Test1_PatchRocket.cs -#nullable enable -using System; -using NodaTime; - -namespace Sample.Core.Operations.Rockets -{ - public partial record PatchRocket - { - public HotChocolate.Optional SerialNumber { get; set; } - - public HotChocolate.Optional Type { get; set; } - - public HotChocolate.Optional PlannedDate { get; set; } - - public global::Sample.Core.Operations.Rockets.Request Create() - { - var value = new global::Sample.Core.Operations.Rockets.Request{Id = Id}; - if (SerialNumber.HasValue) - { - value = value with {SerialNumber = SerialNumber.Value}; - } - - if (Type.HasValue) - { - value = value with {Type = Type.Value ?? default}; - } - - if (PlannedDate.HasValue) - { - value = value with {PlannedDate = PlannedDate.Value ?? default}; - } - - return value; - } - } -} -#nullable restore diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.01.verified.cs.txt index 3c4648cff..2ca95bf7e 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.01.verified.cs.txt @@ -5,6 +5,7 @@ using NodaTime; namespace Sample.Core.Operations.Rockets { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchRocket { public HotChocolate.Optional SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Enum_Property.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Enum_Property.01.verified.cs.txt index ce07f8121..10d6d0b56 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Enum_Property.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Enum_Property.01.verified.cs.txt @@ -6,6 +6,7 @@ using NodaTime; namespace Sample.Core.Operations.Rockets { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchRocketUnderTest { public HotChocolate.Optional Id { get; set; } diff --git a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.01.verified.cs.txt index e96e2a0aa..d7b1c0a08 100644 --- a/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/GraphqlOptionalPropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.01.verified.cs.txt @@ -5,6 +5,7 @@ using NodaTime; namespace Sample.Core.Operations.Rockets { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchRocket { public HotChocolate.Optional SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Class.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Class.01.verified.cs.txt index 0f099dcbd..e1a189096 100644 --- a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Class.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Class.01.verified.cs.txt @@ -8,6 +8,7 @@ namespace Sample.Core.Operations.Rockets { public static partial class CreateRocket { + [System.Runtime.CompilerServices.CompilerGenerated] public partial class Request { public string SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record.01.verified.cs.txt index bff5e3ca7..bf133369b 100644 --- a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record.01.verified.cs.txt @@ -8,6 +8,7 @@ namespace Sample.Core.Operations.Rockets { public static partial class CreateRocket { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record Request { public string SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record_That_Inherits.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record_That_Inherits.01.verified.cs.txt index 554f47c1d..d2d8048f5 100644 --- a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record_That_Inherits.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Generate_With_Method_For_Record_That_Inherits.01.verified.cs.txt @@ -8,6 +8,7 @@ namespace Sample.Core.Operations.Rockets { public static partial class CreateRocket { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record Request { public Request With(Model value) => this with {SerialNumber = value.SerialNumber}; diff --git a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Inherit_Multiple_With_Method_For_Record.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Inherit_Multiple_With_Method_For_Record.01.verified.cs.txt index 264ef0314..02e19a155 100644 --- a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Inherit_Multiple_With_Method_For_Record.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Inherit_Multiple_With_Method_For_Record.01.verified.cs.txt @@ -8,6 +8,7 @@ namespace Sample.Core.Operations.Rockets { public static partial class CreateRocket { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record Request { public string SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt index 6a02ef21d..39d16e61e 100644 --- a/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/InheritFromGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt @@ -8,6 +8,7 @@ namespace Sample.Core.Operations.Rockets { public static class CreateRocket { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record Request { public string SerialNumber { get; set; } diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.01.verified.cs.txt index 669e1bedb..ec0aba611 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.01.verified.cs.txt @@ -2,6 +2,7 @@ #nullable enable using System; +[System.Runtime.CompilerServices.CompilerGenerated] public partial class PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.01.verified.cs.txt index 669e1bedb..ec0aba611 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.01.verified.cs.txt @@ -2,6 +2,7 @@ #nullable enable using System; +[System.Runtime.CompilerServices.CompilerGenerated] public partial class PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.01.verified.cs.txt index 669e1bedb..ec0aba611 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Class_With_Underlying_Properties_And_Track_Changes.01.verified.cs.txt @@ -2,6 +2,7 @@ #nullable enable using System; +[System.Runtime.CompilerServices.CompilerGenerated] public partial class PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.01.verified.cs.txt index 3fa348f63..e118fbf0b 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=SerialNumber_value=12345.01.verified.cs.txt @@ -2,6 +2,7 @@ #nullable enable using System; +[System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned Id { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.01.verified.cs.txt index 3fa348f63..e118fbf0b 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Apply_Changes_property=Type_value=12345.01.verified.cs.txt @@ -2,6 +2,7 @@ #nullable enable using System; +[System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned Id { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.01.verified.cs.txt index 3fa348f63..e118fbf0b 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Generate_Record_With_Underlying_Properties_And_Track_Changes.01.verified.cs.txt @@ -2,6 +2,7 @@ #nullable enable using System; +[System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned Id { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt index d0f233962..ecdb6fe89 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Require_Partial_Parent_Type_Declaration.01.verified.cs.txt @@ -6,6 +6,7 @@ namespace Sample.Core.Operations.Rockets { public static class PublicClass { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.01.verified.cs.txt index 438520a70..dbe92fbda 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Class_Property.01.verified.cs.txt @@ -4,6 +4,7 @@ using System; namespace Sample.Core.Operations.Rockets { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); diff --git a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.01.verified.cs.txt b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.01.verified.cs.txt index 461692843..d1c264b3c 100644 --- a/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.01.verified.cs.txt +++ b/test/Analyzers.Tests/snapshots/PropertyTrackingGeneratorTests.Should_Support_Nullable_Struct_Property.01.verified.cs.txt @@ -4,6 +4,7 @@ using System; namespace Sample.Core.Operations.Rockets { + [System.Runtime.CompilerServices.CompilerGenerated] public partial record PatchRocket { public Rocket.Surgery.LaunchPad.Foundation.Assigned SerialNumber { get; set; } = Rocket.Surgery.LaunchPad.Foundation.Assigned.Empty(default); diff --git a/test/AspNetCore.Tests/Restful/RestfulApiMethodBuilderTests.cs b/test/AspNetCore.Tests/Restful/RestfulApiMethodBuilderTests.cs index c4038acb8..51927c3f7 100644 --- a/test/AspNetCore.Tests/Restful/RestfulApiMethodBuilderTests.cs +++ b/test/AspNetCore.Tests/Restful/RestfulApiMethodBuilderTests.cs @@ -1,18 +1,19 @@ using System.Reflection; -using FluentAssertions; using MediatR; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApplicationModels; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.AspNetCore; using Rocket.Surgery.LaunchPad.AspNetCore.Composition; -using Xunit; -using Xunit.Abstractions; namespace AspNetCore.Tests.Restful; public class RestfulApiMethodBuilderTests : LoggerTest { + public RestfulApiMethodBuilderTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void Should_Have_Method() { @@ -20,10 +21,6 @@ public void Should_Have_Method() builder.Method.Should().Be(RestfulApiMethod.List); } - public RestfulApiMethodBuilderTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory] [InlineData("MyActionName")] [InlineData("myActionName")] diff --git a/test/Extensions.Tests/ConventionFakeTest.cs b/test/Extensions.Tests/ConventionFakeTest.cs index bf7ab4d49..e6fcdb942 100644 --- a/test/Extensions.Tests/ConventionFakeTest.cs +++ b/test/Extensions.Tests/ConventionFakeTest.cs @@ -3,7 +3,6 @@ using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.Testing; using Rocket.Surgery.Extensions.Testing; -using Xunit.Abstractions; namespace Extensions.Tests; diff --git a/test/Extensions.Tests/FakeClockConventionTests.cs b/test/Extensions.Tests/FakeClockConventionTests.cs index cd0c5015c..59e670fc6 100644 --- a/test/Extensions.Tests/FakeClockConventionTests.cs +++ b/test/Extensions.Tests/FakeClockConventionTests.cs @@ -1,11 +1,8 @@ -using FluentAssertions; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using NodaTime; using NodaTime.Testing; using Rocket.Surgery.Conventions; using Rocket.Surgery.LaunchPad.Testing; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests; diff --git a/test/Extensions.Tests/FeatureFactory.cs b/test/Extensions.Tests/FeatureFactory.cs index 9b97fe101..7dae6c59a 100644 --- a/test/Extensions.Tests/FeatureFactory.cs +++ b/test/Extensions.Tests/FeatureFactory.cs @@ -63,42 +63,21 @@ public FeatureFactory() public IAttributesTable CreateRandomAttributes(params (string, TypeCode)[] properties) { var res = new AttributesTable(); - foreach (( var name, var type ) in properties) + foreach (var (name, type) in properties) { - object value = null; - switch (type) + var value = type switch { - case TypeCode.Boolean: - value = _random.NextDouble() > 0.5d; - break; - case TypeCode.Double: - value = (decimal)( 500d * _random.NextDouble() ); - break; - case TypeCode.Single: - value = 500f * (float)_random.NextDouble(); - break; - case TypeCode.Empty: - value = null; - break; - case TypeCode.Int16: - value = (short)_random.Next(short.MinValue, short.MaxValue); - break; - case TypeCode.Int32: - value = _random.Next(int.MinValue, int.MaxValue); - break; - case TypeCode.Int64: - value = 5L * _random.Next(int.MinValue, int.MaxValue); - break; - case TypeCode.String: - value = RandomString(); - break; - case TypeCode.Object: - value = Guid.NewGuid(); - break; - default: - value = _random.NextDouble() > 0.5d ? RandomString() : null; - break; - } + TypeCode.Boolean => _random.NextDouble() > 0.5d, + TypeCode.Double => 500d * _random.NextDouble(), + TypeCode.Single => 500f * (float)_random.NextDouble(), + TypeCode.Empty => null, + TypeCode.Int16 => _random.Next(short.MinValue, short.MaxValue), + TypeCode.Int32 => _random.Next(int.MinValue, int.MaxValue), + TypeCode.Int64 => 5L * _random.Next(int.MinValue, int.MaxValue), + TypeCode.String => RandomString(), + TypeCode.Object => Guid.NewGuid(), + _ => _random.NextDouble() > 0.5d ? RandomString() : null + }; res.Add(name, value); } @@ -164,7 +143,7 @@ public LineString CreateLineString(bool threeD) var ls = new LineSegment(start, end); var dz = ( end.Z - start.Z ) / ls.Length; - var cs = GF.CoordinateSequenceFactory.Create(pointsAt.Length + 2, threeD ? 3 : 2); + var cs = GF.CoordinateSequenceFactory.Create(pointsAt.Length + 2, threeD ? 3 : 2, 0); var j = 0; SetCoordinate(cs, j++, start); for (var i = 0; i < pointsAt.Length; i++) @@ -197,7 +176,7 @@ private Polygon CreatePolygon(in bool threeD) var numHoles = _random.Next(1, 3); radius *= 0.3; - Geometry hole = null; + Geometry? hole = null; for (var i = 0; i < numHoles; i++) { centre = Move(centre, 2 * Math.PI * _random.NextDouble(), _random.NextDouble() * 1.5 * radius); diff --git a/test/Extensions.Tests/Mapping/AutoMapperProfile.cs b/test/Extensions.Tests/Mapping/AutoMapperProfile.cs index 4cedf06ff..36261d505 100644 --- a/test/Extensions.Tests/Mapping/AutoMapperProfile.cs +++ b/test/Extensions.Tests/Mapping/AutoMapperProfile.cs @@ -1,9 +1,6 @@ using AutoMapper; -using FluentAssertions; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.Mapping; -using Xunit; -using Xunit.Abstractions; #pragma warning disable CA1034 // Nested types should not be visible @@ -53,6 +50,10 @@ private class ChildDto public class OnlyDefinedPropertiesTests : AutoFakeTest { + public OnlyDefinedPropertiesTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public void ConfigurationIsValid() { @@ -191,10 +192,6 @@ public void MapOnlyPropertiesThatWereSetOnTheLeftHandSide_WithChildren() destination.Child.String.Should().Be("123"); } - public OnlyDefinedPropertiesTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - private class MyProfile : Profile { protected MyProfile() diff --git a/test/Extensions.Tests/Mapping/DurationTests.cs b/test/Extensions.Tests/Mapping/DurationTests.cs index e140da103..35507830c 100644 --- a/test/Extensions.Tests/Mapping/DurationTests.cs +++ b/test/Extensions.Tests/Mapping/DurationTests.cs @@ -1,9 +1,6 @@ using System.Reflection; using AutoMapper; -using FluentAssertions; using NodaTime; -using Xunit; -using Xunit.Abstractions; #pragma warning disable CA1034 // Nested types should not be visible @@ -11,6 +8,10 @@ namespace Extensions.Tests.Mapping; public class DurationTests : TypeConverterTest { + public DurationTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void ValidateMapping() { @@ -177,10 +178,6 @@ public void MapsTo_Decimal() result.Should().Be(Duration.FromTicks((double)foo.Bar * NodaConstants.TicksPerMillisecond)); } - public DurationTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory] [ClassData(typeof(TypeConverterData))] public void AutomatedTests(Type source, Type destination, object? sourceValue) diff --git a/test/Extensions.Tests/Mapping/InstantTests.cs b/test/Extensions.Tests/Mapping/InstantTests.cs index beedc2c0e..66f1ec991 100644 --- a/test/Extensions.Tests/Mapping/InstantTests.cs +++ b/test/Extensions.Tests/Mapping/InstantTests.cs @@ -1,14 +1,15 @@ using System.Reflection; using AutoMapper; -using FluentAssertions; using NodaTime; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests.Mapping; public class InstantTests : TypeConverterTest { + public InstantTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void ValidateMapping() { @@ -71,10 +72,6 @@ public void MapsTo_DateTimeOffset() result.Should().Be(Instant.FromDateTimeOffset(foo.Bar)); } - public InstantTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory] [ClassData(typeof(TypeConverterData))] public void AutomatedTests(Type source, Type destination, object? sourceValue) diff --git a/test/Extensions.Tests/Mapping/JTokenConverterTests.cs b/test/Extensions.Tests/Mapping/JTokenConverterTests.cs index 5979d8eae..4c7caa570 100644 --- a/test/Extensions.Tests/Mapping/JTokenConverterTests.cs +++ b/test/Extensions.Tests/Mapping/JTokenConverterTests.cs @@ -1,15 +1,16 @@ using System.Text; using AutoMapper; -using FluentAssertions; using Newtonsoft.Json.Linq; using Rocket.Surgery.LaunchPad.Mapping.Profiles; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests.Mapping; public class JTokenConverterTests : TypeConverterTest { + public JTokenConverterTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void ShouldMap_StringValue_To_JObject() { @@ -552,10 +553,6 @@ public void ShouldNotMap_JToken_To_JToken() result.Bar!.Type.Should().Be(JTokenType.Null); } - public JTokenConverterTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory] [ClassData(typeof(ShouldNotMap_StringValue_To_JObject_Data))] public void ShouldNotMap_StringValue_To_JObject(string value) @@ -568,17 +565,6 @@ public void ShouldNotMap_StringValue_To_JObject(string value) a.Should().Throw(); } - private class ShouldNotMap_StringValue_To_JObject_Data : TheoryData - { - public ShouldNotMap_StringValue_To_JObject_Data() - { - Add("[]"); - Add("[1234]"); - Add("1234"); - Add("\"1234\""); - } - } - [Theory] [ClassData(typeof(ShouldNotMap_StringValue_To_JArray_Data))] public void ShouldNotMap_StringValue_To_JArray(string value) @@ -591,17 +577,6 @@ public void ShouldNotMap_StringValue_To_JArray(string value) a.Should().Throw(); } - private class ShouldNotMap_StringValue_To_JArray_Data : TheoryData - { - public ShouldNotMap_StringValue_To_JArray_Data() - { - Add("{}"); - Add("{\"a\":1234}"); - Add("1234"); - Add("\"1234\""); - } - } - [Theory] [InlineData("[]")] @@ -663,17 +638,6 @@ public void ShouldNotMap_ByteArray_To_JObject(byte[] value) a.Should().Throw(); } - private class ShouldNotMap_ByteArray_To_JObject_Data : TheoryData - { - public ShouldNotMap_ByteArray_To_JObject_Data() - { - Add(Encoding.UTF8.GetBytes("[]")); - Add(Encoding.UTF8.GetBytes("[1234]")); - Add(Encoding.UTF8.GetBytes("1234")); - Add(Encoding.UTF8.GetBytes("\"1234\"")); - } - } - [Theory] [ClassData(typeof(ShouldNotMap_ByteArray_To_JArray_Data))] public void ShouldNotMap_ByteArray_To_JArray(byte[] value) @@ -686,17 +650,6 @@ public void ShouldNotMap_ByteArray_To_JArray(byte[] value) a.Should().Throw(); } - private class ShouldNotMap_ByteArray_To_JArray_Data : TheoryData - { - public ShouldNotMap_ByteArray_To_JArray_Data() - { - Add(Encoding.UTF8.GetBytes("{}")); - Add(Encoding.UTF8.GetBytes("{\"a\":1234}")); - Add(Encoding.UTF8.GetBytes("1234")); - Add(Encoding.UTF8.GetBytes("\"1234\"")); - } - } - [Theory] [InlineData("[]")] [InlineData("{}")] @@ -790,6 +743,50 @@ protected override void Configure(IMapperConfigurationExpression expression) expression.CreateMap().ReverseMap(); } + private class ShouldNotMap_StringValue_To_JObject_Data : TheoryData + { + public ShouldNotMap_StringValue_To_JObject_Data() + { + Add("[]"); + Add("[1234]"); + Add("1234"); + Add("\"1234\""); + } + } + + private class ShouldNotMap_StringValue_To_JArray_Data : TheoryData + { + public ShouldNotMap_StringValue_To_JArray_Data() + { + Add("{}"); + Add("{\"a\":1234}"); + Add("1234"); + Add("\"1234\""); + } + } + + private class ShouldNotMap_ByteArray_To_JObject_Data : TheoryData + { + public ShouldNotMap_ByteArray_To_JObject_Data() + { + Add(Encoding.UTF8.GetBytes("[]")); + Add(Encoding.UTF8.GetBytes("[1234]")); + Add(Encoding.UTF8.GetBytes("1234")); + Add(Encoding.UTF8.GetBytes("\"1234\"")); + } + } + + private class ShouldNotMap_ByteArray_To_JArray_Data : TheoryData + { + public ShouldNotMap_ByteArray_To_JArray_Data() + { + Add(Encoding.UTF8.GetBytes("{}")); + Add(Encoding.UTF8.GetBytes("{\"a\":1234}")); + Add(Encoding.UTF8.GetBytes("1234")); + Add(Encoding.UTF8.GetBytes("\"1234\"")); + } + } + private class ByteArray { public byte[]? Bar { get; set; } diff --git a/test/Extensions.Tests/Mapping/JsonElementConverterTests.cs b/test/Extensions.Tests/Mapping/JsonElementConverterTests.cs index 6a688cf99..5426cc7ec 100644 --- a/test/Extensions.Tests/Mapping/JsonElementConverterTests.cs +++ b/test/Extensions.Tests/Mapping/JsonElementConverterTests.cs @@ -1,15 +1,16 @@ using System.Text; using System.Text.Json; using AutoMapper; -using FluentAssertions; using Rocket.Surgery.LaunchPad.Mapping.Profiles; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests.Mapping; public class JsonElementConverterTests : TypeConverterTest { + public JsonElementConverterTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void ShouldMap_StringValue_To_JsonElement_From_Null() { @@ -360,10 +361,6 @@ public void ShouldMap_Nullable_JsonElement_To_JsonElement_From_Null() result.Bar.ValueKind.Should().Be(JsonValueKind.Undefined); } - public JsonElementConverterTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory] [InlineData("[]")] [InlineData("{}")] diff --git a/test/Extensions.Tests/Mapping/LocalDateTests.cs b/test/Extensions.Tests/Mapping/LocalDateTests.cs index f8907e220..b00c725ae 100644 --- a/test/Extensions.Tests/Mapping/LocalDateTests.cs +++ b/test/Extensions.Tests/Mapping/LocalDateTests.cs @@ -1,14 +1,15 @@ using System.Reflection; using AutoMapper; -using FluentAssertions; using NodaTime; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests.Mapping; public class LocalDateTests : TypeConverterTest { + public LocalDateTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void ValidateMapping() { @@ -43,10 +44,6 @@ public void MapsTo() result.Should().Be(LocalDate.FromDateTime(foo.Bar)); } - public LocalDateTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory] [ClassData(typeof(TypeConverterData))] public void AutomatedTests(Type source, Type destination, object? sourceValue) diff --git a/test/Extensions.Tests/Mapping/LocalDateTimeTests.cs b/test/Extensions.Tests/Mapping/LocalDateTimeTests.cs index a54b050e5..b4189f9d1 100644 --- a/test/Extensions.Tests/Mapping/LocalDateTimeTests.cs +++ b/test/Extensions.Tests/Mapping/LocalDateTimeTests.cs @@ -1,9 +1,6 @@ using System.Reflection; using AutoMapper; -using FluentAssertions; using NodaTime; -using Xunit; -using Xunit.Abstractions; #pragma warning disable CA1034 // Nested types should not be visible @@ -11,6 +8,10 @@ namespace Extensions.Tests.Mapping; public class LocalDateTimeTests : TypeConverterTest { + public LocalDateTimeTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void ValidateMapping() { @@ -45,10 +46,6 @@ public void MapsTo() result.Should().Be(LocalDateTime.FromDateTime(foo.Bar)); } - public LocalDateTimeTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory] [ClassData(typeof(TypeConverterData))] public void AutomatedTests(Type source, Type destination, object? sourceValue) diff --git a/test/Extensions.Tests/Mapping/LocalTimeTests.cs b/test/Extensions.Tests/Mapping/LocalTimeTests.cs index 88a762b0e..28779ded5 100644 --- a/test/Extensions.Tests/Mapping/LocalTimeTests.cs +++ b/test/Extensions.Tests/Mapping/LocalTimeTests.cs @@ -1,15 +1,18 @@ using System.Reflection; using AutoMapper; -using FluentAssertions; using NodaTime; +#if NET6_0_OR_GREATER using NodaTime.Extensions; -using Xunit; -using Xunit.Abstractions; +#endif namespace Extensions.Tests.Mapping; public class LocalTimeTests : TypeConverterTest { + public LocalTimeTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void ValidateMapping() { @@ -44,10 +47,6 @@ public void MapsTo_DateTime() result.Should().Be(new LocalTime(502 / 60, 502 % 60)); } - public LocalTimeTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory] [ClassData(typeof(TypeConverterData))] public void AutomatedTests(Type source, Type destination, object? sourceValue) diff --git a/test/Extensions.Tests/Mapping/OffsetDateTimeTests.cs b/test/Extensions.Tests/Mapping/OffsetDateTimeTests.cs index 7efffd11e..2490a4ae0 100644 --- a/test/Extensions.Tests/Mapping/OffsetDateTimeTests.cs +++ b/test/Extensions.Tests/Mapping/OffsetDateTimeTests.cs @@ -1,14 +1,15 @@ using System.Reflection; using AutoMapper; -using FluentAssertions; using NodaTime; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests.Mapping; public class OffsetDateTimeTests : TypeConverterTest { + public OffsetDateTimeTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void ValidateMapping() { @@ -43,10 +44,6 @@ public void MapsTo() result.Should().Be(OffsetDateTime.FromDateTimeOffset(foo.Bar)); } - public OffsetDateTimeTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory] [ClassData(typeof(TypeConverterData))] public void AutomatedTests(Type source, Type destination, object? sourceValue) diff --git a/test/Extensions.Tests/Mapping/OffsetTests.cs b/test/Extensions.Tests/Mapping/OffsetTests.cs index 99c0f7894..7e63cd6e6 100644 --- a/test/Extensions.Tests/Mapping/OffsetTests.cs +++ b/test/Extensions.Tests/Mapping/OffsetTests.cs @@ -1,13 +1,14 @@ using AutoMapper; -using FluentAssertions; using NodaTime; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests.Mapping; public class OffsetTests : TypeConverterTest { + public OffsetTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void ValidateMapping() { @@ -42,10 +43,6 @@ public void MapsTo() result.Should().Be(Offset.FromTimeSpan(foo.Bar)); } - public OffsetTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - protected override void Configure(IMapperConfigurationExpression expression) { if (expression == null) diff --git a/test/Extensions.Tests/Mapping/PeriodTests.cs b/test/Extensions.Tests/Mapping/PeriodTests.cs index 7bce536ee..f59d2a70a 100644 --- a/test/Extensions.Tests/Mapping/PeriodTests.cs +++ b/test/Extensions.Tests/Mapping/PeriodTests.cs @@ -1,14 +1,15 @@ using AutoMapper; -using FluentAssertions; using NodaTime; using NodaTime.Text; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests.Mapping; public class PeriodTests : TypeConverterTest { + public PeriodTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void ValidateMapping() { @@ -43,10 +44,6 @@ public void MapsTo() result!.Should().Be(PeriodPattern.Roundtrip.Parse(foo.Bar).Value); } - public PeriodTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - protected override void Configure(IMapperConfigurationExpression expression) { if (expression == null) diff --git a/test/Extensions.Tests/Mapping/SystemTextJsonTests.cs b/test/Extensions.Tests/Mapping/SystemTextJsonTests.cs index 552d03f4a..93eed275b 100644 --- a/test/Extensions.Tests/Mapping/SystemTextJsonTests.cs +++ b/test/Extensions.Tests/Mapping/SystemTextJsonTests.cs @@ -1,15 +1,16 @@ using System.Text.Json; using AutoMapper; -using FluentAssertions; using Newtonsoft.Json.Linq; using Rocket.Surgery.LaunchPad.Mapping.Profiles; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests.Mapping; public class SystemTextJsonWithNewtonsoftJsonTests : TypeConverterTest { + public SystemTextJsonWithNewtonsoftJsonTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public void ValidateMapping() { @@ -280,10 +281,6 @@ public void ShouldMap_From_JObject_To_JsonElement_Null_Allow_Nulls() result.Bar.ValueKind.Should().Be(JsonValueKind.Undefined); } - public SystemTextJsonWithNewtonsoftJsonTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory] [InlineData("{}", typeof(JObject))] [InlineData("[]", typeof(JArray))] @@ -311,16 +308,6 @@ public void ShouldMap_From_JToken_To_Nullable_JsonElement(string json, JsonValue result.Bar!.Value.ValueKind.Should().Be(kind); } - public class ShouldMap_From_JToken_To_Nullable_JsonElement_Data : TheoryData - { - public ShouldMap_From_JToken_To_Nullable_JsonElement_Data() - { - Add("{}", JsonValueKind.Object); - Add("[]", JsonValueKind.Array); - Add("null", JsonValueKind.Null); - } - } - [Theory] [InlineData("{}", typeof(JObject))] [InlineData("[]", typeof(JArray))] @@ -347,16 +334,6 @@ public void ShouldMap_From_JToken_To_JsonElement(string json, JsonValueKind kind result.Bar.ValueKind.Should().Be(kind); } - public class ShouldMap_From_JToken_To_JsonElement_Data : TheoryData - { - public ShouldMap_From_JToken_To_JsonElement_Data() - { - Add("{}", JsonValueKind.Object); - Add("[]", JsonValueKind.Array); - Add("null", JsonValueKind.Null); - } - } - [Theory] [InlineData("[]", typeof(JArray))] @@ -383,14 +360,6 @@ public void ShouldMap_From_JArray_To_Nullable_JsonElement(string json, JsonValue result.Bar!.Value.ValueKind.Should().Be(kind); } - public class ShouldMap_From_JArray_To_Nullable_JsonElement_Data : TheoryData - { - public ShouldMap_From_JArray_To_Nullable_JsonElement_Data() - { - Add("[]", JsonValueKind.Array); - } - } - [Theory] [InlineData("[]", typeof(JArray))] public void ShouldMap_From_JsonElement_To_JArray(string json, Type type) @@ -415,14 +384,6 @@ public void ShouldMap_From_JArray_To_JsonElement(string json, JsonValueKind kind result.Bar.ValueKind.Should().Be(kind); } - public class ShouldMap_From_JArray_To_JsonElement_Data : TheoryData - { - public ShouldMap_From_JArray_To_JsonElement_Data() - { - Add("[]", JsonValueKind.Array); - } - } - [Theory] [InlineData("{}", typeof(JObject))] @@ -449,14 +410,6 @@ public void ShouldMap_From_JObject_To_Nullable_JsonElement(string json, JsonValu result.Bar!.Value.ValueKind.Should().Be(kind); } - public class ShouldMap_From_JObject_To_Nullable_JsonElement_Data : TheoryData - { - public ShouldMap_From_JObject_To_Nullable_JsonElement_Data() - { - Add("{}", JsonValueKind.Object); - } - } - [Theory] [InlineData("{}", typeof(JObject))] public void ShouldMap_From_JsonElement_To_JObject(string json, Type type) @@ -481,14 +434,6 @@ public void ShouldMap_From_JObject_To_JsonElement(string json, JsonValueKind kin result.Bar.ValueKind.Should().Be(kind); } - public class ShouldMap_From_JObject_To_JsonElement_Data : TheoryData - { - public ShouldMap_From_JObject_To_JsonElement_Data() - { - Add("{}", JsonValueKind.Object); - } - } - [Theory] [ClassData(typeof(ShouldNotMap_From_Nullable_JsonElement_To_JObject_Given_Invalid_Element_Data))] public void ShouldNotMap_From_Nullable_JsonElement_To_JObject_Given_Invalid_Element(JsonElement? element) @@ -501,17 +446,6 @@ public void ShouldNotMap_From_Nullable_JsonElement_To_JObject_Given_Invalid_Elem a.Should().Throw(); } - private class ShouldNotMap_From_Nullable_JsonElement_To_JObject_Given_Invalid_Element_Data : TheoryData - { - public ShouldNotMap_From_Nullable_JsonElement_To_JObject_Given_Invalid_Element_Data() - { - Add(JsonDocument.Parse("[1234]").RootElement); - Add(JsonDocument.Parse("null").RootElement); - Add(JsonDocument.Parse("1234").RootElement); - Add(JsonDocument.Parse("\"1234\"").RootElement); - } - } - [Theory] [ClassData(typeof(ShouldNotMap_From_JsonElement_To_JObject_Given_Invalid_Element_Data))] public void ShouldNotMap_From_JsonElement_To_JObject_Given_Invalid_Element(JsonElement element) @@ -524,22 +458,23 @@ public void ShouldNotMap_From_JsonElement_To_JObject_Given_Invalid_Element(JsonE a.Should().Throw(); } - private class ShouldNotMap_From_JsonElement_To_JObject_Given_Invalid_Element_Data : TheoryData + [Theory] + [ClassData(typeof(ShouldNotMap_From_Nullable_JsonElement_To_JArray_Given_Invalid_Element_Data))] + public void ShouldNotMap_From_Nullable_JsonElement_To_JArray_Given_Invalid_Element(JsonElement? element) { - public ShouldNotMap_From_JsonElement_To_JObject_Given_Invalid_Element_Data() + var item = new JsonElementA { - Add(JsonDocument.Parse("[1234]").RootElement); - Add(JsonDocument.Parse("null").RootElement); - Add(JsonDocument.Parse("1234").RootElement); - Add(JsonDocument.Parse("\"1234\"").RootElement); - } + Bar = element + }; + Action a = () => Mapper.Map(item); + a.Should().Throw(); } [Theory] - [ClassData(typeof(ShouldNotMap_From_Nullable_JsonElement_To_JArray_Given_Invalid_Element_Data))] - public void ShouldNotMap_From_Nullable_JsonElement_To_JArray_Given_Invalid_Element(JsonElement? element) + [ClassData(typeof(ShouldNotMap_From_JsonElement_To_JArray_Given_Invalid_Element_Data))] + public void ShouldNotMap_From_JsonElement_To_JArray_Given_Invalid_Element(JsonElement element) { - var item = new JsonElementA + var item = new JsonElementB { Bar = element }; @@ -547,32 +482,95 @@ public void ShouldNotMap_From_Nullable_JsonElement_To_JArray_Given_Invalid_Eleme a.Should().Throw(); } - private class ShouldNotMap_From_Nullable_JsonElement_To_JArray_Given_Invalid_Element_Data : TheoryData + protected override void Configure(IMapperConfigurationExpression expression) { - public ShouldNotMap_From_Nullable_JsonElement_To_JArray_Given_Invalid_Element_Data() + expression.AddProfile(new NewtonsoftJsonProfile()); + expression.AddProfile(new SystemJsonTextProfile()); + expression.CreateMap().ReverseMap(); + expression.CreateMap().ReverseMap(); + expression.CreateMap().ReverseMap(); + expression.CreateMap().ReverseMap(); + expression.CreateMap().ReverseMap(); + expression.CreateMap().ReverseMap(); + } + + public class ShouldMap_From_JToken_To_Nullable_JsonElement_Data : TheoryData + { + public ShouldMap_From_JToken_To_Nullable_JsonElement_Data() { - Add(JsonDocument.Parse("{\"a\": \"123\"}").RootElement); + Add("{}", JsonValueKind.Object); + Add("[]", JsonValueKind.Array); + Add("null", JsonValueKind.Null); + } + } + + public class ShouldMap_From_JToken_To_JsonElement_Data : TheoryData + { + public ShouldMap_From_JToken_To_JsonElement_Data() + { + Add("{}", JsonValueKind.Object); + Add("[]", JsonValueKind.Array); + Add("null", JsonValueKind.Null); + } + } + + public class ShouldMap_From_JArray_To_Nullable_JsonElement_Data : TheoryData + { + public ShouldMap_From_JArray_To_Nullable_JsonElement_Data() + { + Add("[]", JsonValueKind.Array); + } + } + + public class ShouldMap_From_JArray_To_JsonElement_Data : TheoryData + { + public ShouldMap_From_JArray_To_JsonElement_Data() + { + Add("[]", JsonValueKind.Array); + } + } + + public class ShouldMap_From_JObject_To_Nullable_JsonElement_Data : TheoryData + { + public ShouldMap_From_JObject_To_Nullable_JsonElement_Data() + { + Add("{}", JsonValueKind.Object); + } + } + + public class ShouldMap_From_JObject_To_JsonElement_Data : TheoryData + { + public ShouldMap_From_JObject_To_JsonElement_Data() + { + Add("{}", JsonValueKind.Object); + } + } + + private class ShouldNotMap_From_Nullable_JsonElement_To_JObject_Given_Invalid_Element_Data : TheoryData + { + public ShouldNotMap_From_Nullable_JsonElement_To_JObject_Given_Invalid_Element_Data() + { + Add(JsonDocument.Parse("[1234]").RootElement); Add(JsonDocument.Parse("null").RootElement); Add(JsonDocument.Parse("1234").RootElement); Add(JsonDocument.Parse("\"1234\"").RootElement); } } - [Theory] - [ClassData(typeof(ShouldNotMap_From_JsonElement_To_JArray_Given_Invalid_Element_Data))] - public void ShouldNotMap_From_JsonElement_To_JArray_Given_Invalid_Element(JsonElement element) + private class ShouldNotMap_From_JsonElement_To_JObject_Given_Invalid_Element_Data : TheoryData { - var item = new JsonElementB + public ShouldNotMap_From_JsonElement_To_JObject_Given_Invalid_Element_Data() { - Bar = element - }; - Action a = () => Mapper.Map(item); - a.Should().Throw(); + Add(JsonDocument.Parse("[1234]").RootElement); + Add(JsonDocument.Parse("null").RootElement); + Add(JsonDocument.Parse("1234").RootElement); + Add(JsonDocument.Parse("\"1234\"").RootElement); + } } - private class ShouldNotMap_From_JsonElement_To_JArray_Given_Invalid_Element_Data : TheoryData + private class ShouldNotMap_From_Nullable_JsonElement_To_JArray_Given_Invalid_Element_Data : TheoryData { - public ShouldNotMap_From_JsonElement_To_JArray_Given_Invalid_Element_Data() + public ShouldNotMap_From_Nullable_JsonElement_To_JArray_Given_Invalid_Element_Data() { Add(JsonDocument.Parse("{\"a\": \"123\"}").RootElement); Add(JsonDocument.Parse("null").RootElement); @@ -581,16 +579,15 @@ public ShouldNotMap_From_JsonElement_To_JArray_Given_Invalid_Element_Data() } } - protected override void Configure(IMapperConfigurationExpression expression) + private class ShouldNotMap_From_JsonElement_To_JArray_Given_Invalid_Element_Data : TheoryData { - expression.AddProfile(new NewtonsoftJsonProfile()); - expression.AddProfile(new SystemJsonTextProfile()); - expression.CreateMap().ReverseMap(); - expression.CreateMap().ReverseMap(); - expression.CreateMap().ReverseMap(); - expression.CreateMap().ReverseMap(); - expression.CreateMap().ReverseMap(); - expression.CreateMap().ReverseMap(); + public ShouldNotMap_From_JsonElement_To_JArray_Given_Invalid_Element_Data() + { + Add(JsonDocument.Parse("{\"a\": \"123\"}").RootElement); + Add(JsonDocument.Parse("null").RootElement); + Add(JsonDocument.Parse("1234").RootElement); + Add(JsonDocument.Parse("\"1234\"").RootElement); + } } private class JsonElementA diff --git a/test/Extensions.Tests/Mapping/TypeConverterTest.cs b/test/Extensions.Tests/Mapping/TypeConverterTest.cs index 903aa4422..5026f2369 100644 --- a/test/Extensions.Tests/Mapping/TypeConverterTest.cs +++ b/test/Extensions.Tests/Mapping/TypeConverterTest.cs @@ -1,12 +1,9 @@ using AutoMapper; -using Bogus; using NodaTime; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.Mapping; using Rocket.Surgery.LaunchPad.Mapping.Profiles; using Serilog.Events; -using Xunit; -using Xunit.Abstractions; #pragma warning disable CA1000 // Do not declare static members on generic types diff --git a/test/Extensions.Tests/MediatRTests.cs b/test/Extensions.Tests/MediatRTests.cs index d3c4dad4c..43f7867a9 100644 --- a/test/Extensions.Tests/MediatRTests.cs +++ b/test/Extensions.Tests/MediatRTests.cs @@ -1,6 +1,5 @@ using System.Reflection; using FakeItEasy; -using FluentAssertions; using MediatR; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -9,8 +8,6 @@ using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.Foundation; using Rocket.Surgery.LaunchPad.Foundation.Conventions; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests; diff --git a/test/Extensions.Tests/ModuleInitializer.cs b/test/Extensions.Tests/ModuleInitializer.cs index 0865d98f7..9fff3e62a 100644 --- a/test/Extensions.Tests/ModuleInitializer.cs +++ b/test/Extensions.Tests/ModuleInitializer.cs @@ -2,6 +2,8 @@ using System.Runtime.CompilerServices; using DiffEngine; +namespace Extensions.Tests; + public static class ModuleInitializer { [ModuleInitializer] @@ -9,7 +11,7 @@ public static void Init() { DiffRunner.Disabled = true; VerifierSettings.DerivePathInfo( - (sourceFile, projectDirectory, type, method) => + (sourceFile, _, type, method) => { static string GetTypeName(Type type) { diff --git a/test/Extensions.Tests/NewtonsoftJsonNetTopologySuiteTests.cs b/test/Extensions.Tests/NewtonsoftJsonNetTopologySuiteTests.cs index 2a5d4b0b7..efc5bb5f8 100644 --- a/test/Extensions.Tests/NewtonsoftJsonNetTopologySuiteTests.cs +++ b/test/Extensions.Tests/NewtonsoftJsonNetTopologySuiteTests.cs @@ -1,11 +1,8 @@ -using FluentAssertions; using FluentAssertions.Primitives; using NetTopologySuite.Geometries; using Newtonsoft.Json; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.Spatial; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests; diff --git a/test/Extensions.Tests/NewtonsoftJsonNodaTimeTests.cs b/test/Extensions.Tests/NewtonsoftJsonNodaTimeTests.cs index df386b412..7d2682554 100644 --- a/test/Extensions.Tests/NewtonsoftJsonNodaTimeTests.cs +++ b/test/Extensions.Tests/NewtonsoftJsonNodaTimeTests.cs @@ -1,10 +1,7 @@ -using FluentAssertions; using Newtonsoft.Json; using NodaTime; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.Foundation; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests; diff --git a/test/Extensions.Tests/SerilogDestructuringTests.cs b/test/Extensions.Tests/SerilogDestructuringTests.cs index f38a67163..bdca02b6d 100644 --- a/test/Extensions.Tests/SerilogDestructuringTests.cs +++ b/test/Extensions.Tests/SerilogDestructuringTests.cs @@ -9,7 +9,6 @@ using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.Foundation; using Rocket.Surgery.LaunchPad.Spatial; -using Serilog; using Serilog.Context; namespace Extensions.Tests; @@ -94,8 +93,6 @@ public async Task Should_Destructure_NetTopologySuite_AttributesTable() [Fact] public async Task Should_Destructure_NodaTime_Instant() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", _clock.GetCurrentInstant()); await Verify(logs.Select(z => z.RenderMessage())); @@ -104,8 +101,6 @@ public async Task Should_Destructure_NodaTime_Instant() [Fact] public async Task Should_Destructure_NodaTime_LocalDateTime() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", LocalDateTime.FromDateTime(_clock.GetCurrentInstant().ToDateTimeUtc())); await Verify(logs.Select(z => z.RenderMessage())); @@ -114,8 +109,6 @@ public async Task Should_Destructure_NodaTime_LocalDateTime() [Fact] public async Task Should_Destructure_NodaTime_LocalDate() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", LocalDate.FromDateTime(_clock.GetCurrentInstant().ToDateTimeUtc())); await Verify(logs.Select(z => z.RenderMessage())); @@ -124,8 +117,6 @@ public async Task Should_Destructure_NodaTime_LocalDate() [Fact] public async Task Should_Destructure_NodaTime_LocalTime() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", LocalTime.FromHoursSinceMidnight(4)); await Verify(logs.Select(z => z.RenderMessage())); @@ -134,8 +125,6 @@ public async Task Should_Destructure_NodaTime_LocalTime() [Fact] public async Task Should_Destructure_NodaTime_OffsetDateTime() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", OffsetDateTime.FromDateTimeOffset(_clock.GetCurrentInstant().ToDateTimeOffset())); await Verify(logs.Select(z => z.RenderMessage())); @@ -144,8 +133,6 @@ public async Task Should_Destructure_NodaTime_OffsetDateTime() [Fact] public async Task Should_Destructure_NodaTime_OffsetDate() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", OffsetDateTime.FromDateTimeOffset(_clock.GetCurrentInstant().ToDateTimeOffset()).ToOffsetDate()); await Verify(logs.Select(z => z.RenderMessage())); @@ -154,8 +141,6 @@ public async Task Should_Destructure_NodaTime_OffsetDate() [Fact] public async Task Should_Destructure_NodaTime_OffsetTime() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", OffsetDateTime.FromDateTimeOffset(_clock.GetCurrentInstant().ToDateTimeOffset()).ToOffsetTime()); await Verify(logs.Select(z => z.RenderMessage())); @@ -164,8 +149,6 @@ public async Task Should_Destructure_NodaTime_OffsetTime() [Fact] public async Task Should_Destructure_NodaTime_ZonedDateTime() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", ZonedDateTime.FromDateTimeOffset(_clock.GetCurrentInstant().ToDateTimeOffset())); await Verify(logs.Select(z => z.RenderMessage())); @@ -174,8 +157,6 @@ public async Task Should_Destructure_NodaTime_ZonedDateTime() [Fact] public async Task Should_Destructure_NodaTime_DateTimeZone() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", DateTimeZoneProviders.Tzdb["America/New_York"]); await Verify(logs.Select(z => z.RenderMessage())); @@ -184,8 +165,6 @@ public async Task Should_Destructure_NodaTime_DateTimeZone() [Fact] public async Task Should_Destructure_NodaTime_Duration() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", Duration.FromDays(1)); await Verify(logs.Select(z => z.RenderMessage())); @@ -194,8 +173,6 @@ public async Task Should_Destructure_NodaTime_Duration() [Fact] public async Task Should_Destructure_NodaTime_Period() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", Period.FromDays(1)); await Verify(logs.Select(z => z.RenderMessage())); @@ -204,8 +181,6 @@ public async Task Should_Destructure_NodaTime_Period() [Fact] public async Task Should_Destructure_NodaTime_Interval() { - var faker = new Faker { Random = new Randomizer(17) }; - using var _ = CaptureLogs(out var logs); Logger.LogInformation("This is just a test {@Data}", new Interval(_clock.GetCurrentInstant(), _clock.GetCurrentInstant())); await Verify(logs.Select(z => z.RenderMessage())); diff --git a/test/Extensions.Tests/StringInValidatorTests.cs b/test/Extensions.Tests/StringInValidatorTests.cs index 60446f253..9647e27de 100644 --- a/test/Extensions.Tests/StringInValidatorTests.cs +++ b/test/Extensions.Tests/StringInValidatorTests.cs @@ -1,8 +1,5 @@ -using FluentAssertions; using FluentValidation; using Microsoft.Extensions.DependencyInjection; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests; @@ -18,7 +15,7 @@ public async Task Should_Validate_Invalid() TypeIgnoreCase = "nottruck" }; - var validator = ServiceProvider.GetRequiredService().GetValidator(); + var validator = ServiceProvider.GetRequiredService>(); var result = await validator.ValidateAsync(data); var result2 = validator.Validate(data); @@ -39,7 +36,7 @@ public async Task Should_Validate_CaseSensitive() TypeIgnoreCase = "truck" }; - var validator = ServiceProvider.GetRequiredService().GetValidator(); + var validator = ServiceProvider.GetRequiredService>(); var result = await validator.ValidateAsync(data); var result2 = validator.Validate(data); @@ -59,7 +56,7 @@ public async Task Should_Validate_CaseInsensitive() TypeIgnoreCase = "nottruck" }; - var validator = ServiceProvider.GetRequiredService().GetValidator(); + var validator = ServiceProvider.GetRequiredService>(); var result = await validator.ValidateAsync(data); var result2 = validator.Validate(data); diff --git a/test/Extensions.Tests/SystemTextJsonNetTopologySuiteTests.cs b/test/Extensions.Tests/SystemTextJsonNetTopologySuiteTests.cs index 77a75d313..2ec8ed580 100644 --- a/test/Extensions.Tests/SystemTextJsonNetTopologySuiteTests.cs +++ b/test/Extensions.Tests/SystemTextJsonNetTopologySuiteTests.cs @@ -1,11 +1,8 @@ using System.Text.Json; -using FluentAssertions; using FluentAssertions.Primitives; using NetTopologySuite.Geometries; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.Spatial; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests; diff --git a/test/Extensions.Tests/SystemTextJsonNodaTimeTests.cs b/test/Extensions.Tests/SystemTextJsonNodaTimeTests.cs index 24fb72901..9d87348ec 100644 --- a/test/Extensions.Tests/SystemTextJsonNodaTimeTests.cs +++ b/test/Extensions.Tests/SystemTextJsonNodaTimeTests.cs @@ -1,10 +1,7 @@ using System.Text.Json; -using FluentAssertions; using NodaTime; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.Foundation; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests; diff --git a/test/Extensions.Tests/Validation/ValidatorFactoryTests.cs b/test/Extensions.Tests/Validation/ValidatorFactoryTests.cs index 750a862df..b2e74759a 100644 --- a/test/Extensions.Tests/Validation/ValidatorFactoryTests.cs +++ b/test/Extensions.Tests/Validation/ValidatorFactoryTests.cs @@ -1,11 +1,6 @@ -using FakeItEasy; -using FluentAssertions; using FluentValidation; using Microsoft.Extensions.Logging; using Rocket.Surgery.Extensions.Testing; -using Rocket.Surgery.LaunchPad.Foundation.Validation; -using Xunit; -using Xunit.Abstractions; namespace Extensions.Tests.Validation; diff --git a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_AttributesTable.verified.txt b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_AttributesTable.verified.txt index 7716451be..e7af06636 100644 --- a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_AttributesTable.verified.txt +++ b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_AttributesTable.verified.txt @@ -1,3 +1,3 @@ [ - This is just a test { id: -1304539648, label: "Caso - 93", number1: 440.645365016835, number2: 4457612420 } + This is just a test { id: -1304539648, label: "Caso - 93", number1: 440.64536501683546, number2: 4457612420 } ] \ No newline at end of file diff --git a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=LineString_num=5_threeD=False.verified.txt b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=LineString_num=5_threeD=False.verified.txt index 116b21280..72e1f1308 100644 --- a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=LineString_num=5_threeD=False.verified.txt +++ b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=LineString_num=5_threeD=False.verified.txt @@ -1,3 +1,3 @@ [ - This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97], [31.87, 47.11], [37.84, 9.76], [43.69, -2.83], [44.04, -5.01], [45.1, -51.93], [54.29, -56.4]] }, properties: { id: -1389899152, label: "Hasard - 68", number1: 448.537396941584, number2: 812898345 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97], [31.87, 47.11], [37.84, 9.76], [43.69, -2.83], [44.04, -5.01], [45.1, -51.93], [54.29, -56.4]] }, properties: { id: -1389899152, label: "Hasard - 68", number1: 448.537396941584, number2: 812898345 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97], [31.87, 47.11], [37.84, 9.76], [43.69, -2.83], [44.04, -5.01], [45.1, -51.93], [54.29, -56.4]] }, properties: { id: -1389899152, label: "Hasard - 68", number1: 448.537396941584, number2: 812898345 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97], [31.87, 47.11], [37.84, 9.76], [43.69, -2.83], [44.04, -5.01], [45.1, -51.93], [54.29, -56.4]] }, properties: { id: -1389899152, label: "Hasard - 68", number1: 448.537396941584, number2: 812898345 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97], [31.87, 47.11], [37.84, 9.76], [43.69, -2.83], [44.04, -5.01], [45.1, -51.93], [54.29, -56.4]] }, properties: { id: -1389899152, label: "Hasard - 68", number1: 448.537396941584, number2: 812898345 } }] } + This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97], [31.87, 47.11], [37.84, 9.76], [43.69, -2.83], [44.04, -5.01], [45.1, -51.93], [54.29, -56.4]] }, properties: { id: -1389899152, label: "Hasard - 68", number1: 448.53739694158423, number2: 812898345 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97], [31.87, 47.11], [37.84, 9.76], [43.69, -2.83], [44.04, -5.01], [45.1, -51.93], [54.29, -56.4]] }, properties: { id: -1389899152, label: "Hasard - 68", number1: 448.53739694158423, number2: 812898345 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97], [31.87, 47.11], [37.84, 9.76], [43.69, -2.83], [44.04, -5.01], [45.1, -51.93], [54.29, -56.4]] }, properties: { id: -1389899152, label: "Hasard - 68", number1: 448.53739694158423, number2: 812898345 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97], [31.87, 47.11], [37.84, 9.76], [43.69, -2.83], [44.04, -5.01], [45.1, -51.93], [54.29, -56.4]] }, properties: { id: -1389899152, label: "Hasard - 68", number1: 448.53739694158423, number2: 812898345 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97], [31.87, 47.11], [37.84, 9.76], [43.69, -2.83], [44.04, -5.01], [45.1, -51.93], [54.29, -56.4]] }, properties: { id: -1389899152, label: "Hasard - 68", number1: 448.53739694158423, number2: 812898345 } }] } ] \ No newline at end of file diff --git a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=LineString_num=5_threeD=True.verified.txt b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=LineString_num=5_threeD=True.verified.txt index 7b2d5c8b8..3dd36fb7d 100644 --- a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=LineString_num=5_threeD=True.verified.txt +++ b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=LineString_num=5_threeD=True.verified.txt @@ -1,3 +1,3 @@ [ - This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97, 65.08], [27.19, 47.94, 65.06748958211027], [-42.83, 55.02, 64.99593883666306], [-108.09, 65.05, 64.9295637035744], [-112.8, 68.63, 41.51]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.667820568973, number2: -1475082015 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97, 65.08], [27.19, 47.94, 65.06748958211027], [-42.83, 55.02, 64.99593883666306], [-108.09, 65.05, 64.9295637035744], [-112.8, 68.63, 41.51]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.667820568973, number2: -1475082015 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97, 65.08], [27.19, 47.94, 65.06748958211027], [-42.83, 55.02, 64.99593883666306], [-108.09, 65.05, 64.9295637035744], [-112.8, 68.63, 41.51]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.667820568973, number2: -1475082015 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97, 65.08], [27.19, 47.94, 65.06748958211027], [-42.83, 55.02, 64.99593883666306], [-108.09, 65.05, 64.9295637035744], [-112.8, 68.63, 41.51]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.667820568973, number2: -1475082015 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97, 65.08], [27.19, 47.94, 65.06748958211027], [-42.83, 55.02, 64.99593883666306], [-108.09, 65.05, 64.9295637035744], [-112.8, 68.63, 41.51]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.667820568973, number2: -1475082015 } }] } + This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97, 65.08], [27.19, 47.94, 65.06748958211027], [-42.83, 55.02, 64.99593883666306], [-108.09, 65.05, 64.9295637035744], [-112.8, 68.63, 41.51]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.66782056897307, number2: -1475082015 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97, 65.08], [27.19, 47.94, 65.06748958211027], [-42.83, 55.02, 64.99593883666306], [-108.09, 65.05, 64.9295637035744], [-112.8, 68.63, 41.51]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.66782056897307, number2: -1475082015 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97, 65.08], [27.19, 47.94, 65.06748958211027], [-42.83, 55.02, 64.99593883666306], [-108.09, 65.05, 64.9295637035744], [-112.8, 68.63, 41.51]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.66782056897307, number2: -1475082015 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97, 65.08], [27.19, 47.94, 65.06748958211027], [-42.83, 55.02, 64.99593883666306], [-108.09, 65.05, 64.9295637035744], [-112.8, 68.63, 41.51]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.66782056897307, number2: -1475082015 } }, { type: "Feature", geometry: { type: LineString, coordinates: [[38.69, 54.97, 65.08], [27.19, 47.94, 65.06748958211027], [-42.83, 55.02, 64.99593883666306], [-108.09, 65.05, 64.9295637035744], [-112.8, 68.63, 41.51]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.66782056897307, number2: -1475082015 } }] } ] \ No newline at end of file diff --git a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiLineString_num=5_threeD=False.verified.txt b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiLineString_num=5_threeD=False.verified.txt index 7650ff364..3cb339cc0 100644 --- a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiLineString_num=5_threeD=False.verified.txt +++ b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiLineString_num=5_threeD=False.verified.txt @@ -1,3 +1,3 @@ [ - This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14], [-6.4, 48.05], [-105.31, 62.09], [-112.8, 68.63]], [[113.87, 43.1], [112.06, 41.75], [89.22, 32.4], [14.68, -5.86], [-5.75, -15.41], [-48.08, -28.99], [-65.05, -33.51]], [[-14.26, 9], [-28.88, -3.25], [-52.71, -18.17], [-54.79, -17.59], [-99.76, -50.69], [-100.46, -46.37]], [[-88.41, 19.81], [-77.49, 23.86], [-68.28, 18.24], [-10.92, 1.23], [-6.34, -0.11], [3.38, 2.39], [20.14, -10.99]], [[162.47, 17.78], [126.15, 29.77], [108.84, 40.87], [55.68, 67.53], [53.31, 62.98], [31.93, 79.28]], [[38.22, 72.82], [37.11, 70.38], [45.55, 49.21], [61.14, 23.99], [84.64, -21.25]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.247021573245, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14], [-6.4, 48.05], [-105.31, 62.09], [-112.8, 68.63]], [[113.87, 43.1], [112.06, 41.75], [89.22, 32.4], [14.68, -5.86], [-5.75, -15.41], [-48.08, -28.99], [-65.05, -33.51]], [[-14.26, 9], [-28.88, -3.25], [-52.71, -18.17], [-54.79, -17.59], [-99.76, -50.69], [-100.46, -46.37]], [[-88.41, 19.81], [-77.49, 23.86], [-68.28, 18.24], [-10.92, 1.23], [-6.34, -0.11], [3.38, 2.39], [20.14, -10.99]], [[162.47, 17.78], [126.15, 29.77], [108.84, 40.87], [55.68, 67.53], [53.31, 62.98], [31.93, 79.28]], [[38.22, 72.82], [37.11, 70.38], [45.55, 49.21], [61.14, 23.99], [84.64, -21.25]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.247021573245, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14], [-6.4, 48.05], [-105.31, 62.09], [-112.8, 68.63]], [[113.87, 43.1], [112.06, 41.75], [89.22, 32.4], [14.68, -5.86], [-5.75, -15.41], [-48.08, -28.99], [-65.05, -33.51]], [[-14.26, 9], [-28.88, -3.25], [-52.71, -18.17], [-54.79, -17.59], [-99.76, -50.69], [-100.46, -46.37]], [[-88.41, 19.81], [-77.49, 23.86], [-68.28, 18.24], [-10.92, 1.23], [-6.34, -0.11], [3.38, 2.39], [20.14, -10.99]], [[162.47, 17.78], [126.15, 29.77], [108.84, 40.87], [55.68, 67.53], [53.31, 62.98], [31.93, 79.28]], [[38.22, 72.82], [37.11, 70.38], [45.55, 49.21], [61.14, 23.99], [84.64, -21.25]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.247021573245, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14], [-6.4, 48.05], [-105.31, 62.09], [-112.8, 68.63]], [[113.87, 43.1], [112.06, 41.75], [89.22, 32.4], [14.68, -5.86], [-5.75, -15.41], [-48.08, -28.99], [-65.05, -33.51]], [[-14.26, 9], [-28.88, -3.25], [-52.71, -18.17], [-54.79, -17.59], [-99.76, -50.69], [-100.46, -46.37]], [[-88.41, 19.81], [-77.49, 23.86], [-68.28, 18.24], [-10.92, 1.23], [-6.34, -0.11], [3.38, 2.39], [20.14, -10.99]], [[162.47, 17.78], [126.15, 29.77], [108.84, 40.87], [55.68, 67.53], [53.31, 62.98], [31.93, 79.28]], [[38.22, 72.82], [37.11, 70.38], [45.55, 49.21], [61.14, 23.99], [84.64, -21.25]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.247021573245, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14], [-6.4, 48.05], [-105.31, 62.09], [-112.8, 68.63]], [[113.87, 43.1], [112.06, 41.75], [89.22, 32.4], [14.68, -5.86], [-5.75, -15.41], [-48.08, -28.99], [-65.05, -33.51]], [[-14.26, 9], [-28.88, -3.25], [-52.71, -18.17], [-54.79, -17.59], [-99.76, -50.69], [-100.46, -46.37]], [[-88.41, 19.81], [-77.49, 23.86], [-68.28, 18.24], [-10.92, 1.23], [-6.34, -0.11], [3.38, 2.39], [20.14, -10.99]], [[162.47, 17.78], [126.15, 29.77], [108.84, 40.87], [55.68, 67.53], [53.31, 62.98], [31.93, 79.28]], [[38.22, 72.82], [37.11, 70.38], [45.55, 49.21], [61.14, 23.99], [84.64, -21.25]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.247021573245, number2: -4438177620 } }] } + This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14], [-6.4, 48.05], [-105.31, 62.09], [-112.8, 68.63]], [[113.87, 43.1], [112.06, 41.75], [89.22, 32.4], [14.68, -5.86], [-5.75, -15.41], [-48.08, -28.99], [-65.05, -33.51]], [[-14.26, 9], [-28.88, -3.25], [-52.71, -18.17], [-54.79, -17.59], [-99.76, -50.69], [-100.46, -46.37]], [[-88.41, 19.81], [-77.49, 23.86], [-68.28, 18.24], [-10.92, 1.23], [-6.34, -0.11], [3.38, 2.39], [20.14, -10.99]], [[162.47, 17.78], [126.15, 29.77], [108.84, 40.87], [55.68, 67.53], [53.31, 62.98], [31.93, 79.28]], [[38.22, 72.82], [37.11, 70.38], [45.55, 49.21], [61.14, 23.99], [84.64, -21.25]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.24702157324504, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14], [-6.4, 48.05], [-105.31, 62.09], [-112.8, 68.63]], [[113.87, 43.1], [112.06, 41.75], [89.22, 32.4], [14.68, -5.86], [-5.75, -15.41], [-48.08, -28.99], [-65.05, -33.51]], [[-14.26, 9], [-28.88, -3.25], [-52.71, -18.17], [-54.79, -17.59], [-99.76, -50.69], [-100.46, -46.37]], [[-88.41, 19.81], [-77.49, 23.86], [-68.28, 18.24], [-10.92, 1.23], [-6.34, -0.11], [3.38, 2.39], [20.14, -10.99]], [[162.47, 17.78], [126.15, 29.77], [108.84, 40.87], [55.68, 67.53], [53.31, 62.98], [31.93, 79.28]], [[38.22, 72.82], [37.11, 70.38], [45.55, 49.21], [61.14, 23.99], [84.64, -21.25]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.24702157324504, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14], [-6.4, 48.05], [-105.31, 62.09], [-112.8, 68.63]], [[113.87, 43.1], [112.06, 41.75], [89.22, 32.4], [14.68, -5.86], [-5.75, -15.41], [-48.08, -28.99], [-65.05, -33.51]], [[-14.26, 9], [-28.88, -3.25], [-52.71, -18.17], [-54.79, -17.59], [-99.76, -50.69], [-100.46, -46.37]], [[-88.41, 19.81], [-77.49, 23.86], [-68.28, 18.24], [-10.92, 1.23], [-6.34, -0.11], [3.38, 2.39], [20.14, -10.99]], [[162.47, 17.78], [126.15, 29.77], [108.84, 40.87], [55.68, 67.53], [53.31, 62.98], [31.93, 79.28]], [[38.22, 72.82], [37.11, 70.38], [45.55, 49.21], [61.14, 23.99], [84.64, -21.25]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.24702157324504, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14], [-6.4, 48.05], [-105.31, 62.09], [-112.8, 68.63]], [[113.87, 43.1], [112.06, 41.75], [89.22, 32.4], [14.68, -5.86], [-5.75, -15.41], [-48.08, -28.99], [-65.05, -33.51]], [[-14.26, 9], [-28.88, -3.25], [-52.71, -18.17], [-54.79, -17.59], [-99.76, -50.69], [-100.46, -46.37]], [[-88.41, 19.81], [-77.49, 23.86], [-68.28, 18.24], [-10.92, 1.23], [-6.34, -0.11], [3.38, 2.39], [20.14, -10.99]], [[162.47, 17.78], [126.15, 29.77], [108.84, 40.87], [55.68, 67.53], [53.31, 62.98], [31.93, 79.28]], [[38.22, 72.82], [37.11, 70.38], [45.55, 49.21], [61.14, 23.99], [84.64, -21.25]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.24702157324504, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14], [-6.4, 48.05], [-105.31, 62.09], [-112.8, 68.63]], [[113.87, 43.1], [112.06, 41.75], [89.22, 32.4], [14.68, -5.86], [-5.75, -15.41], [-48.08, -28.99], [-65.05, -33.51]], [[-14.26, 9], [-28.88, -3.25], [-52.71, -18.17], [-54.79, -17.59], [-99.76, -50.69], [-100.46, -46.37]], [[-88.41, 19.81], [-77.49, 23.86], [-68.28, 18.24], [-10.92, 1.23], [-6.34, -0.11], [3.38, 2.39], [20.14, -10.99]], [[162.47, 17.78], [126.15, 29.77], [108.84, 40.87], [55.68, 67.53], [53.31, 62.98], [31.93, 79.28]], [[38.22, 72.82], [37.11, 70.38], [45.55, 49.21], [61.14, 23.99], [84.64, -21.25]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.24702157324504, number2: -4438177620 } }] } ] \ No newline at end of file diff --git a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiLineString_num=5_threeD=True.verified.txt b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiLineString_num=5_threeD=True.verified.txt index 4cd95fac4..bd614d557 100644 --- a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiLineString_num=5_threeD=True.verified.txt +++ b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiLineString_num=5_threeD=True.verified.txt @@ -1,3 +1,3 @@ [ - This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14, 18.66], [109.52, 25.41, 18.713816154405887], [111.26, 18.37, 18.872859853565156], [119.32, 7.63, 19.021606509515006], [130.07, -4.18, 19.15291593980007], [127.74, -4.59, 19.20415328287212], [137.26, -15.28, 52.29]], [[-130.55, 71.47, 7.57], [-150.51, 66.62, 8.527130768027146], [-154.36, 65.89, 8.713460748633855], [-173.25, 65.69, 97.15]], [[98, -6.64, 93.12], [72.07, -10.16, 93.10279764905636], [-124.54, -21.15, 92.97199470885812], [-132.02, -15.35, 57.87]], [[20.14, -10.99, 84.54], [-109, 66.61, 76.56]], [[80.47, 55.37, 46.81], [6.5, 6.56, 47.01703729460373], [2.9, 2.03, 47.020596272882266], [-3.9, 0.6, 47.04890553686023], [-23.4, -13.87, 47.0986124254275], [-35.75, -19.52, 47.1407454193607], [-41.36, -21.49, 97.47]], [[-151.45, 69.31, 60.61], [-139.28, 71.57, 60.60684421117555], [-68.57, 68.07, 60.58888787162895], [5.04, 56.81, 60.57037256344025], [145.64, 42.32, 38.19]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.247021573245, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14, 18.66], [109.52, 25.41, 18.713816154405887], [111.26, 18.37, 18.872859853565156], [119.32, 7.63, 19.021606509515006], [130.07, -4.18, 19.15291593980007], [127.74, -4.59, 19.20415328287212], [137.26, -15.28, 52.29]], [[-130.55, 71.47, 7.57], [-150.51, 66.62, 8.527130768027146], [-154.36, 65.89, 8.713460748633855], [-173.25, 65.69, 97.15]], [[98, -6.64, 93.12], [72.07, -10.16, 93.10279764905636], [-124.54, -21.15, 92.97199470885812], [-132.02, -15.35, 57.87]], [[20.14, -10.99, 84.54], [-109, 66.61, 76.56]], [[80.47, 55.37, 46.81], [6.5, 6.56, 47.01703729460373], [2.9, 2.03, 47.020596272882266], [-3.9, 0.6, 47.04890553686023], [-23.4, -13.87, 47.0986124254275], [-35.75, -19.52, 47.1407454193607], [-41.36, -21.49, 97.47]], [[-151.45, 69.31, 60.61], [-139.28, 71.57, 60.60684421117555], [-68.57, 68.07, 60.58888787162895], [5.04, 56.81, 60.57037256344025], [145.64, 42.32, 38.19]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.247021573245, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14, 18.66], [109.52, 25.41, 18.713816154405887], [111.26, 18.37, 18.872859853565156], [119.32, 7.63, 19.021606509515006], [130.07, -4.18, 19.15291593980007], [127.74, -4.59, 19.20415328287212], [137.26, -15.28, 52.29]], [[-130.55, 71.47, 7.57], [-150.51, 66.62, 8.527130768027146], [-154.36, 65.89, 8.713460748633855], [-173.25, 65.69, 97.15]], [[98, -6.64, 93.12], [72.07, -10.16, 93.10279764905636], [-124.54, -21.15, 92.97199470885812], [-132.02, -15.35, 57.87]], [[20.14, -10.99, 84.54], [-109, 66.61, 76.56]], [[80.47, 55.37, 46.81], [6.5, 6.56, 47.01703729460373], [2.9, 2.03, 47.020596272882266], [-3.9, 0.6, 47.04890553686023], [-23.4, -13.87, 47.0986124254275], [-35.75, -19.52, 47.1407454193607], [-41.36, -21.49, 97.47]], [[-151.45, 69.31, 60.61], [-139.28, 71.57, 60.60684421117555], [-68.57, 68.07, 60.58888787162895], [5.04, 56.81, 60.57037256344025], [145.64, 42.32, 38.19]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.247021573245, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14, 18.66], [109.52, 25.41, 18.713816154405887], [111.26, 18.37, 18.872859853565156], [119.32, 7.63, 19.021606509515006], [130.07, -4.18, 19.15291593980007], [127.74, -4.59, 19.20415328287212], [137.26, -15.28, 52.29]], [[-130.55, 71.47, 7.57], [-150.51, 66.62, 8.527130768027146], [-154.36, 65.89, 8.713460748633855], [-173.25, 65.69, 97.15]], [[98, -6.64, 93.12], [72.07, -10.16, 93.10279764905636], [-124.54, -21.15, 92.97199470885812], [-132.02, -15.35, 57.87]], [[20.14, -10.99, 84.54], [-109, 66.61, 76.56]], [[80.47, 55.37, 46.81], [6.5, 6.56, 47.01703729460373], [2.9, 2.03, 47.020596272882266], [-3.9, 0.6, 47.04890553686023], [-23.4, -13.87, 47.0986124254275], [-35.75, -19.52, 47.1407454193607], [-41.36, -21.49, 97.47]], [[-151.45, 69.31, 60.61], [-139.28, 71.57, 60.60684421117555], [-68.57, 68.07, 60.58888787162895], [5.04, 56.81, 60.57037256344025], [145.64, 42.32, 38.19]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.247021573245, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14, 18.66], [109.52, 25.41, 18.713816154405887], [111.26, 18.37, 18.872859853565156], [119.32, 7.63, 19.021606509515006], [130.07, -4.18, 19.15291593980007], [127.74, -4.59, 19.20415328287212], [137.26, -15.28, 52.29]], [[-130.55, 71.47, 7.57], [-150.51, 66.62, 8.527130768027146], [-154.36, 65.89, 8.713460748633855], [-173.25, 65.69, 97.15]], [[98, -6.64, 93.12], [72.07, -10.16, 93.10279764905636], [-124.54, -21.15, 92.97199470885812], [-132.02, -15.35, 57.87]], [[20.14, -10.99, 84.54], [-109, 66.61, 76.56]], [[80.47, 55.37, 46.81], [6.5, 6.56, 47.01703729460373], [2.9, 2.03, 47.020596272882266], [-3.9, 0.6, 47.04890553686023], [-23.4, -13.87, 47.0986124254275], [-35.75, -19.52, 47.1407454193607], [-41.36, -21.49, 97.47]], [[-151.45, 69.31, 60.61], [-139.28, 71.57, 60.60684421117555], [-68.57, 68.07, 60.58888787162895], [5.04, 56.81, 60.57037256344025], [145.64, 42.32, 38.19]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.247021573245, number2: -4438177620 } }] } + This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14, 18.66], [109.52, 25.41, 18.713816154405887], [111.26, 18.37, 18.872859853565156], [119.32, 7.63, 19.021606509515006], [130.07, -4.18, 19.15291593980007], [127.74, -4.59, 19.20415328287212], [137.26, -15.28, 52.29]], [[-130.55, 71.47, 7.57], [-150.51, 66.62, 8.527130768027146], [-154.36, 65.89, 8.713460748633855], [-173.25, 65.69, 97.15]], [[98, -6.64, 93.12], [72.07, -10.16, 93.10279764905636], [-124.54, -21.15, 92.97199470885812], [-132.02, -15.35, 57.87]], [[20.14, -10.99, 84.54], [-109, 66.61, 76.56]], [[80.47, 55.37, 46.81], [6.5, 6.56, 47.01703729460373], [2.9, 2.03, 47.020596272882266], [-3.9, 0.6, 47.04890553686023], [-23.4, -13.87, 47.0986124254275], [-35.75, -19.52, 47.1407454193607], [-41.36, -21.49, 97.47]], [[-151.45, 69.31, 60.61], [-139.28, 71.57, 60.60684421117555], [-68.57, 68.07, 60.58888787162895], [5.04, 56.81, 60.57037256344025], [145.64, 42.32, 38.19]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.24702157324504, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14, 18.66], [109.52, 25.41, 18.713816154405887], [111.26, 18.37, 18.872859853565156], [119.32, 7.63, 19.021606509515006], [130.07, -4.18, 19.15291593980007], [127.74, -4.59, 19.20415328287212], [137.26, -15.28, 52.29]], [[-130.55, 71.47, 7.57], [-150.51, 66.62, 8.527130768027146], [-154.36, 65.89, 8.713460748633855], [-173.25, 65.69, 97.15]], [[98, -6.64, 93.12], [72.07, -10.16, 93.10279764905636], [-124.54, -21.15, 92.97199470885812], [-132.02, -15.35, 57.87]], [[20.14, -10.99, 84.54], [-109, 66.61, 76.56]], [[80.47, 55.37, 46.81], [6.5, 6.56, 47.01703729460373], [2.9, 2.03, 47.020596272882266], [-3.9, 0.6, 47.04890553686023], [-23.4, -13.87, 47.0986124254275], [-35.75, -19.52, 47.1407454193607], [-41.36, -21.49, 97.47]], [[-151.45, 69.31, 60.61], [-139.28, 71.57, 60.60684421117555], [-68.57, 68.07, 60.58888787162895], [5.04, 56.81, 60.57037256344025], [145.64, 42.32, 38.19]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.24702157324504, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14, 18.66], [109.52, 25.41, 18.713816154405887], [111.26, 18.37, 18.872859853565156], [119.32, 7.63, 19.021606509515006], [130.07, -4.18, 19.15291593980007], [127.74, -4.59, 19.20415328287212], [137.26, -15.28, 52.29]], [[-130.55, 71.47, 7.57], [-150.51, 66.62, 8.527130768027146], [-154.36, 65.89, 8.713460748633855], [-173.25, 65.69, 97.15]], [[98, -6.64, 93.12], [72.07, -10.16, 93.10279764905636], [-124.54, -21.15, 92.97199470885812], [-132.02, -15.35, 57.87]], [[20.14, -10.99, 84.54], [-109, 66.61, 76.56]], [[80.47, 55.37, 46.81], [6.5, 6.56, 47.01703729460373], [2.9, 2.03, 47.020596272882266], [-3.9, 0.6, 47.04890553686023], [-23.4, -13.87, 47.0986124254275], [-35.75, -19.52, 47.1407454193607], [-41.36, -21.49, 97.47]], [[-151.45, 69.31, 60.61], [-139.28, 71.57, 60.60684421117555], [-68.57, 68.07, 60.58888787162895], [5.04, 56.81, 60.57037256344025], [145.64, 42.32, 38.19]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.24702157324504, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14, 18.66], [109.52, 25.41, 18.713816154405887], [111.26, 18.37, 18.872859853565156], [119.32, 7.63, 19.021606509515006], [130.07, -4.18, 19.15291593980007], [127.74, -4.59, 19.20415328287212], [137.26, -15.28, 52.29]], [[-130.55, 71.47, 7.57], [-150.51, 66.62, 8.527130768027146], [-154.36, 65.89, 8.713460748633855], [-173.25, 65.69, 97.15]], [[98, -6.64, 93.12], [72.07, -10.16, 93.10279764905636], [-124.54, -21.15, 92.97199470885812], [-132.02, -15.35, 57.87]], [[20.14, -10.99, 84.54], [-109, 66.61, 76.56]], [[80.47, 55.37, 46.81], [6.5, 6.56, 47.01703729460373], [2.9, 2.03, 47.020596272882266], [-3.9, 0.6, 47.04890553686023], [-23.4, -13.87, 47.0986124254275], [-35.75, -19.52, 47.1407454193607], [-41.36, -21.49, 97.47]], [[-151.45, 69.31, 60.61], [-139.28, 71.57, 60.60684421117555], [-68.57, 68.07, 60.58888787162895], [5.04, 56.81, 60.57037256344025], [145.64, 42.32, 38.19]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.24702157324504, number2: -4438177620 } }, { type: "Feature", geometry: { type: MultiLineString, coordinates: [[[109.95, 27.14, 18.66], [109.52, 25.41, 18.713816154405887], [111.26, 18.37, 18.872859853565156], [119.32, 7.63, 19.021606509515006], [130.07, -4.18, 19.15291593980007], [127.74, -4.59, 19.20415328287212], [137.26, -15.28, 52.29]], [[-130.55, 71.47, 7.57], [-150.51, 66.62, 8.527130768027146], [-154.36, 65.89, 8.713460748633855], [-173.25, 65.69, 97.15]], [[98, -6.64, 93.12], [72.07, -10.16, 93.10279764905636], [-124.54, -21.15, 92.97199470885812], [-132.02, -15.35, 57.87]], [[20.14, -10.99, 84.54], [-109, 66.61, 76.56]], [[80.47, 55.37, 46.81], [6.5, 6.56, 47.01703729460373], [2.9, 2.03, 47.020596272882266], [-3.9, 0.6, 47.04890553686023], [-23.4, -13.87, 47.0986124254275], [-35.75, -19.52, 47.1407454193607], [-41.36, -21.49, 97.47]], [[-151.45, 69.31, 60.61], [-139.28, 71.57, 60.60684421117555], [-68.57, 68.07, 60.58888787162895], [5.04, 56.81, 60.57037256344025], [145.64, 42.32, 38.19]]] }, properties: { id: 1433977599, label: "Caso - 169", number1: 413.24702157324504, number2: -4438177620 } }] } ] \ No newline at end of file diff --git a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiPoint_num=5_threeD=False.verified.txt b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiPoint_num=5_threeD=False.verified.txt index 28981bc6e..38ac28bb8 100644 --- a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiPoint_num=5_threeD=False.verified.txt +++ b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiPoint_num=5_threeD=False.verified.txt @@ -1,3 +1,3 @@ [ - This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14], [-112.8, 68.63], [-30.55, 4.13], [169.49, -75.47], [15.29, 56.93], [86.2, -32.53]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.667820568973, number2: -1475082015 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14], [-112.8, 68.63], [-30.55, 4.13], [169.49, -75.47], [15.29, 56.93], [86.2, -32.53]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.667820568973, number2: -1475082015 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14], [-112.8, 68.63], [-30.55, 4.13], [169.49, -75.47], [15.29, 56.93], [86.2, -32.53]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.667820568973, number2: -1475082015 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14], [-112.8, 68.63], [-30.55, 4.13], [169.49, -75.47], [15.29, 56.93], [86.2, -32.53]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.667820568973, number2: -1475082015 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14], [-112.8, 68.63], [-30.55, 4.13], [169.49, -75.47], [15.29, 56.93], [86.2, -32.53]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.667820568973, number2: -1475082015 } }] } + This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14], [-112.8, 68.63], [-30.55, 4.13], [169.49, -75.47], [15.29, 56.93], [86.2, -32.53]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.66782056897307, number2: -1475082015 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14], [-112.8, 68.63], [-30.55, 4.13], [169.49, -75.47], [15.29, 56.93], [86.2, -32.53]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.66782056897307, number2: -1475082015 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14], [-112.8, 68.63], [-30.55, 4.13], [169.49, -75.47], [15.29, 56.93], [86.2, -32.53]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.66782056897307, number2: -1475082015 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14], [-112.8, 68.63], [-30.55, 4.13], [169.49, -75.47], [15.29, 56.93], [86.2, -32.53]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.66782056897307, number2: -1475082015 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14], [-112.8, 68.63], [-30.55, 4.13], [169.49, -75.47], [15.29, 56.93], [86.2, -32.53]] }, properties: { id: -673990871, label: "Caso - 4", number1: 267.66782056897307, number2: -1475082015 } }] } ] \ No newline at end of file diff --git a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiPoint_num=5_threeD=True.verified.txt b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiPoint_num=5_threeD=True.verified.txt index f8428da01..3d1d81b31 100644 --- a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiPoint_num=5_threeD=True.verified.txt +++ b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=MultiPoint_num=5_threeD=True.verified.txt @@ -1,3 +1,3 @@ [ - This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14, 18.66], [137.26, -15.28, 52.29], [169.49, -75.47, 54.24], [113.87, 43.1, 31.93], [-67.02, 68.7, 64.72], [-176.95, 6.36, 13.73]] }, properties: { id: -1926453452, label: "Random - 432", number1: 485.752573463019, number2: -3930315055 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14, 18.66], [137.26, -15.28, 52.29], [169.49, -75.47, 54.24], [113.87, 43.1, 31.93], [-67.02, 68.7, 64.72], [-176.95, 6.36, 13.73]] }, properties: { id: -1926453452, label: "Random - 432", number1: 485.752573463019, number2: -3930315055 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14, 18.66], [137.26, -15.28, 52.29], [169.49, -75.47, 54.24], [113.87, 43.1, 31.93], [-67.02, 68.7, 64.72], [-176.95, 6.36, 13.73]] }, properties: { id: -1926453452, label: "Random - 432", number1: 485.752573463019, number2: -3930315055 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14, 18.66], [137.26, -15.28, 52.29], [169.49, -75.47, 54.24], [113.87, 43.1, 31.93], [-67.02, 68.7, 64.72], [-176.95, 6.36, 13.73]] }, properties: { id: -1926453452, label: "Random - 432", number1: 485.752573463019, number2: -3930315055 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14, 18.66], [137.26, -15.28, 52.29], [169.49, -75.47, 54.24], [113.87, 43.1, 31.93], [-67.02, 68.7, 64.72], [-176.95, 6.36, 13.73]] }, properties: { id: -1926453452, label: "Random - 432", number1: 485.752573463019, number2: -3930315055 } }] } + This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14, 18.66], [137.26, -15.28, 52.29], [169.49, -75.47, 54.24], [113.87, 43.1, 31.93], [-67.02, 68.7, 64.72], [-176.95, 6.36, 13.73]] }, properties: { id: -1926453452, label: "Random - 432", number1: 485.75257346301925, number2: -3930315055 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14, 18.66], [137.26, -15.28, 52.29], [169.49, -75.47, 54.24], [113.87, 43.1, 31.93], [-67.02, 68.7, 64.72], [-176.95, 6.36, 13.73]] }, properties: { id: -1926453452, label: "Random - 432", number1: 485.75257346301925, number2: -3930315055 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14, 18.66], [137.26, -15.28, 52.29], [169.49, -75.47, 54.24], [113.87, 43.1, 31.93], [-67.02, 68.7, 64.72], [-176.95, 6.36, 13.73]] }, properties: { id: -1926453452, label: "Random - 432", number1: 485.75257346301925, number2: -3930315055 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14, 18.66], [137.26, -15.28, 52.29], [169.49, -75.47, 54.24], [113.87, 43.1, 31.93], [-67.02, 68.7, 64.72], [-176.95, 6.36, 13.73]] }, properties: { id: -1926453452, label: "Random - 432", number1: 485.75257346301925, number2: -3930315055 } }, { type: "Feature", geometry: { type: MultiPoint, coordinates: [[109.95, 27.14, 18.66], [137.26, -15.28, 52.29], [169.49, -75.47, 54.24], [113.87, 43.1, 31.93], [-67.02, 68.7, 64.72], [-176.95, 6.36, 13.73]] }, properties: { id: -1926453452, label: "Random - 432", number1: 485.75257346301925, number2: -3930315055 } }] } ] \ No newline at end of file diff --git a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Point_num=5_threeD=False.verified.txt b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Point_num=5_threeD=False.verified.txt index 564c5faa5..b8cd84163 100644 --- a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Point_num=5_threeD=False.verified.txt +++ b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Point_num=5_threeD=False.verified.txt @@ -1,3 +1,3 @@ [ - This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97] }, properties: { id: -1397622147, label: "Azar - 207", number1: 261.495462507706, number2: 10424022210 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97] }, properties: { id: -1397622147, label: "Azar - 207", number1: 261.495462507706, number2: 10424022210 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97] }, properties: { id: -1397622147, label: "Azar - 207", number1: 261.495462507706, number2: 10424022210 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97] }, properties: { id: -1397622147, label: "Azar - 207", number1: 261.495462507706, number2: 10424022210 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97] }, properties: { id: -1397622147, label: "Azar - 207", number1: 261.495462507706, number2: 10424022210 } }] } + This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97] }, properties: { id: -1397622147, label: "Azar - 207", number1: 261.4954625077059, number2: 10424022210 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97] }, properties: { id: -1397622147, label: "Azar - 207", number1: 261.4954625077059, number2: 10424022210 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97] }, properties: { id: -1397622147, label: "Azar - 207", number1: 261.4954625077059, number2: 10424022210 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97] }, properties: { id: -1397622147, label: "Azar - 207", number1: 261.4954625077059, number2: 10424022210 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97] }, properties: { id: -1397622147, label: "Azar - 207", number1: 261.4954625077059, number2: 10424022210 } }] } ] \ No newline at end of file diff --git a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Point_num=5_threeD=True.verified.txt b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Point_num=5_threeD=True.verified.txt index 2ec355ad6..5256e4f89 100644 --- a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Point_num=5_threeD=True.verified.txt +++ b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Point_num=5_threeD=True.verified.txt @@ -1,3 +1,3 @@ [ - This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97, 65.08] }, properties: { id: 400915893, label: "Hasard - 261", number1: 485.406360582172, number2: 866871070 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97, 65.08] }, properties: { id: 400915893, label: "Hasard - 261", number1: 485.406360582172, number2: 866871070 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97, 65.08] }, properties: { id: 400915893, label: "Hasard - 261", number1: 485.406360582172, number2: 866871070 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97, 65.08] }, properties: { id: 400915893, label: "Hasard - 261", number1: 485.406360582172, number2: 866871070 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97, 65.08] }, properties: { id: 400915893, label: "Hasard - 261", number1: 485.406360582172, number2: 866871070 } }] } + This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97, 65.08] }, properties: { id: 400915893, label: "Hasard - 261", number1: 485.4063605821721, number2: 866871070 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97, 65.08] }, properties: { id: 400915893, label: "Hasard - 261", number1: 485.4063605821721, number2: 866871070 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97, 65.08] }, properties: { id: 400915893, label: "Hasard - 261", number1: 485.4063605821721, number2: 866871070 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97, 65.08] }, properties: { id: 400915893, label: "Hasard - 261", number1: 485.4063605821721, number2: 866871070 } }, { type: "Feature", geometry: { type: Point, coordinates: [38.69, 54.97, 65.08] }, properties: { id: 400915893, label: "Hasard - 261", number1: 485.4063605821721, number2: 866871070 } }] } ] \ No newline at end of file diff --git a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Polygon_num=5_threeD=False.verified.txt b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Polygon_num=5_threeD=False.verified.txt index 5ed5413bc..6167de2fb 100644 --- a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Polygon_num=5_threeD=False.verified.txt +++ b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Polygon_num=5_threeD=False.verified.txt @@ -1,3 +1,3 @@ [ - This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: Polygon, coordinates: [[[41.14, 54.97], [40.81, 53.75], [39.92, 52.85], [38.69, 52.52], [37.46, 52.85], [36.57, 53.75], [36.24, 54.97], [36.57, 56.2], [37.46, 57.09], [38.69, 57.42], [39.92, 57.09], [40.81, 56.2], [41.14, 54.97]]] }, properties: { id: 1892557430, label: "Hasard - 485", number1: 40.3668300902316, number2: -5824760755 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[41.14, 54.97], [40.81, 53.75], [39.92, 52.85], [38.69, 52.52], [37.46, 52.85], [36.57, 53.75], [36.24, 54.97], [36.57, 56.2], [37.46, 57.09], [38.69, 57.42], [39.92, 57.09], [40.81, 56.2], [41.14, 54.97]]] }, properties: { id: 1892557430, label: "Hasard - 485", number1: 40.3668300902316, number2: -5824760755 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[41.14, 54.97], [40.81, 53.75], [39.92, 52.85], [38.69, 52.52], [37.46, 52.85], [36.57, 53.75], [36.24, 54.97], [36.57, 56.2], [37.46, 57.09], [38.69, 57.42], [39.92, 57.09], [40.81, 56.2], [41.14, 54.97]]] }, properties: { id: 1892557430, label: "Hasard - 485", number1: 40.3668300902316, number2: -5824760755 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[41.14, 54.97], [40.81, 53.75], [39.92, 52.85], [38.69, 52.52], [37.46, 52.85], [36.57, 53.75], [36.24, 54.97], [36.57, 56.2], [37.46, 57.09], [38.69, 57.42], [39.92, 57.09], [40.81, 56.2], [41.14, 54.97]]] }, properties: { id: 1892557430, label: "Hasard - 485", number1: 40.3668300902316, number2: -5824760755 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[41.14, 54.97], [40.81, 53.75], [39.92, 52.85], [38.69, 52.52], [37.46, 52.85], [36.57, 53.75], [36.24, 54.97], [36.57, 56.2], [37.46, 57.09], [38.69, 57.42], [39.92, 57.09], [40.81, 56.2], [41.14, 54.97]]] }, properties: { id: 1892557430, label: "Hasard - 485", number1: 40.3668300902316, number2: -5824760755 } }] } + This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: Polygon, coordinates: [[[41.14, 54.97], [40.81, 53.75], [39.92, 52.85], [38.69, 52.52], [37.46, 52.85], [36.57, 53.75], [36.24, 54.97], [36.57, 56.2], [37.46, 57.09], [38.69, 57.42], [39.92, 57.09], [40.81, 56.2], [41.14, 54.97]]] }, properties: { id: 1892557430, label: "Hasard - 485", number1: 40.366830090231645, number2: -5824760755 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[41.14, 54.97], [40.81, 53.75], [39.92, 52.85], [38.69, 52.52], [37.46, 52.85], [36.57, 53.75], [36.24, 54.97], [36.57, 56.2], [37.46, 57.09], [38.69, 57.42], [39.92, 57.09], [40.81, 56.2], [41.14, 54.97]]] }, properties: { id: 1892557430, label: "Hasard - 485", number1: 40.366830090231645, number2: -5824760755 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[41.14, 54.97], [40.81, 53.75], [39.92, 52.85], [38.69, 52.52], [37.46, 52.85], [36.57, 53.75], [36.24, 54.97], [36.57, 56.2], [37.46, 57.09], [38.69, 57.42], [39.92, 57.09], [40.81, 56.2], [41.14, 54.97]]] }, properties: { id: 1892557430, label: "Hasard - 485", number1: 40.366830090231645, number2: -5824760755 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[41.14, 54.97], [40.81, 53.75], [39.92, 52.85], [38.69, 52.52], [37.46, 52.85], [36.57, 53.75], [36.24, 54.97], [36.57, 56.2], [37.46, 57.09], [38.69, 57.42], [39.92, 57.09], [40.81, 56.2], [41.14, 54.97]]] }, properties: { id: 1892557430, label: "Hasard - 485", number1: 40.366830090231645, number2: -5824760755 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[41.14, 54.97], [40.81, 53.75], [39.92, 52.85], [38.69, 52.52], [37.46, 52.85], [36.57, 53.75], [36.24, 54.97], [36.57, 56.2], [37.46, 57.09], [38.69, 57.42], [39.92, 57.09], [40.81, 56.2], [41.14, 54.97]]] }, properties: { id: 1892557430, label: "Hasard - 485", number1: 40.366830090231645, number2: -5824760755 } }] } ] \ No newline at end of file diff --git a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Polygon_num=5_threeD=True.verified.txt b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Polygon_num=5_threeD=True.verified.txt index f4be716d3..a1b94e15c 100644 --- a/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Polygon_num=5_threeD=True.verified.txt +++ b/test/Extensions.Tests/snapshots/SerilogDestructuringTests.Should_Destructure_NetTopologySuite_FeatureCollection_type=Polygon_num=5_threeD=True.verified.txt @@ -1,3 +1,3 @@ [ - This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: Polygon, coordinates: [[[39.75, 54.97], [39.61, 54.44], [39.22, 54.05], [38.69, 53.91], [38.16, 54.05], [37.77, 54.44], [37.63, 54.97], [37.77, 55.5], [38.16, 55.89], [38.69, 56.03], [39.22, 55.89], [39.61, 55.5], [39.75, 54.97]], [[38.55, 54.9], [38.51, 55.06], [38.39, 55.18], [38.23, 55.22], [38.07, 55.18], [37.96, 55.06], [37.91, 54.9], [37.96, 54.74], [38.07, 54.63], [38.23, 54.59], [38.39, 54.63], [38.51, 54.74], [38.55, 54.9]]] }, properties: { id: 173374214, label: "Azar - 369", number1: 159.663536660217, number2: -3369954355 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[39.75, 54.97], [39.61, 54.44], [39.22, 54.05], [38.69, 53.91], [38.16, 54.05], [37.77, 54.44], [37.63, 54.97], [37.77, 55.5], [38.16, 55.89], [38.69, 56.03], [39.22, 55.89], [39.61, 55.5], [39.75, 54.97]], [[38.55, 54.9], [38.51, 55.06], [38.39, 55.18], [38.23, 55.22], [38.07, 55.18], [37.96, 55.06], [37.91, 54.9], [37.96, 54.74], [38.07, 54.63], [38.23, 54.59], [38.39, 54.63], [38.51, 54.74], [38.55, 54.9]]] }, properties: { id: 173374214, label: "Azar - 369", number1: 159.663536660217, number2: -3369954355 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[39.75, 54.97], [39.61, 54.44], [39.22, 54.05], [38.69, 53.91], [38.16, 54.05], [37.77, 54.44], [37.63, 54.97], [37.77, 55.5], [38.16, 55.89], [38.69, 56.03], [39.22, 55.89], [39.61, 55.5], [39.75, 54.97]], [[38.55, 54.9], [38.51, 55.06], [38.39, 55.18], [38.23, 55.22], [38.07, 55.18], [37.96, 55.06], [37.91, 54.9], [37.96, 54.74], [38.07, 54.63], [38.23, 54.59], [38.39, 54.63], [38.51, 54.74], [38.55, 54.9]]] }, properties: { id: 173374214, label: "Azar - 369", number1: 159.663536660217, number2: -3369954355 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[39.75, 54.97], [39.61, 54.44], [39.22, 54.05], [38.69, 53.91], [38.16, 54.05], [37.77, 54.44], [37.63, 54.97], [37.77, 55.5], [38.16, 55.89], [38.69, 56.03], [39.22, 55.89], [39.61, 55.5], [39.75, 54.97]], [[38.55, 54.9], [38.51, 55.06], [38.39, 55.18], [38.23, 55.22], [38.07, 55.18], [37.96, 55.06], [37.91, 54.9], [37.96, 54.74], [38.07, 54.63], [38.23, 54.59], [38.39, 54.63], [38.51, 54.74], [38.55, 54.9]]] }, properties: { id: 173374214, label: "Azar - 369", number1: 159.663536660217, number2: -3369954355 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[39.75, 54.97], [39.61, 54.44], [39.22, 54.05], [38.69, 53.91], [38.16, 54.05], [37.77, 54.44], [37.63, 54.97], [37.77, 55.5], [38.16, 55.89], [38.69, 56.03], [39.22, 55.89], [39.61, 55.5], [39.75, 54.97]], [[38.55, 54.9], [38.51, 55.06], [38.39, 55.18], [38.23, 55.22], [38.07, 55.18], [37.96, 55.06], [37.91, 54.9], [37.96, 54.74], [38.07, 54.63], [38.23, 54.59], [38.39, 54.63], [38.51, 54.74], [38.55, 54.9]]] }, properties: { id: 173374214, label: "Azar - 369", number1: 159.663536660217, number2: -3369954355 } }] } + This is just a test { type: "FeatureCollection", features: [{ type: "Feature", geometry: { type: Polygon, coordinates: [[[39.75, 54.97], [39.61, 54.44], [39.22, 54.05], [38.69, 53.91], [38.16, 54.05], [37.77, 54.44], [37.63, 54.97], [37.77, 55.5], [38.16, 55.89], [38.69, 56.03], [39.22, 55.89], [39.61, 55.5], [39.75, 54.97]], [[38.55, 54.9], [38.51, 55.06], [38.39, 55.18], [38.23, 55.22], [38.07, 55.18], [37.96, 55.06], [37.91, 54.9], [37.96, 54.74], [38.07, 54.63], [38.23, 54.59], [38.39, 54.63], [38.51, 54.74], [38.55, 54.9]]] }, properties: { id: 173374214, label: "Azar - 369", number1: 159.66353666021655, number2: -3369954355 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[39.75, 54.97], [39.61, 54.44], [39.22, 54.05], [38.69, 53.91], [38.16, 54.05], [37.77, 54.44], [37.63, 54.97], [37.77, 55.5], [38.16, 55.89], [38.69, 56.03], [39.22, 55.89], [39.61, 55.5], [39.75, 54.97]], [[38.55, 54.9], [38.51, 55.06], [38.39, 55.18], [38.23, 55.22], [38.07, 55.18], [37.96, 55.06], [37.91, 54.9], [37.96, 54.74], [38.07, 54.63], [38.23, 54.59], [38.39, 54.63], [38.51, 54.74], [38.55, 54.9]]] }, properties: { id: 173374214, label: "Azar - 369", number1: 159.66353666021655, number2: -3369954355 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[39.75, 54.97], [39.61, 54.44], [39.22, 54.05], [38.69, 53.91], [38.16, 54.05], [37.77, 54.44], [37.63, 54.97], [37.77, 55.5], [38.16, 55.89], [38.69, 56.03], [39.22, 55.89], [39.61, 55.5], [39.75, 54.97]], [[38.55, 54.9], [38.51, 55.06], [38.39, 55.18], [38.23, 55.22], [38.07, 55.18], [37.96, 55.06], [37.91, 54.9], [37.96, 54.74], [38.07, 54.63], [38.23, 54.59], [38.39, 54.63], [38.51, 54.74], [38.55, 54.9]]] }, properties: { id: 173374214, label: "Azar - 369", number1: 159.66353666021655, number2: -3369954355 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[39.75, 54.97], [39.61, 54.44], [39.22, 54.05], [38.69, 53.91], [38.16, 54.05], [37.77, 54.44], [37.63, 54.97], [37.77, 55.5], [38.16, 55.89], [38.69, 56.03], [39.22, 55.89], [39.61, 55.5], [39.75, 54.97]], [[38.55, 54.9], [38.51, 55.06], [38.39, 55.18], [38.23, 55.22], [38.07, 55.18], [37.96, 55.06], [37.91, 54.9], [37.96, 54.74], [38.07, 54.63], [38.23, 54.59], [38.39, 54.63], [38.51, 54.74], [38.55, 54.9]]] }, properties: { id: 173374214, label: "Azar - 369", number1: 159.66353666021655, number2: -3369954355 } }, { type: "Feature", geometry: { type: Polygon, coordinates: [[[39.75, 54.97], [39.61, 54.44], [39.22, 54.05], [38.69, 53.91], [38.16, 54.05], [37.77, 54.44], [37.63, 54.97], [37.77, 55.5], [38.16, 55.89], [38.69, 56.03], [39.22, 55.89], [39.61, 55.5], [39.75, 54.97]], [[38.55, 54.9], [38.51, 55.06], [38.39, 55.18], [38.23, 55.22], [38.07, 55.18], [37.96, 55.06], [37.91, 54.9], [37.96, 54.74], [38.07, 54.63], [38.23, 54.59], [38.39, 54.63], [38.51, 54.74], [38.55, 54.9]]] }, properties: { id: 173374214, label: "Azar - 369", number1: 159.66353666021655, number2: -3369954355 } }] } ] \ No newline at end of file diff --git a/test/Functions.Tests/RocketHostBuilderTests.cs b/test/Functions.Tests/RocketHostBuilderTests.cs index a744a05aa..6c0f1570f 100644 --- a/test/Functions.Tests/RocketHostBuilderTests.cs +++ b/test/Functions.Tests/RocketHostBuilderTests.cs @@ -1,5 +1,4 @@ using FakeItEasy; -using FluentAssertions; using Microsoft.Azure.Functions.Extensions.DependencyInjection; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -7,8 +6,6 @@ using Rocket.Surgery.Conventions.DependencyInjection; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.Functions; -using Xunit; -using Xunit.Abstractions; namespace Functions.Tests; diff --git a/test/Metadata.Tests/GitVersionTests.cs b/test/Metadata.Tests/GitVersionTests.cs index 31d42aaea..e646aa24c 100644 --- a/test/Metadata.Tests/GitVersionTests.cs +++ b/test/Metadata.Tests/GitVersionTests.cs @@ -1,9 +1,6 @@ using System.Reflection; -using FluentAssertions; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.Metadata; -using Xunit; -using Xunit.Abstractions; namespace Metadata.Tests; diff --git a/test/Sample.BlazorServer.Tests/FoundationTests.cs b/test/Sample.BlazorServer.Tests/FoundationTests.cs index 81ce903ad..d2504824e 100644 --- a/test/Sample.BlazorServer.Tests/FoundationTests.cs +++ b/test/Sample.BlazorServer.Tests/FoundationTests.cs @@ -1,11 +1,8 @@ using System.Net; using AutoMapper; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.AspNetCore.Testing; -using Xunit; -using Xunit.Abstractions; namespace Sample.BlazorServer.Tests; diff --git a/test/Sample.BlazorServer.Tests/TestWebHost.cs b/test/Sample.BlazorServer.Tests/TestWebHost.cs index a4d7e6767..87416a6d3 100644 --- a/test/Sample.BlazorServer.Tests/TestWebHost.cs +++ b/test/Sample.BlazorServer.Tests/TestWebHost.cs @@ -19,7 +19,9 @@ public TestWebHost() protected override IHostBuilder CreateHostBuilder() { _connection.Open(); +#pragma warning disable CS8602 return base.CreateHostBuilder() +#pragma warning restore CS8602 .ConfigureServices( (_, services) => { diff --git a/test/Sample.BlazorWasm.Tests/FoundationTests.cs b/test/Sample.BlazorWasm.Tests/FoundationTests.cs index 15117be9d..d714eae36 100644 --- a/test/Sample.BlazorWasm.Tests/FoundationTests.cs +++ b/test/Sample.BlazorWasm.Tests/FoundationTests.cs @@ -1,7 +1,5 @@ using AutoMapper; using Microsoft.Extensions.DependencyInjection; -using Xunit; -using Xunit.Abstractions; namespace Sample.BlazorWasm.Tests; diff --git a/test/Sample.BlazorWasm.Tests/HandleTestHostBase.cs b/test/Sample.BlazorWasm.Tests/HandleTestHostBase.cs index 779c28939..7dba5cb9d 100644 --- a/test/Sample.BlazorWasm.Tests/HandleTestHostBase.cs +++ b/test/Sample.BlazorWasm.Tests/HandleTestHostBase.cs @@ -4,7 +4,6 @@ using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.Testing; using Rocket.Surgery.Extensions.Testing; -using Xunit.Abstractions; namespace Sample.BlazorWasm.Tests; diff --git a/test/Sample.Core.Tests/FoundationTests.cs b/test/Sample.Core.Tests/FoundationTests.cs index 461c4b46c..ddb9b288a 100644 --- a/test/Sample.Core.Tests/FoundationTests.cs +++ b/test/Sample.Core.Tests/FoundationTests.cs @@ -1,7 +1,5 @@ using AutoMapper; using Microsoft.Extensions.DependencyInjection; -using Xunit; -using Xunit.Abstractions; namespace Sample.Core.Tests; diff --git a/test/Sample.Core.Tests/HandleTestHostBase.cs b/test/Sample.Core.Tests/HandleTestHostBase.cs index fe65da844..b35123d3f 100644 --- a/test/Sample.Core.Tests/HandleTestHostBase.cs +++ b/test/Sample.Core.Tests/HandleTestHostBase.cs @@ -8,8 +8,6 @@ using Rocket.Surgery.DependencyInjection; using Rocket.Surgery.Extensions.Testing; using Sample.Core.Domain; -using Xunit; -using Xunit.Abstractions; namespace Sample.Core.Tests; diff --git a/test/Sample.Core.Tests/LaunchRecords/CreateLaunchRecordTests.cs b/test/Sample.Core.Tests/LaunchRecords/CreateLaunchRecordTests.cs index 0c36ac441..3904607e4 100644 --- a/test/Sample.Core.Tests/LaunchRecords/CreateLaunchRecordTests.cs +++ b/test/Sample.Core.Tests/LaunchRecords/CreateLaunchRecordTests.cs @@ -1,12 +1,9 @@ -using Bogus; -using MediatR; +using MediatR; using Microsoft.Extensions.Logging; using NodaTime; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Core.Operations.LaunchRecords; -using Xunit; -using Xunit.Abstractions; namespace Sample.Core.Tests.LaunchRecords; diff --git a/test/Sample.Core.Tests/LaunchRecords/GetLaunchRecordTests.cs b/test/Sample.Core.Tests/LaunchRecords/GetLaunchRecordTests.cs index 8a325adab..87311bff1 100644 --- a/test/Sample.Core.Tests/LaunchRecords/GetLaunchRecordTests.cs +++ b/test/Sample.Core.Tests/LaunchRecords/GetLaunchRecordTests.cs @@ -1,6 +1,4 @@ -using Bogus; -using FluentAssertions; -using MediatR; +using MediatR; using Microsoft.Extensions.Logging; using NodaTime; using Rocket.Surgery.DependencyInjection; @@ -8,8 +6,6 @@ using Sample.Core.Domain; using Sample.Core.Models; using Sample.Core.Operations.LaunchRecords; -using Xunit; -using Xunit.Abstractions; namespace Sample.Core.Tests.LaunchRecords; diff --git a/test/Sample.Core.Tests/LaunchRecords/ListLaunchRecordsTests.cs b/test/Sample.Core.Tests/LaunchRecords/ListLaunchRecordsTests.cs index edcf348f4..e249f8b60 100644 --- a/test/Sample.Core.Tests/LaunchRecords/ListLaunchRecordsTests.cs +++ b/test/Sample.Core.Tests/LaunchRecords/ListLaunchRecordsTests.cs @@ -1,12 +1,8 @@ -using Bogus; -using FluentAssertions; -using MediatR; +using MediatR; using Microsoft.Extensions.Logging; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Core.Operations.LaunchRecords; -using Xunit; -using Xunit.Abstractions; namespace Sample.Core.Tests.LaunchRecords; diff --git a/test/Sample.Core.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs b/test/Sample.Core.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs index c69d0992a..c9629cc56 100644 --- a/test/Sample.Core.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs +++ b/test/Sample.Core.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs @@ -1,15 +1,10 @@ -using Bogus; -using FluentAssertions; -using MediatR; +using MediatR; using Microsoft.Extensions.Logging; using Rocket.Surgery.DependencyInjection; using Rocket.Surgery.LaunchPad.Foundation; using Sample.Core.Domain; using Sample.Core.Models; using Sample.Core.Operations.LaunchRecords; -using Sample.Core.Operations.Rockets; -using Xunit; -using Xunit.Abstractions; namespace Sample.Core.Tests.LaunchRecords; diff --git a/test/Sample.Core.Tests/LaunchRecords/UpdateLaunchRecordTests.cs b/test/Sample.Core.Tests/LaunchRecords/UpdateLaunchRecordTests.cs index b75248a2c..d7a59dd64 100644 --- a/test/Sample.Core.Tests/LaunchRecords/UpdateLaunchRecordTests.cs +++ b/test/Sample.Core.Tests/LaunchRecords/UpdateLaunchRecordTests.cs @@ -1,6 +1,4 @@ -using Bogus; -using FluentAssertions; -using MediatR; +using MediatR; using Microsoft.Extensions.Logging; using NodaTime; using NodaTime.Extensions; @@ -8,8 +6,6 @@ using Sample.Core.Domain; using Sample.Core.Models; using Sample.Core.Operations.LaunchRecords; -using Xunit; -using Xunit.Abstractions; namespace Sample.Core.Tests.LaunchRecords; diff --git a/test/Sample.Core.Tests/Rockets/CreateRocketTests.cs b/test/Sample.Core.Tests/Rockets/CreateRocketTests.cs index 7f3639106..dfbd8c93a 100644 --- a/test/Sample.Core.Tests/Rockets/CreateRocketTests.cs +++ b/test/Sample.Core.Tests/Rockets/CreateRocketTests.cs @@ -1,14 +1,10 @@ -using Bogus; -using FluentAssertions; -using MediatR; +using MediatR; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Rocket.Surgery.DependencyInjection; using Rocket.Surgery.LaunchPad.Foundation; using Sample.Core.Domain; using Sample.Core.Operations.Rockets; -using Xunit; -using Xunit.Abstractions; using ValidationException = FluentValidation.ValidationException; namespace Sample.Core.Tests.Rockets; diff --git a/test/Sample.Core.Tests/Rockets/GetRocketTests.cs b/test/Sample.Core.Tests/Rockets/GetRocketTests.cs index 7330614e6..9f74ea852 100644 --- a/test/Sample.Core.Tests/Rockets/GetRocketTests.cs +++ b/test/Sample.Core.Tests/Rockets/GetRocketTests.cs @@ -1,14 +1,10 @@ -using Bogus; -using FluentAssertions; -using MediatR; +using MediatR; using Microsoft.Extensions.Logging; using Rocket.Surgery.DependencyInjection; using Rocket.Surgery.LaunchPad.Foundation; using Sample.Core.Domain; using Sample.Core.Models; using Sample.Core.Operations.Rockets; -using Xunit; -using Xunit.Abstractions; namespace Sample.Core.Tests.Rockets; diff --git a/test/Sample.Core.Tests/Rockets/ListRocketsTests.cs b/test/Sample.Core.Tests/Rockets/ListRocketsTests.cs index 5c21a4c7e..a2d0fe30a 100644 --- a/test/Sample.Core.Tests/Rockets/ListRocketsTests.cs +++ b/test/Sample.Core.Tests/Rockets/ListRocketsTests.cs @@ -1,12 +1,8 @@ -using Bogus; -using FluentAssertions; -using MediatR; +using MediatR; using Microsoft.Extensions.Logging; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Core.Operations.Rockets; -using Xunit; -using Xunit.Abstractions; namespace Sample.Core.Tests.Rockets; diff --git a/test/Sample.Core.Tests/Rockets/RemoveRocketsTests.cs b/test/Sample.Core.Tests/Rockets/RemoveRocketsTests.cs index 33b97e705..6df1b0d2c 100644 --- a/test/Sample.Core.Tests/Rockets/RemoveRocketsTests.cs +++ b/test/Sample.Core.Tests/Rockets/RemoveRocketsTests.cs @@ -1,13 +1,8 @@ -using Bogus; -using FluentAssertions; -using MediatR; +using MediatR; using Microsoft.Extensions.Logging; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; -using Sample.Core.Models; using Sample.Core.Operations.Rockets; -using Xunit; -using Xunit.Abstractions; namespace Sample.Core.Tests.Rockets; diff --git a/test/Sample.Core.Tests/Rockets/UpdateRocketTests.cs b/test/Sample.Core.Tests/Rockets/UpdateRocketTests.cs index 833e089bc..1eb0814d2 100644 --- a/test/Sample.Core.Tests/Rockets/UpdateRocketTests.cs +++ b/test/Sample.Core.Tests/Rockets/UpdateRocketTests.cs @@ -1,14 +1,10 @@ -using Bogus; -using FluentAssertions; -using MediatR; +using MediatR; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Core.Models; using Sample.Core.Operations.Rockets; -using Xunit; -using Xunit.Abstractions; using ValidationException = FluentValidation.ValidationException; namespace Sample.Core.Tests.Rockets; diff --git a/test/Sample.Graphql.Tests/FoundationTests.cs b/test/Sample.Graphql.Tests/FoundationTests.cs index 0d7ac2d80..c5b17e1bd 100644 --- a/test/Sample.Graphql.Tests/FoundationTests.cs +++ b/test/Sample.Graphql.Tests/FoundationTests.cs @@ -1,13 +1,10 @@ using System.Net; using AutoMapper; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Rocket.Surgery.DependencyInjection; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.AspNetCore.Testing; -using Xunit; -using Xunit.Abstractions; using IRequestExecutorResolver = HotChocolate.Execution.IRequestExecutorResolver; namespace Sample.Graphql.Tests; diff --git a/test/Sample.Graphql.Tests/HandleWebHostBase.cs b/test/Sample.Graphql.Tests/HandleWebHostBase.cs index e4b61b962..8bce540f4 100644 --- a/test/Sample.Graphql.Tests/HandleWebHostBase.cs +++ b/test/Sample.Graphql.Tests/HandleWebHostBase.cs @@ -9,8 +9,6 @@ using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.AspNetCore.Testing; using Sample.Core.Domain; -using Xunit; -using Xunit.Abstractions; namespace Sample.Graphql.Tests; @@ -46,7 +44,7 @@ protected HandleWebHostBase( options.HttpMessageHandlerBuilderActions.Add( builder => { - if (Factory.ClientOptions.AllowAutoRedirect) + if (Factory!.ClientOptions.AllowAutoRedirect) { builder.AdditionalHandlers.Add(new RedirectHandler(Factory.ClientOptions.MaxAutomaticRedirections)); } @@ -61,7 +59,7 @@ protected HandleWebHostBase( ); options.HttpClientActions.Add( - client => client.BaseAddress = new Uri(Factory.ClientOptions.BaseAddress + "graphql/") + client => client.BaseAddress = new Uri(Factory!.ClientOptions.BaseAddress + "graphql/") ); } ); diff --git a/test/Sample.Graphql.Tests/LaunchRecords/CreateLaunchRecordTests.cs b/test/Sample.Graphql.Tests/LaunchRecords/CreateLaunchRecordTests.cs index 7055d28e5..486b6e8a7 100644 --- a/test/Sample.Graphql.Tests/LaunchRecords/CreateLaunchRecordTests.cs +++ b/test/Sample.Graphql.Tests/LaunchRecords/CreateLaunchRecordTests.cs @@ -8,6 +8,12 @@ namespace Sample.Graphql.Tests.LaunchRecords; public class CreateLaunchRecordTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public CreateLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Create_A_LaunchRecord() { @@ -42,12 +48,6 @@ public async Task Should_Create_A_LaunchRecord() ); response.EnsureNoErrors(); - response.Data.CreateLaunchRecord.Id.Should().NotBeEmpty(); + response.Data!.CreateLaunchRecord.Id.Should().NotBeEmpty(); } - - public CreateLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Graphql.Tests/LaunchRecords/GetLaunchRecordTests.cs b/test/Sample.Graphql.Tests/LaunchRecords/GetLaunchRecordTests.cs index 072bedabc..573aeeb3b 100644 --- a/test/Sample.Graphql.Tests/LaunchRecords/GetLaunchRecordTests.cs +++ b/test/Sample.Graphql.Tests/LaunchRecords/GetLaunchRecordTests.cs @@ -9,6 +9,12 @@ namespace Sample.Graphql.Tests.LaunchRecords; public class GetLaunchRecordTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public GetLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Get_A_LaunchRecord() { @@ -43,16 +49,10 @@ public async Task Should_Get_A_LaunchRecord() var response = await client.GetLaunchRecord.ExecuteAsync(record.Id.Value); response.EnsureNoErrors(); - response.Data.LaunchRecords.Items[0].Partner.Should().Be("partner"); + response.Data!.LaunchRecords!.Items![0].Partner.Should().Be("partner"); response.Data.LaunchRecords.Items[0].Payload.Should().Be("geo-fence-ftl"); response.Data.LaunchRecords.Items[0].Rocket.Type.Should().Be(RocketType.Falcon9); response.Data.LaunchRecords.Items[0].Rocket.SerialNumber.Should().Be("12345678901234"); response.Data.LaunchRecords.Items[0].ScheduledLaunchDate.Should().Be(record.ScheduledLaunchDate); } - - public GetLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Graphql.Tests/LaunchRecords/ListLaunchRecordsTests.cs b/test/Sample.Graphql.Tests/LaunchRecords/ListLaunchRecordsTests.cs index 4c8bde2bc..3efcdb697 100644 --- a/test/Sample.Graphql.Tests/LaunchRecords/ListLaunchRecordsTests.cs +++ b/test/Sample.Graphql.Tests/LaunchRecords/ListLaunchRecordsTests.cs @@ -1,15 +1,18 @@ -using Bogus; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.DependencyInjection; using Sample.Core; using Sample.Core.Domain; -using Xunit; -using Xunit.Abstractions; namespace Sample.Graphql.Tests.LaunchRecords; public class ListLaunchRecordsTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public ListLaunchRecordsTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_List_LaunchRecords() { @@ -30,7 +33,7 @@ await ServiceProvider.WithScoped() var response = await client.GetLaunchRecords.ExecuteAsync(); response.EnsureNoErrors(); - response.Data.LaunchRecords.Items.Should().HaveCount(10); + response.Data!.LaunchRecords!.Items.Should().HaveCount(10); } @@ -54,12 +57,6 @@ await ServiceProvider.WithScoped() var response = await client.GetFilteredLaunchRecords.ExecuteAsync(RocketType.FalconHeavy); response.EnsureNoErrors(); - response.Data.LaunchRecords.Items.Should().HaveCount(3); + response.Data!.LaunchRecords!.Items.Should().HaveCount(3); } - - public ListLaunchRecordsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Graphql.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs b/test/Sample.Graphql.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs index 8d7809eae..b15f0c87e 100644 --- a/test/Sample.Graphql.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs +++ b/test/Sample.Graphql.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs @@ -1,16 +1,18 @@ -using Bogus; -using FluentAssertions; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.DependencyInjection; using Sample.Core; using Sample.Core.Domain; -using Xunit; -using Xunit.Abstractions; namespace Sample.Graphql.Tests.LaunchRecords; public class RemoveLaunchRecordsTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public RemoveLaunchRecordsTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Remove_LaunchRecord() { @@ -35,10 +37,4 @@ public async Task Should_Remove_LaunchRecord() ServiceProvider.WithScoped().Invoke(c => c.LaunchRecords.Should().BeEmpty()); } - - public RemoveLaunchRecordsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Graphql.Tests/LaunchRecords/UpdateLaunchRecordTests.cs b/test/Sample.Graphql.Tests/LaunchRecords/UpdateLaunchRecordTests.cs index 71faa3df5..0ae5ac45d 100644 --- a/test/Sample.Graphql.Tests/LaunchRecords/UpdateLaunchRecordTests.cs +++ b/test/Sample.Graphql.Tests/LaunchRecords/UpdateLaunchRecordTests.cs @@ -10,11 +10,16 @@ namespace Sample.Graphql.Tests.LaunchRecords; public class UpdateLaunchRecordTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public UpdateLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Update_A_LaunchRecord() { var client = Factory.Services.GetRequiredService(); - var clock = ServiceProvider.GetRequiredService(); var record = await ServiceProvider.WithScoped() .Invoke( async (context, clk) => @@ -57,14 +62,8 @@ await client.UpdateLaunchRecord.ExecuteAsync( var response = await client.GetLaunchRecord.ExecuteAsync(record.Id.Value); response.EnsureNoErrors(); - response.Data.LaunchRecords.Items[0].ScheduledLaunchDate.Should() + response.Data!.LaunchRecords!.Items![0].ScheduledLaunchDate.Should() .Be(( record.ScheduledLaunchDate.ToInstant() + Duration.FromSeconds(1) ).ToDateTimeOffset()); response.Data.LaunchRecords.Items[0].PayloadWeightKg.Should().Be(200); } - - public UpdateLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Graphql.Tests/NamedSchemaTests.cs b/test/Sample.Graphql.Tests/NamedSchemaTests.cs index 84f2cc385..6151a779a 100644 --- a/test/Sample.Graphql.Tests/NamedSchemaTests.cs +++ b/test/Sample.Graphql.Tests/NamedSchemaTests.cs @@ -3,8 +3,6 @@ using Rocket.Surgery.Conventions; using Rocket.Surgery.Conventions.Testing; using Rocket.Surgery.Extensions.Testing; -using Xunit; -using Xunit.Abstractions; namespace Sample.Graphql.Tests; diff --git a/test/Sample.Graphql.Tests/Rockets/CreateRocketTests.cs b/test/Sample.Graphql.Tests/Rockets/CreateRocketTests.cs index 77733effc..86b54f129 100644 --- a/test/Sample.Graphql.Tests/Rockets/CreateRocketTests.cs +++ b/test/Sample.Graphql.Tests/Rockets/CreateRocketTests.cs @@ -5,6 +5,10 @@ namespace Sample.Graphql.Tests.Rockets; public class CreateRocketTests : HandleWebHostBase { + public CreateRocketTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public async Task Should_Create_A_Rocket() { @@ -17,14 +21,15 @@ public async Task Should_Create_A_Rocket() } ); - response.Data.CreateRocket.Id.Should().NotBeEmpty(); + response.EnsureNoErrors(); + response.Data!.CreateRocket.Id.Should().NotBeEmpty(); } [Fact] public async Task Should_Throw_If_Rocket_Exists() { var client = Factory.Services.GetRequiredService(); - var response = await client.CreateRocket.ExecuteAsync( + await client.CreateRocket.ExecuteAsync( new CreateRocketRequest { Type = RocketType.Falcon9, @@ -32,13 +37,6 @@ public async Task Should_Throw_If_Rocket_Exists() } ); - Func action = () => client.CreateRocket.ExecuteAsync( - new CreateRocketRequest - { - Type = RocketType.Falcon9, - SerialNumber = "12345678901234" - } - ); var response2 = await client.CreateRocket.ExecuteAsync( new CreateRocketRequest { @@ -49,8 +47,4 @@ public async Task Should_Throw_If_Rocket_Exists() response2.IsErrorResult().Should().BeTrue(); response2.Errors[0].Message.Should().Be("A Rocket already exists with that serial number!"); } - - public CreateRocketTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } } diff --git a/test/Sample.Graphql.Tests/Rockets/GetRocketTests.cs b/test/Sample.Graphql.Tests/Rockets/GetRocketTests.cs index bafaabf81..f261d0c9d 100644 --- a/test/Sample.Graphql.Tests/Rockets/GetRocketTests.cs +++ b/test/Sample.Graphql.Tests/Rockets/GetRocketTests.cs @@ -7,6 +7,12 @@ namespace Sample.Graphql.Tests.Rockets; public class GetRocketTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public GetRocketTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Get_A_Rocket() { @@ -30,13 +36,7 @@ public async Task Should_Get_A_Rocket() var response = await client.GetRocket.ExecuteAsync(rocket.Value); response.EnsureNoErrors(); - response.Data.Rockets.Items[0].Type.Should().Be(RocketType.Falcon9); + response.Data!.Rockets!.Items![0].Type.Should().Be(RocketType.Falcon9); response.Data.Rockets.Items[0].SerialNumber.Should().Be("12345678901234"); } - - public GetRocketTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Graphql.Tests/Rockets/ListRocketsTests.cs b/test/Sample.Graphql.Tests/Rockets/ListRocketsTests.cs index 9b237d1b5..f14afae16 100644 --- a/test/Sample.Graphql.Tests/Rockets/ListRocketsTests.cs +++ b/test/Sample.Graphql.Tests/Rockets/ListRocketsTests.cs @@ -7,6 +7,12 @@ namespace Sample.Graphql.Tests.Rockets; public class ListRocketsTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public ListRocketsTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_List_Rockets() { @@ -25,7 +31,7 @@ await ServiceProvider.WithScoped() var response = await client.GetRockets.ExecuteAsync(); response.EnsureNoErrors(); - response.Data.Rockets.Items.Should().HaveCount(10); + response.Data!.Rockets!.Items.Should().HaveCount(10); } [Fact] @@ -46,12 +52,6 @@ await ServiceProvider.WithScoped() var response = await client.GetFilteredRockets.ExecuteAsync(RocketType.AtlasV); response.EnsureNoErrors(); - response.Data.Rockets.Items.Should().HaveCount(5); + response.Data!.Rockets!.Items.Should().HaveCount(5); } - - public ListRocketsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Graphql.Tests/Rockets/RemoveRocketsTests.cs b/test/Sample.Graphql.Tests/Rockets/RemoveRocketsTests.cs index fe3a9a8a6..d53ca62c3 100644 --- a/test/Sample.Graphql.Tests/Rockets/RemoveRocketsTests.cs +++ b/test/Sample.Graphql.Tests/Rockets/RemoveRocketsTests.cs @@ -1,16 +1,18 @@ -using Bogus; -using FluentAssertions; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.DependencyInjection; using Sample.Core; using Sample.Core.Domain; -using Xunit; -using Xunit.Abstractions; namespace Sample.Graphql.Tests.Rockets; public class RemoveRocketsTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public RemoveRocketsTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Remove_Rocket() { @@ -32,10 +34,4 @@ public async Task Should_Remove_Rocket() ServiceProvider.WithScoped().Invoke(c => c.Rockets.Should().BeEmpty()); } - - public RemoveRocketsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Graphql.Tests/Rockets/UpdateRocketTests.cs b/test/Sample.Graphql.Tests/Rockets/UpdateRocketTests.cs index de19817b3..280088b16 100644 --- a/test/Sample.Graphql.Tests/Rockets/UpdateRocketTests.cs +++ b/test/Sample.Graphql.Tests/Rockets/UpdateRocketTests.cs @@ -1,5 +1,4 @@ -using HotChocolate; -using Humanizer; +using Humanizer; using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; @@ -9,6 +8,12 @@ namespace Sample.Graphql.Tests.Rockets; public class UpdateRocketTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public UpdateRocketTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public async Task Should_Update_A_Rocket() { @@ -142,12 +147,6 @@ public async Task Should_Patch_A_Rocket_Type() u.Data!.PatchRocket.SerialNumber.Should().Be("12345678901234"); } - public UpdateRocketTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - - private static readonly Faker Faker = new(); - [Theory] [ClassData(typeof(ShouldValidateUsersRequiredFieldData))] public async Task Should_Validate_Required_Fields(EditRocketRequest request, string propertyName) diff --git a/test/Sample.Graphql.Tests/TestWebHost.cs b/test/Sample.Graphql.Tests/TestWebHost.cs index 43242794e..c9947beac 100644 --- a/test/Sample.Graphql.Tests/TestWebHost.cs +++ b/test/Sample.Graphql.Tests/TestWebHost.cs @@ -19,7 +19,9 @@ public TestWebHost() protected override IHostBuilder CreateHostBuilder() { _connection.Open(); +#pragma warning disable CS8602 return base.CreateHostBuilder() +#pragma warning restore CS8602 .ConfigureServices( (_, services) => { diff --git a/test/Sample.Grpc.Tests/FoundationTests.cs b/test/Sample.Grpc.Tests/FoundationTests.cs index 09eaa6cd6..f084278b8 100644 --- a/test/Sample.Grpc.Tests/FoundationTests.cs +++ b/test/Sample.Grpc.Tests/FoundationTests.cs @@ -1,11 +1,8 @@ using System.Net; using AutoMapper; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.AspNetCore.Testing; -using Xunit; -using Xunit.Abstractions; namespace Sample.Grpc.Tests; diff --git a/test/Sample.Grpc.Tests/HandleWebHostBase.cs b/test/Sample.Grpc.Tests/HandleWebHostBase.cs index fde43bf99..a20541131 100644 --- a/test/Sample.Grpc.Tests/HandleWebHostBase.cs +++ b/test/Sample.Grpc.Tests/HandleWebHostBase.cs @@ -7,8 +7,6 @@ using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.AspNetCore.Testing; using Sample.Core.Domain; -using Xunit; -using Xunit.Abstractions; namespace Sample.Grpc.Tests; diff --git a/test/Sample.Grpc.Tests/LaunchRecords/CreateLaunchRecordTests.cs b/test/Sample.Grpc.Tests/LaunchRecords/CreateLaunchRecordTests.cs index a0c84c4ba..f273fbc68 100644 --- a/test/Sample.Grpc.Tests/LaunchRecords/CreateLaunchRecordTests.cs +++ b/test/Sample.Grpc.Tests/LaunchRecords/CreateLaunchRecordTests.cs @@ -1,19 +1,21 @@ -using Bogus; -using FluentAssertions; -using Google.Protobuf.WellKnownTypes; +using Google.Protobuf.WellKnownTypes; using Microsoft.Extensions.DependencyInjection; using NodaTime; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Grpc.Tests.Validation; -using Xunit; -using Xunit.Abstractions; using LR = Sample.Grpc.LaunchRecords; namespace Sample.Grpc.Tests.LaunchRecords; public class CreateLaunchRecordTests : HandleGrpcHostBase { + private static readonly Faker Faker = new(); + + public CreateLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Create_A_LaunchRecord() { @@ -49,10 +51,4 @@ public async Task Should_Create_A_LaunchRecord() response.Id.Should().NotBeEmpty(); } - - public CreateLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Grpc.Tests/LaunchRecords/GetLaunchRecordTests.cs b/test/Sample.Grpc.Tests/LaunchRecords/GetLaunchRecordTests.cs index d0684caef..55e8e7d18 100644 --- a/test/Sample.Grpc.Tests/LaunchRecords/GetLaunchRecordTests.cs +++ b/test/Sample.Grpc.Tests/LaunchRecords/GetLaunchRecordTests.cs @@ -1,19 +1,21 @@ -using Bogus; -using FluentAssertions; -using Google.Protobuf.WellKnownTypes; +using Google.Protobuf.WellKnownTypes; using NodaTime; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Core.Models; using Sample.Grpc.Tests.Validation; -using Xunit; -using Xunit.Abstractions; using LR = Sample.Grpc.LaunchRecords; namespace Sample.Grpc.Tests.LaunchRecords; public class GetLaunchRecordTests : HandleGrpcHostBase { + private static readonly Faker Faker = new(); + + public GetLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Get_A_LaunchRecord() { @@ -53,10 +55,4 @@ public async Task Should_Get_A_LaunchRecord() response.RocketSerialNumber.Should().Be("12345678901234"); response.ScheduledLaunchDate.Should().Be(record.ScheduledLaunchDate.ToTimestamp()); } - - public GetLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Grpc.Tests/LaunchRecords/ListLaunchRecordsTests.cs b/test/Sample.Grpc.Tests/LaunchRecords/ListLaunchRecordsTests.cs index a557aa6d0..a92a70514 100644 --- a/test/Sample.Grpc.Tests/LaunchRecords/ListLaunchRecordsTests.cs +++ b/test/Sample.Grpc.Tests/LaunchRecords/ListLaunchRecordsTests.cs @@ -1,18 +1,20 @@ -using Bogus; -using FluentAssertions; -using Grpc.Core; +using Grpc.Core; using Rocket.Surgery.DependencyInjection; using Sample.Core; using Sample.Core.Domain; using Sample.Grpc.Tests.Validation; -using Xunit; -using Xunit.Abstractions; using LR = Sample.Grpc.LaunchRecords; namespace Sample.Grpc.Tests.LaunchRecords; public class ListLaunchRecordsTests : HandleGrpcHostBase { + private static readonly Faker Faker = new(); + + public ListLaunchRecordsTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_List_LaunchRecords() { @@ -64,10 +66,4 @@ await ServiceProvider.WithScoped() response.Should().HaveCount(3); } - - public ListLaunchRecordsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Grpc.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs b/test/Sample.Grpc.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs index 7b3f0f49d..33d3afe91 100644 --- a/test/Sample.Grpc.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs +++ b/test/Sample.Grpc.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs @@ -1,17 +1,19 @@ -using Bogus; -using FluentAssertions; -using Rocket.Surgery.DependencyInjection; +using Rocket.Surgery.DependencyInjection; using Sample.Core; using Sample.Core.Domain; using Sample.Grpc.Tests.Validation; -using Xunit; -using Xunit.Abstractions; using LR = Sample.Grpc.LaunchRecords; namespace Sample.Grpc.Tests.LaunchRecords; public class RemoveLaunchRecordsTests : HandleGrpcHostBase { + private static readonly Faker Faker = new(); + + public RemoveLaunchRecordsTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Remove_LaunchRecord() { @@ -35,10 +37,4 @@ public async Task Should_Remove_LaunchRecord() ServiceProvider.WithScoped().Invoke(c => c.LaunchRecords.Should().BeEmpty()); } - - public RemoveLaunchRecordsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Grpc.Tests/LaunchRecords/UpdateLaunchRecordTests.cs b/test/Sample.Grpc.Tests/LaunchRecords/UpdateLaunchRecordTests.cs index 1a432200c..8ccbf7bb9 100644 --- a/test/Sample.Grpc.Tests/LaunchRecords/UpdateLaunchRecordTests.cs +++ b/test/Sample.Grpc.Tests/LaunchRecords/UpdateLaunchRecordTests.cs @@ -1,6 +1,4 @@ -using Bogus; -using FluentAssertions; -using Google.Protobuf.WellKnownTypes; +using Google.Protobuf.WellKnownTypes; using Microsoft.Extensions.DependencyInjection; using NodaTime; using NodaTime.Extensions; @@ -8,8 +6,6 @@ using Sample.Core.Domain; using Sample.Core.Models; using Sample.Grpc.Tests.Validation; -using Xunit; -using Xunit.Abstractions; using Duration = NodaTime.Duration; using LR = Sample.Grpc.LaunchRecords; @@ -17,6 +13,12 @@ namespace Sample.Grpc.Tests.LaunchRecords; public class UpdateLaunchRecordTests : HandleGrpcHostBase { + private static readonly Faker Faker = new(); + + public UpdateLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Update_A_LaunchRecord() { @@ -67,10 +69,4 @@ await client.EditLaunchRecordAsync( response.ScheduledLaunchDate.Should().Be(( record.ScheduledLaunchDate.ToInstant() + Duration.FromSeconds(1) ).ToDateTimeOffset().ToTimestamp()); response.PayloadWeightKg.Should().Be(200); } - - public UpdateLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Grpc.Tests/Rockets/CreateRocketTests.cs b/test/Sample.Grpc.Tests/Rockets/CreateRocketTests.cs index 964678c60..a880283f5 100644 --- a/test/Sample.Grpc.Tests/Rockets/CreateRocketTests.cs +++ b/test/Sample.Grpc.Tests/Rockets/CreateRocketTests.cs @@ -1,14 +1,15 @@ -using FluentAssertions; -using Grpc.Core; +using Grpc.Core; using Sample.Grpc.Tests.Validation; -using Xunit; -using Xunit.Abstractions; using R = Sample.Grpc.Rockets; namespace Sample.Grpc.Tests.Rockets; public class CreateRocketTests : HandleGrpcHostBase { + public CreateRocketTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public async Task Should_Create_A_Rocket() { @@ -48,8 +49,4 @@ await client.CreateRocketAsync( .And; r.Message.Should().Contain("Rocket Creation Failed"); } - - public CreateRocketTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } } diff --git a/test/Sample.Grpc.Tests/Rockets/GetRocketTests.cs b/test/Sample.Grpc.Tests/Rockets/GetRocketTests.cs index cb5065120..856d016d2 100644 --- a/test/Sample.Grpc.Tests/Rockets/GetRocketTests.cs +++ b/test/Sample.Grpc.Tests/Rockets/GetRocketTests.cs @@ -1,16 +1,18 @@ -using Bogus; -using FluentAssertions; -using Rocket.Surgery.DependencyInjection; +using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Grpc.Tests.Validation; -using Xunit; -using Xunit.Abstractions; using R = Sample.Grpc.Rockets; namespace Sample.Grpc.Tests.Rockets; public class GetRocketTests : HandleGrpcHostBase { + private static readonly Faker Faker = new(); + + public GetRocketTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Get_A_Rocket() { @@ -36,10 +38,4 @@ public async Task Should_Get_A_Rocket() response.Type.Should().Be(RocketType.Falcon9); response.Sn.Should().Be("12345678901234"); } - - public GetRocketTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Grpc.Tests/Rockets/ListRocketsTests.cs b/test/Sample.Grpc.Tests/Rockets/ListRocketsTests.cs index 1c130d90d..44186d2fb 100644 --- a/test/Sample.Grpc.Tests/Rockets/ListRocketsTests.cs +++ b/test/Sample.Grpc.Tests/Rockets/ListRocketsTests.cs @@ -1,18 +1,20 @@ -using Bogus; -using FluentAssertions; -using Grpc.Core; +using Grpc.Core; using Rocket.Surgery.DependencyInjection; using Sample.Core; using Sample.Core.Domain; using Sample.Grpc.Tests.Validation; -using Xunit; -using Xunit.Abstractions; using R = Sample.Grpc.Rockets; namespace Sample.Grpc.Tests.Rockets; public class ListRocketsTests : HandleGrpcHostBase { + private static readonly Faker Faker = new(); + + public ListRocketsTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_List_Rockets() { @@ -60,10 +62,4 @@ await ServiceProvider.WithScoped() response.Should().HaveCount(5); } - - public ListRocketsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Grpc.Tests/Rockets/RemoveRocketsTests.cs b/test/Sample.Grpc.Tests/Rockets/RemoveRocketsTests.cs index 728b60995..763afb80a 100644 --- a/test/Sample.Grpc.Tests/Rockets/RemoveRocketsTests.cs +++ b/test/Sample.Grpc.Tests/Rockets/RemoveRocketsTests.cs @@ -1,17 +1,19 @@ -using Bogus; -using FluentAssertions; -using Rocket.Surgery.DependencyInjection; +using Rocket.Surgery.DependencyInjection; using Sample.Core; using Sample.Core.Domain; using Sample.Grpc.Tests.Validation; -using Xunit; -using Xunit.Abstractions; using R = Sample.Grpc.Rockets; namespace Sample.Grpc.Tests.Rockets; public class RemoveRocketsTests : HandleGrpcHostBase { + private static readonly Faker Faker = new(); + + public RemoveRocketsTests(ITestOutputHelper outputHelper) : base(outputHelper) + { + } + [Fact] public async Task Should_Remove_Rocket() { @@ -33,10 +35,4 @@ public async Task Should_Remove_Rocket() ServiceProvider.WithScoped().Invoke(c => c.Rockets.Should().BeEmpty()); } - - public RemoveRocketsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Grpc.Tests/Rockets/UpdateRocketTests.cs b/test/Sample.Grpc.Tests/Rockets/UpdateRocketTests.cs index 9c4aaee6a..0c2f95102 100644 --- a/test/Sample.Grpc.Tests/Rockets/UpdateRocketTests.cs +++ b/test/Sample.Grpc.Tests/Rockets/UpdateRocketTests.cs @@ -1,17 +1,19 @@ -using Bogus; -using FluentAssertions; -using Grpc.Core; +using Grpc.Core; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Grpc.Tests.Validation; -using Xunit; -using Xunit.Abstractions; using R = Sample.Grpc.Rockets; namespace Sample.Grpc.Tests.Rockets; public class UpdateRocketTests : HandleGrpcHostBase { + private static readonly Faker Faker = new(); + + public UpdateRocketTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + [Fact] public async Task Should_Update_A_Rocket() { @@ -49,12 +51,6 @@ public async Task Should_Update_A_Rocket() // response.Sn.Should().Be("43210987654321"); } - public UpdateRocketTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - - private static readonly Faker Faker = new(); - [Theory] [ClassData(typeof(ShouldValidateUsersRequiredFieldData))] public async Task Should_Validate_Required_Fields(UpdateRocketRequest request, string propertyName) diff --git a/test/Sample.Grpc.Tests/TestWebHost.cs b/test/Sample.Grpc.Tests/TestWebHost.cs index 94f53f675..7c4f21f41 100644 --- a/test/Sample.Grpc.Tests/TestWebHost.cs +++ b/test/Sample.Grpc.Tests/TestWebHost.cs @@ -19,7 +19,9 @@ public TestWebHost() protected override IHostBuilder CreateHostBuilder() { _connection.Open(); +#pragma warning disable CS8602 return base.CreateHostBuilder() +#pragma warning restore CS8602 .ConfigureServices( (_, services) => { diff --git a/test/Sample.Grpc.Tests/Validation/Integration/CustomMessageHandlerIntegrationTest.cs b/test/Sample.Grpc.Tests/Validation/Integration/CustomMessageHandlerIntegrationTest.cs index 35a617864..68f4bf877 100644 --- a/test/Sample.Grpc.Tests/Validation/Integration/CustomMessageHandlerIntegrationTest.cs +++ b/test/Sample.Grpc.Tests/Validation/Integration/CustomMessageHandlerIntegrationTest.cs @@ -5,13 +5,22 @@ using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.AspNetCore.Testing; using Rocket.Surgery.LaunchPad.Grpc.Validation; -using Xunit; -using Xunit.Abstractions; namespace Sample.Grpc.Tests.Validation.Integration; public class CustomMessageHandlerIntegrationTest : LoggerTest, IClassFixture { + private readonly ConventionTestWebHost _factory; + + public CustomMessageHandlerIntegrationTest(ITestOutputHelper testOutputHelper, TestWebHost factory) : base(testOutputHelper) + { + _factory = factory + .ConfigureLoggerFactory(LoggerFactory) + .ConfigureHostBuilder( + options => options.ConfigureServices(services => { services.AddSingleton(new CustomMessageHandler()); }) + ); + } + [Fact] public async Task Should_ThrowInvalidArgument_When_NameOfMessageIsEmpty() { @@ -35,17 +44,6 @@ await client.GetRocketsAsync( Assert.Equal("Validation Error!", rpcException.Status.Detail); } - public CustomMessageHandlerIntegrationTest(ITestOutputHelper testOutputHelper, TestWebHost factory) : base(testOutputHelper) - { - _factory = factory - .ConfigureLoggerFactory(LoggerFactory) - .ConfigureHostBuilder( - options => options.ConfigureServices(services => { services.AddSingleton(new CustomMessageHandler()); }) - ); - } - - private readonly ConventionTestWebHost _factory; - private class CustomMessageHandler : IValidatorErrorMessageHandler { public Task HandleAsync(IEnumerable failures) diff --git a/test/Sample.Grpc.Tests/Validation/Integration/CustomValidatorIntegrationTest.cs b/test/Sample.Grpc.Tests/Validation/Integration/CustomValidatorIntegrationTest.cs index 930f3a145..3ad87f70f 100644 --- a/test/Sample.Grpc.Tests/Validation/Integration/CustomValidatorIntegrationTest.cs +++ b/test/Sample.Grpc.Tests/Validation/Integration/CustomValidatorIntegrationTest.cs @@ -1,17 +1,21 @@ -using FluentAssertions; using Grpc.Core; using Rocket.Surgery.DependencyInjection; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.AspNetCore.Testing; using Sample.Core; using Sample.Core.Domain; -using Xunit; -using Xunit.Abstractions; namespace Sample.Grpc.Tests.Validation.Integration; public class CustomValidatorIntegrationTest : LoggerTest, IClassFixture { + private readonly ConventionTestWebHost _factory; + + public CustomValidatorIntegrationTest(ITestOutputHelper testOutputHelper, TestWebHost factory) : base(testOutputHelper) + { + _factory = factory.ConfigureLoggerFactory(LoggerFactory); + } + [Fact] public async Task Should_ResponseMessage_When_MessageIsValid() { @@ -54,11 +58,4 @@ async Task Action() var rpcException = await Assert.ThrowsAsync(Action); Assert.Equal(StatusCode.InvalidArgument, rpcException.Status.StatusCode); } - - public CustomValidatorIntegrationTest(ITestOutputHelper testOutputHelper, TestWebHost factory) : base(testOutputHelper) - { - _factory = factory.ConfigureLoggerFactory(LoggerFactory); - } - - private readonly ConventionTestWebHost _factory; } diff --git a/test/Sample.Pages.Tests/FoundationTests.cs b/test/Sample.Pages.Tests/FoundationTests.cs index b30e18073..a34e8da8e 100644 --- a/test/Sample.Pages.Tests/FoundationTests.cs +++ b/test/Sample.Pages.Tests/FoundationTests.cs @@ -1,11 +1,8 @@ using System.Net; using AutoMapper; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.AspNetCore.Testing; -using Xunit; -using Xunit.Abstractions; namespace Sample.Pages.Tests; diff --git a/test/Sample.Pages.Tests/TestWebHost.cs b/test/Sample.Pages.Tests/TestWebHost.cs index 57e8b5fb8..eec134892 100644 --- a/test/Sample.Pages.Tests/TestWebHost.cs +++ b/test/Sample.Pages.Tests/TestWebHost.cs @@ -19,7 +19,9 @@ public TestWebHost() protected override IHostBuilder CreateHostBuilder() { _connection.Open(); +#pragma warning disable CS8602 return base.CreateHostBuilder() +#pragma warning restore CS8602 .ConfigureServices( (_, services) => { diff --git a/test/Sample.Restful.Tests/ApiDescriptionData.cs b/test/Sample.Restful.Tests/ApiDescriptionData.cs index d10a3a368..19394b94d 100644 --- a/test/Sample.Restful.Tests/ApiDescriptionData.cs +++ b/test/Sample.Restful.Tests/ApiDescriptionData.cs @@ -1,12 +1,12 @@ using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Extensions.DependencyInjection; -using Xunit; namespace Sample.Restful.Tests; -internal class ApiDescriptionData : TheoryData - where T : WebApplicationFactory, new() +internal class ApiDescriptionData : TheoryData + where TProgramOrStartup : class + where T : WebApplicationFactory, new() { public ApiDescriptionData() { diff --git a/test/Sample.Restful.Tests/ClassicFoundationTests.cs b/test/Sample.Restful.Tests/ClassicFoundationTests.cs new file mode 100644 index 000000000..13ec9ff01 --- /dev/null +++ b/test/Sample.Restful.Tests/ClassicFoundationTests.cs @@ -0,0 +1,47 @@ +using System.Net; +using AutoMapper; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Rocket.Surgery.Extensions.Testing; +using Rocket.Surgery.LaunchPad.AspNetCore.Testing; +using Sample.Classic.Restful; +using Swashbuckle.AspNetCore.Swagger; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Sample.Restful.Tests; + +public class ClassicFoundationTests : AutoFakeTest, IClassFixture> +{ + [Fact] + public void AutoMapper() + { + _factory.Services.GetRequiredService() + .ConfigurationProvider.AssertConfigurationIsValid(); + } + + [Fact] + public async Task Starts() + { + var response = await _factory.CreateClient().GetAsync("/"); + response.StatusCode.Should().Be(HttpStatusCode.NotFound); + } + + [Fact] + public void OpenApiDocument() + { + var docs = _factory.Services + .GetRequiredService>().Value.SwaggerDocs.Keys; + foreach (var document in docs) + { + _factory.Services.GetRequiredService() + .GetSwagger(document).Should().NotBeNull(); + } + } + + public ClassicFoundationTests(ITestOutputHelper testOutputHelper, TestWebHost factory) : base(testOutputHelper) + { + _factory = factory.ConfigureLogger(SerilogLogger); + } + + private readonly ConventionTestWebHost _factory; +} diff --git a/test/Sample.Restful.Tests/ClassicRestfulConventionTests.cs b/test/Sample.Restful.Tests/ClassicRestfulConventionTests.cs new file mode 100644 index 000000000..eedc74093 --- /dev/null +++ b/test/Sample.Restful.Tests/ClassicRestfulConventionTests.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc.Controllers; +using Sample.Classic.Restful; + +namespace Sample.Restful.Tests; + +public class ClassicRestfulConventionTests +{ + [Theory] + [ClassData(typeof(ApiDescriptionData, Startup>))] + public void Should_Have_Success_Response_Types(ApiDescriptionData description) + { + description.Description.SupportedResponseTypes.Should().Contain(z => z.StatusCode >= 200 && z.StatusCode < 300); + } + + [Theory] + [ClassData(typeof(ApiDescriptionData, Startup>))] + public void Should_Have_Not_Found_Responses(ApiDescriptionData description) + { + var method = ( description.Description.ActionDescriptor as ControllerActionDescriptor )!.MethodInfo; + if (method.ReturnType.IsGenericType && method.ReturnType.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>)) return; + description.Description.SupportedResponseTypes.Should().Contain(z => z.StatusCode == StatusCodes.Status404NotFound); + } + + [Theory] + [ClassData(typeof(ApiDescriptionData, Startup>))] + public void Should_Have_Validation_Responses(ApiDescriptionData description) + { + description.Description.SupportedResponseTypes.Should().Contain(z => z.StatusCode == StatusCodes.Status422UnprocessableEntity); + } + + [Theory] + [ClassData(typeof(ApiDescriptionData, Startup>))] + public void Should_Have_Bad_Request_Responses(ApiDescriptionData description) + { + description.Description.SupportedResponseTypes.Should().Contain(z => z.IsDefaultResponse); + } +} diff --git a/test/Sample.Restful.Tests/FoundationTests.cs b/test/Sample.Restful.Tests/FoundationTests.cs index 43d39a01b..0038b9529 100644 --- a/test/Sample.Restful.Tests/FoundationTests.cs +++ b/test/Sample.Restful.Tests/FoundationTests.cs @@ -1,18 +1,15 @@ using System.Net; using AutoMapper; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Rocket.Surgery.Extensions.Testing; using Rocket.Surgery.LaunchPad.AspNetCore.Testing; using Swashbuckle.AspNetCore.Swagger; using Swashbuckle.AspNetCore.SwaggerGen; -using Xunit; -using Xunit.Abstractions; namespace Sample.Restful.Tests; -public class FoundationTests : AutoFakeTest, IClassFixture +public class FoundationTests : AutoFakeTest, IClassFixture> { [Fact] public void AutoMapper() @@ -28,7 +25,7 @@ public async Task Starts() response.StatusCode.Should().Be(HttpStatusCode.NotFound); } - public FoundationTests(ITestOutputHelper testOutputHelper, TestWebHost factory) : base(testOutputHelper) + public FoundationTests(ITestOutputHelper testOutputHelper, TestWebHost factory) : base(testOutputHelper) { _factory = factory.ConfigureLoggerFactory(LoggerFactory); } @@ -47,7 +44,7 @@ private class OpenApiDocuments : TheoryData { public OpenApiDocuments() { - using var host = new TestWebHost(); + using var host = new TestWebHost(); foreach (var item in host.Services.GetRequiredService>().Value.SwaggerDocs.Keys) { Add(item); diff --git a/test/Sample.Restful.Tests/HandleWebHostBase.cs b/test/Sample.Restful.Tests/HandleWebHostBase.cs index ae45eab8d..83b3eab3d 100644 --- a/test/Sample.Restful.Tests/HandleWebHostBase.cs +++ b/test/Sample.Restful.Tests/HandleWebHostBase.cs @@ -1,44 +1,33 @@ -using Microsoft.Data.Sqlite; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Rocket.Surgery.Conventions; -using Rocket.Surgery.DependencyInjection; using Rocket.Surgery.Extensions.Testing; -using Rocket.Surgery.LaunchPad.AspNetCore.Testing; using Sample.Core.Domain; -using Xunit; -using Xunit.Abstractions; namespace Sample.Restful.Tests; -[ImportConventions] -public abstract partial class HandleWebHostBase : LoggerTest, IAsyncLifetime +public abstract partial class HandleWebHostBase : LoggerTest, IAsyncLifetime, IClassFixture> + where TProgramOrStartup : class { protected HandleWebHostBase( ITestOutputHelper outputHelper, + TestWebHost host, LogLevel logLevel = LogLevel.Trace - ) : base( - outputHelper, - logLevel, - "[{Timestamp:HH:mm:ss} {Level:w4}] {Message} <{SourceContext}>{NewLine}{Exception}" - ) + ) : base(outputHelper, logLevel) { - Factory = new TestWebHost() - .ConfigureLoggerFactory(LoggerFactory); + Factory = host; } - protected ConventionTestWebHost Factory { get; private set; } + protected TestWebHost Factory { get; private set; } protected IServiceProvider ServiceProvider => Factory.Services; public async Task InitializeAsync() { - await Task.Yield(); - await ServiceProvider.GetRequiredService().Database.EnsureDeletedAsync(); + await ServiceProvider.GetRequiredService().Database.EnsureCreatedAsync(); } public async Task DisposeAsync() { - await Factory.DisposeAsync(); + await ServiceProvider.GetRequiredService().Database.EnsureDeletedAsync(); + Factory.Reset(); } } diff --git a/test/Sample.Restful.Tests/LaunchRecords/CreateLaunchRecordTests.cs b/test/Sample.Restful.Tests/LaunchRecords/CreateLaunchRecordTests.cs index 8e9a7e784..a75ee1b11 100644 --- a/test/Sample.Restful.Tests/LaunchRecords/CreateLaunchRecordTests.cs +++ b/test/Sample.Restful.Tests/LaunchRecords/CreateLaunchRecordTests.cs @@ -1,18 +1,20 @@ -using Bogus; -using FluentAssertions; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using NodaTime; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Restful.Client; -using Xunit; -using Xunit.Abstractions; using RocketType = Sample.Core.Domain.RocketType; namespace Sample.Restful.Tests.LaunchRecords; -public class CreateLaunchRecordTests : HandleWebHostBase +public class CreateLaunchRecordTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public CreateLaunchRecordTests(ITestOutputHelper outputHelper, TestWebHost host) : base(outputHelper, host) + { + } + [Fact] public async Task Should_Create_A_LaunchRecord() { @@ -48,10 +50,4 @@ public async Task Should_Create_A_LaunchRecord() response.Result.Id.Should().NotBeEmpty(); } - - public CreateLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Restful.Tests/LaunchRecords/GetLaunchRecordTests.cs b/test/Sample.Restful.Tests/LaunchRecords/GetLaunchRecordTests.cs index d45d54a23..46d3774cf 100644 --- a/test/Sample.Restful.Tests/LaunchRecords/GetLaunchRecordTests.cs +++ b/test/Sample.Restful.Tests/LaunchRecords/GetLaunchRecordTests.cs @@ -1,19 +1,21 @@ -using Bogus; -using FluentAssertions; -using NodaTime; +using NodaTime; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Core.Models; using Sample.Restful.Client; -using Xunit; -using Xunit.Abstractions; using HttpRocketType = Sample.Restful.Client.RocketType; using RocketType = Sample.Core.Domain.RocketType; namespace Sample.Restful.Tests.LaunchRecords; -public class GetLaunchRecordTests : HandleWebHostBase +public class GetLaunchRecordTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public GetLaunchRecordTests(ITestOutputHelper outputHelper, TestWebHost host) : base(outputHelper, host) + { + } + [Fact] public async Task Should_Get_A_LaunchRecord() { @@ -65,10 +67,4 @@ await action.Should().ThrowAsync>() z => z.StatusCode == 404 && z.Result.Status == 404 && z.Result.Title == "Not Found" ); } - - public GetLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Restful.Tests/LaunchRecords/ListLaunchRecordsTests.cs b/test/Sample.Restful.Tests/LaunchRecords/ListLaunchRecordsTests.cs index cf8f6d764..b0da46e62 100644 --- a/test/Sample.Restful.Tests/LaunchRecords/ListLaunchRecordsTests.cs +++ b/test/Sample.Restful.Tests/LaunchRecords/ListLaunchRecordsTests.cs @@ -1,18 +1,20 @@ #if NET6_0_OR_GREATER -using Bogus; -using FluentAssertions; using Rocket.Surgery.DependencyInjection; using Sample.Core; using Sample.Core.Domain; using Sample.Restful.Client; -using Xunit; -using Xunit.Abstractions; using RocketType = Sample.Restful.Client.RocketType; namespace Sample.Restful.Tests.LaunchRecords; -public class ListLaunchRecordsTests : HandleWebHostBase +public class ListLaunchRecordsTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public ListLaunchRecordsTests(ITestOutputHelper outputHelper, TestWebHost host) : base(outputHelper, host) + { + } + [Fact] public async Task Should_List_LaunchRecords() { @@ -55,11 +57,5 @@ await ServiceProvider.WithScoped() var response = await client.ListLaunchRecordsAsync(RocketType.FalconHeavy); response.Result.Should().HaveCount(3); } - - public ListLaunchRecordsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } #endif diff --git a/test/Sample.Restful.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs b/test/Sample.Restful.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs index 1940eab7c..8168344e9 100644 --- a/test/Sample.Restful.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs +++ b/test/Sample.Restful.Tests/LaunchRecords/RemoveLaunchRecordsTests.cs @@ -1,20 +1,19 @@ -using Bogus; -using FluentAssertions; -using MediatR; -using Rocket.Surgery.DependencyInjection; -using Rocket.Surgery.LaunchPad.Foundation; +using Rocket.Surgery.DependencyInjection; using Sample.Core; using Sample.Core.Domain; using Sample.Core.Models; -using Sample.Core.Operations.LaunchRecords; using Sample.Restful.Client; -using Xunit; -using Xunit.Abstractions; namespace Sample.Restful.Tests.LaunchRecords; -public class RemoveLaunchRecordsTests : HandleWebHostBase +public class RemoveLaunchRecordsTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public RemoveLaunchRecordsTests(ITestOutputHelper outputHelper, TestWebHost host) : base(outputHelper, host) + { + } + [Fact] public async Task Should_Remove_LaunchRecord() { @@ -65,10 +64,4 @@ await ServiceProvider.WithScoped() await action.Should().ThrowAsync>() .Where(z => z.StatusCode == 403 && z.Result.Status == 403 && z.Result.Title == "Forbidden"); } - - public RemoveLaunchRecordsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Restful.Tests/LaunchRecords/UpdateLaunchRecordTests.cs b/test/Sample.Restful.Tests/LaunchRecords/UpdateLaunchRecordTests.cs index 827a66ef9..a59ed717d 100644 --- a/test/Sample.Restful.Tests/LaunchRecords/UpdateLaunchRecordTests.cs +++ b/test/Sample.Restful.Tests/LaunchRecords/UpdateLaunchRecordTests.cs @@ -1,20 +1,22 @@ -using Bogus; -using FluentAssertions; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using NodaTime; using NodaTime.Extensions; using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Core.Models; using Sample.Restful.Client; -using Xunit; -using Xunit.Abstractions; using RocketType = Sample.Core.Domain.RocketType; namespace Sample.Restful.Tests.LaunchRecords; -public class UpdateLaunchRecordTests : HandleWebHostBase +public class UpdateLaunchRecordTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public UpdateLaunchRecordTests(ITestOutputHelper outputHelper, TestWebHost host) : base(outputHelper, host) + { + } + [Fact] public async Task Should_Update_A_LaunchRecord() { @@ -64,10 +66,4 @@ await client.EditLaunchRecordAsync( response.Result.ScheduledLaunchDate.Should().Be(( record.ScheduledLaunchDate.ToInstant() + Duration.FromSeconds(1) ).ToDateTimeOffset()); response.Result.PayloadWeightKg.Should().Be(200); } - - public UpdateLaunchRecordTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Restful.Tests/RestfulConventionTests.cs b/test/Sample.Restful.Tests/RestfulConventionTests.cs index 7f557abe5..44e4597d4 100644 --- a/test/Sample.Restful.Tests/RestfulConventionTests.cs +++ b/test/Sample.Restful.Tests/RestfulConventionTests.cs @@ -1,39 +1,37 @@ -using FluentAssertions; -using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Controllers; -using Xunit; namespace Sample.Restful.Tests; public class RestfulConventionTests { -// [Theory] -// [ClassData(typeof(ApiDescriptionData))] -// public void Should_Have_Success_Response_Types(ApiDescriptionData description) -// { -// description.Description.SupportedResponseTypes.Should().Contain(z => z.StatusCode >= 200 && z.StatusCode < 300); -// } -// -// [Theory] -// [ClassData(typeof(ApiDescriptionData))] -// public void Should_Have_Not_Found_Responses(ApiDescriptionData description) -// { -// var method = ( description.Description.ActionDescriptor as ControllerActionDescriptor )!.MethodInfo!; -// if (method.ReturnType.IsGenericType && method.ReturnType.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>)) return; -// description.Description.SupportedResponseTypes.Should().Contain(z => z.StatusCode == StatusCodes.Status404NotFound); -// } -// -// [Theory] -// [ClassData(typeof(ApiDescriptionData))] -// public void Should_Have_Validation_Responses(ApiDescriptionData description) -// { -// description.Description.SupportedResponseTypes.Should().Contain(z => z.StatusCode == StatusCodes.Status422UnprocessableEntity); -// } -// -// [Theory] -// [ClassData(typeof(ApiDescriptionData))] -// public void Should_Have_Bad_Request_Responses(ApiDescriptionData description) -// { -// description.Description.SupportedResponseTypes.Should().Contain(z => z.IsDefaultResponse); -// } + [Theory] + [ClassData(typeof(ApiDescriptionData, Program>))] + public void Should_Have_Success_Response_Types(ApiDescriptionData description) + { + description.Description.SupportedResponseTypes.Should().Contain(z => z.StatusCode >= 200 && z.StatusCode < 300); + } + + [Theory] + [ClassData(typeof(ApiDescriptionData, Program>))] + public void Should_Have_Not_Found_Responses(ApiDescriptionData description) + { + var method = ( description.Description.ActionDescriptor as ControllerActionDescriptor )!.MethodInfo; + if (method.ReturnType.IsGenericType && method.ReturnType.GetGenericTypeDefinition() == typeof(IAsyncEnumerable<>)) return; + description.Description.SupportedResponseTypes.Should().Contain(z => z.StatusCode == StatusCodes.Status404NotFound); + } + + [Theory] + [ClassData(typeof(ApiDescriptionData, Program>))] + public void Should_Have_Validation_Responses(ApiDescriptionData description) + { + description.Description.SupportedResponseTypes.Should().Contain(z => z.StatusCode == StatusCodes.Status422UnprocessableEntity); + } + + [Theory] + [ClassData(typeof(ApiDescriptionData, Program>))] + public void Should_Have_Bad_Request_Responses(ApiDescriptionData description) + { + description.Description.SupportedResponseTypes.Should().Contain(z => z.IsDefaultResponse); + } } diff --git a/test/Sample.Restful.Tests/Rockets/CreateRocketTests.cs b/test/Sample.Restful.Tests/Rockets/CreateRocketTests.cs index 7578373e4..fecbcc0e0 100644 --- a/test/Sample.Restful.Tests/Rockets/CreateRocketTests.cs +++ b/test/Sample.Restful.Tests/Rockets/CreateRocketTests.cs @@ -1,12 +1,13 @@ -using FluentAssertions; -using Sample.Restful.Client; -using Xunit; -using Xunit.Abstractions; +using Sample.Restful.Client; namespace Sample.Restful.Tests.Rockets; -public class CreateRocketTests : HandleWebHostBase +public class CreateRocketTests : HandleWebHostBase { + public CreateRocketTests(ITestOutputHelper testOutputHelper, TestWebHost host) : base(testOutputHelper, host) + { + } + [Fact] public async Task Should_Create_A_Rocket() { @@ -46,8 +47,4 @@ await client.CreateRocketAsync( .And.Result; r.Title.Should().Be("Rocket Creation Failed"); } - - public CreateRocketTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } } diff --git a/test/Sample.Restful.Tests/Rockets/GetRocketTests.cs b/test/Sample.Restful.Tests/Rockets/GetRocketTests.cs index f5c0586b6..92f53901c 100644 --- a/test/Sample.Restful.Tests/Rockets/GetRocketTests.cs +++ b/test/Sample.Restful.Tests/Rockets/GetRocketTests.cs @@ -1,17 +1,19 @@ -using Bogus; -using FluentAssertions; -using Rocket.Surgery.DependencyInjection; +using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Restful.Client; -using Xunit; -using Xunit.Abstractions; using HttpRocketType = Sample.Restful.Client.RocketType; using RocketType = Sample.Core.Domain.RocketType; namespace Sample.Restful.Tests.Rockets; -public class GetRocketTests : HandleWebHostBase +public class GetRocketTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public GetRocketTests(ITestOutputHelper outputHelper, TestWebHost host) : base(outputHelper, host) + { + } + [Fact] public async Task Should_Get_A_Rocket() { @@ -49,10 +51,4 @@ await action.Should().ThrowAsync>() z => z.StatusCode == 404 && z.Result.Status == 404 && z.Result.Title == "Not Found" ); } - - public GetRocketTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Restful.Tests/Rockets/ListRocketsTests.cs b/test/Sample.Restful.Tests/Rockets/ListRocketsTests.cs index 18d718ae0..97a1be68d 100644 --- a/test/Sample.Restful.Tests/Rockets/ListRocketsTests.cs +++ b/test/Sample.Restful.Tests/Rockets/ListRocketsTests.cs @@ -1,18 +1,20 @@ #if NET6_0_OR_GREATER -using Bogus; -using FluentAssertions; using Rocket.Surgery.DependencyInjection; using Sample.Core; using Sample.Core.Domain; using Sample.Restful.Client; -using Xunit; -using Xunit.Abstractions; using RocketType = Sample.Restful.Client.RocketType; namespace Sample.Restful.Tests.Rockets; -public class ListRocketsTests : HandleWebHostBase +public class ListRocketsTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public ListRocketsTests(ITestOutputHelper outputHelper, TestWebHost host) : base(outputHelper, host) + { + } + [Fact] public async Task Should_List_Rockets() { @@ -52,11 +54,5 @@ await ServiceProvider.WithScoped() response.Result.Should().HaveCount(5); } - - public ListRocketsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } #endif diff --git a/test/Sample.Restful.Tests/Rockets/RemoveRocketsTests.cs b/test/Sample.Restful.Tests/Rockets/RemoveRocketsTests.cs index 22a99210b..6bd9684a6 100644 --- a/test/Sample.Restful.Tests/Rockets/RemoveRocketsTests.cs +++ b/test/Sample.Restful.Tests/Rockets/RemoveRocketsTests.cs @@ -1,16 +1,18 @@ -using Bogus; -using FluentAssertions; -using Rocket.Surgery.DependencyInjection; +using Rocket.Surgery.DependencyInjection; using Sample.Core; using Sample.Core.Domain; using Sample.Restful.Client; -using Xunit; -using Xunit.Abstractions; namespace Sample.Restful.Tests.Rockets; -public class RemoveRocketsTests : HandleWebHostBase +public class RemoveRocketsTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public RemoveRocketsTests(ITestOutputHelper outputHelper, TestWebHost host) : base(outputHelper, host) + { + } + [Fact] public async Task Should_Remove_Rocket() { @@ -32,10 +34,4 @@ public async Task Should_Remove_Rocket() ServiceProvider.WithScoped().Invoke(c => c.Rockets.Should().BeEmpty()); } - - public RemoveRocketsTests(ITestOutputHelper outputHelper) : base(outputHelper) - { - } - - private static readonly Faker Faker = new(); } diff --git a/test/Sample.Restful.Tests/Rockets/UpdateRocketTests.cs b/test/Sample.Restful.Tests/Rockets/UpdateRocketTests.cs index 092c031e6..563f4c0a6 100644 --- a/test/Sample.Restful.Tests/Rockets/UpdateRocketTests.cs +++ b/test/Sample.Restful.Tests/Rockets/UpdateRocketTests.cs @@ -1,17 +1,19 @@ -using Bogus; -using FluentAssertions; -using Rocket.Surgery.DependencyInjection; +using Rocket.Surgery.DependencyInjection; using Sample.Core.Domain; using Sample.Restful.Client; -using Xunit; -using Xunit.Abstractions; using RocketType = Sample.Core.Domain.RocketType; using ClientRocketType = Sample.Restful.Client.RocketType; namespace Sample.Restful.Tests.Rockets; -public class UpdateRocketTests : HandleWebHostBase +public class UpdateRocketTests : HandleWebHostBase { + private static readonly Faker Faker = new(); + + public UpdateRocketTests(ITestOutputHelper outputHelper, TestWebHost host) : base(outputHelper, host) + { + } + [Fact] public async Task Should_Update_A_Rocket() { @@ -153,12 +155,6 @@ public async Task Should_Patch_A_Rocket_Type() response.Result.Sn.Should().Be("12345678901234"); } - public UpdateRocketTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - - private static readonly Faker Faker = new(); - [Theory] [ClassData(typeof(ShouldValidateUsersRequiredFieldData))] public async Task Should_Validate_Required_Fields(EditRocketRequest request, string propertyName) diff --git a/test/Sample.Restful.Tests/Sample.Restful.Tests.csproj b/test/Sample.Restful.Tests/Sample.Restful.Tests.csproj index 50aa77833..17bb74d97 100644 --- a/test/Sample.Restful.Tests/Sample.Restful.Tests.csproj +++ b/test/Sample.Restful.Tests/Sample.Restful.Tests.csproj @@ -9,6 +9,7 @@ + diff --git a/test/Sample.Restful.Tests/TestWebHost.cs b/test/Sample.Restful.Tests/TestWebHost.cs index a576c02c3..ab3de0bb3 100644 --- a/test/Sample.Restful.Tests/TestWebHost.cs +++ b/test/Sample.Restful.Tests/TestWebHost.cs @@ -2,12 +2,16 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Rocket.Surgery.Conventions; +using Rocket.Surgery.LaunchPad.AspNetCore; using Rocket.Surgery.LaunchPad.AspNetCore.Testing; +using Sample.Classic.Restful; using Sample.Core.Domain; namespace Sample.Restful.Tests; -public class TestWebHost : ConventionTestWebHost +public class TestWebHost : ConventionTestWebHost, IAsyncLifetime + where TProgramOrStartup : class { private SqliteConnection _connection; @@ -15,6 +19,20 @@ public TestWebHost() { _connection = new SqliteConnection("DataSource=:memory:"); _connection.Open(); + + ConfigureHostBuilder( + builder => + { + var excludeConvention = typeof(TProgramOrStartup) == typeof(Program) ? typeof(Startup).Assembly : typeof(Program).Assembly; + builder.ExceptConvention(excludeConvention) + .Set( + new AspNetCoreOptions + { + AssemblyPartFilter = assembly => assembly != excludeConvention + } + ); + } + ); } @@ -37,10 +55,26 @@ protected override IHost CreateHost(IHostBuilder builder) ); } + public void Reset() + { + _connection.Close(); + _connection.Open(); + } + protected override void Dispose(bool disposing) { _connection.Close(); _connection.Dispose(); base.Dispose(disposing); } + + public async Task InitializeAsync() + { + await Services.GetRequiredService().Database.EnsureCreatedAsync(); + } + + async Task IAsyncLifetime.DisposeAsync() + { + await DisposeAsync(); + } }