From 0fa689a2c692a18aef325e298deac3f4542eab51 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 00:10:27 +0000 Subject: [PATCH 1/9] Update dotnet monorepo to v9 --- src/HomeInventory/Directory.Packages.props | 34 +++++++++++----------- src/HomeInventory/Dockerfile | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/HomeInventory/Directory.Packages.props b/src/HomeInventory/Directory.Packages.props index a159166b..85b72c5b 100644 --- a/src/HomeInventory/Directory.Packages.props +++ b/src/HomeInventory/Directory.Packages.props @@ -55,19 +55,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -78,8 +78,8 @@ - - + + @@ -95,8 +95,8 @@ - - + + diff --git a/src/HomeInventory/Dockerfile b/src/HomeInventory/Dockerfile index 7be5506d..75c1c886 100644 --- a/src/HomeInventory/Dockerfile +++ b/src/HomeInventory/Dockerfile @@ -6,7 +6,7 @@ WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM mcr.microsoft.com/dotnet/sdk:8.0.403 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0.100 AS build WORKDIR /src COPY ["Directory.Packages.props", "."] COPY ["Directory.Build.props", "."] From 12721619fe18f7ae40e3651e8005a63029effa22 Mon Sep 17 00:00:00 2001 From: "Serhii A. Hrytsenko" Date: Tue, 12 Nov 2024 19:41:25 -0500 Subject: [PATCH 2/9] Update to .NET 9 Signed-off-by: Serhii A. Hrytsenko --- src/HomeInventory/Directory.Build.props | 2 +- src/HomeInventory/global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HomeInventory/Directory.Build.props b/src/HomeInventory/Directory.Build.props index 437392ff..4af6b2dc 100644 --- a/src/HomeInventory/Directory.Build.props +++ b/src/HomeInventory/Directory.Build.props @@ -1,7 +1,7 @@ - net8 + net9 enable enable latest diff --git a/src/HomeInventory/global.json b/src/HomeInventory/global.json index a3cf554a..4eda5222 100644 --- a/src/HomeInventory/global.json +++ b/src/HomeInventory/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.403", + "version": "9.0.100", "rollForward": "latestMajor", "allowPrerelease": false } From ce5ea582fc782838980a38911e9ffeedfec63cd0 Mon Sep 17 00:00:00 2001 From: "Serhii A. Hrytsenko" Date: Tue, 12 Nov 2024 20:37:38 -0500 Subject: [PATCH 3/9] Update packages Signed-off-by: Serhii A. Hrytsenko --- src/HomeInventory/Directory.Packages.props | 3 +++ .../HomeInventory.Application.Framework.csproj | 1 + ...HomeInventory.Application.UserManagement.Interfaces.csproj | 3 +++ .../HomeInventory.Application.UserManagement.csproj | 3 +++ .../HomeInventory.Application.csproj | 1 + .../HomeInventory.Tests.Acceptance.csproj | 2 ++ .../HomeInventory.Tests.Framework.csproj | 2 ++ .../HomeInventory.Tests.Integration.csproj | 4 +++- .../HomeInventory.Tests/HomeInventory.Tests.csproj | 4 +++- .../HomeInventory.Web.Framework.csproj | 1 + .../HomeInventory.Web.UserManagement.csproj | 4 ++++ src/HomeInventory/HomeInventory.Web/HomeInventory.Web.csproj | 1 + 12 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/HomeInventory/Directory.Packages.props b/src/HomeInventory/Directory.Packages.props index 85b72c5b..1022c973 100644 --- a/src/HomeInventory/Directory.Packages.props +++ b/src/HomeInventory/Directory.Packages.props @@ -32,6 +32,7 @@ + @@ -52,6 +53,8 @@ + + diff --git a/src/HomeInventory/HomeInventory.Application.Framework/HomeInventory.Application.Framework.csproj b/src/HomeInventory/HomeInventory.Application.Framework/HomeInventory.Application.Framework.csproj index eaa46173..7a4d0e62 100644 --- a/src/HomeInventory/HomeInventory.Application.Framework/HomeInventory.Application.Framework.csproj +++ b/src/HomeInventory/HomeInventory.Application.Framework/HomeInventory.Application.Framework.csproj @@ -2,6 +2,7 @@ + diff --git a/src/HomeInventory/HomeInventory.Application.UserManagement.Interfaces/HomeInventory.Application.UserManagement.Interfaces.csproj b/src/HomeInventory/HomeInventory.Application.UserManagement.Interfaces/HomeInventory.Application.UserManagement.Interfaces.csproj index ab9fbce6..3bcfd545 100644 --- a/src/HomeInventory/HomeInventory.Application.UserManagement.Interfaces/HomeInventory.Application.UserManagement.Interfaces.csproj +++ b/src/HomeInventory/HomeInventory.Application.UserManagement.Interfaces/HomeInventory.Application.UserManagement.Interfaces.csproj @@ -1,4 +1,7 @@ + + + diff --git a/src/HomeInventory/HomeInventory.Application.UserManagement/HomeInventory.Application.UserManagement.csproj b/src/HomeInventory/HomeInventory.Application.UserManagement/HomeInventory.Application.UserManagement.csproj index 6a513b08..f2dce19a 100644 --- a/src/HomeInventory/HomeInventory.Application.UserManagement/HomeInventory.Application.UserManagement.csproj +++ b/src/HomeInventory/HomeInventory.Application.UserManagement/HomeInventory.Application.UserManagement.csproj @@ -1,4 +1,7 @@ + + + diff --git a/src/HomeInventory/HomeInventory.Application/HomeInventory.Application.csproj b/src/HomeInventory/HomeInventory.Application/HomeInventory.Application.csproj index 92b1a1f9..4993cdd1 100644 --- a/src/HomeInventory/HomeInventory.Application/HomeInventory.Application.csproj +++ b/src/HomeInventory/HomeInventory.Application/HomeInventory.Application.csproj @@ -2,6 +2,7 @@ + diff --git a/src/HomeInventory/HomeInventory.Tests.Acceptance/HomeInventory.Tests.Acceptance.csproj b/src/HomeInventory/HomeInventory.Tests.Acceptance/HomeInventory.Tests.Acceptance.csproj index 896bcce6..346e1cc4 100644 --- a/src/HomeInventory/HomeInventory.Tests.Acceptance/HomeInventory.Tests.Acceptance.csproj +++ b/src/HomeInventory/HomeInventory.Tests.Acceptance/HomeInventory.Tests.Acceptance.csproj @@ -7,6 +7,8 @@ + + diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj b/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj index 74c27667..c27d0f75 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj +++ b/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj @@ -14,6 +14,8 @@ + + diff --git a/src/HomeInventory/HomeInventory.Tests.Integration/HomeInventory.Tests.Integration.csproj b/src/HomeInventory/HomeInventory.Tests.Integration/HomeInventory.Tests.Integration.csproj index 5fa0a094..6955ed44 100644 --- a/src/HomeInventory/HomeInventory.Tests.Integration/HomeInventory.Tests.Integration.csproj +++ b/src/HomeInventory/HomeInventory.Tests.Integration/HomeInventory.Tests.Integration.csproj @@ -1,4 +1,4 @@ - + CA1707 @@ -10,6 +10,8 @@ + + diff --git a/src/HomeInventory/HomeInventory.Tests/HomeInventory.Tests.csproj b/src/HomeInventory/HomeInventory.Tests/HomeInventory.Tests.csproj index 78bdae54..b38a4a18 100644 --- a/src/HomeInventory/HomeInventory.Tests/HomeInventory.Tests.csproj +++ b/src/HomeInventory/HomeInventory.Tests/HomeInventory.Tests.csproj @@ -1,4 +1,4 @@ - + $(NoWarn);CA1707;AD0001 @@ -16,6 +16,8 @@ + + diff --git a/src/HomeInventory/HomeInventory.Web.Framework/HomeInventory.Web.Framework.csproj b/src/HomeInventory/HomeInventory.Web.Framework/HomeInventory.Web.Framework.csproj index ee047402..dd1f530a 100644 --- a/src/HomeInventory/HomeInventory.Web.Framework/HomeInventory.Web.Framework.csproj +++ b/src/HomeInventory/HomeInventory.Web.Framework/HomeInventory.Web.Framework.csproj @@ -7,6 +7,7 @@ + diff --git a/src/HomeInventory/HomeInventory.Web.UserManagement/HomeInventory.Web.UserManagement.csproj b/src/HomeInventory/HomeInventory.Web.UserManagement/HomeInventory.Web.UserManagement.csproj index f99c2a57..3ad5919a 100644 --- a/src/HomeInventory/HomeInventory.Web.UserManagement/HomeInventory.Web.UserManagement.csproj +++ b/src/HomeInventory/HomeInventory.Web.UserManagement/HomeInventory.Web.UserManagement.csproj @@ -14,4 +14,8 @@ + + + + diff --git a/src/HomeInventory/HomeInventory.Web/HomeInventory.Web.csproj b/src/HomeInventory/HomeInventory.Web/HomeInventory.Web.csproj index 1bd60ba4..a69242ba 100644 --- a/src/HomeInventory/HomeInventory.Web/HomeInventory.Web.csproj +++ b/src/HomeInventory/HomeInventory.Web/HomeInventory.Web.csproj @@ -13,6 +13,7 @@ + From e464cc8b1126f5c585d8ee0eddf921420704adb3 Mon Sep 17 00:00:00 2001 From: "Serhii A. Hrytsenko" Date: Wed, 13 Nov 2024 06:57:00 -0500 Subject: [PATCH 4/9] Update packages Signed-off-by: Serhii A. Hrytsenko --- .gitignore | 14 +++++++ src/HomeInventory/Directory.Packages.props | 38 +++++++++---------- .../HomeInventory.Infrastructure.csproj | 1 + 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 3e895aa1..d0709c8d 100644 --- a/.gitignore +++ b/.gitignore @@ -350,3 +350,17 @@ MigrationBackup/ .ionide/ *.feature.cs src/HomeInventory/coverage + +# Default ignored files for Idea +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/.idea.HomeInventory.iml +/contentModel.xml +/modules.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/src/HomeInventory/Directory.Packages.props b/src/HomeInventory/Directory.Packages.props index 1022c973..3caea5f6 100644 --- a/src/HomeInventory/Directory.Packages.props +++ b/src/HomeInventory/Directory.Packages.props @@ -2,8 +2,7 @@ true - - + @@ -28,13 +27,9 @@ - - - - - + @@ -45,35 +40,37 @@ - - - - - + + + + - - + + + + - + + + - - + @@ -84,8 +81,8 @@ - + @@ -93,9 +90,7 @@ - - - + @@ -103,6 +98,7 @@ + \ No newline at end of file diff --git a/src/HomeInventory/HomeInventory.Infrastructure/HomeInventory.Infrastructure.csproj b/src/HomeInventory/HomeInventory.Infrastructure/HomeInventory.Infrastructure.csproj index 8e4e16c2..57838c8a 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure/HomeInventory.Infrastructure.csproj +++ b/src/HomeInventory/HomeInventory.Infrastructure/HomeInventory.Infrastructure.csproj @@ -3,6 +3,7 @@ + From f6190c97aed481fbe1d75e1801d8872fa3f38827 Mon Sep 17 00:00:00 2001 From: "Serhii A. Hrytsenko" Date: Wed, 13 Nov 2024 07:00:21 -0500 Subject: [PATCH 5/9] Update packages Signed-off-by: Serhii A. Hrytsenko --- .../HomeInventory.Tests.Acceptance.csproj | 2 -- .../HomeInventory.Tests.Framework.csproj | 2 +- .../HomeInventory.Tests.Integration.csproj | 2 -- .../HomeInventory.Tests/HomeInventory.Tests.csproj | 6 ++---- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/HomeInventory/HomeInventory.Tests.Acceptance/HomeInventory.Tests.Acceptance.csproj b/src/HomeInventory/HomeInventory.Tests.Acceptance/HomeInventory.Tests.Acceptance.csproj index 346e1cc4..896bcce6 100644 --- a/src/HomeInventory/HomeInventory.Tests.Acceptance/HomeInventory.Tests.Acceptance.csproj +++ b/src/HomeInventory/HomeInventory.Tests.Acceptance/HomeInventory.Tests.Acceptance.csproj @@ -7,8 +7,6 @@ - - diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj b/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj index c27d0f75..07f0ec9c 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj +++ b/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj @@ -13,9 +13,9 @@ - + diff --git a/src/HomeInventory/HomeInventory.Tests.Integration/HomeInventory.Tests.Integration.csproj b/src/HomeInventory/HomeInventory.Tests.Integration/HomeInventory.Tests.Integration.csproj index 6955ed44..d38ebfd9 100644 --- a/src/HomeInventory/HomeInventory.Tests.Integration/HomeInventory.Tests.Integration.csproj +++ b/src/HomeInventory/HomeInventory.Tests.Integration/HomeInventory.Tests.Integration.csproj @@ -10,8 +10,6 @@ - - diff --git a/src/HomeInventory/HomeInventory.Tests/HomeInventory.Tests.csproj b/src/HomeInventory/HomeInventory.Tests/HomeInventory.Tests.csproj index b38a4a18..4357c9e4 100644 --- a/src/HomeInventory/HomeInventory.Tests/HomeInventory.Tests.csproj +++ b/src/HomeInventory/HomeInventory.Tests/HomeInventory.Tests.csproj @@ -9,15 +9,13 @@ - + + - - - From d15d0f344d75959d00cb45127bfeb89a4e21d329 Mon Sep 17 00:00:00 2001 From: "Serhii A. Hrytsenko" Date: Wed, 13 Nov 2024 07:02:27 -0500 Subject: [PATCH 6/9] Add idea files Signed-off-by: Serhii A. Hrytsenko --- .idea/.gitignore | 13 ++++ .idea/indexLayout.xml | 8 +++ .idea/vcs.xml | 6 ++ .../.idea.HomeInventory/.idea/.gitignore | 13 ++++ .../.idea.HomeInventory/.idea/indexLayout.xml | 8 +++ .../.idea/.idea.HomeInventory/.idea/vcs.xml | 6 ++ .../.idea.HomeInventory/.idea/workspace.xml | 71 +++++++++++++++++++ 7 files changed, 125 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/indexLayout.xml create mode 100644 .idea/vcs.xml create mode 100644 src/HomeInventory/.idea/.idea.HomeInventory/.idea/.gitignore create mode 100644 src/HomeInventory/.idea/.idea.HomeInventory/.idea/indexLayout.xml create mode 100644 src/HomeInventory/.idea/.idea.HomeInventory/.idea/vcs.xml create mode 100644 src/HomeInventory/.idea/.idea.HomeInventory/.idea/workspace.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..8f5aaa3f --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/.idea.HomeInventory.iml +/projectSettingsUpdater.xml +/modules.xml +/contentModel.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/indexLayout.xml b/.idea/indexLayout.xml new file mode 100644 index 00000000..7b08163c --- /dev/null +++ b/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/HomeInventory/.idea/.idea.HomeInventory/.idea/.gitignore b/src/HomeInventory/.idea/.idea.HomeInventory/.idea/.gitignore new file mode 100644 index 00000000..50b72f87 --- /dev/null +++ b/src/HomeInventory/.idea/.idea.HomeInventory/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/.idea.HomeInventory.iml +/contentModel.xml +/modules.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/src/HomeInventory/.idea/.idea.HomeInventory/.idea/indexLayout.xml b/src/HomeInventory/.idea/.idea.HomeInventory/.idea/indexLayout.xml new file mode 100644 index 00000000..7b08163c --- /dev/null +++ b/src/HomeInventory/.idea/.idea.HomeInventory/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/HomeInventory/.idea/.idea.HomeInventory/.idea/vcs.xml b/src/HomeInventory/.idea/.idea.HomeInventory/.idea/vcs.xml new file mode 100644 index 00000000..b2bdec2d --- /dev/null +++ b/src/HomeInventory/.idea/.idea.HomeInventory/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/HomeInventory/.idea/.idea.HomeInventory/.idea/workspace.xml b/src/HomeInventory/.idea/.idea.HomeInventory/.idea/workspace.xml new file mode 100644 index 00000000..d0792d88 --- /dev/null +++ b/src/HomeInventory/.idea/.idea.HomeInventory/.idea/workspace.xml @@ -0,0 +1,71 @@ + + + + HomeInventory.Api/HomeInventory.Api.csproj + + + + + + + + + + + + + + + + + + + + + + + + + + + 1731499300524 + + + + + + \ No newline at end of file From 2b96d85b9e0627282d79f4defc63a6b439c32390 Mon Sep 17 00:00:00 2001 From: "Serhii A. Hrytsenko" Date: Wed, 13 Nov 2024 08:42:42 -0500 Subject: [PATCH 7/9] Fix and mute errors/warnings Signed-off-by: Serhii A. Hrytsenko --- src/HomeInventory/.editorconfig | 76 ++++++++++++++++--- src/HomeInventory/Directory.Build.props | 4 +- src/HomeInventory/Directory.Packages.props | 2 + .../HomeInventory.Api/AppBuilder.cs | 2 +- .../HomeInventory.Api/AssemblyReference.cs | 1 + .../HomeInventory.Api.csproj | 2 + .../HomeInventory.Api/Program.cs | 1 + .../FeatureManagerExtensions.cs | 2 +- .../Messaging/CommandHandler.cs | 4 +- .../Messaging/IQueryResult.cs | 3 +- .../Cqrs/Behaviors/LoggingBehavior.cs | 1 - .../PasswordCharacterSets.cs | 2 +- .../RegisterRequestValidator.cs | 10 +-- .../LoginRequestValidator.cs | 6 +- .../HomeInventory.Core/IParseable.cs | 4 +- .../ISpannableCollection.cs | 8 +- .../ScopeAccessorExtensions.cs | 2 +- .../HomeInventory.Core/TypeExtensions.cs | 1 - .../ValidationExtensions.cs | 4 +- .../EnumerationItemsCollection.cs | 3 +- .../IBuildableObject.cs | 2 +- .../IRepository.cs | 5 +- .../Ids/IIdBuildable.cs | 2 +- .../DomainServiceCollectionExtensions.cs | 2 +- .../ValueObjects/AmountFactory.cs | 2 +- .../IDatabaseContext.cs | 2 +- .../IEventsPersistenceService.cs | 2 +- ...ureFrameworkServiceCollectionExtensions.cs | 4 +- .../Models/IPersistentModel.cs | 2 +- .../Repository.cs | 29 +++---- .../Specifications/ByIdFilterSpecification.cs | 2 +- ...erManagementServiceCollectionExtensions.cs | 2 +- .../Configurations/DomainEventJsonTypeInfo.cs | 2 +- .../Configurations/UserModelConfiguration.cs | 8 +- .../Models/UserModel.cs | 1 + .../UserRepository.cs | 3 +- .../HomeInventory.Infrastructure.csproj | 1 + ...frastructureServiceCollectionExtensions.cs | 7 +- .../Persistence/DatabaseContext.cs | 7 +- .../Persistence/Mapping/ModelMappings.cs | 4 +- .../PolymorphicDomainEventTypeResolver.cs | 2 +- .../PublishDomainEventsInterceptor.cs | 2 +- .../Persistence/Models/OutboxMessage.cs | 1 + .../Services/EventsPersistenceService.cs | 2 +- .../Drivers/HomeInventoryAPIDriver.cs | 2 +- .../Assertions/AssertionExtensions.cs | 3 +- .../Assertions/ObjectExtensions.cs | 2 +- .../Assertions/UlidAssertions.cs | 3 +- .../Attributes/ArchitectureTestAttribute.cs | 2 +- .../HomeInventory.Tests.Framework/BaseTest.cs | 6 +- .../ApiBehaviorOptionsCustomization.cs | 4 +- .../Customizations/FixtureExtensions.cs | 4 +- .../GivenContext.cs | 2 +- .../HomeInventory.Tests.Framework.csproj | 2 + .../RandomExtensions.cs | 3 +- .../VariableValues.cs | 5 +- .../BaseIntegrationTest.cs | 4 +- .../UserManagementApiTests.cs | 4 +- .../FeatureFlagGivenTestContext.cs | 22 ++++++ .../Application/FeatureFlagTests.cs | 45 +++-------- .../Core/InternalTestSubject.cs | 7 +- .../InfrastructureDependencyInjectionTests.cs | 1 + .../DependencyInjection/TestAppBuilder.cs | 2 +- .../HomeInventory.Tests/Domain/EntityTests.cs | 58 +++++++------- .../Domain/EquatableComponentTests.cs | 28 +++---- .../Domain/ValueObjects/AmountTests.cs | 3 +- .../Domain/ValueObjects/AmountUnitTests.cs | 4 +- .../ValueObjects/MeasurementTypeTests.cs | 7 +- .../ServiceDescriptorExtensionsTests.cs | 2 + .../CorrelationIdMiddlewareTests.cs | 4 +- .../Presentation/Web/SectionPathTests.cs | 10 +-- .../BCryptPasswordHasherTests.cs | 14 ++-- .../Authentication/JwtTokenGeneratorTests.cs | 4 +- .../Handlers/RegisterCommandHandlerTests.cs | 4 +- .../Systems/Mapping/BaseMappingsTests.cs | 4 +- .../Systems/Mapping/UlidIdConverterTests.cs | 12 +-- .../Modules/AuthenticationModuleTests.cs | 10 +-- .../Modules/BaseApiModuleGivenTestContext.cs | 2 +- .../Systems/Modules/ErrorMappingTests.cs | 6 +- .../Modules/JsonOpenApiValueConverterTests.cs | 10 +-- .../Modules/UserManagementModuleTests.cs | 10 +-- .../AmountValueObjectConverterTests.cs | 8 +- .../Persistence/BaseDatabaseContextTest.cs | 2 +- .../Systems/Persistence/BaseRepositoryTest.cs | 4 +- .../ByIdFilterSpecificationTests.cs | 4 +- .../EventsPersistenceServiceTests.cs | 2 +- .../OutboxMessageConfigurationTests.cs | 2 +- .../Systems/Persistence/RepositoryTests.cs | 2 +- .../UserHasEmailSpecificationTests.cs | 4 +- .../UserModelConfigurationTests.cs | 2 +- .../Persistence/UserRepositoryTests.cs | 6 +- .../Validation/PasswordValidatorTests.cs | 5 +- .../HomeInventoryProblemDetailsFactory.cs | 2 +- .../ProblemDetailsExtensions.cs | 10 +-- .../ProblemDetailsFactoryExtensions.cs | 4 +- .../ValidationContextFactory.cs | 2 +- .../ValidationEndpointFilter.cs | 4 +- ...WebFrameworkServiceCollectionExtensions.cs | 6 +- .../UserManagementContractsMappings.cs | 4 +- ...uthorizationServiceCollectionExtensions.cs | 6 +- .../Validation/JwtOptionsValidator.cs | 10 +-- .../Modules/AuthenticationModule.cs | 2 +- .../Modules/PermissionModule.cs | 2 +- .../WebServiceCollectionExtensions.cs | 18 ++--- 104 files changed, 360 insertions(+), 300 deletions(-) create mode 100644 src/HomeInventory/HomeInventory.Tests/Application/FeatureFlagGivenTestContext.cs diff --git a/src/HomeInventory/.editorconfig b/src/HomeInventory/.editorconfig index 3dd0c3bb..a8aa075c 100644 --- a/src/HomeInventory/.editorconfig +++ b/src/HomeInventory/.editorconfig @@ -4,7 +4,7 @@ dotnet_diagnostic.CA2016.severity = warning # IDE0008: Use explicit type -csharp_style_var_elsewhere = true +csharp_style_var_elsewhere = true:suggestion [*.cs] #### Naming styles #### @@ -30,21 +30,30 @@ dotnet_naming_style.begin_with__.capitalization = camel_case csharp_indent_labels = one_less_than_current csharp_using_directive_placement = outside_namespace:silent csharp_prefer_simple_using_statement = true:suggestion -csharp_prefer_braces = true:silent +csharp_prefer_braces = true:suggestion csharp_style_namespace_declarations = file_scoped:suggestion csharp_style_prefer_method_group_conversion = true:silent csharp_style_prefer_top_level_statements = true:silent -csharp_style_expression_bodied_methods = false:silent -csharp_style_expression_bodied_constructors = false:silent -csharp_style_expression_bodied_operators = false:silent -csharp_style_expression_bodied_properties = true:silent -csharp_style_expression_bodied_indexers = true:silent -csharp_style_expression_bodied_accessors = true:silent -csharp_style_expression_bodied_lambdas = true:silent -csharp_style_expression_bodied_local_functions = false:silent +csharp_style_expression_bodied_methods = true:suggestion +csharp_style_expression_bodied_constructors = true:suggestion +csharp_style_expression_bodied_operators = true:suggestion +csharp_style_expression_bodied_properties = true:suggestion +csharp_style_expression_bodied_indexers = true:suggestion +csharp_style_expression_bodied_accessors = true:suggestion +csharp_style_expression_bodied_lambdas = true:suggestion +csharp_style_expression_bodied_local_functions = true:suggestion csharp_style_throw_expression = true:suggestion csharp_style_prefer_null_check_over_type_check = true:suggestion +# CS1591: Missing XML comment for publicly visible type or member +dotnet_diagnostic.CS1591.severity = none + +# IDE0058: Expression value is never used +dotnet_diagnostic.IDE0058.severity = suggestion + +# CA1515: Consider making public types internal +dotnet_diagnostic.CA1515.severity = suggestion + [*.{cs,vb}] #### Naming styles #### @@ -121,3 +130,50 @@ spelling_exclusion_path = .\exclusion.dic spelling_use_default_exclusion_dictionary = true csharp_style_prefer_primary_constructors = true:suggestion dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion +csharp_space_around_binary_operators = before_and_after +csharp_prefer_system_threading_lock = true:suggestion +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_unused_value_assignment_preference = unused_local_variable:silent +csharp_style_unused_value_expression_statement_preference = unused_local_variable:suggestion +dotnet_style_readonly_field = true:suggestion +dotnet_style_predefined_type_for_member_access = true:silent +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent +csharp_prefer_static_anonymous_function = true:suggestion +csharp_prefer_static_local_function = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion +csharp_style_prefer_readonly_struct = true:suggestion +dotnet_style_allow_multiple_blank_lines_experimental = false:suggestion +dotnet_style_allow_statement_immediately_after_block_experimental = false:suggestion +csharp_style_allow_embedded_statements_on_same_line_experimental = false:suggestion +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:suggestion +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:suggestion +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false:suggestion +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion +dotnet_code_quality_unused_parameters = non_public:suggestion +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion +dotnet_style_qualification_for_event = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_property = false:silent +dotnet_style_qualification_for_field = false:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent +csharp_style_prefer_extended_property_pattern = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_prefer_pattern_matching = true:suggestion +csharp_style_prefer_switch_expression = true:suggestion +dotnet_diagnostic.xUnit2001.severity = suggestion diff --git a/src/HomeInventory/Directory.Build.props b/src/HomeInventory/Directory.Build.props index 4af6b2dc..69918492 100644 --- a/src/HomeInventory/Directory.Build.props +++ b/src/HomeInventory/Directory.Build.props @@ -12,13 +12,15 @@ True 9999 false - CA1062;CA2007;CA1716;VISLIB0001 + $(NoWarn);CA1062;CA2007;CA1716 + True + diff --git a/src/HomeInventory/Directory.Packages.props b/src/HomeInventory/Directory.Packages.props index 3caea5f6..aadbfabd 100644 --- a/src/HomeInventory/Directory.Packages.props +++ b/src/HomeInventory/Directory.Packages.props @@ -49,6 +49,8 @@ + + diff --git a/src/HomeInventory/HomeInventory.Api/AppBuilder.cs b/src/HomeInventory/HomeInventory.Api/AppBuilder.cs index 0c5105f6..e0022575 100644 --- a/src/HomeInventory/HomeInventory.Api/AppBuilder.cs +++ b/src/HomeInventory/HomeInventory.Api/AppBuilder.cs @@ -20,7 +20,7 @@ public WebApplication Build() .AddSerilog(builder.Configuration); var app = builder.Build(); - app.UseSerilogRequestLogging(options => options.IncludeQueryInRequestPath = true); + app.UseSerilogRequestLogging(static options => options.IncludeQueryInRequestPath = true); return app.UseWeb(); } diff --git a/src/HomeInventory/HomeInventory.Api/AssemblyReference.cs b/src/HomeInventory/HomeInventory.Api/AssemblyReference.cs index 972a990f..fe1716e1 100644 --- a/src/HomeInventory/HomeInventory.Api/AssemblyReference.cs +++ b/src/HomeInventory/HomeInventory.Api/AssemblyReference.cs @@ -2,6 +2,7 @@ namespace HomeInventory.Api; +[System.Diagnostics.CodeAnalysis.SuppressMessage("Maintainability", "CA1515:Consider making public types internal", Justification = "By design")] public static class AssemblyReference { public static readonly Assembly Assembly = typeof(AssemblyReference).Assembly; diff --git a/src/HomeInventory/HomeInventory.Api/HomeInventory.Api.csproj b/src/HomeInventory/HomeInventory.Api/HomeInventory.Api.csproj index 5de39493..4f9b5018 100644 --- a/src/HomeInventory/HomeInventory.Api/HomeInventory.Api.csproj +++ b/src/HomeInventory/HomeInventory.Api/HomeInventory.Api.csproj @@ -24,6 +24,8 @@ + + diff --git a/src/HomeInventory/HomeInventory.Api/Program.cs b/src/HomeInventory/HomeInventory.Api/Program.cs index 6a40b5f1..128e7921 100644 --- a/src/HomeInventory/HomeInventory.Api/Program.cs +++ b/src/HomeInventory/HomeInventory.Api/Program.cs @@ -11,6 +11,7 @@ await Execute.AndCatchAsync( }, (Exception ex) => log.Fatal(ex, "An unhandled exception occurred during bootstrapping")); +[System.Diagnostics.CodeAnalysis.SuppressMessage("Maintainability", "CA1515:Consider making public types internal", Justification = "For testing")] public partial class Program { protected Program() diff --git a/src/HomeInventory/HomeInventory.Application.Framework/FeatureManagerExtensions.cs b/src/HomeInventory/HomeInventory.Application.Framework/FeatureManagerExtensions.cs index fc6784ee..3aa19ccc 100644 --- a/src/HomeInventory/HomeInventory.Application.Framework/FeatureManagerExtensions.cs +++ b/src/HomeInventory/HomeInventory.Application.Framework/FeatureManagerExtensions.cs @@ -4,5 +4,5 @@ namespace HomeInventory.Application.Framework; public static class FeatureManagerExtensions { - public static IAsyncEnumerable CreateFeaturesAsync(this IFeatureManager manager) => manager.GetFeatureNamesAsync().Select(name => FeatureFlag.Create(name)); + public static IAsyncEnumerable CreateFeaturesAsync(this IFeatureManager manager) => manager.GetFeatureNamesAsync().Select(static name => FeatureFlag.Create(name)); } diff --git a/src/HomeInventory/HomeInventory.Application.Framework/Messaging/CommandHandler.cs b/src/HomeInventory/HomeInventory.Application.Framework/Messaging/CommandHandler.cs index 5b6e4a36..03c7d765 100644 --- a/src/HomeInventory/HomeInventory.Application.Framework/Messaging/CommandHandler.cs +++ b/src/HomeInventory/HomeInventory.Application.Framework/Messaging/CommandHandler.cs @@ -1,6 +1,4 @@ -using Unit = LanguageExt.Unit; - -namespace HomeInventory.Application.Interfaces.Messaging; +namespace HomeInventory.Application.Interfaces.Messaging; public abstract class CommandHandler : ICommandHandler where TCommand : ICommand diff --git a/src/HomeInventory/HomeInventory.Application.Framework/Messaging/IQueryResult.cs b/src/HomeInventory/HomeInventory.Application.Framework/Messaging/IQueryResult.cs index de173772..42bfdce8 100644 --- a/src/HomeInventory/HomeInventory.Application.Framework/Messaging/IQueryResult.cs +++ b/src/HomeInventory/HomeInventory.Application.Framework/Messaging/IQueryResult.cs @@ -1,5 +1,4 @@ -using LanguageExt.Pretty; -using Unit = LanguageExt.Unit; +using Unit = LanguageExt.Unit; namespace HomeInventory.Application.Interfaces.Messaging; diff --git a/src/HomeInventory/HomeInventory.Application/Cqrs/Behaviors/LoggingBehavior.cs b/src/HomeInventory/HomeInventory.Application/Cqrs/Behaviors/LoggingBehavior.cs index 535cea52..ea0c99e5 100644 --- a/src/HomeInventory/HomeInventory.Application/Cqrs/Behaviors/LoggingBehavior.cs +++ b/src/HomeInventory/HomeInventory.Application/Cqrs/Behaviors/LoggingBehavior.cs @@ -1,5 +1,4 @@ using HomeInventory.Application.Interfaces.Messaging; -using LanguageExt; using Unit = LanguageExt.Unit; namespace HomeInventory.Application.Cqrs.Behaviors; diff --git a/src/HomeInventory/HomeInventory.Contracts.UserManagement.Validators/PasswordCharacterSets.cs b/src/HomeInventory/HomeInventory.Contracts.UserManagement.Validators/PasswordCharacterSets.cs index 333f9d15..1988b8d8 100644 --- a/src/HomeInventory/HomeInventory.Contracts.UserManagement.Validators/PasswordCharacterSets.cs +++ b/src/HomeInventory/HomeInventory.Contracts.UserManagement.Validators/PasswordCharacterSets.cs @@ -8,5 +8,5 @@ internal static class PasswordCharacterSets public static IPasswordCharacterSet Lowercase { get; } = new PasswordCharacterSet(char.IsLower, "lowercase"); - public static IPasswordCharacterSet NonAlphanumeric { get; } = new PasswordCharacterSet(c => !char.IsLetterOrDigit(c), "non-alphanumeric"); + public static IPasswordCharacterSet NonAlphanumeric { get; } = new PasswordCharacterSet(static c => !char.IsLetterOrDigit(c), "non-alphanumeric"); } diff --git a/src/HomeInventory/HomeInventory.Contracts.UserManagement.Validators/RegisterRequestValidator.cs b/src/HomeInventory/HomeInventory.Contracts.UserManagement.Validators/RegisterRequestValidator.cs index 54b7916f..c21fc4d1 100644 --- a/src/HomeInventory/HomeInventory.Contracts.UserManagement.Validators/RegisterRequestValidator.cs +++ b/src/HomeInventory/HomeInventory.Contracts.UserManagement.Validators/RegisterRequestValidator.cs @@ -6,11 +6,11 @@ public class RegisterRequestValidator : AbstractValidator { public RegisterRequestValidator() { - RuleFor(x => x.Email).NotEmpty(); - RuleFor(x => x.Email).EmailAddress(); + RuleFor(static x => x.Email).NotEmpty(); + RuleFor(static x => x.Email).EmailAddress(); - RuleFor(x => x.Password).NotEmpty(); - RuleFor(x => x.Password).MinimumLength(8); - RuleFor(x => x.Password).Password(); + RuleFor(static x => x.Password).NotEmpty(); + RuleFor(static x => x.Password).MinimumLength(8); + RuleFor(static x => x.Password).Password(); } } diff --git a/src/HomeInventory/HomeInventory.Contracts.Validations/LoginRequestValidator.cs b/src/HomeInventory/HomeInventory.Contracts.Validations/LoginRequestValidator.cs index 1c6f086d..e79c8499 100644 --- a/src/HomeInventory/HomeInventory.Contracts.Validations/LoginRequestValidator.cs +++ b/src/HomeInventory/HomeInventory.Contracts.Validations/LoginRequestValidator.cs @@ -6,9 +6,9 @@ internal sealed class LoginRequestValidator : AbstractValidator { public LoginRequestValidator() { - RuleFor(x => x.Email).NotEmpty(); - RuleFor(x => x.Email).EmailAddress(); + RuleFor(static x => x.Email).NotEmpty(); + RuleFor(static x => x.Email).EmailAddress(); - RuleFor(x => x.Password).NotEmpty(); + RuleFor(static x => x.Password).NotEmpty(); } } diff --git a/src/HomeInventory/HomeInventory.Core/IParseable.cs b/src/HomeInventory/HomeInventory.Core/IParseable.cs index a8e651f0..8a500665 100644 --- a/src/HomeInventory/HomeInventory.Core/IParseable.cs +++ b/src/HomeInventory/HomeInventory.Core/IParseable.cs @@ -4,8 +4,8 @@ public interface IParseable where TSelf : notnull, IParseable { [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "By design")] - abstract static TSelf Parse(string text); + static abstract TSelf Parse(string text); [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "By design")] - abstract static Option TryParse(string text); + static abstract Option TryParse(string text); } diff --git a/src/HomeInventory/HomeInventory.Core/ISpannableCollection.cs b/src/HomeInventory/HomeInventory.Core/ISpannableCollection.cs index b7742e84..7ec4713e 100644 --- a/src/HomeInventory/HomeInventory.Core/ISpannableCollection.cs +++ b/src/HomeInventory/HomeInventory.Core/ISpannableCollection.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace HomeInventory.Core; +namespace HomeInventory.Core; public interface ISpannableCollection : IReadOnlyCollection { diff --git a/src/HomeInventory/HomeInventory.Core/ScopeAccessorExtensions.cs b/src/HomeInventory/HomeInventory.Core/ScopeAccessorExtensions.cs index 7f84280f..8133b438 100644 --- a/src/HomeInventory/HomeInventory.Core/ScopeAccessorExtensions.cs +++ b/src/HomeInventory/HomeInventory.Core/ScopeAccessorExtensions.cs @@ -7,5 +7,5 @@ public static TContext GetRequiredContext(this IScopeAccessor scopeAcc scopeAccessor .GetScope() .Get() - .ThrowIfNone(() => new InvalidOperationException($"Required context of type {typeof(TContext).FullName} not found")); + .ThrowIfNone(static () => new InvalidOperationException($"Required context of type {typeof(TContext).FullName} not found")); } diff --git a/src/HomeInventory/HomeInventory.Core/TypeExtensions.cs b/src/HomeInventory/HomeInventory.Core/TypeExtensions.cs index af077e7f..ce0541bb 100644 --- a/src/HomeInventory/HomeInventory.Core/TypeExtensions.cs +++ b/src/HomeInventory/HomeInventory.Core/TypeExtensions.cs @@ -30,7 +30,6 @@ public static string GetFormattedName(this Type type) => _ => type.Name, }; - private static string FormatGenericType(Type type) { var args = type.GenericTypeArguments; diff --git a/src/HomeInventory/HomeInventory.Core/ValidationExtensions.cs b/src/HomeInventory/HomeInventory.Core/ValidationExtensions.cs index 567e4af1..3c36231c 100644 --- a/src/HomeInventory/HomeInventory.Core/ValidationExtensions.cs +++ b/src/HomeInventory/HomeInventory.Core/ValidationExtensions.cs @@ -1,6 +1,4 @@ -using LanguageExt.Pretty; - -namespace HomeInventory.Core; +namespace HomeInventory.Core; public static class ValidationExtensions { diff --git a/src/HomeInventory/HomeInventory.Domain.Primitives/EnumerationItemsCollection.cs b/src/HomeInventory/HomeInventory.Domain.Primitives/EnumerationItemsCollection.cs index 0b0636d4..8bc1f243 100644 --- a/src/HomeInventory/HomeInventory.Domain.Primitives/EnumerationItemsCollection.cs +++ b/src/HomeInventory/HomeInventory.Domain.Primitives/EnumerationItemsCollection.cs @@ -1,5 +1,4 @@ -using HomeInventory.Core; -using System.Collections; +using System.Collections; namespace HomeInventory.Domain.Primitives; diff --git a/src/HomeInventory/HomeInventory.Domain.Primitives/IBuildableObject.cs b/src/HomeInventory/HomeInventory.Domain.Primitives/IBuildableObject.cs index b44d013f..56ac2dcd 100644 --- a/src/HomeInventory/HomeInventory.Domain.Primitives/IBuildableObject.cs +++ b/src/HomeInventory/HomeInventory.Domain.Primitives/IBuildableObject.cs @@ -5,5 +5,5 @@ public interface IBuildableObject where TBuilder : notnull, IObjectBuilder { [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "As designed")] - abstract static TBuilder CreateBuilder(); + static abstract TBuilder CreateBuilder(); } diff --git a/src/HomeInventory/HomeInventory.Domain.Primitives/IRepository.cs b/src/HomeInventory/HomeInventory.Domain.Primitives/IRepository.cs index 7dfc4db0..98f7ba32 100644 --- a/src/HomeInventory/HomeInventory.Domain.Primitives/IRepository.cs +++ b/src/HomeInventory/HomeInventory.Domain.Primitives/IRepository.cs @@ -7,6 +7,7 @@ public interface IRepository : IReadOnlyRepository /// The entity to add. + /// /// /// A task that represents the asynchronous operation. /// The task result contains the . @@ -20,7 +21,6 @@ public interface IRepository : IReadOnlyRepository /// /// A task that represents the asynchronous operation. - /// The task result contains the . /// Task AddRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default); @@ -28,6 +28,7 @@ public interface IRepository : IReadOnlyRepository /// The entity to update. + /// /// A task that represents the asynchronous operation. Task UpdateAsync(TAggregateRoot entity, CancellationToken cancellationToken = default); @@ -43,6 +44,7 @@ public interface IRepository : IReadOnlyRepository /// The entity to delete. + /// /// A task that represents the asynchronous operation. Task DeleteAsync(TAggregateRoot entity, CancellationToken cancellationToken = default); @@ -50,6 +52,7 @@ public interface IRepository : IReadOnlyRepository /// The entities to remove. + /// /// A task that represents the asynchronous operation. Task DeleteRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default); } diff --git a/src/HomeInventory/HomeInventory.Domain.Primitives/Ids/IIdBuildable.cs b/src/HomeInventory/HomeInventory.Domain.Primitives/Ids/IIdBuildable.cs index 159aaab1..050b5ab9 100644 --- a/src/HomeInventory/HomeInventory.Domain.Primitives/Ids/IIdBuildable.cs +++ b/src/HomeInventory/HomeInventory.Domain.Primitives/Ids/IIdBuildable.cs @@ -6,5 +6,5 @@ public interface IIdBuildable where TId : notnull { [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "As designed")] - abstract static TSelf CreateFrom(TId value); + static abstract TSelf CreateFrom(TId value); } diff --git a/src/HomeInventory/HomeInventory.Domain/DomainServiceCollectionExtensions.cs b/src/HomeInventory/HomeInventory.Domain/DomainServiceCollectionExtensions.cs index 1f0294a4..1266ca6f 100644 --- a/src/HomeInventory/HomeInventory.Domain/DomainServiceCollectionExtensions.cs +++ b/src/HomeInventory/HomeInventory.Domain/DomainServiceCollectionExtensions.cs @@ -13,7 +13,7 @@ public static IServiceCollection AddDomain(this IServiceCollection services) services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); - services.AddTransient(_ => new FixedTimeProvider(TimeProvider.System)); + services.AddTransient(static _ => new FixedTimeProvider(TimeProvider.System)); return services; } } diff --git a/src/HomeInventory/HomeInventory.Domain/ValueObjects/AmountFactory.cs b/src/HomeInventory/HomeInventory.Domain/ValueObjects/AmountFactory.cs index 784ba357..57ed7fb1 100644 --- a/src/HomeInventory/HomeInventory.Domain/ValueObjects/AmountFactory.cs +++ b/src/HomeInventory/HomeInventory.Domain/ValueObjects/AmountFactory.cs @@ -7,7 +7,7 @@ internal sealed class AmountFactory : IAmountFactory public Validation Create(decimal value, AmountUnit unit) => new UnitValidator(unit) .Validate(value) - .Bind(t => new Amount(t.Value, t.Unit)); + .Bind(static t => new Amount(t.Value, t.Unit)); private readonly ref struct UnitValidator(AmountUnit unit) { diff --git a/src/HomeInventory/HomeInventory.Infrastructure.Framework/IDatabaseContext.cs b/src/HomeInventory/HomeInventory.Infrastructure.Framework/IDatabaseContext.cs index 5f9a46bc..6de01f1d 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure.Framework/IDatabaseContext.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure.Framework/IDatabaseContext.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore; -namespace HomeInventory.Infrastructure.Persistence; +namespace HomeInventory.Infrastructure.Framework; public interface IDatabaseContext { diff --git a/src/HomeInventory/HomeInventory.Infrastructure.Framework/IEventsPersistenceService.cs b/src/HomeInventory/HomeInventory.Infrastructure.Framework/IEventsPersistenceService.cs index 0acf61a8..f19006dc 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure.Framework/IEventsPersistenceService.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure.Framework/IEventsPersistenceService.cs @@ -1,6 +1,6 @@ using HomeInventory.Domain.Primitives; -namespace HomeInventory.Infrastructure.Persistence; +namespace HomeInventory.Infrastructure.Framework; public interface IEventsPersistenceService { diff --git a/src/HomeInventory/HomeInventory.Infrastructure.Framework/InfrastructureFrameworkServiceCollectionExtensions.cs b/src/HomeInventory/HomeInventory.Infrastructure.Framework/InfrastructureFrameworkServiceCollectionExtensions.cs index 1fac1357..50e39efe 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure.Framework/InfrastructureFrameworkServiceCollectionExtensions.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure.Framework/InfrastructureFrameworkServiceCollectionExtensions.cs @@ -10,6 +10,6 @@ public static IServiceCollection AddRepository services .AddScoped() - .AddScoped>(sp => sp.GetRequiredService()) - .AddScoped>(sp => sp.GetRequiredService>()); + .AddScoped>(static sp => sp.GetRequiredService()) + .AddScoped>(static sp => sp.GetRequiredService>()); } diff --git a/src/HomeInventory/HomeInventory.Infrastructure.Framework/Models/IPersistentModel.cs b/src/HomeInventory/HomeInventory.Infrastructure.Framework/Models/IPersistentModel.cs index 3de803a7..235eef86 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure.Framework/Models/IPersistentModel.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure.Framework/Models/IPersistentModel.cs @@ -1,4 +1,4 @@ -namespace HomeInventory.Infrastructure.Persistence.Models; +namespace HomeInventory.Infrastructure.Framework.Models; public interface IPersistentModel : IPersistentModel { diff --git a/src/HomeInventory/HomeInventory.Infrastructure.Framework/Repository.cs b/src/HomeInventory/HomeInventory.Infrastructure.Framework/Repository.cs index 5f87d5c2..7bc69386 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure.Framework/Repository.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure.Framework/Repository.cs @@ -3,11 +3,11 @@ using HomeInventory.Domain.Primitives; using HomeInventory.Domain.Primitives.Ids; using HomeInventory.Infrastructure.Framework.Mapping; -using HomeInventory.Infrastructure.Persistence.Models; +using HomeInventory.Infrastructure.Framework.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; -namespace HomeInventory.Infrastructure.Persistence; +namespace HomeInventory.Infrastructure.Framework; public abstract class Repository(IDatabaseContext context, IMapper mapper, ISpecificationEvaluator evaluator, IEventsPersistenceService eventsPersistenceService) : IRepository where TModel : class, IPersistentModel @@ -77,18 +77,16 @@ public async Task AnyAsync(CancellationToken cancellationToken = default) await Set().AnyAsync(cancellationToken); public IAsyncEnumerable GetAllAsync(CancellationToken cancellationToken = default) => - AsyncEnumerable.ToAsyncEnumerable(ToEntity(Set(), cancellationToken)); + ToEntity(Set(), cancellationToken).ToAsyncEnumerable(); public async Task> FindFirstOptionAsync(ISpecification specification, CancellationToken cancellationToken = default) { var query = ApplySpecification(Set(), specification); var projected = ToEntity(query, cancellationToken); - if (await projected.FirstOrDefaultAsync(cancellationToken) is TAggregateRoot entity) - { - return entity; - } - - return OptionNone.Default; + var entity = await projected.FirstOrDefaultAsync(cancellationToken); + return entity is null + ? OptionNone.Default + : entity; } public async Task HasAsync(ISpecification specification, CancellationToken cancellationToken = default) @@ -98,32 +96,35 @@ public async Task HasAsync(ISpecification specification, Cancellat } /// - /// Filters the entities of , to those that match the encapsulated query logic of the + /// Filters the entities of , to those that match the encapsulated query logic of the /// . /// + /// /// The encapsulated query logic. + /// /// The filtered entities as an . protected virtual IQueryable ApplySpecification(IQueryable inputQuery, ISpecification specification, bool evaluateCriteriaOnly = false) => _evaluator.GetQuery(inputQuery, specification, evaluateCriteriaOnly); /// - /// Filters all entities of , that matches the encapsulated query logic of the + /// Filters all entities of , that matches the encapsulated query logic of the /// , from the database. /// /// Projects each entity into a new form, being . /// /// /// The type of the value returned by the projection. + /// /// The encapsulated query logic. /// The filtered projected entities as an . protected virtual IQueryable ApplySpecification(IQueryable inputQuery, ISpecification specification) => _evaluator.GetQuery(inputQuery, specification); - private async Task> InternalAddAsync(DbSet set, TAggregateRoot entity, CancellationToken cancellationToken) => await InternalModifyAsync(set, entity, (s, m) => s.Add(m), cancellationToken); + private async Task> InternalAddAsync(DbSet set, TAggregateRoot entity, CancellationToken cancellationToken) => await InternalModifyAsync(set, entity, static (s, m) => s.Add(m), cancellationToken); - private async Task> InternalUpdateAsync(DbSet set, TAggregateRoot entity, CancellationToken cancellationToken) => await InternalModifyAsync(set, entity, (s, m) => s.Update(m), cancellationToken); + private async Task> InternalUpdateAsync(DbSet set, TAggregateRoot entity, CancellationToken cancellationToken) => await InternalModifyAsync(set, entity, static (s, m) => s.Update(m), cancellationToken); - private async Task> InternalDeleteAsync(DbSet set, TAggregateRoot entity, CancellationToken cancellationToken) => await InternalModifyAsync(set, entity, (s, m) => s.Remove(m), cancellationToken); + private async Task> InternalDeleteAsync(DbSet set, TAggregateRoot entity, CancellationToken cancellationToken) => await InternalModifyAsync(set, entity, static (s, m) => s.Remove(m), cancellationToken); private async Task> InternalModifyAsync(DbSet set, TAggregateRoot entity, Func, TModel, EntityEntry> modifyAction, CancellationToken cancellationToken) { diff --git a/src/HomeInventory/HomeInventory.Infrastructure.Framework/Specifications/ByIdFilterSpecification.cs b/src/HomeInventory/HomeInventory.Infrastructure.Framework/Specifications/ByIdFilterSpecification.cs index c407c43d..4ca59ac1 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure.Framework/Specifications/ByIdFilterSpecification.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure.Framework/Specifications/ByIdFilterSpecification.cs @@ -1,6 +1,6 @@ using Ardalis.Specification; using HomeInventory.Domain.Primitives.Ids; -using HomeInventory.Infrastructure.Persistence.Models; +using HomeInventory.Infrastructure.Framework.Models; using Microsoft.EntityFrameworkCore; namespace HomeInventory.Infrastructure.Specifications; diff --git a/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/InfrastructureUserManagementServiceCollectionExtensions.cs b/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/InfrastructureUserManagementServiceCollectionExtensions.cs index ece0e0cc..1071858c 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/InfrastructureUserManagementServiceCollectionExtensions.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/InfrastructureUserManagementServiceCollectionExtensions.cs @@ -18,7 +18,7 @@ public static IServiceCollection AddUserManagementInfrastructure(this IServiceCo services.AddMappingAssemblySource(HomeInventory.Infrastructure.UserManagement.AssemblyReference.Assembly); services.AddSingleton(); - services.AddSingleton(_ => new DomainEventJsonTypeInfo(typeof(UserCreatedDomainEvent))); + services.AddSingleton(static _ => new DomainEventJsonTypeInfo(typeof(UserCreatedDomainEvent))); services.AddScoped(); diff --git a/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/Configurations/DomainEventJsonTypeInfo.cs b/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/Configurations/DomainEventJsonTypeInfo.cs index 257f3299..88627a9f 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/Configurations/DomainEventJsonTypeInfo.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/Configurations/DomainEventJsonTypeInfo.cs @@ -7,5 +7,5 @@ internal sealed class DomainEventJsonTypeInfo(params Type[] types) : IJsonDerive { private readonly Type[] _types = types; - public IEnumerable DerivedTypes => _types.Select(t => new JsonDerivedType(t, t.FullName ?? t.Name)); + public IEnumerable DerivedTypes => _types.Select(static t => new JsonDerivedType(t, t.FullName ?? t.Name)); } diff --git a/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/Configurations/UserModelConfiguration.cs b/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/Configurations/UserModelConfiguration.cs index 0bfd379b..56e66bfb 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/Configurations/UserModelConfiguration.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/Configurations/UserModelConfiguration.cs @@ -7,14 +7,14 @@ internal sealed class UserModelConfiguration : IEntityTypeConfiguration builder) { - builder.HasKey(x => x.Id); - builder.Property(x => x.Id) + builder.HasKey(static x => x.Id); + builder.Property(static x => x.Id) .HasIdConversion(); - builder.Property(x => x.Email) + builder.Property(static x => x.Email) .IsRequired(); - builder.Property(x => x.Password) + builder.Property(static x => x.Password) .IsRequired(); } } diff --git a/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/UserModel.cs b/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/UserModel.cs index a5ea1ddb..b0c38c0e 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/UserModel.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/Models/UserModel.cs @@ -1,5 +1,6 @@ using HomeInventory.Domain.Primitives; using HomeInventory.Domain.ValueObjects; +using HomeInventory.Infrastructure.Framework.Models; namespace HomeInventory.Infrastructure.Persistence.Models; diff --git a/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/UserRepository.cs b/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/UserRepository.cs index 07e8a483..c72af9e3 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/UserRepository.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure.UserManagement/UserRepository.cs @@ -3,6 +3,7 @@ using HomeInventory.Domain.Aggregates; using HomeInventory.Domain.Persistence; using HomeInventory.Domain.ValueObjects; +using HomeInventory.Infrastructure.Framework; using HomeInventory.Infrastructure.Persistence.Models; using HomeInventory.Infrastructure.Specifications; @@ -20,7 +21,7 @@ public async Task> FindFirstByEmailUserOptionalAsync(Email email, C public async Task HasPermissionAsync(UserId userId, string permission, CancellationToken cancellationToken = default) { var userResult = await FindFirstOptionAsync(new ByIdFilterSpecification(userId), cancellationToken) - .Convert(x => true); + .Convert(static x => true); #pragma warning disable CA1849 // Call async methods when in an async method return userResult.IfNone(false); #pragma warning restore CA1849 // Call async methods when in an async method diff --git a/src/HomeInventory/HomeInventory.Infrastructure/HomeInventory.Infrastructure.csproj b/src/HomeInventory/HomeInventory.Infrastructure/HomeInventory.Infrastructure.csproj index 57838c8a..44cbad3e 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure/HomeInventory.Infrastructure.csproj +++ b/src/HomeInventory/HomeInventory.Infrastructure/HomeInventory.Infrastructure.csproj @@ -13,6 +13,7 @@ + diff --git a/src/HomeInventory/HomeInventory.Infrastructure/InfrastructureServiceCollectionExtensions.cs b/src/HomeInventory/HomeInventory.Infrastructure/InfrastructureServiceCollectionExtensions.cs index 02d38347..112ce7c4 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure/InfrastructureServiceCollectionExtensions.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure/InfrastructureServiceCollectionExtensions.cs @@ -2,6 +2,7 @@ using Ardalis.Specification.EntityFrameworkCore; using HomeInventory.Application; using HomeInventory.Domain.Primitives; +using HomeInventory.Infrastructure.Framework; using HomeInventory.Infrastructure.Persistence; using HomeInventory.Infrastructure.Persistence.Mapping; using HomeInventory.Infrastructure.Persistence.Models.Configurations; @@ -35,13 +36,13 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi private static IServiceCollection AddDatabase(this IServiceCollection services) => services .AddScoped() - .AddDbContext((sp, builder) => + .AddDbContext(static (sp, builder) => { var env = sp.GetRequiredService(); builder.UseInMemoryDatabase("HomeInventory"); builder.EnableDetailedErrors(!env.IsProduction()); builder.EnableSensitiveDataLogging(!env.IsProduction()); }) - .AddScoped(sp => sp.GetRequiredService()) - .AddScoped(sp => sp.GetRequiredService()); + .AddScoped(static sp => sp.GetRequiredService()) + .AddScoped(static sp => sp.GetRequiredService()); } diff --git a/src/HomeInventory/HomeInventory.Infrastructure/Persistence/DatabaseContext.cs b/src/HomeInventory/HomeInventory.Infrastructure/Persistence/DatabaseContext.cs index 3b0278cb..863b8321 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure/Persistence/DatabaseContext.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure/Persistence/DatabaseContext.cs @@ -1,5 +1,6 @@ using System.Linq.Expressions; using HomeInventory.Domain.Primitives; +using HomeInventory.Infrastructure.Framework; using HomeInventory.Infrastructure.Persistence.Models.Interceptors; using Microsoft.EntityFrameworkCore; @@ -22,7 +23,7 @@ public Option FindTracked(Func condition) where TEntity : class => ChangeTracker .Entries() - .Select(e => e.Entity) + .Select(static e => e.Entity) .Where(condition) .HeadOrNone(); @@ -47,8 +48,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) private void UpdateAuditableEntities(DateTimeOffset now) { - UpdateTimeAuditEntities(now, EntityState.Added, x => x.CreatedOn); - UpdateTimeAuditEntities(now, EntityState.Modified, x => x.ModifiedOn); + UpdateTimeAuditEntities(now, EntityState.Added, static x => x.CreatedOn); + UpdateTimeAuditEntities(now, EntityState.Modified, static x => x.ModifiedOn); } private void UpdateTimeAuditEntities(DateTimeOffset now, EntityState state, Expression> propertyExpression) diff --git a/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Mapping/ModelMappings.cs b/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Mapping/ModelMappings.cs index 58656a68..7de8dd30 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Mapping/ModelMappings.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Mapping/ModelMappings.cs @@ -8,7 +8,7 @@ internal sealed class ModelMappings : BaseMappingsProfile { public ModelMappings() { - CreateMap().Using(x => x.Value, ProductId.Converter); - CreateMap().Using(obj => new() { Value = obj.Value, UnitName = obj.Unit.Name }); + CreateMap().Using(static x => x.Value, ProductId.Converter); + CreateMap().Using(static obj => new() { Value = obj.Value, UnitName = obj.Unit.Name }); } } diff --git a/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/Configurations/PolymorphicDomainEventTypeResolver.cs b/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/Configurations/PolymorphicDomainEventTypeResolver.cs index 374a1b73..c70359d1 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/Configurations/PolymorphicDomainEventTypeResolver.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/Configurations/PolymorphicDomainEventTypeResolver.cs @@ -8,7 +8,7 @@ namespace HomeInventory.Infrastructure.Persistence.Models.Configurations; internal sealed class PolymorphicDomainEventTypeResolver(IEnumerable eventTypeInfoProviders) : DefaultJsonTypeInfoResolver { - private readonly IReadOnlyCollection _derivedTypes = eventTypeInfoProviders.SelectMany(p => p.DerivedTypes).ToArray(); + private readonly IReadOnlyCollection _derivedTypes = eventTypeInfoProviders.SelectMany(static p => p.DerivedTypes).ToArray(); public override JsonTypeInfo GetTypeInfo(Type type, JsonSerializerOptions options) { diff --git a/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/Interceptors/PublishDomainEventsInterceptor.cs b/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/Interceptors/PublishDomainEventsInterceptor.cs index 1d0d84d2..745335ef 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/Interceptors/PublishDomainEventsInterceptor.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/Interceptors/PublishDomainEventsInterceptor.cs @@ -23,7 +23,7 @@ private async ValueTask PublishEventsAsync(DbContext context, CancellationToken { var domainEvents = context.ChangeTracker .Entries() - .Select(e => e.Entity.Content); + .Select(static e => e.Entity.Content); foreach (var domainEvent in domainEvents) { diff --git a/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/OutboxMessage.cs b/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/OutboxMessage.cs index f48997e4..8f3c571b 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/OutboxMessage.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure/Persistence/Models/OutboxMessage.cs @@ -1,4 +1,5 @@ using HomeInventory.Domain.Primitives; +using HomeInventory.Infrastructure.Framework.Models; namespace HomeInventory.Infrastructure.Persistence.Models; diff --git a/src/HomeInventory/HomeInventory.Infrastructure/Services/EventsPersistenceService.cs b/src/HomeInventory/HomeInventory.Infrastructure/Services/EventsPersistenceService.cs index 4e14f1b1..8024870c 100644 --- a/src/HomeInventory/HomeInventory.Infrastructure/Services/EventsPersistenceService.cs +++ b/src/HomeInventory/HomeInventory.Infrastructure/Services/EventsPersistenceService.cs @@ -1,5 +1,5 @@ using HomeInventory.Domain.Primitives; -using HomeInventory.Infrastructure.Persistence; +using HomeInventory.Infrastructure.Framework; using HomeInventory.Infrastructure.Persistence.Models; namespace HomeInventory.Infrastructure.Services; diff --git a/src/HomeInventory/HomeInventory.Tests.Acceptance/Drivers/HomeInventoryAPIDriver.cs b/src/HomeInventory/HomeInventory.Tests.Acceptance/Drivers/HomeInventoryAPIDriver.cs index 5152d119..ae9c402b 100644 --- a/src/HomeInventory/HomeInventory.Tests.Acceptance/Drivers/HomeInventoryAPIDriver.cs +++ b/src/HomeInventory/HomeInventory.Tests.Acceptance/Drivers/HomeInventoryAPIDriver.cs @@ -6,7 +6,7 @@ namespace HomeInventory.Tests.Acceptance.Drivers; -internal sealed class HomeInventoryApiDriver : WebApplicationFactory, IHomeInventoryApiDriver +internal sealed class HomeInventoryApiDriver : WebApplicationFactory, IHomeInventoryApiDriver { private readonly ITestingConfiguration _configuration; private readonly Lazy _lazyUserManagement; diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/AssertionExtensions.cs b/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/AssertionExtensions.cs index bcade450..92702ede 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/AssertionExtensions.cs +++ b/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/AssertionExtensions.cs @@ -1,5 +1,4 @@ -using System.Collections; -using System.Text.Json; +using System.Text.Json; using FluentAssertions.LanguageExt; using HomeInventory.Application.Interfaces.Messaging; using Microsoft.AspNetCore.Http; diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/ObjectExtensions.cs b/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/ObjectExtensions.cs index d8c822c5..5955f028 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/ObjectExtensions.cs +++ b/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/ObjectExtensions.cs @@ -8,7 +8,7 @@ internal static class ObjectExtensions { if (typeof(T) == typeof(object)) { - return (actual, expected) => + return static (actual, expected) => { if (actual is null && expected is null) { diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/UlidAssertions.cs b/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/UlidAssertions.cs index 5d9e19ea..924c6935 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/UlidAssertions.cs +++ b/src/HomeInventory/HomeInventory.Tests.Framework/Assertions/UlidAssertions.cs @@ -1,5 +1,4 @@ -using FluentAssertions.Execution; -using Execute = FluentAssertions.Execution.Execute; +using Execute = FluentAssertions.Execution.Execute; namespace HomeInventory.Tests.Framework.Assertions; diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/Attributes/ArchitectureTestAttribute.cs b/src/HomeInventory/HomeInventory.Tests.Framework/Attributes/ArchitectureTestAttribute.cs index b2f56355..926aea95 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/Attributes/ArchitectureTestAttribute.cs +++ b/src/HomeInventory/HomeInventory.Tests.Framework/Attributes/ArchitectureTestAttribute.cs @@ -7,7 +7,7 @@ public sealed class ArchitectureTestAttribute : CategoryTraitAttribute { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public ArchitectureTestAttribute() : base("Architecture") diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/BaseTest.cs b/src/HomeInventory/HomeInventory.Tests.Framework/BaseTest.cs index 0c94883d..eeb0e98a 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/BaseTest.cs +++ b/src/HomeInventory/HomeInventory.Tests.Framework/BaseTest.cs @@ -8,9 +8,9 @@ namespace HomeInventory.Tests.Framework; public abstract class BaseTest : IAsyncLifetime { private readonly List _asyncDisposables = []; - private readonly Lazy _lazyCancellation = new(() => new CancellationImplementation()); - private readonly Lazy _lazyFixture = new(() => new Fixture()); - private readonly Lazy _lazyDateTime = new(() => new FixedTimeProvider(TimeProvider.System)); + private readonly Lazy _lazyCancellation = new(static () => new CancellationImplementation()); + private readonly Lazy _lazyFixture = new(static () => new Fixture()); + private readonly Lazy _lazyDateTime = new(static () => new FixedTimeProvider(TimeProvider.System)); protected BaseTest() { diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/Customizations/ApiBehaviorOptionsCustomization.cs b/src/HomeInventory/HomeInventory.Tests.Framework/Customizations/ApiBehaviorOptionsCustomization.cs index 0b5e5560..1280bddb 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/Customizations/ApiBehaviorOptionsCustomization.cs +++ b/src/HomeInventory/HomeInventory.Tests.Framework/Customizations/ApiBehaviorOptionsCustomization.cs @@ -6,7 +6,7 @@ internal class ApiBehaviorOptionsCustomization : ICustomization { public void Customize(IFixture fixture) { - fixture.Customize(c => c - .Without(x => x.InvalidModelStateResponseFactory)); + fixture.Customize(static c => c + .Without(static x => x.InvalidModelStateResponseFactory)); } } diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/Customizations/FixtureExtensions.cs b/src/HomeInventory/HomeInventory.Tests.Framework/Customizations/FixtureExtensions.cs index 96d720e3..4eab60e9 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/Customizations/FixtureExtensions.cs +++ b/src/HomeInventory/HomeInventory.Tests.Framework/Customizations/FixtureExtensions.cs @@ -9,12 +9,12 @@ public static IFixture CustomizeId(this IFixture fixture) where TId : class, IUlidBuildable, IUlidIdentifierObject, IValuableIdentifierObject => fixture .CustomizeUlid() - .CustomizeFromFactory>(s => (TId)TId.CreateBuilder().WithValue(s.Supply()).Build()); + .CustomizeFromFactory>(static s => (TId)TId.CreateBuilder().WithValue(s.Supply()).Build()); public static IFixture CustomizeEmail(this IFixture fixture) => fixture .CustomizeUlid() - .CustomizeFromFactory>(s => new Email(s.Supply().ToString() + "@email.com")); + .CustomizeFromFactory>(static s => new Email(s.Supply().ToString() + "@email.com")); public static IFixture CustomizeFromFactory(this IFixture fixture, Func createFunc) { diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/GivenContext.cs b/src/HomeInventory/HomeInventory.Tests.Framework/GivenContext.cs index 36300abe..46f43c87 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/GivenContext.cs +++ b/src/HomeInventory/HomeInventory.Tests.Framework/GivenContext.cs @@ -37,7 +37,7 @@ public TContext New(out IVariable variable, Func> createMan } public TContext EmptyHashCode(out IVariable emptyHash) => - New(out emptyHash, () => new HashCode()); + New(out emptyHash, static () => new HashCode()); public TContext SubstituteFor(out IVariable variable, IVariable arg1, IVariable arg2, Action setup, [CallerArgumentExpression(nameof(variable))] string? name = null) where T : class diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj b/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj index 07f0ec9c..80a9fbdd 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj +++ b/src/HomeInventory/HomeInventory.Tests.Framework/HomeInventory.Tests.Framework.csproj @@ -13,7 +13,9 @@ + + diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/RandomExtensions.cs b/src/HomeInventory/HomeInventory.Tests.Framework/RandomExtensions.cs index 446df34a..5ff0aefc 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/RandomExtensions.cs +++ b/src/HomeInventory/HomeInventory.Tests.Framework/RandomExtensions.cs @@ -1,5 +1,4 @@ -using HomeInventory.Domain.Primitives; -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace HomeInventory.Tests.Framework; diff --git a/src/HomeInventory/HomeInventory.Tests.Framework/VariableValues.cs b/src/HomeInventory/HomeInventory.Tests.Framework/VariableValues.cs index d6326f61..71928d2b 100644 --- a/src/HomeInventory/HomeInventory.Tests.Framework/VariableValues.cs +++ b/src/HomeInventory/HomeInventory.Tests.Framework/VariableValues.cs @@ -26,7 +26,7 @@ public Option> TryGetOrAdd(int index, Func createValueFunc) ? OptionNone.Default : GetOrAdd(index, createValueFunc); - public IEnumerable GetAll() => _values.Select(x => x.Value); + public IEnumerable GetAll() => _values.Select(static x => x.Value); private PropertyValue GetOrAdd(int index, Func createValueFunc) => index == _values.Count @@ -51,8 +51,11 @@ public async ValueTask DisposeAsync() case IDisposable disposable: disposable.Dispose(); break; + default: + break; } } + _values.Clear(); } } diff --git a/src/HomeInventory/HomeInventory.Tests.Integration/BaseIntegrationTest.cs b/src/HomeInventory/HomeInventory.Tests.Integration/BaseIntegrationTest.cs index eb0715b2..fc74b4a8 100644 --- a/src/HomeInventory/HomeInventory.Tests.Integration/BaseIntegrationTest.cs +++ b/src/HomeInventory/HomeInventory.Tests.Integration/BaseIntegrationTest.cs @@ -10,7 +10,7 @@ namespace HomeInventory.Tests.Integration; [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1001:Types that own disposable fields should be disposable", Justification = "See InitializeDisposables")] public abstract class BaseIntegrationTest : BaseTest { - private readonly WebApplicationFactory _appFactory = new(); + private readonly WebApplicationFactory _appFactory = new(); private readonly HttpClient _client; private readonly ITestOutputHelper _testOutputHelper; @@ -27,7 +27,7 @@ protected IEnumerable GetEndpoints() => _appFactory .Services .GetServices() - .SelectMany(s => s.Endpoints) + .SelectMany(static s => s.Endpoints) .OfType(); protected async Task PostAsync(string route, JsonContent content) diff --git a/src/HomeInventory/HomeInventory.Tests.Integration/UserManagementApiTests.cs b/src/HomeInventory/HomeInventory.Tests.Integration/UserManagementApiTests.cs index b56527fe..f03b2830 100644 --- a/src/HomeInventory/HomeInventory.Tests.Integration/UserManagementApiTests.cs +++ b/src/HomeInventory/HomeInventory.Tests.Integration/UserManagementApiTests.cs @@ -33,7 +33,7 @@ public void VerifyEndpoints() using var scope = new AssertionScope(); endpoints.Should().ContainEndpoint(_registerRoute, HttpMethods.Post) - .Which.Metadata.Should().ContainSingle(x => x is AllowAnonymousAttribute); + .Which.Metadata.Should().ContainSingle(static x => x is AllowAnonymousAttribute); } [Fact] @@ -74,7 +74,7 @@ public async Task RegisterSameTwice_ReturnsFailure() #pragma warning disable CA1308 // Normalize strings to uppercase body.Extensions.Should().ContainKey("errors") .WhoseValue.Should().BeJsonElement() - .Which.Should().BeArray(e => e.Should().HaveProperty(nameof(DuplicateEmailError.Message).ToLowerInvariant()) + .Which.Should().BeArray(static e => e.Should().HaveProperty(nameof(DuplicateEmailError.Message).ToLowerInvariant()) .Which.Should().HaveValue(DuplicateEmailError.DefaultMessage)); #pragma warning restore CA1308 // Normalize strings to uppercase } diff --git a/src/HomeInventory/HomeInventory.Tests/Application/FeatureFlagGivenTestContext.cs b/src/HomeInventory/HomeInventory.Tests/Application/FeatureFlagGivenTestContext.cs new file mode 100644 index 00000000..322d0e86 --- /dev/null +++ b/src/HomeInventory/HomeInventory.Tests/Application/FeatureFlagGivenTestContext.cs @@ -0,0 +1,22 @@ +using HomeInventory.Application.Framework; + +namespace HomeInventory.Tests.Application; + +public sealed class FeatureFlagGivenTestContext(BaseTest test) : GivenContext(test) +{ + private static readonly Variable _sut = new(nameof(_sut)); + private static readonly Variable> _sutContext = new(nameof(_sutContext)); + + internal FeatureFlagGivenTestContext Sut(out IVariable sut, IVariable nameVariable) => + New(out sut, () => Create(nameVariable)); + + internal FeatureFlagGivenTestContext Sut(out IVariable> sut, IVariable nameVariable, IVariable contextVariable) => + New(out sut, () => Create(nameVariable, contextVariable)); + + private IFeatureFlag Create(IVariable nameVariable) => + FeatureFlag.Create(GetValue(nameVariable)); + + private IFeatureFlag Create(IVariable nameVariable, IVariable contextVariable) + where TContext : notnull => + FeatureFlag.Create(GetValue(nameVariable), GetValue(contextVariable)); +} diff --git a/src/HomeInventory/HomeInventory.Tests/Application/FeatureFlagTests.cs b/src/HomeInventory/HomeInventory.Tests/Application/FeatureFlagTests.cs index 140bc291..e3037641 100644 --- a/src/HomeInventory/HomeInventory.Tests/Application/FeatureFlagTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Application/FeatureFlagTests.cs @@ -4,7 +4,7 @@ namespace HomeInventory.Tests.Application; [UnitTest] -public sealed class FeatureFlagTests() : BaseTest(t => new(t)) +public sealed class FeatureFlagTests() : BaseTest(static t => new(t)) { private static readonly Variable _manager = new(nameof(_manager)); @@ -16,10 +16,10 @@ public void ConstructorShouldPreserveName() .Sut(out var sut, name); var then = When - .Invoked(sut, sut => sut.Name); + .Invoked(sut, static sut => sut.Name); then - .Result(name, (actual, expected) => actual.Should().Be(expected)); + .Result(name, static (actual, expected) => actual.Should().Be(expected)); } [Fact] @@ -32,8 +32,8 @@ public void CreateShouldPreserveName() .Invoked(name, FeatureFlag.Create); then - .Result(flag => flag.Should().NotBeNull()) - .Result(name, (actual, expected) => actual.Name.Should().Be(expected)); + .Result(static flag => flag.Should().NotBeNull()) + .Result(name, static (actual, expected) => actual.Name.Should().Be(expected)); } [Fact] @@ -47,9 +47,9 @@ public void CreateWithContextShouldPreserveName() .Invoked(name, context, FeatureFlag.Create); then - .Result(flag => flag.Should().NotBeNull()) - .Result(name, (actual, expected) => actual.Name.Should().Be(expected)) - .Result(context, (actual, expected) => actual.Context.Should().Be(expected)); + .Result(static flag => flag.Should().NotBeNull()) + .Result(name, static (actual, expected) => actual.Name.Should().Be(expected)) + .Result(context, static (actual, expected) => actual.Context.Should().Be(expected)); } [Theory] @@ -79,12 +79,12 @@ public void WithContextShouldReturn() .Sut(out var sut, name); var then = When - .Invoked(sut, context, (sut, context) => sut.WithContext(context)); + .Invoked(sut, context, static (sut, context) => sut.WithContext(context)); then - .Result(flag => flag.Should().NotBeNull()) - .Result(name, (actual, expected) => actual.Name.Should().Be(expected)) - .Result(context, (actual, expected) => actual.Context.Should().Be(expected)); + .Result(static flag => flag.Should().NotBeNull()) + .Result(name, static (actual, expected) => actual.Name.Should().Be(expected)) + .Result(context, static (actual, expected) => actual.Context.Should().Be(expected)); } [Theory] @@ -105,25 +105,4 @@ public async Task IsEnabledContextShouldReturnManagerValue(bool expectedValue) then .Result(flag => flag.Should().Be(expectedValue)); } - -#pragma warning disable CA1034 // Nested types should not be visible - public sealed class GivenTestContext(BaseTest test) : GivenContext(test) -#pragma warning restore CA1034 // Nested types should not be visible - { - private static readonly Variable _sut = new(nameof(_sut)); - private static readonly Variable> _sutContext = new(nameof(_sutContext)); - - internal GivenTestContext Sut(out IVariable sut, IVariable nameVariable) => - New(out sut, () => Create(nameVariable)); - - internal GivenTestContext Sut(out IVariable> sut, IVariable nameVariable, IVariable contextVariable) => - New(out sut, () => Create(nameVariable, contextVariable)); - - private IFeatureFlag Create(IVariable nameVariable) => - FeatureFlag.Create(GetValue(nameVariable)); - - private IFeatureFlag Create(IVariable nameVariable, IVariable contextVariable) - where TContext : notnull => - FeatureFlag.Create(GetValue(nameVariable), GetValue(contextVariable)); - } } diff --git a/src/HomeInventory/HomeInventory.Tests/Core/InternalTestSubject.cs b/src/HomeInventory/HomeInventory.Tests/Core/InternalTestSubject.cs index 81a35e7b..a188beec 100644 --- a/src/HomeInventory/HomeInventory.Tests/Core/InternalTestSubject.cs +++ b/src/HomeInventory/HomeInventory.Tests/Core/InternalTestSubject.cs @@ -1,13 +1,10 @@ namespace HomeInventory.Tests.Core; -public sealed class InternalTestSubject +internal sealed class InternalTestSubject { internal InternalTestSubject() { } - internal InternalTestSubject(object arg) - { - _ = arg; - } + internal InternalTestSubject(object arg) => _ = arg; } diff --git a/src/HomeInventory/HomeInventory.Tests/DependencyInjection/InfrastructureDependencyInjectionTests.cs b/src/HomeInventory/HomeInventory.Tests/DependencyInjection/InfrastructureDependencyInjectionTests.cs index ba483ef8..8ec03107 100644 --- a/src/HomeInventory/HomeInventory.Tests/DependencyInjection/InfrastructureDependencyInjectionTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/DependencyInjection/InfrastructureDependencyInjectionTests.cs @@ -4,6 +4,7 @@ using HomeInventory.Application; using HomeInventory.Domain.Primitives; using HomeInventory.Domain.ValueObjects; +using HomeInventory.Infrastructure.Framework; using HomeInventory.Infrastructure.Persistence; using HomeInventory.Infrastructure.Persistence.Mapping; using HomeInventory.Infrastructure.Persistence.Models.Configurations; diff --git a/src/HomeInventory/HomeInventory.Tests/DependencyInjection/TestAppBuilder.cs b/src/HomeInventory/HomeInventory.Tests/DependencyInjection/TestAppBuilder.cs index 3df4dc5d..99909b89 100644 --- a/src/HomeInventory/HomeInventory.Tests/DependencyInjection/TestAppBuilder.cs +++ b/src/HomeInventory/HomeInventory.Tests/DependencyInjection/TestAppBuilder.cs @@ -22,7 +22,7 @@ public TestAppBuilder(IServiceCollection collection) public IServiceProvider ServiceProvider { get; } public ICollection DataSources { get; } = []; - public RequestDelegate Build() => (HttpContext ctx) => Task.CompletedTask; + public RequestDelegate Build() => static (HttpContext ctx) => Task.CompletedTask; public IApplicationBuilder CreateApplicationBuilder() => this; diff --git a/src/HomeInventory/HomeInventory.Tests/Domain/EntityTests.cs b/src/HomeInventory/HomeInventory.Tests/Domain/EntityTests.cs index ef6080cd..cf4481de 100644 --- a/src/HomeInventory/HomeInventory.Tests/Domain/EntityTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Domain/EntityTests.cs @@ -4,7 +4,7 @@ namespace HomeInventory.Tests.Domain; [UnitTest] -public sealed class EntityTests() : BaseTest(t => new(t)) +public sealed class EntityTests() : BaseTest(static t => new(t)) { [Fact] public void EqualsTEntity_Should_ReturnTrueWhenSameReference() @@ -14,8 +14,8 @@ public void EqualsTEntity_Should_ReturnTrueWhenSameReference() .Sut(out var sut, id); When - .Invoked(sut, sut => sut.Equals(sut)) - .Result(actual => actual.Should().BeTrue()); + .Invoked(sut, static sut => sut.Equals(sut)) + .Result(static actual => actual.Should().BeTrue()); } [Fact] @@ -27,8 +27,8 @@ public void EqualsTEntity_Should_ReturnTrueWhenOtherHasSameId() .Sut(out var sut, id); When - .Invoked(sut, other, (sut, other) => sut.Equals(other)) - .Result(actual => actual.Should().BeTrue()); + .Invoked(sut, other, static (sut, other) => sut.Equals(other)) + .Result(static actual => actual.Should().BeTrue()); } [Fact] @@ -39,8 +39,8 @@ public void EqualsTEntity_Should_ReturnFalseWhenOtherIsNull() .Sut(out var sut, id); When - .Invoked(sut, sut => sut.Equals(default)) - .Result(actual => actual.Should().BeFalse()); + .Invoked(sut, static sut => sut.Equals(default)) + .Result(static actual => actual.Should().BeFalse()); } [Fact] @@ -52,8 +52,8 @@ public void EqualsTEntity_Should_ReturnFalseWhenOtherHasDifferentId() .Sut(out var sut, id[1]); When - .Invoked(sut, other, (sut, other) => sut.Equals(other)) - .Result(actual => actual.Should().BeFalse()); + .Invoked(sut, other, static (sut, other) => sut.Equals(other)) + .Result(static actual => actual.Should().BeFalse()); } [Fact] @@ -65,8 +65,8 @@ public void EqualsObject_Should_ReturnFalseWhenOtherHasDifferentType() .Sut(out var sut, id); When - .Invoked(sut, other, (sut, other) => sut.Equals(other)) - .Result(actual => actual.Should().BeFalse()); + .Invoked(sut, other, static (sut, other) => sut.Equals(other)) + .Result(static actual => actual.Should().BeFalse()); } [Fact] @@ -77,8 +77,8 @@ public void EqualsObject_Should_ReturnTrueWhenSameReference() .Sut(out var sut, id); When - .Invoked(sut, sut => sut.Equals((object)sut)) - .Result(actual => actual.Should().BeTrue()); + .Invoked(sut, static sut => sut.Equals((object)sut)) + .Result(static actual => actual.Should().BeTrue()); } [Fact] @@ -90,8 +90,8 @@ public void EqualsObject_Should_ReturnTrueWhenOtherHasSameId() .Sut(out var sut, id); When - .Invoked(sut, other, (sut, other) => sut.Equals((object)other)) - .Result(actual => actual.Should().BeTrue()); + .Invoked(sut, other, static (sut, other) => sut.Equals((object)other)) + .Result(static actual => actual.Should().BeTrue()); } [Fact] @@ -102,8 +102,8 @@ public void EqualsObject_Should_ReturnFalseWhenOtherIsNull() .Sut(out var sut, id); When - .Invoked(sut, sut => sut.Equals(default(object?))) - .Result(actual => actual.Should().BeFalse()); + .Invoked(sut, static sut => sut.Equals(default(object?))) + .Result(static actual => actual.Should().BeFalse()); } [Fact] @@ -115,8 +115,8 @@ public void EqualsObject_Should_ReturnFalseWhenOtherHasDifferentId() .Sut(out var sut, id[1]); When - .Invoked(sut, other, (sut, other) => sut.Equals((object)other)) - .Result(actual => actual.Should().BeFalse()); + .Invoked(sut, other, static (sut, other) => sut.Equals((object)other)) + .Result(static actual => actual.Should().BeFalse()); } [Fact] @@ -128,8 +128,8 @@ public void GetHashCode_Should_ReturnGetHashCodeFromId() .Sut(out var sut, id); When - .Invoked(sut, sut => sut.GetHashCode()) - .Result(hash, (actual, hash) => actual.Should().Be(hash.ToHashCode())); + .Invoked(sut, static sut => sut.GetHashCode()) + .Result(hash, static (actual, hash) => actual.Should().Be(hash.ToHashCode())); } [Fact] @@ -141,8 +141,8 @@ public void OpEquals_Should_ReturnTrueWhenOtherHasSameId() .Sut(out var sut, id); When - .Invoked(sut, other, (sut, other) => sut == other) - .Result(actual => actual.Should().BeTrue()); + .Invoked(sut, other, static (sut, other) => sut == other) + .Result(static actual => actual.Should().BeTrue()); } [Fact] @@ -154,8 +154,8 @@ public void OpEquals_Should_ReturnFalseWhenOtherHasDifferentId() .Sut(out var sut, id[1]); When - .Invoked(sut, other, (sut, other) => sut == other) - .Result(actual => actual.Should().BeFalse()); + .Invoked(sut, other, static (sut, other) => sut == other) + .Result(static actual => actual.Should().BeFalse()); } [Fact] @@ -167,8 +167,8 @@ public void OpNotEquals_Should_ReturnFalseWhenOtherHasSameId() .Sut(out var sut, id); When - .Invoked(sut, other, (sut, other) => sut != other) - .Result(actual => actual.Should().BeFalse()); + .Invoked(sut, other, static (sut, other) => sut != other) + .Result(static actual => actual.Should().BeFalse()); } [Fact] @@ -180,8 +180,8 @@ public void OpNotEquals_Should_ReturnTrueWhenOtherHasDifferentId() .Sut(out var sut, id[1]); When - .Invoked(sut, other, (sut, other) => sut != other) - .Result(actual => actual.Should().BeTrue()); + .Invoked(sut, other, static (sut, other) => sut != other) + .Result(static actual => actual.Should().BeTrue()); } } diff --git a/src/HomeInventory/HomeInventory.Tests/Domain/EquatableComponentTests.cs b/src/HomeInventory/HomeInventory.Tests/Domain/EquatableComponentTests.cs index 318388e6..0509c0a1 100644 --- a/src/HomeInventory/HomeInventory.Tests/Domain/EquatableComponentTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Domain/EquatableComponentTests.cs @@ -4,7 +4,7 @@ namespace HomeInventory.Tests.Domain; [UnitTest] -public class EquatableComponentTests() : BaseTest(t => new(t)) +public class EquatableComponentTests() : BaseTest(static t => new(t)) { [Fact] public void GetHashCode_ShoudReturnZero_WhenNoComponents() @@ -14,8 +14,8 @@ public void GetHashCode_ShoudReturnZero_WhenNoComponents() .EmptyHashCode(out var hash); When - .Invoked(sut, sut => sut.GetHashCode()) - .Result(hash, (actual, hash) => actual.Should().Be(hash.ToHashCode())); + .Invoked(sut, static sut => sut.GetHashCode()) + .Result(hash, static (actual, hash) => actual.Should().Be(hash.ToHashCode())); } [Theory] @@ -30,8 +30,8 @@ public void GetHashCode_ShoudReturnCombinedComponentsHash_WhenManyComponents(int .Sut(out var sut, component); When - .Invoked(sut, sut => sut.GetHashCode()) - .Result(hash, (actual, hash) => actual.Should().Be(hash.ToHashCode())); + .Invoked(sut, static sut => sut.GetHashCode()) + .Result(hash, static (actual, hash) => actual.Should().Be(hash.ToHashCode())); } [Fact] @@ -41,8 +41,8 @@ public void Equals_ShoudBeEqualToEmpty_WhenNoComponents() .Sut(out var sut, 2); When - .Invoked(sut[0], sut[1], (sut, other) => sut.Equals(other)) - .Result(actual => actual.Should().BeTrue()); + .Invoked(sut[0], sut[1], static (sut, other) => sut.Equals(other)) + .Result(static actual => actual.Should().BeTrue()); } [Theory] @@ -57,8 +57,8 @@ public void Equals_ShoudNotBeEqualToEmpty_WhenManyComponents(int count) .Sut(out var sut2); When - .Invoked(sut1, sut2, (sut, other) => sut.Equals(other)) - .Result(actual => actual.Should().BeFalse()); + .Invoked(sut1, sut2, static (sut, other) => sut.Equals(other)) + .Result(static actual => actual.Should().BeFalse()); } [Theory] @@ -72,8 +72,8 @@ public void Equals_ShoudBeEqualToComponentWithSameItems_WhenManyComponents(int c .Sut(out var sut, component, 2); When - .Invoked(sut[0], sut[1], (sut, other) => sut.Equals(other)) - .Result(actual => actual.Should().BeTrue()); + .Invoked(sut[0], sut[1], static (sut, other) => sut.Equals(other)) + .Result(static actual => actual.Should().BeTrue()); } [Theory] @@ -87,8 +87,8 @@ public void Equals_ShoudNotBeEqualToComponentWithDifferentItems_WhenManyComponen .Sut(out var sut, component, ..count, count..); When - .Invoked(sut[0], sut[1], (sut, other) => sut.Equals(other)) - .Result(actual => actual.Should().BeFalse()); + .Invoked(sut[0], sut[1], static (sut, other) => sut.Equals(other)) + .Result(static actual => actual.Should().BeFalse()); } } @@ -115,5 +115,5 @@ public EquatableComponentTestsGivenContext Sut(out IVariable> sut, IVariable variable, string name, params Range[] ranges) => New(out sut, i => CreateSut(variable, ranges[i]), ranges.Length, name); - private EquatableComponent CreateSut(IVariable variable, Range range) => new(Array.ConvertAll(Variables.GetMany(variable, range).ToArray(), x => (object)x)); + private EquatableComponent CreateSut(IVariable variable, Range range) => new(Array.ConvertAll(Variables.GetMany(variable, range).ToArray(), static x => (object)x)); } diff --git a/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/AmountTests.cs b/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/AmountTests.cs index dda90e18..6ddccf8e 100644 --- a/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/AmountTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/AmountTests.cs @@ -1,5 +1,4 @@ -using FluentAssertions.Execution; -using HomeInventory.Domain.Primitives; +using HomeInventory.Domain.Primitives; using HomeInventory.Domain.ValueObjects; namespace HomeInventory.Tests.Domain.ValueObjects; diff --git a/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/AmountUnitTests.cs b/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/AmountUnitTests.cs index 5c022d2f..1f1881a0 100644 --- a/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/AmountUnitTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/AmountUnitTests.cs @@ -57,14 +57,14 @@ public void FieldsShoulHaveMatchedName() var fields = typeof(AmountUnit).GetFieldsOfType().ToArray(); fields.Should().NotBeEmpty() - .And.AllSatisfy(t => t.Value!.Name.Should().Be(t.Field.Name)); + .And.AllSatisfy(static t => t.Value!.Name.Should().Be(t.Field.Name)); } [Fact] public void CanBeUsedAsDictionaryKey() { - var dictionary = _items.ToDictionary(x => x, x => x.Name); + var dictionary = _items.ToDictionary(static x => x, static x => x.Name); var values = typeof(AmountUnit).GetFieldValuesOfType().ToArray(); dictionary.Should().ContainKeys(values); diff --git a/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/MeasurementTypeTests.cs b/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/MeasurementTypeTests.cs index 174ce347..72c3b98a 100644 --- a/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/MeasurementTypeTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Domain/ValueObjects/MeasurementTypeTests.cs @@ -1,5 +1,4 @@ -using FluentAssertions.Execution; -using HomeInventory.Domain.Primitives; +using HomeInventory.Domain.Primitives; using HomeInventory.Domain.Primitives.Ids; using HomeInventory.Domain.ValueObjects; @@ -41,13 +40,13 @@ public void FieldsShoulHaveMatchedName() var fields = typeof(MeasurementType).GetFieldsOfType().ToArray(); fields.Should().NotBeEmpty() - .And.AllSatisfy(t => t.Value!.Name.Should().Be(t.Field.Name)); + .And.AllSatisfy(static t => t.Value!.Name.Should().Be(t.Field.Name)); } [Fact] public void CanBeUsedAsDictionaryKey() { - var dictionary = _items.ToDictionary(x => x, x => x.Name); + var dictionary = _items.ToDictionary(static x => x, static x => x.Name); var values = typeof(MeasurementType).GetFieldValuesOfType().ToArray(); dictionary.Should().ContainKeys(values); diff --git a/src/HomeInventory/HomeInventory.Tests/Framework/Assertions/ServiceDescriptorExtensionsTests.cs b/src/HomeInventory/HomeInventory.Tests/Framework/Assertions/ServiceDescriptorExtensionsTests.cs index 664817cd..a6dd5e42 100644 --- a/src/HomeInventory/HomeInventory.Tests/Framework/Assertions/ServiceDescriptorExtensionsTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Framework/Assertions/ServiceDescriptorExtensionsTests.cs @@ -39,7 +39,9 @@ public void GetInstance_ShouldReturnFromImplementationFactory() public void GetInstance_ShouldReturnFromImplementationType() { var expectedType = typeof(object); +#pragma warning disable CA2263 // Prefer generic overload when type is known var descriptor = ServiceDescriptor.Singleton(typeof(object), expectedType); +#pragma warning restore CA2263 // Prefer generic overload when type is known var actual = ServiceDescriptorExtensions.GetInstance(descriptor, _serviceProvider); diff --git a/src/HomeInventory/HomeInventory.Tests/Middlewares/CorrelationIdMiddlewareTests.cs b/src/HomeInventory/HomeInventory.Tests/Middlewares/CorrelationIdMiddlewareTests.cs index 3632ec6d..0c2093b5 100644 --- a/src/HomeInventory/HomeInventory.Tests/Middlewares/CorrelationIdMiddlewareTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Middlewares/CorrelationIdMiddlewareTests.cs @@ -96,8 +96,8 @@ public async Task InvokeAsync_Should_CreateCorrelationId_When_HeaderIsNotSet() public async Task InvokeAsync_Should_AddCorrelationIdToResponse() { _httpResponseFeature - .When(f => f.OnStarting(Arg.Any>(), Arg.Any())) - .Do(async ci => + .When(static f => f.OnStarting(Arg.Any>(), Arg.Any())) + .Do(static async ci => { var func = ci.Arg>(); var state = ci.Arg(); diff --git a/src/HomeInventory/HomeInventory.Tests/Presentation/Web/SectionPathTests.cs b/src/HomeInventory/HomeInventory.Tests/Presentation/Web/SectionPathTests.cs index 8d7dad0d..27bcbd21 100644 --- a/src/HomeInventory/HomeInventory.Tests/Presentation/Web/SectionPathTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Presentation/Web/SectionPathTests.cs @@ -3,7 +3,7 @@ namespace HomeInventory.Tests.Presentation.Web; [UnitTest] -public sealed class SectionPathTests() : BaseTest(t => new(t)) +public sealed class SectionPathTests() : BaseTest(static t => new(t)) { [Fact] public void ToString_Should_ReturnPath() @@ -13,10 +13,10 @@ public void ToString_Should_ReturnPath() .Sut(out var sut, path); var then = When - .Invoked(sut, sut => sut.ToString()); + .Invoked(sut, static sut => sut.ToString()); then - .Result(path, (actual, expected) => actual.Should().Be(expected)); + .Result(path, static (actual, expected) => actual.Should().Be(expected)); } [Fact] @@ -28,10 +28,10 @@ public void Divide_Should_ReturnCombinedPath() .Sut(out var sut, path); var then = When - .Invoked(sut, subPath, (sut, subPath) => SectionPath.Divide(sut, subPath).ToString()); + .Invoked(sut, subPath, static (sut, subPath) => SectionPath.Divide(sut, subPath).ToString()); then - .Result(path, subPath, (actual, path, subPath) => actual.Should().Be($"{path}:{subPath}")); + .Result(path, subPath, static (actual, path, subPath) => actual.Should().Be($"{path}:{subPath}")); } } diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Authentication/BCryptPasswordHasherTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Authentication/BCryptPasswordHasherTests.cs index f9144de3..e91b26a9 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Authentication/BCryptPasswordHasherTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Authentication/BCryptPasswordHasherTests.cs @@ -4,7 +4,7 @@ namespace HomeInventory.Tests.Systems.Authentication; [UnitTest] -public class BCryptPasswordHasherTests() : BaseTest(t => new(t)) +public class BCryptPasswordHasherTests() : BaseTest(static t => new(t)) { [Fact] public async Task HashAsync_ShouldReturnSomethingDifferentFromInput() @@ -14,10 +14,10 @@ public async Task HashAsync_ShouldReturnSomethingDifferentFromInput() .Sut(out var sut); var then = await When - .InvokedAsync(sut, password, async (sut, password, ct) => await sut.HashAsync(password, ct)); + .InvokedAsync(sut, password, static async (sut, password, ct) => await sut.HashAsync(password, ct)); then - .Result(password, (actual, password) => + .Result(password, static (actual, password) => actual.Should().NotBe(password)); } @@ -29,13 +29,13 @@ public async Task HashAsync_ShouldReturnDifferentHashesForDifferentInputs() .Sut(out var sut); var then = await When - .InvokedAsync(sut, password[0], password[1], async (sut, password1, password2, ct) => + .InvokedAsync(sut, password[0], password[1], static async (sut, password1, password2, ct) => { return new[] { await sut.HashAsync(password1, ct), await sut.HashAsync(password2, ct) }; }); then - .Result(actual => + .Result(static actual => actual[0].Should().NotBe(actual[1])); } @@ -47,14 +47,14 @@ public async Task VerifyAsync_ShouldConfirmHashed() .Sut(out var sut); var then = await When - .InvokedAsync(sut, password, async (sut, password, ct) => + .InvokedAsync(sut, password, static async (sut, password, ct) => { var hash = await sut.HashAsync(password, ct); return await sut.VarifyHashAsync(password, hash, ct); }); then - .Result(actual => + .Result(static actual => actual.Should().BeTrue()); } } diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Authentication/JwtTokenGeneratorTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Authentication/JwtTokenGeneratorTests.cs index fcc7afa1..e2feef5c 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Authentication/JwtTokenGeneratorTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Authentication/JwtTokenGeneratorTests.cs @@ -22,8 +22,8 @@ public JwtTokenGeneratorTests() Fixture.CustomizeId(); Fixture.CustomizeEmail(); _options = Fixture.Build() - .With(x => x.Expiry, TimeSpan.FromSeconds(Fixture.Create())) - .With(x => x.Algorithm, SecurityAlgorithms.HmacSha256) + .With(static x => x.Expiry, TimeSpan.FromSeconds(Fixture.Create())) + .With(static x => x.Algorithm, SecurityAlgorithms.HmacSha256) .Create(); _expectedHeader = new JwtHeader(new SigningCredentials(_options.SecurityKey, _options.Algorithm)); _user = Fixture.Create(); diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Handlers/RegisterCommandHandlerTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Handlers/RegisterCommandHandlerTests.cs index bc434f7b..0f4f3c11 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Handlers/RegisterCommandHandlerTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Handlers/RegisterCommandHandlerTests.cs @@ -20,7 +20,7 @@ public RegisterCommandHandlerTests() { Fixture.CustomizeId(); Fixture.CustomizeEmail(); - Fixture.CustomizeFromFactory>((e, s) => new RegisterCommand(e, s.Supply().ToString())); + Fixture.CustomizeFromFactory>(static (e, s) => new RegisterCommand(e, s.Supply().ToString())); } private RegisterCommandHandler CreateSut() => new(_scopeAccessor, DateTime, _hasher, IdSuppliers.Ulid); @@ -61,7 +61,7 @@ public async Task Handle_OnFailure_ReturnsError() // Then using var scope = new AssertionScope(); - result.Should().BeSome(error => error.Should().BeOfType()); + result.Should().BeSome(static error => error.Should().BeOfType()); await _userRepository.DidNotReceiveWithAnyArgs().AddAsync(Arg.Any(), Cancellation.Token); } } \ No newline at end of file diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Mapping/BaseMappingsTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Mapping/BaseMappingsTests.cs index 3ac46904..692657d0 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Mapping/BaseMappingsTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Mapping/BaseMappingsTests.cs @@ -17,7 +17,7 @@ protected BaseMappingsTests() protected IMapper CreateSut() where TMapper : Profile, new() { - var config = new MapperConfiguration(x => + var config = new MapperConfiguration(static x => { x.AddProfile(); }); @@ -29,7 +29,7 @@ protected IMapper CreateSut() where TMapper1 : Profile, new() where TMapper2 : Profile, new() { - var config = new MapperConfiguration(x => + var config = new MapperConfiguration(static x => { x.AddProfile(); x.AddProfile(); diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Mapping/UlidIdConverterTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Mapping/UlidIdConverterTests.cs index 594f43d2..b53b81e7 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Mapping/UlidIdConverterTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Mapping/UlidIdConverterTests.cs @@ -4,7 +4,7 @@ namespace HomeInventory.Tests.Systems.Mapping; [UnitTest] -public class UlidIdConverterTests() : BaseTest(t => new(t)) +public class UlidIdConverterTests() : BaseTest(static t => new(t)) { [Fact] public void TryConvert_Should_ReturnValue_When_IdIsNotEmpty() @@ -28,10 +28,10 @@ public void TryConvert_Should_ReturnError_When_IdIsEmpty() .Empty(out var id); var then = When - .Invoked(sut, id, (sut, id) => sut.TryConvert(id)); + .Invoked(sut, id, static (sut, id) => sut.TryConvert(id)); then - .Result(validation => validation + .Result(static validation => validation .Should().BeFail() .Which.Head.Should().BeOfType() .Which.Value.Should().BeOfType() @@ -46,8 +46,8 @@ public void Convert_Should_Throw_When_IdIsEmpty() .Empty(out var id); When - .Catched(sut, id, (sut, id) => sut.Convert(id)) - .Exception(ex => ex.Which.Value.Should().Be(Ulid.Empty)); + .Catched(sut, id, static (sut, id) => sut.Convert(id)) + .Exception(static ex => ex.Which.Value.Should().Be(Ulid.Empty)); } } @@ -60,7 +60,7 @@ public UlidIdConverterTestsGivenContext(BaseTest test) } internal UlidIdConverterTestsGivenContext Empty(out IVariable empty) => - New(out empty, () => Ulid.Empty); + New(out empty, static () => Ulid.Empty); protected override UlidIdConverter CreateSut() => new(); } diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Modules/AuthenticationModuleTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Modules/AuthenticationModuleTests.cs index 0b346f64..75c7fd92 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Modules/AuthenticationModuleTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Modules/AuthenticationModuleTests.cs @@ -8,7 +8,7 @@ namespace HomeInventory.Tests.Systems.Modules; [UnitTest] -public class AuthenticationModuleTests() : BaseApiModuleTests(t => new(t)) +public class AuthenticationModuleTests() : BaseApiModuleTests(static t => new(t)) { [Fact] public void AddRoutes_ShouldRegister() @@ -19,10 +19,10 @@ public void AddRoutes_ShouldRegister() .Sut(out var sut); var then = When - .Invoked(sut, routeBuilder, (sut, routeBuilder) => sut.AddRoutes(routeBuilder)); + .Invoked(sut, routeBuilder, static (sut, routeBuilder) => sut.AddRoutes(routeBuilder)); then - .Ensure(sut, dataSources, (module, dataSources) => + .Ensure(sut, dataSources, static (module, dataSources) => dataSources.Should().ContainSingle() .Which.Endpoints.OfType().Should().ContainSingle() .Which.Should().HaveRoutePattern(module.GroupPrefix, RoutePatternFactory.Parse("login")) @@ -43,10 +43,10 @@ public async Task LoginAsync_OnSuccess_ReturnsHttp200() var then = await When - .InvokedAsync(sut, loginRequest, context, (sut, body, context, ct) => sut.LoginAsync(body, context, ct)); + .InvokedAsync(sut, loginRequest, context, static (sut, body, context, ct) => sut.LoginAsync(body, context, ct)); then - .Result(loginResponse, (actual, expected) => + .Result(loginResponse, static (actual, expected) => actual.Result.Should().BeOfType>() .Which.Should().HaveValue(expected)); } diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Modules/BaseApiModuleGivenTestContext.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Modules/BaseApiModuleGivenTestContext.cs index 29d3533a..69e7435a 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Modules/BaseApiModuleGivenTestContext.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Modules/BaseApiModuleGivenTestContext.cs @@ -52,7 +52,7 @@ public TGiven HttpContext(out IVariable context) => New(out context, CreateHttpContext); public TGiven DataSources(out IVariable> dataSources) => - New(out dataSources, () => new List()); + New(out dataSources, static () => new List()); public TGiven RouteBuilder(out IVariable routeBuilder, IVariable> dataSources) => SubstituteFor(out routeBuilder, dataSources, (b, s) => diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Modules/ErrorMappingTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Modules/ErrorMappingTests.cs index 9f8d228e..61bf7f48 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Modules/ErrorMappingTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Modules/ErrorMappingTests.cs @@ -4,7 +4,7 @@ namespace HomeInventory.Tests.Systems.Modules; [UnitTest] -public class ErrorMappingTests() : BaseTest(t => new(t)) +public class ErrorMappingTests() : BaseTest(static t => new(t)) { [Fact] public void GetDefaultError_Shoud_Return500() @@ -13,8 +13,8 @@ public void GetDefaultError_Shoud_Return500() .Sut(out var sut); When - .Invoked(sut, sut => sut.GetDefaultError()) - .Result(actual => actual.Should().Be(HttpStatusCode.InternalServerError)); + .Invoked(sut, static sut => sut.GetDefaultError()) + .Result(static actual => actual.Should().Be(HttpStatusCode.InternalServerError)); } [Theory] diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Modules/JsonOpenApiValueConverterTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Modules/JsonOpenApiValueConverterTests.cs index 023d1832..682b9d8b 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Modules/JsonOpenApiValueConverterTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Modules/JsonOpenApiValueConverterTests.cs @@ -3,7 +3,7 @@ namespace HomeInventory.Tests.Systems.Modules; [UnitTest] -public sealed class JsonOpenApiValueConverterTests() : BaseTest(t => new(t)) +public sealed class JsonOpenApiValueConverterTests() : BaseTest(static t => new(t)) { [Fact] public void Convert_ShouldReturnNull_WhenValueIsNull() @@ -13,10 +13,10 @@ public void Convert_ShouldReturnNull_WhenValueIsNull() .Sut(out var sut); var then = When - .Invoked(sut, value, (sut, value) => sut.Convert(value, typeof(object))); + .Invoked(sut, value, static (sut, value) => sut.Convert(value, typeof(object))); then - .Result(any => any.Should().BeOfType()); + .Result(static any => any.Should().BeOfType()); } [Fact] @@ -27,10 +27,10 @@ public void Convert_ShouldReturnOpenApiNull_WhenValueIsDbNull() .Sut(out var sut); var then = When - .Invoked(sut, value, (sut, value) => sut.Convert(value, value.GetType())); + .Invoked(sut, value, static (sut, value) => sut.Convert(value, value.GetType())); then - .Result(any => any.Should().BeOfType()); + .Result(static any => any.Should().BeOfType()); } [Theory] diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Modules/UserManagementModuleTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Modules/UserManagementModuleTests.cs index 89ebf7b4..cf2496bb 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Modules/UserManagementModuleTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Modules/UserManagementModuleTests.cs @@ -9,7 +9,7 @@ namespace HomeInventory.Tests.Systems.Modules; [UnitTest] -public class UserManagementModuleTests() : BaseApiModuleTests(t => new(t)) +public class UserManagementModuleTests() : BaseApiModuleTests(static t => new(t)) { [Fact] public void AddRoutes_ShouldRegister() @@ -20,10 +20,10 @@ public void AddRoutes_ShouldRegister() .Sut(out var sut); var then = When - .Invoked(sut, routeBuilder, (sut, routeBuilder) => sut.AddRoutes(routeBuilder)); + .Invoked(sut, routeBuilder, static (sut, routeBuilder) => sut.AddRoutes(routeBuilder)); then - .Ensure(sut, dataSources, (module, dataSources) => + .Ensure(sut, dataSources, static (module, dataSources) => dataSources.Should().ContainSingle() .Which.Endpoints.OfType().Should().ContainSingle() .Which.Should().HaveRoutePattern(module.GroupPrefix, RoutePatternFactory.Parse("register")) @@ -45,10 +45,10 @@ public async Task RegisterAsync_OnSuccess_ReturnsHttp200() .Sut(out var sut); var then = await When - .InvokedAsync(sut, registerRequest, context, (sut, body, context, ct) => sut.RegisterAsync(body, null!, null!, context, ct)); + .InvokedAsync(sut, registerRequest, context, static (sut, body, context, ct) => sut.RegisterAsync(body, null!, null!, context, ct)); then - .Result(registerResponse, (actual, expected) => + .Result(registerResponse, static (actual, expected) => actual.Result.Should().BeOfType>() .Which.Should().HaveValue(expected)); } diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/AmountValueObjectConverterTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/AmountValueObjectConverterTests.cs index 3bb1d3ec..acfa60a3 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/AmountValueObjectConverterTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/AmountValueObjectConverterTests.cs @@ -18,7 +18,7 @@ public class AmountValueObjectConverterTests : IAsyncLifetime public void TryConvert() => _test.TryConvert(); } -internal class InternalAmountValueObjectConverterTests() : BaseTest(t => new(t)) +internal class InternalAmountValueObjectConverterTests() : BaseTest(static t => new(t)) { public void TryConvert() { @@ -53,8 +53,8 @@ private sealed class ProductAmountModelCustomization : ICustomization { public void Customize(IFixture fixture) { - fixture.Customize(c => c - .With(m => m.UnitName, u => u.Name)); + fixture.Customize(static c => c + .With(static m => m.UnitName, static u => u.Name)); } } private sealed class AmountUnitCustomization : ICustomization @@ -71,7 +71,7 @@ private sealed class AmountCustomization : ICustomization { public void Customize(IFixture fixture) { - fixture.Customize(c => c.FromFactory((v, u) => new Amount(v, u))); + fixture.Customize(static c => c.FromFactory(static (v, u) => new Amount(v, u))); } } } diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/BaseDatabaseContextTest.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/BaseDatabaseContextTest.cs index dd2656bd..dd084b9f 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/BaseDatabaseContextTest.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/BaseDatabaseContextTest.cs @@ -12,5 +12,5 @@ protected BaseDatabaseContextTest() AddAsyncDisposable(_context); } - protected private DatabaseContext Context => _context; + private protected DatabaseContext Context => _context; } diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/BaseRepositoryTest.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/BaseRepositoryTest.cs index 0d7cfb41..576ea02a 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/BaseRepositoryTest.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/BaseRepositoryTest.cs @@ -1,5 +1,5 @@ using AutoMapper; -using HomeInventory.Infrastructure.Persistence; +using HomeInventory.Infrastructure.Framework; using HomeInventory.Infrastructure.Persistence.Mapping; using HomeInventory.Infrastructure.UserManagement.Mapping; using HomeInventory.Web.UserManagement; @@ -13,7 +13,7 @@ protected BaseRepositoryTest() var services = new ServiceCollection(); var factory = new DefaultServiceProviderFactory(); - var config = new MapperConfiguration(x => + var config = new MapperConfiguration(static x => { x.AddProfile(); x.AddProfile(); diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/ByIdFilterSpecificationTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/ByIdFilterSpecificationTests.cs index 561f0e6f..9b2d2c63 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/ByIdFilterSpecificationTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/ByIdFilterSpecificationTests.cs @@ -21,7 +21,7 @@ public ByIdFilterSpecificationTests() public void Should_SatisfyWithCorrectId() { var user = Fixture.Build() - .With(m => m.Id, _id) + .With(static m => m.Id, _id) .Create(); var query = new[] { user }.AsQueryable(); var sut = CreateSut(); @@ -47,7 +47,7 @@ public void Should_NotSatisfyWithWrongId() public async Task ExecuteAsync_Should_SatisfyWithCorrectId() { var user = Fixture.Build() - .With(m => m.Id, _id) + .With(static m => m.Id, _id) .Create(); await Context.Set().AddAsync(user, Cancellation.Token); await Context.SaveChangesAsync(); diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/EventsPersistenceServiceTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/EventsPersistenceServiceTests.cs index 9c82907e..6c7f410b 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/EventsPersistenceServiceTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/EventsPersistenceServiceTests.cs @@ -12,7 +12,7 @@ public class EventsPersistenceServiceTests : BaseTest _options; public EventsPersistenceServiceTests() - : base(t => new(t)) + : base(static t => new(t)) { _options = DbContextFactory.CreateInMemoryOptions("database"); } diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/OutboxMessageConfigurationTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/OutboxMessageConfigurationTests.cs index ca2328eb..a9c6ac61 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/OutboxMessageConfigurationTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/OutboxMessageConfigurationTests.cs @@ -32,7 +32,7 @@ public void UserModel_Should_HavePrimaryKey() type.Should().NotBeNull(); var primaryKey = type!.FindPrimaryKey(); primaryKey.Should().NotBeNull(); - primaryKey!.Properties.Should().ContainSingle(x => x.Name == nameof(OutboxMessage.Id)); + primaryKey!.Properties.Should().ContainSingle(static x => x.Name == nameof(OutboxMessage.Id)); } [Fact] diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/RepositoryTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/RepositoryTests.cs index 175354bd..aa0cb0c4 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/RepositoryTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/RepositoryTests.cs @@ -2,7 +2,7 @@ using AutoMapper; using HomeInventory.Domain.Aggregates; using HomeInventory.Domain.ValueObjects; -using HomeInventory.Infrastructure.Persistence; +using HomeInventory.Infrastructure.Framework; using HomeInventory.Infrastructure.Persistence.Models; using HomeInventory.Infrastructure.Specifications; using Microsoft.EntityFrameworkCore; diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserHasEmailSpecificationTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserHasEmailSpecificationTests.cs index 5c493be2..bad61d89 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserHasEmailSpecificationTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserHasEmailSpecificationTests.cs @@ -20,7 +20,7 @@ public void Should_SatisfyWithCorrectEmail() { var email = Fixture.Create(); var user = Fixture.Build() - .With(x => x.Email, email) + .With(static x => x.Email, email) .Create(); var query = new[] { user }.AsQueryable(); var sut = new UserHasEmailSpecification(new Email(email)); @@ -34,7 +34,7 @@ public void Should_SatisfyWithCorrectEmail() public void Should_NotSatisfyWithWrongEmail() { var query = Fixture.Build() - .With(x => x.Email, Fixture.Create()) + .With(static x => x.Email, Fixture.Create()) .CreateMany() .AsQueryable(); var sut = new UserHasEmailSpecification(new Email(Fixture.Create())); diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserModelConfigurationTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserModelConfigurationTests.cs index b3f65916..66d23408 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserModelConfigurationTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserModelConfigurationTests.cs @@ -20,7 +20,7 @@ public void UserModel_Should_HavePrimaryKey() type.Should().NotBeNull(); var primaryKey = type!.FindPrimaryKey(); primaryKey.Should().NotBeNull(); - primaryKey!.Properties.Should().ContainSingle(x => x.Name == nameof(UserModel.Id)); + primaryKey!.Properties.Should().ContainSingle(static x => x.Name == nameof(UserModel.Id)); } private static UserModelConfiguration CreateSut() => new(); diff --git a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserRepositoryTests.cs b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserRepositoryTests.cs index ed10003a..4d4e1c01 100644 --- a/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserRepositoryTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Systems/Persistence/UserRepositoryTests.cs @@ -19,9 +19,9 @@ public UserRepositoryTests() _user = Fixture.Create(); _userModel = Fixture.Build() - .With(x => x.Id, _user.Id) - .With(x => x.Email, _user.Email.Value) - .With(x => x.Password, _user.Password) + .With(static x => x.Id, _user.Id) + .With(static x => x.Email, _user.Email.Value) + .With(static x => x.Password, _user.Password) .Create(); } diff --git a/src/HomeInventory/HomeInventory.Tests/Validation/PasswordValidatorTests.cs b/src/HomeInventory/HomeInventory.Tests/Validation/PasswordValidatorTests.cs index 6bab1d89..cdcaf6d9 100644 --- a/src/HomeInventory/HomeInventory.Tests/Validation/PasswordValidatorTests.cs +++ b/src/HomeInventory/HomeInventory.Tests/Validation/PasswordValidatorTests.cs @@ -44,7 +44,7 @@ public void Should_NotPassValidation(string? password) var results = sut.TestValidate(container); - results.ShouldHaveValidationErrorFor(c => c.Password); + results.ShouldHaveValidationErrorFor(static c => c.Password); } private class Container @@ -54,7 +54,6 @@ private class Container private static InlineValidator CreateSut() => new() - { - v => v.RuleFor(x => x.Password).Password() + { static v => v.RuleFor(static x => x.Password).Password() }; } diff --git a/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/HomeInventoryProblemDetailsFactory.cs b/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/HomeInventoryProblemDetailsFactory.cs index 3f170e17..c096a873 100644 --- a/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/HomeInventoryProblemDetailsFactory.cs +++ b/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/HomeInventoryProblemDetailsFactory.cs @@ -63,7 +63,7 @@ private ProblemDetails InternalConvertToProblem(IEnumerable errors) return problems.FirstOrDefault() ?? throw new InvalidOperationException("Has to be at least one error provided"); } - var statuses = problems.Select(x => x.Status).ToHashSet(); + var statuses = problems.Select(static x => x.Status).ToHashSet(); var status = (statuses.Count == 1 ? statuses.First() : default) ?? _defaultStatusCode; return CreateProblem( status, diff --git a/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/ProblemDetailsExtensions.cs b/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/ProblemDetailsExtensions.cs index d3de81c8..445728da 100644 --- a/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/ProblemDetailsExtensions.cs +++ b/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/ProblemDetailsExtensions.cs @@ -39,7 +39,7 @@ public static TProblem AddProblemDetailsExtensions(this TProblem probl public static TProblem AddProblemDetailsExtensions(this TProblem problemDetails, Seq errors) where TProblem : ProblemDetails { - problemDetails.Extensions["errorCodes"] = errors.Select(e => e.GetType().Name).ToArray(); + problemDetails.Extensions["errorCodes"] = errors.Select(static e => e.GetType().Name).ToArray(); problemDetails.Extensions["errors"] = errors.ToArray(); return problemDetails; } @@ -53,15 +53,15 @@ public static TProblem AddProblemsAndStatuses(this TProblem problemDet private static Dictionary ToErrorDictionary(this ModelStateDictionary modelState) => modelState - .Select(p => (p.Key, Messages: p.Value?.Errors.GetErrorMessages() ?? [])) - .Where(x => x.Messages.Length > 0) - .ToDictionary(x => x.Key, x => x.Messages); + .Select(static p => (p.Key, Messages: p.Value?.Errors.GetErrorMessages() ?? [])) + .Where(static x => x.Messages.Length > 0) + .ToDictionary(static x => x.Key, static x => x.Messages); private static string[] GetErrorMessages(this ModelErrorCollection collection) => collection switch { { Count: 1 } errors => [errors[0].GetErrorMessage()], - { } errors => errors.Select(e => e.GetErrorMessage()).ToArray(), + { } errors => errors.Select(static e => e.GetErrorMessage()).ToArray(), _ => [], }; diff --git a/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/ProblemDetailsFactoryExtensions.cs b/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/ProblemDetailsFactoryExtensions.cs index 7f28853f..d3c5775a 100644 --- a/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/ProblemDetailsFactoryExtensions.cs +++ b/src/HomeInventory/HomeInventory.Web.Framework/Infrastructure/ProblemDetailsFactoryExtensions.cs @@ -13,7 +13,7 @@ public static ProblemDetails ConvertToProblem(this IProblemDetailsFactory factor factory.ConvertToProblem(result.Errors, traceIdentifier); public static ProblemDetails ConvertToProblem(this IProblemDetailsFactory factory, IEnumerable results, string? traceIdentifier = null) => - factory.ConvertToProblem(results.SelectMany(r => r.Errors), traceIdentifier); + factory.ConvertToProblem(results.SelectMany(static r => r.Errors), traceIdentifier); public static Results, ProblemHttpResult> MatchToOk(this IProblemDetailsFactory factory, IQueryResult errorOrResult, Func onValue, string? traceIdentifier = null) where T : notnull => @@ -29,5 +29,5 @@ public static Results, ProblemHttpResult> MatchToOk( }); private static ProblemDetails ConvertToProblem(this IProblemDetailsFactory factory, IEnumerable failures, string? traceIdentifier = null) => - factory.ConvertToProblem(failures.Select(x => new ValidationError(x.ErrorMessage, x.AttemptedValue)).Cast().ToSeq(), traceIdentifier); + factory.ConvertToProblem(failures.Select(static x => new ValidationError(x.ErrorMessage, x.AttemptedValue)).Cast().ToSeq(), traceIdentifier); } diff --git a/src/HomeInventory/HomeInventory.Web.Framework/ValidationContextFactory.cs b/src/HomeInventory/HomeInventory.Web.Framework/ValidationContextFactory.cs index b7b772f9..a64c524b 100644 --- a/src/HomeInventory/HomeInventory.Web.Framework/ValidationContextFactory.cs +++ b/src/HomeInventory/HomeInventory.Web.Framework/ValidationContextFactory.cs @@ -5,7 +5,7 @@ namespace HomeInventory.Web.Framework; internal sealed class ValidationContextFactory(Action>? validationOptions = null) : IValidationContextFactory { - private readonly Action> _validationOptions = validationOptions ?? (_ => { }); + private readonly Action> _validationOptions = validationOptions ?? (static _ => { }); public IValidationContext CreateContext(TOptions options) => ValidationContext.CreateWithOptions(options, _validationOptions); diff --git a/src/HomeInventory/HomeInventory.Web.Framework/ValidationEndpointFilter.cs b/src/HomeInventory/HomeInventory.Web.Framework/ValidationEndpointFilter.cs index 6fe13b65..b12178f2 100644 --- a/src/HomeInventory/HomeInventory.Web.Framework/ValidationEndpointFilter.cs +++ b/src/HomeInventory/HomeInventory.Web.Framework/ValidationEndpointFilter.cs @@ -19,12 +19,12 @@ internal sealed class ValidationEndpointFilter(IValidationContextFactory v var validator = httpContext.RequestServices.GetValidator(); var results = await ValidateArgumentAsync(validator, arguments, httpContext.RequestAborted).ToArrayAsync(httpContext.RequestAborted); - if (results.Length == 0 || Array.TrueForAll(results, r => r.IsValid)) + if (results.Length == 0 || Array.TrueForAll(results, static r => r.IsValid)) { return await next(context); } - var problem = _problemDetailsFactory.ConvertToProblem(results.Where(r => !r.IsValid), httpContext.TraceIdentifier); + var problem = _problemDetailsFactory.ConvertToProblem(results.Where(static r => !r.IsValid), httpContext.TraceIdentifier); return TypedResults.Problem(problem); } diff --git a/src/HomeInventory/HomeInventory.Web.Framework/WebFrameworkServiceCollectionExtensions.cs b/src/HomeInventory/HomeInventory.Web.Framework/WebFrameworkServiceCollectionExtensions.cs index cf5318f3..fab12b29 100644 --- a/src/HomeInventory/HomeInventory.Web.Framework/WebFrameworkServiceCollectionExtensions.cs +++ b/src/HomeInventory/HomeInventory.Web.Framework/WebFrameworkServiceCollectionExtensions.cs @@ -12,10 +12,10 @@ public static class WebFrameworkServiceCollectionExtensions public static IServiceCollection AddWebFramework(this IServiceCollection services) { services.AddSingleton(ErrorMappingBuilder.CreateDefault()); - services.AddSingleton(sp => sp.GetRequiredService().Build()); + services.AddSingleton(static sp => sp.GetRequiredService().Build()); services.AddTransient(); - services.AddTransient(sp => sp.GetRequiredService()); - services.AddTransient(sp => sp.GetRequiredService()); + services.AddTransient(static sp => sp.GetRequiredService()); + services.AddTransient(static sp => sp.GetRequiredService()); return services; } diff --git a/src/HomeInventory/HomeInventory.Web.UserManagement/UserManagementContractsMappings.cs b/src/HomeInventory/HomeInventory.Web.UserManagement/UserManagementContractsMappings.cs index eb11ffa6..52664e7b 100644 --- a/src/HomeInventory/HomeInventory.Web.UserManagement/UserManagementContractsMappings.cs +++ b/src/HomeInventory/HomeInventory.Web.UserManagement/UserManagementContractsMappings.cs @@ -12,8 +12,8 @@ internal sealed class UserManagementContractsMappings : BaseMappingsProfile { public UserManagementContractsMappings() { - CreateMap().Using(x => x.Value, UserId.Converter); - CreateMap().Using(x => x.Value, x => new Email(x)); + CreateMap().Using(static x => x.Value, UserId.Converter); + CreateMap().Using(static x => x.Value, static x => new Email(x)); CreateMap().Using(CreateRegisterCommand); diff --git a/src/HomeInventory/HomeInventory.Web/Authorization/Dynamic/DynamicAuthorizationServiceCollectionExtensions.cs b/src/HomeInventory/HomeInventory.Web/Authorization/Dynamic/DynamicAuthorizationServiceCollectionExtensions.cs index 6ec7aca1..3d83b838 100644 --- a/src/HomeInventory/HomeInventory.Web/Authorization/Dynamic/DynamicAuthorizationServiceCollectionExtensions.cs +++ b/src/HomeInventory/HomeInventory.Web/Authorization/Dynamic/DynamicAuthorizationServiceCollectionExtensions.cs @@ -15,10 +15,10 @@ public static IServiceCollection AddDynamicAuthorization(this IServiceCollection services.AddTransient(); services.AddAuthorizationBuilder() - .AddPolicy(AuthorizationPolicyNames.Dynamic, pb => pb + .AddPolicy(AuthorizationPolicyNames.Dynamic, static pb => pb .RequireAuthenticatedUser() .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme) - .AddRequirements(new DynamicPermissionRequirement(ep => ep.GetPermissions()))); + .AddRequirements(new DynamicPermissionRequirement(static ep => ep.GetPermissions()))); return services; } @@ -48,7 +48,7 @@ public static TBuilder RequireDynamicAuthorization(this TBuilder build builder.RequireAuthorization(AuthorizationPolicyNames.Dynamic).WithMetadata(new PermissionMetadata(permissions)); private static IEnumerable GetPermissions(this Endpoint endpoint) => - endpoint.Metadata.GetOrderedMetadata().SelectMany(a => a.Permissions); + endpoint.Metadata.GetOrderedMetadata().SelectMany(static a => a.Permissions); private static class AuthorizationPolicyNames { diff --git a/src/HomeInventory/HomeInventory.Web/Configuration/Validation/JwtOptionsValidator.cs b/src/HomeInventory/HomeInventory.Web/Configuration/Validation/JwtOptionsValidator.cs index b3e511e2..8bcd9123 100644 --- a/src/HomeInventory/HomeInventory.Web/Configuration/Validation/JwtOptionsValidator.cs +++ b/src/HomeInventory/HomeInventory.Web/Configuration/Validation/JwtOptionsValidator.cs @@ -6,10 +6,10 @@ internal sealed class JwtOptionsValidator : AbstractValidator, IOpti { public JwtOptionsValidator() { - RuleFor(x => x.Secret).NotEmpty(); - RuleFor(x => x.Issuer).NotEmpty(); - RuleFor(x => x.Audience).NotEmpty(); - RuleFor(x => x.Algorithm).NotEmpty(); - RuleFor(x => x.Expiry).GreaterThan(TimeSpan.FromSeconds(1)); + RuleFor(static x => x.Secret).NotEmpty(); + RuleFor(static x => x.Issuer).NotEmpty(); + RuleFor(static x => x.Audience).NotEmpty(); + RuleFor(static x => x.Algorithm).NotEmpty(); + RuleFor(static x => x.Expiry).GreaterThan(TimeSpan.FromSeconds(1)); } } diff --git a/src/HomeInventory/HomeInventory.Web/Modules/AuthenticationModule.cs b/src/HomeInventory/HomeInventory.Web/Modules/AuthenticationModule.cs index 8d947661..8a9f3ebb 100644 --- a/src/HomeInventory/HomeInventory.Web/Modules/AuthenticationModule.cs +++ b/src/HomeInventory/HomeInventory.Web/Modules/AuthenticationModule.cs @@ -22,7 +22,7 @@ protected override void AddRoutes(RouteGroupBuilder group) { group.MapPost("login", LoginAsync) .AllowAnonymous() - .WithValidationOf(s => s.IncludeAllRuleSets()); + .WithValidationOf(static s => s.IncludeAllRuleSets()); } public async Task, ProblemHttpResult>> LoginAsync([FromBody] LoginRequest body, HttpContext context, CancellationToken cancellationToken = default) diff --git a/src/HomeInventory/HomeInventory.Web/Modules/PermissionModule.cs b/src/HomeInventory/HomeInventory.Web/Modules/PermissionModule.cs index cd5f7073..e71f59b6 100644 --- a/src/HomeInventory/HomeInventory.Web/Modules/PermissionModule.cs +++ b/src/HomeInventory/HomeInventory.Web/Modules/PermissionModule.cs @@ -22,5 +22,5 @@ protected override void AddRoutes(RouteGroupBuilder group) } public static Task>> GetPermissionsAsync([FromServices] PermissionList list, CancellationToken cancellationToken = default) - => Task.FromResult(TypedResults.Ok(list.Select(p => p.ToString()))); + => Task.FromResult(TypedResults.Ok(list.Select(static p => p.ToString()))); } diff --git a/src/HomeInventory/HomeInventory.Web/WebServiceCollectionExtensions.cs b/src/HomeInventory/HomeInventory.Web/WebServiceCollectionExtensions.cs index 64251392..2bf0f770 100644 --- a/src/HomeInventory/HomeInventory.Web/WebServiceCollectionExtensions.cs +++ b/src/HomeInventory/HomeInventory.Web/WebServiceCollectionExtensions.cs @@ -39,9 +39,9 @@ public static IServiceCollection AddWeb(this IServiceCollection services, params services.AddScoped(); services.AddMappingAssemblySource(moduleAssemblies); - services.AddAutoMapper((sp, configExpression) => + services.AddAutoMapper(static (sp, configExpression) => { - configExpression.AddMaps(sp.GetServices().SelectMany(s => s.GetAssemblies())); + configExpression.AddMaps(sp.GetServices().SelectMany(static s => s.GetAssemblies())); configExpression.ConstructServicesUsing(sp.GetService); }, Type.EmptyTypes); @@ -76,13 +76,13 @@ private static void AddOpenApiDocs(this IServiceCollection services) services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); - services.AddSwaggerGen(options => options.OperationFilter()); - services.AddApiVersioning(options => + services.AddSwaggerGen(static options => options.OperationFilter()); + services.AddApiVersioning(static options => { options.DefaultApiVersion = new ApiVersion(1); options.AssumeDefaultVersionWhenUnspecified = true; options.ApiVersionReader = new QueryStringApiVersionReader(); - }).AddApiExplorer(options => options.GroupNameFormat = "'v'VVV"); + }).AddApiExplorer(static options => options.GroupNameFormat = "'v'VVV"); } public static TApp UseWeb(this TApp app) @@ -95,7 +95,7 @@ public static TApp UseWeb(this TApp app) app.UseHealthChecksUI(); app.UseExceptionHandler(new ExceptionHandlerOptions { ExceptionHandlingPath = "/error", }); - app.Map("/error", (HttpContext context) => Results.Problem(detail: context.GetFeature()?.Error?.Message)); + app.Map("/error", static (HttpContext context) => Results.Problem(detail: context.GetFeature()?.Error?.Message)); app.UseMiddleware(); app.UseMiddleware(); @@ -133,17 +133,17 @@ private static void MapHealthChecks(this IEndpointRouteBuilder app) { app.MapHealthChecks("/health", new HealthCheckOptions { - Predicate = _ => true, + Predicate = static _ => true, ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse }); app.MapHealthChecks("/health/ready", new HealthCheckOptions { - Predicate = x => x.Tags.Contains(HealthCheckTags.Ready), + Predicate = static x => x.Tags.Contains(HealthCheckTags.Ready), ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse }); app.MapHealthChecks("/health/live", new HealthCheckOptions { - Predicate = _ => false, + Predicate = static _ => false, ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse, }); } From ac5f8184dcd45bd320678770acf4176b4f9c4460 Mon Sep 17 00:00:00 2001 From: "Serhii A. Hrytsenko" Date: Wed, 13 Nov 2024 08:47:49 -0500 Subject: [PATCH 8/9] Update acceptance-test Signed-off-by: Serhii A. Hrytsenko --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bde2d00c..892b87a2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -293,7 +293,7 @@ jobs: - name: Install Living Documentation Tool run: dotnet tool install --global SpecFlow.Plus.LivingDoc.CLI - name: Generate Living Documentation Specification - run: livingdoc test-assembly "HomeInventory.Tests.Acceptance/bin/Release/net8/HomeInventory.Tests.Acceptance.dll" -t "HomeInventory.Tests.Acceptance/bin/Release/net8/TestExecution.json" -o "./Acceptance/AcceptanceTestResults.html" + run: livingdoc test-assembly "HomeInventory.Tests.Acceptance/bin/Release/net9/HomeInventory.Tests.Acceptance.dll" -t "HomeInventory.Tests.Acceptance/bin/Release/net9/TestExecution.json" -o "./Acceptance/AcceptanceTestResults.html" working-directory: ./src/HomeInventory - name: Publish Specflow Test Results if: success() || failure() From 7f6f8f58c2dcfbd02dd50242a5363dcf63c601db Mon Sep 17 00:00:00 2001 From: "Serhii A. Hrytsenko" Date: Wed, 13 Nov 2024 08:53:08 -0500 Subject: [PATCH 9/9] Remove unused class Signed-off-by: Serhii A. Hrytsenko --- .../HomeInventory.Core/PowerExtensions.cs | 57 ------------------- 1 file changed, 57 deletions(-) delete mode 100644 src/HomeInventory/HomeInventory.Core/PowerExtensions.cs diff --git a/src/HomeInventory/HomeInventory.Core/PowerExtensions.cs b/src/HomeInventory/HomeInventory.Core/PowerExtensions.cs deleted file mode 100644 index 894d8746..00000000 --- a/src/HomeInventory/HomeInventory.Core/PowerExtensions.cs +++ /dev/null @@ -1,57 +0,0 @@ -using LanguageExt.SomeHelp; -using System.Numerics; - -namespace HomeInventory.Core; - -public static class PowerExtensions -{ - public static TBase AsPowerWithBase(this TPower power, TBase @base) - where TPower : IAdditiveIdentity, IComparisonOperators, IIncrementOperators - where TBase : IMultiplyOperators - { - var result = @base; - for (var i = TPower.AdditiveIdentity; i < power; i++) - { - result *= @base; - } - - return result; - } - - public static bool IsPow10(this decimal d) => d.IsPowOf(power: 10); - - public static bool IsPowOf(this decimal d, int power) => decimal.Abs(d).GetBase().DividesBy(power); - - private static Int128 GetBase(this decimal abs) - { - Span bits = stackalloc int[4]; - _ = decimal.GetBits(abs, bits); - return (Int128)bits[0] + ((Int128)bits[1] << 32) + ((Int128)bits[2] << 64); - } - - private static bool DividesBy(this Int128 value, Int128 power) - { - while (value > 0) - { - (value, var divides) = value.DividesByCore(power); - if (divides) - { - return (bool)divides; - } - } - - return false; - } - - private static (Int128 Quotient, Option Divides) DividesByCore(this Int128 value, Int128 power) - { - var (quotient, reminder) = Int128.DivRem(value, power); - - if (reminder == 0) - { - return (quotient, quotient == 1 ? true.ToSome() : OptionNone.Default); - } - - return (quotient, false); - } -}