diff --git a/src/BuildingBlocks/EventBus/EventBus.Tests/EventBus.Tests.csproj b/src/BuildingBlocks/EventBus/EventBus.Tests/EventBus.Tests.csproj index 415ba11bc8..9e640f87c0 100644 --- a/src/BuildingBlocks/EventBus/EventBus.Tests/EventBus.Tests.csproj +++ b/src/BuildingBlocks/EventBus/EventBus.Tests/EventBus.Tests.csproj @@ -1,7 +1,8 @@  - + net7.0 + enable false false diff --git a/src/BuildingBlocks/EventBus/EventBus.Tests/InMemory_SubscriptionManager_Tests.cs b/src/BuildingBlocks/EventBus/EventBus.Tests/InMemory_SubscriptionManager_Tests.cs index 5309a4a9f8..9b5a30103b 100644 --- a/src/BuildingBlocks/EventBus/EventBus.Tests/InMemory_SubscriptionManager_Tests.cs +++ b/src/BuildingBlocks/EventBus/EventBus.Tests/InMemory_SubscriptionManager_Tests.cs @@ -1,5 +1,4 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBus; -using System.Linq; using Xunit; namespace EventBus.Tests diff --git a/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEventHandler.cs b/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEventHandler.cs index b82ac6a5f3..177c1eab76 100644 --- a/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEventHandler.cs +++ b/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationEventHandler.cs @@ -1,5 +1,4 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using System.Threading.Tasks; namespace EventBus.Tests { diff --git a/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationOtherEventHandler.cs b/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationOtherEventHandler.cs index 82ea25baa5..3f529219be 100644 --- a/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationOtherEventHandler.cs +++ b/src/BuildingBlocks/EventBus/EventBus.Tests/TestIntegrationOtherEventHandler.cs @@ -1,5 +1,4 @@ using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; -using System.Threading.Tasks; namespace EventBus.Tests { diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 9a7ce49ecd..2eefee58b3 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -88,6 +88,6 @@ - + \ No newline at end of file diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs index 8796197c07..22b1a830bd 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/OrderStartedIntegrationEventHandler.cs @@ -15,7 +15,7 @@ public OrderStartedIntegrationEventHandler( public async Task Handle(OrderStartedIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs index 94c39cd5ea..b84d16591e 100644 --- a/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs +++ b/src/Services/Basket/Basket.API/IntegrationEvents/EventHandling/ProductPriceChangedIntegrationEventHandler.cs @@ -15,7 +15,7 @@ public ProductPriceChangedIntegrationEventHandler( public async Task Handle(ProductPriceChangedIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj b/src/Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj index 717520e679..9df4803122 100644 --- a/src/Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj +++ b/src/Services/Basket/Basket.FunctionalTests/Basket.FunctionalTests.csproj @@ -2,6 +2,7 @@ net7.0 + enable false false diff --git a/src/Services/Basket/Basket.FunctionalTests/BasketScenarios.cs b/src/Services/Basket/Basket.FunctionalTests/BasketScenarios.cs index 4a96207a49..fa9d2036eb 100644 --- a/src/Services/Basket/Basket.FunctionalTests/BasketScenarios.cs +++ b/src/Services/Basket/Basket.FunctionalTests/BasketScenarios.cs @@ -1,6 +1,6 @@ namespace Basket.FunctionalTests; -public class BasketScenarios : +public class BasketScenarios : BasketScenarioBase { [Fact] @@ -33,7 +33,7 @@ await server.CreateClient() var contentCheckout = new StringContent(BuildCheckout(), UTF8Encoding.UTF8, "application/json") { - Headers = { { "x-requestid", Guid.NewGuid().ToString() } } + Headers = { { "x-requestid", Guid.NewGuid().ToString() } } }; var response = await server.CreateClient() diff --git a/src/Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj b/src/Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj index e39449ab90..cf88eb79b5 100644 --- a/src/Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj +++ b/src/Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj @@ -2,6 +2,7 @@ net7.0 + enable false false false diff --git a/src/Services/Basket/Basket.UnitTests/GlobalUsings.cs b/src/Services/Basket/Basket.UnitTests/GlobalUsings.cs index 62eb6d21a7..5f73c46307 100644 --- a/src/Services/Basket/Basket.UnitTests/GlobalUsings.cs +++ b/src/Services/Basket/Basket.UnitTests/GlobalUsings.cs @@ -1,18 +1,18 @@ -global using Basket.API.IntegrationEvents.Events; +global using System; +global using System.Collections.Generic; +global using System.Security.Claims; +global using System.Threading.Tasks; +global using Basket.API.IntegrationEvents.Events; global using Basket.API.Model; global using Microsoft.AspNetCore.Http; global using Microsoft.AspNetCore.Mvc; global using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; global using Microsoft.eShopOnContainers.Services.Basket.API.Controllers; +global using Microsoft.eShopOnContainers.WebMVC.Controllers; +global using Microsoft.eShopOnContainers.WebMVC.Services; +global using Microsoft.eShopOnContainers.WebMVC.ViewModels; global using Microsoft.Extensions.Logging; global using Moq; -global using System; -global using System.Collections.Generic; -global using System.Security.Claims; -global using System.Threading.Tasks; global using Xunit; global using IBasketIdentityService = Microsoft.eShopOnContainers.Services.Basket.API.Services.IIdentityService; -global using Microsoft.eShopOnContainers.WebMVC.Controllers; -global using Microsoft.eShopOnContainers.WebMVC.Services; -global using Microsoft.eShopOnContainers.WebMVC.ViewModels; global using BasketModel = Microsoft.eShopOnContainers.WebMVC.ViewModels.Basket; diff --git a/src/Services/Catalog/Catalog.API/Apis/PicApi.cs b/src/Services/Catalog/Catalog.API/Apis/PicApi.cs index 277b718a7b..70442d5309 100644 --- a/src/Services/Catalog/Catalog.API/Apis/PicApi.cs +++ b/src/Services/Catalog/Catalog.API/Apis/PicApi.cs @@ -1,6 +1,4 @@ -using Microsoft.AspNetCore.Routing; - -namespace Catalog.API.Apis; +namespace Catalog.API.Apis; public static class PicApi { diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs index 6ad0a3867d..453e975e69 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs @@ -14,12 +14,12 @@ public OrderStatusChangedToAwaitingValidationIntegrationEventHandler( { _catalogContext = catalogContext; _catalogIntegrationEventService = catalogIntegrationEventService; - _logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } public async Task Handle(OrderStatusChangedToAwaitingValidationIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs index 48e7fe571b..7d3519b90e 100644 --- a/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs +++ b/src/Services/Catalog/Catalog.API/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs @@ -11,12 +11,12 @@ public OrderStatusChangedToPaidIntegrationEventHandler( ILogger logger) { _catalogContext = catalogContext; - _logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } public async Task Handle(OrderStatusChangedToPaidIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj b/src/Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj index 37f9cf89bb..ac5bd1a76d 100644 --- a/src/Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj +++ b/src/Services/Catalog/Catalog.FunctionalTests/Catalog.FunctionalTests.csproj @@ -2,6 +2,7 @@ net7.0 + enable false false diff --git a/src/Services/Catalog/Catalog.FunctionalTests/CatalogScenarioBase.cs b/src/Services/Catalog/Catalog.FunctionalTests/CatalogScenarioBase.cs index 64296dd0a3..d49cad5f76 100644 --- a/src/Services/Catalog/Catalog.FunctionalTests/CatalogScenarioBase.cs +++ b/src/Services/Catalog/Catalog.FunctionalTests/CatalogScenarioBase.cs @@ -1,9 +1,8 @@ -using System; -using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.AspNetCore.Mvc.Testing; namespace Catalog.FunctionalTests; -public class CatalogScenariosBase +public class CatalogScenariosBase { private class CatalogApplication : WebApplicationFactory { diff --git a/src/Services/Catalog/Catalog.FunctionalTests/GlobalUsings.cs b/src/Services/Catalog/Catalog.FunctionalTests/GlobalUsings.cs index 2ceffc5354..58dbf6ade1 100644 --- a/src/Services/Catalog/Catalog.FunctionalTests/GlobalUsings.cs +++ b/src/Services/Catalog/Catalog.FunctionalTests/GlobalUsings.cs @@ -1,16 +1,8 @@ -global using Microsoft.AspNetCore.Hosting; +global using System.IO; +global using System.Net; +global using System.Threading.Tasks; +global using Microsoft.AspNetCore.Hosting; global using Microsoft.AspNetCore.TestHost; -global using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF; -global using Microsoft.eShopOnContainers.Services.Catalog.API.Extensions; -global using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; -global using Microsoft.eShopOnContainers.Services.Catalog.API; global using Microsoft.Extensions.Configuration; -global using Microsoft.Extensions.DependencyInjection; global using Microsoft.Extensions.Hosting; -global using Microsoft.Extensions.Logging; -global using Microsoft.Extensions.Options; -global using System.IO; -global using System.Net; -global using System.Reflection; -global using System.Threading.Tasks; global using Xunit; diff --git a/src/Services/Catalog/Catalog.UnitTests/Application/CatalogControllerTest.cs b/src/Services/Catalog/Catalog.UnitTests/Application/CatalogControllerTest.cs index 53efafbfde..1ea092cbb2 100644 --- a/src/Services/Catalog/Catalog.UnitTests/Application/CatalogControllerTest.cs +++ b/src/Services/Catalog/Catalog.UnitTests/Application/CatalogControllerTest.cs @@ -1,16 +1,13 @@ -using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.eShopOnContainers.Services.Catalog.API; using Microsoft.eShopOnContainers.Services.Catalog.API.Controllers; using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; +using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents; using Microsoft.eShopOnContainers.Services.Catalog.API.Model; using Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel; using Microsoft.Extensions.Options; using Moq; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Xunit; namespace UnitTest.Catalog.Application; diff --git a/src/Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj b/src/Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj index a0fbbf2f18..9b49e8fb86 100644 --- a/src/Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj +++ b/src/Services/Catalog/Catalog.UnitTests/Catalog.UnitTests.csproj @@ -2,6 +2,7 @@ net7.0 + enable false false false diff --git a/src/Services/Identity/Identity.API/SeedData.cs b/src/Services/Identity/Identity.API/SeedData.cs index fa8365f9e8..ad2c37bf35 100644 --- a/src/Services/Identity/Identity.API/SeedData.cs +++ b/src/Services/Identity/Identity.API/SeedData.cs @@ -92,7 +92,7 @@ await retryPolicy.ExecuteAsync(async () => }); } - private static AsyncPolicy CreateRetryPolicy(IConfiguration configuration, Microsoft.Extensions.Logging.ILogger logger) + private static AsyncPolicy CreateRetryPolicy(IConfiguration configuration, ILogger logger) { var retryMigrations = false; bool.TryParse(configuration["RetryMigrations"], out retryMigrations); diff --git a/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs b/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs index acebd9cda7..a4ddcc2038 100644 --- a/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs +++ b/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs @@ -36,7 +36,7 @@ await strategy.ExecuteAsync(async () => Guid transactionId; await using var transaction = await _dbContext.BeginTransactionAsync(); - using (_logger.BeginScope(new List> { new ("TransactionContext", transaction.TransactionId) })) + using (_logger.BeginScope(new List> { new("TransactionContext", transaction.TransactionId) })) { _logger.LogInformation("Begin transaction {TransactionId} for {CommandName} ({@Command})", transaction.TransactionId, typeName, request); diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/GracePeriodConfirmedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/GracePeriodConfirmedIntegrationEventHandler.cs index fdab024585..3639df4362 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/GracePeriodConfirmedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/GracePeriodConfirmedIntegrationEventHandler.cs @@ -10,7 +10,7 @@ public GracePeriodConfirmedIntegrationEventHandler( ILogger logger) { _mediator = mediator; - _logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } /// @@ -23,7 +23,7 @@ public GracePeriodConfirmedIntegrationEventHandler( /// public async Task Handle(GracePeriodConfirmedIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs index 6982a5a250..2596c759bf 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentFailedIntegrationEventHandler.cs @@ -16,7 +16,7 @@ public OrderPaymentFailedIntegrationEventHandler( public async Task Handle(OrderPaymentFailedIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs index 31606ead2e..bbe7186b50 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderPaymentSucceededIntegrationEventHandler.cs @@ -16,7 +16,7 @@ public OrderPaymentSucceededIntegrationEventHandler( public async Task Handle(OrderPaymentSucceededIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs index a9faea4658..2b35ef3c49 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs @@ -16,7 +16,7 @@ public OrderStockConfirmedIntegrationEventHandler( public async Task Handle(OrderStockConfirmedIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs index 0d47e7a84c..a6bafa568f 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockRejectedIntegrationEventHandler.cs @@ -9,12 +9,12 @@ public OrderStockRejectedIntegrationEventHandler( ILogger logger) { _mediator = mediator; - _logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } public async Task Handle(OrderStockRejectedIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs index 731bc986f8..e2d5584d80 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/UserCheckoutAcceptedIntegrationEventHandler.cs @@ -24,7 +24,7 @@ public UserCheckoutAcceptedIntegrationEventHandler( /// public async Task Handle(UserCheckoutAcceptedIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); @@ -32,7 +32,7 @@ public async Task Handle(UserCheckoutAcceptedIntegrationEvent @event) if (@event.RequestId != Guid.Empty) { - using (_logger.BeginScope(new List> { new ("IdentifiedCommandId", @event.RequestId) })) + using (_logger.BeginScope(new List> { new("IdentifiedCommandId", @event.RequestId) })) { var createOrderCommand = new CreateOrderCommand(@event.Basket.Items, @event.UserId, @event.UserName, @event.City, @event.Street, @event.State, @event.Country, @event.ZipCode, diff --git a/src/Services/Ordering/Ordering.API/Application/Validations/CreateOrderCommandValidator.cs b/src/Services/Ordering/Ordering.API/Application/Validations/CreateOrderCommandValidator.cs index 51953b25dd..0e7db99ec3 100644 --- a/src/Services/Ordering/Ordering.API/Application/Validations/CreateOrderCommandValidator.cs +++ b/src/Services/Ordering/Ordering.API/Application/Validations/CreateOrderCommandValidator.cs @@ -1,7 +1,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Validations; - -using static Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands.CreateOrderCommand; - public class CreateOrderCommandValidator : AbstractValidator { public CreateOrderCommandValidator(ILogger logger) diff --git a/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs b/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs index 23525d5bff..1a2d17537e 100644 --- a/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs +++ b/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs @@ -1,8 +1,7 @@ using GrpcOrdering; - -using OrderDraftDTO = GrpcOrdering.OrderDraftDTO; -using CreateOrderDraftCommand = GrpcOrdering.CreateOrderDraftCommand; using BasketItem = GrpcOrdering.BasketItem; +using CreateOrderDraftCommand = GrpcOrdering.CreateOrderDraftCommand; +using OrderDraftDTO = GrpcOrdering.OrderDraftDTO; using OrderItemDTO = GrpcOrdering.OrderItemDTO; public class OrderingService : OrderingGrpc.OrderingGrpcBase diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj b/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj index eefdf03f43..41ce41ed12 100644 --- a/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj +++ b/src/Services/Ordering/Ordering.BackgroundTasks/Ordering.BackgroundTasks.csproj @@ -4,7 +4,7 @@ net7.0 enable dotnet-Ordering.BackgroundTasks-9D3E1DD6-405B-447F-8AAB-1708B36D260E - Linux + Linux diff --git a/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs b/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs index 5f6409546c..016f0eb9cc 100644 --- a/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs +++ b/src/Services/Ordering/Ordering.BackgroundTasks/Services/GracePeriodManagerService.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Data.SqlClient; -using System.Threading; -using System.Threading.Tasks; +using System.Data.SqlClient; using Dapper; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Microsoft.Extensions.Options; diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs index 8e452c42f5..8926524ef2 100644 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs +++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Order.cs @@ -19,15 +19,15 @@ public class Order private string _description; - - // Draft orders have this set to true. Currently we don't check anywhere the draft status of an Order, but we could do it if needed +#pragma warning disable CS0414 // The field 'Order._isDraft' is assigned but its value is never used private bool _isDraft; +#pragma warning restore CS0414 // DDD Patterns comment // Using a private collection field, better for DDD Aggregate's encapsulation // so OrderItems cannot be added from "outside the AggregateRoot" directly to the collection, - // but only through the method OrderAggrergateRoot.AddOrderItem() which includes behaviour. + // but only through the method OrderAggregateRoot.AddOrderItem() which includes behavior. private readonly List _orderItems; public IReadOnlyCollection OrderItems => _orderItems; @@ -35,8 +35,10 @@ public class Order public static Order NewDraft() { - var order = new Order(); - order._isDraft = true; + var order = new Order + { + _isDraft = true + }; return order; } @@ -56,13 +58,13 @@ public Order(string userId, string userName, Address address, int cardTypeId, st Address = address; // Add the OrderStarterDomainEvent to the domain events collection - // to be raised/dispatched when comitting changes into the Database [ After DbContext.SaveChanges() ] + // to be raised/dispatched when committing changes into the Database [ After DbContext.SaveChanges() ] AddOrderStartedDomainEvent(userId, userName, cardTypeId, cardNumber, cardSecurityNumber, cardHolderName, cardExpiration); } // DDD Patterns comment - // This Order AggregateRoot's method "AddOrderitem()" should be the only way to add Items to the Order, + // This Order AggregateRoot's method "AddOrderItem()" should be the only way to add Items to the Order, // so any behavior (discounts, etc.) and validations are controlled by the AggregateRoot // in order to maintain consistency between the whole Aggregate. public void AddOrderItem(int productId, string productName, decimal unitPrice, decimal discount, string pictureUrl, int units = 1) diff --git a/src/Services/Ordering/Ordering.Domain/GlobalUsings.cs b/src/Services/Ordering/Ordering.Domain/GlobalUsings.cs index 866be7bcb0..a7b4f4d403 100644 --- a/src/Services/Ordering/Ordering.Domain/GlobalUsings.cs +++ b/src/Services/Ordering/Ordering.Domain/GlobalUsings.cs @@ -1,5 +1,5 @@ global using System.Reflection; -global using global::Microsoft.eShopOnContainers.Services.Ordering.Domain.Exceptions; +global using Microsoft.eShopOnContainers.Services.Ordering.Domain.Exceptions; global using MediatR; global using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate; global using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate; diff --git a/src/Services/Ordering/Ordering.FunctionalTests/GlobalUsings.cs b/src/Services/Ordering/Ordering.FunctionalTests/GlobalUsings.cs index cee4b67336..5c3815a9f7 100644 --- a/src/Services/Ordering/Ordering.FunctionalTests/GlobalUsings.cs +++ b/src/Services/Ordering/Ordering.FunctionalTests/GlobalUsings.cs @@ -1,19 +1,9 @@ -global using Microsoft.AspNetCore.Builder; +global using System.IO; +global using System.Net.Http; +global using System.Security.Claims; +global using Microsoft.AspNetCore.Builder; global using Microsoft.AspNetCore.Hosting; global using Microsoft.AspNetCore.Http; -global using Microsoft.AspNetCore.Routing; global using Microsoft.AspNetCore.TestHost; -global using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF; -global using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure; -global using Microsoft.eShopOnContainers.Services.Ordering.API; -global using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; global using Microsoft.Extensions.Configuration; global using Microsoft.Extensions.DependencyInjection; -global using Microsoft.Extensions.Logging; -global using Microsoft.Extensions.Options; -global using System.IO; -global using System.Net.Http; -global using System.Reflection; -global using System.Security.Claims; -global using System.Threading.Tasks; -global using System; diff --git a/src/Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj b/src/Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj index 9d998af72d..29fe059ac2 100644 --- a/src/Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj +++ b/src/Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj @@ -2,6 +2,7 @@ net7.0 + enable false false diff --git a/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs b/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs index 66af0bbd59..b7ff89a681 100644 --- a/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs +++ b/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs @@ -50,7 +50,7 @@ public async Task SaveEntitiesAsync(CancellationToken cancellationToken = // After executing this line all the changes (from the Command Handler and Domain Event Handlers) // performed through the DbContext will be committed - var result = await base.SaveChangesAsync(cancellationToken); + _ = await base.SaveChangesAsync(cancellationToken); return true; } @@ -106,6 +106,8 @@ public void RollbackTransaction() } } +#nullable enable + public class OrderingContextDesignFactory : IDesignTimeDbContextFactory { public OrderingContext CreateDbContext(string[] args) @@ -120,12 +122,12 @@ class NoMediator : IMediator { public IAsyncEnumerable CreateStream(IStreamRequest request, CancellationToken cancellationToken = default) { - return default; + return default!; } public IAsyncEnumerable CreateStream(object request, CancellationToken cancellationToken = default) { - return default; + return default!; } public Task Publish(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification @@ -140,10 +142,10 @@ public Task Publish(object notification, CancellationToken cancellationToken = d public Task Send(IRequest request, CancellationToken cancellationToken = default) { - return Task.FromResult(default); + return Task.FromResult(default!); } - public Task Send(object request, CancellationToken cancellationToken = default) + public Task Send(object request, CancellationToken cancellationToken = default) { return Task.FromResult(default(object)); } diff --git a/src/Services/Ordering/Ordering.SignalrHub/Extensions/Extensions.cs b/src/Services/Ordering/Ordering.SignalrHub/Extensions/Extensions.cs index 40b8d1ff6f..ee11e7fea3 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/Extensions/Extensions.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/Extensions/Extensions.cs @@ -1,6 +1,4 @@ -using Microsoft.AspNetCore.Http; - -internal static class Extensions +internal static class Extensions { public static IServiceCollection AddSignalR(this IServiceCollection services, IConfiguration configuration) { diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs index 4210830dc1..02d118d49d 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToAwaitingValidationIntegrationEventHandler.cs @@ -16,7 +16,7 @@ public OrderStatusChangedToAwaitingValidationIntegrationEventHandler( public async Task Handle(OrderStatusChangedToAwaitingValidationIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs index d0642702a5..5c07407e6c 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToCancelledIntegrationEventHandler.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; public class OrderStatusChangedToCancelledIntegrationEventHandler : IIntegrationEventHandler { @@ -18,7 +16,7 @@ public OrderStatusChangedToCancelledIntegrationEventHandler( public async Task Handle(OrderStatusChangedToCancelledIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs index 5b96fd7da2..1b8488076a 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToPaidIntegrationEventHandler.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; public class OrderStatusChangedToPaidIntegrationEventHandler : IIntegrationEventHandler { @@ -18,7 +16,7 @@ public OrderStatusChangedToPaidIntegrationEventHandler( public async Task Handle(OrderStatusChangedToPaidIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs index 283c6f8a2b..ec448e8c5e 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToShippedIntegrationEventHandler.cs @@ -15,7 +15,7 @@ public OrderStatusChangedToShippedIntegrationEventHandler( public async Task Handle(OrderStatusChangedToShippedIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs index eea86552db..b6b04f4b9a 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; public class OrderStatusChangedToStockConfirmedIntegrationEventHandler : IIntegrationEventHandler @@ -19,7 +17,7 @@ public OrderStatusChangedToStockConfirmedIntegrationEventHandler( public async Task Handle(OrderStatusChangedToStockConfirmedIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs index 7a536971c3..fad3a38c7d 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/IntegrationEvents/EventHandling/OrderStatusChangedToSubmittedIntegrationEventHandler.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; +namespace Microsoft.eShopOnContainers.Services.Ordering.SignalrHub.IntegrationEvents.EventHandling; public class OrderStatusChangedToSubmittedIntegrationEventHandler : IIntegrationEventHandler @@ -19,7 +17,7 @@ public OrderStatusChangedToSubmittedIntegrationEventHandler( public async Task Handle(OrderStatusChangedToSubmittedIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Ordering/Ordering.UnitTests/Application/NewOrderCommandHandlerTest.cs b/src/Services/Ordering/Ordering.UnitTests/Application/NewOrderCommandHandlerTest.cs index 734435cc66..6d6cc19045 100644 --- a/src/Services/Ordering/Ordering.UnitTests/Application/NewOrderCommandHandlerTest.cs +++ b/src/Services/Ordering/Ordering.UnitTests/Application/NewOrderCommandHandlerTest.cs @@ -29,7 +29,7 @@ public async Task Handle_return_false_if_order_is_not_persisted() { ["cardExpiration"] = DateTime.Now.AddYears(1) }); _orderRepositoryMock.Setup(orderRepo => orderRepo.GetAsync(It.IsAny())) - .Returns(Task.FromResult(FakeOrder())); + .Returns(Task.FromResult(FakeOrder())); _orderRepositoryMock.Setup(buyerRepo => buyerRepo.UnitOfWork.SaveChangesAsync(default)) .Returns(Task.FromResult(1)); @@ -39,7 +39,7 @@ public async Task Handle_return_false_if_order_is_not_persisted() var LoggerMock = new Mock>(); //Act var handler = new CreateOrderCommandHandler(_mediator.Object, _orderingIntegrationEventService.Object, _orderRepositoryMock.Object, _identityServiceMock.Object, LoggerMock.Object); - var cltToken = new System.Threading.CancellationToken(); + var cltToken = new CancellationToken(); var result = await handler.Handle(fakeOrderCmd, cltToken); //Assert diff --git a/src/Services/Ordering/Ordering.UnitTests/GlobalUsings.cs b/src/Services/Ordering/Ordering.UnitTests/GlobalUsings.cs index 02e80ea8f8..86a296fecd 100644 --- a/src/Services/Ordering/Ordering.UnitTests/GlobalUsings.cs +++ b/src/Services/Ordering/Ordering.UnitTests/GlobalUsings.cs @@ -1,20 +1,15 @@ -global using System; -global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models; -global using MediatR; +global using MediatR; +global using Microsoft.AspNetCore.Mvc; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands; -global using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency; -global using Microsoft.Extensions.Logging; -global using Moq; -global using System.Collections.Generic; -global using System.Threading.Tasks; -global using Xunit; +global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models; +global using Microsoft.eShopOnContainers.Services.Ordering.API.Controllers; global using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services; global using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate; -global using System.Threading; -global using Microsoft.AspNetCore.Mvc; -global using Microsoft.eShopOnContainers.Services.Ordering.API.Controllers; -global using System.Linq; -global using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; -global using Microsoft.eShopOnContainers.Services.Ordering.Domain.Exceptions; global using Microsoft.eShopOnContainers.Services.Ordering.Domain.Events; +global using Microsoft.eShopOnContainers.Services.Ordering.Domain.Exceptions; +global using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; +global using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency; +global using Microsoft.Extensions.Logging; +global using Moq; global using UnitTest.Ordering; +global using Xunit; diff --git a/src/Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj b/src/Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj index 6622b384e2..688e5297fb 100644 --- a/src/Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj +++ b/src/Services/Ordering/Ordering.UnitTests/Ordering.UnitTests.csproj @@ -2,6 +2,7 @@ net7.0 + enable false false false diff --git a/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs b/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs index c68ab0959a..140f7acad2 100644 --- a/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs +++ b/src/Services/Payment/Payment.API/IntegrationEvents/EventHandling/OrderStatusChangedToStockConfirmedIntegrationEventHandler.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace Microsoft.eShopOnContainers.Payment.API.IntegrationEvents.EventHandling; +namespace Microsoft.eShopOnContainers.Payment.API.IntegrationEvents.EventHandling; public class OrderStatusChangedToStockConfirmedIntegrationEventHandler : IIntegrationEventHandler @@ -16,14 +14,14 @@ public OrderStatusChangedToStockConfirmedIntegrationEventHandler( { _eventBus = eventBus; _settings = settings.Value; - _logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _logger.LogTrace("PaymentSettings: {@PaymentSettings}", _settings); } public async Task Handle(OrderStatusChangedToStockConfirmedIntegrationEvent @event) { - using (_logger.BeginScope(new List> { new ("IntegrationEventContext", @event.Id) })) + using (_logger.BeginScope(new List> { new("IntegrationEventContext", @event.Id) })) { _logger.LogInformation("Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event); diff --git a/src/Services/Services.Common/AuthorizeCheckOperationFilter.cs b/src/Services/Services.Common/AuthorizeCheckOperationFilter.cs index 21785ae161..fd7d14b3f6 100644 --- a/src/Services/Services.Common/AuthorizeCheckOperationFilter.cs +++ b/src/Services/Services.Common/AuthorizeCheckOperationFilter.cs @@ -16,8 +16,8 @@ public AuthorizeCheckOperationFilter(IConfiguration configuration) public void Apply(OpenApiOperation operation, OperationFilterContext context) { // Check for authorize attribute - var hasAuthorize = context.MethodInfo.DeclaringType.GetCustomAttributes(true).OfType().Any() || - context.MethodInfo.GetCustomAttributes(true).OfType().Any(); + var hasAuthorize = context.MethodInfo.DeclaringType?.GetCustomAttributes(true)?.OfType().Any() ?? false + || context.MethodInfo.GetCustomAttributes(true).OfType().Any(); if (!hasAuthorize) return; diff --git a/src/Services/Webhooks/Webhooks.API/Controllers/WebhookSubscriptionRequest.cs b/src/Services/Webhooks/Webhooks.API/Controllers/WebhookSubscriptionRequest.cs index 069cd22afc..d768bce26c 100644 --- a/src/Services/Webhooks/Webhooks.API/Controllers/WebhookSubscriptionRequest.cs +++ b/src/Services/Webhooks/Webhooks.API/Controllers/WebhookSubscriptionRequest.cs @@ -19,7 +19,7 @@ public IEnumerable Validate(ValidationContext validationContex yield return new ValidationResult("Url is not valid", new[] { nameof(Url) }); } - var isOk = Enum.TryParse(Event, ignoreCase: true, result: out WebhookType whtype); + var isOk = Enum.TryParse(Event, ignoreCase: true, result: out WebhookType whtype); if (!isOk) { yield return new ValidationResult($"{Event} is invalid event name", new[] { nameof(Event) }); diff --git a/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj b/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj index 4e53734c4c..bb22aa4730 100644 --- a/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj +++ b/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj @@ -2,6 +2,7 @@ net7.0 + enable true false false diff --git a/src/Tests/Services/Application.FunctionalTests/Services/IntegrationEventsScenarios.cs b/src/Tests/Services/Application.FunctionalTests/Services/IntegrationEventsScenarios.cs index f7b348631a..38a4c9b042 100644 --- a/src/Tests/Services/Application.FunctionalTests/Services/IntegrationEventsScenarios.cs +++ b/src/Tests/Services/Application.FunctionalTests/Services/IntegrationEventsScenarios.cs @@ -1,7 +1,7 @@ namespace FunctionalTests.Services; -using global::Basket.FunctionalTests.Base; -using global::Catalog.FunctionalTests; +using Basket.FunctionalTests.Base; +using Catalog.FunctionalTests; using Microsoft.eShopOnContainers.Services.Basket.API.Model; using Microsoft.eShopOnContainers.Services.Catalog.API.Model; using Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel; diff --git a/src/Web/WebMVC/Controllers/AccountController.cs b/src/Web/WebMVC/Controllers/AccountController.cs index 9f5a1dc442..7acdac9e2b 100644 --- a/src/Web/WebMVC/Controllers/AccountController.cs +++ b/src/Web/WebMVC/Controllers/AccountController.cs @@ -29,6 +29,6 @@ public async Task Signout() // https://github.com/aspnet/Mvc/issues/5853 var homeUrl = Url.Action(nameof(CatalogController.Index), "Catalog"); return new SignOutResult(OpenIdConnectDefaults.AuthenticationScheme, - new AspNetCore.Authentication.AuthenticationProperties { RedirectUri = homeUrl }); + new AuthenticationProperties { RedirectUri = homeUrl }); } } diff --git a/src/Web/WebMVC/globalusings.cs b/src/Web/WebMVC/globalusings.cs index d315d7434a..324a3df0f7 100644 --- a/src/Web/WebMVC/globalusings.cs +++ b/src/Web/WebMVC/globalusings.cs @@ -7,7 +7,6 @@ global using System.IO.Compression; global using System.Linq; global using System.Net.Http; -global using System.Net.Http.Headers; global using System.Security.Claims; global using System.Security.Principal; global using System.Text; diff --git a/src/Web/WebStatus/Program.cs b/src/Web/WebStatus/Program.cs index d9eadc5d52..9a95703b3c 100644 --- a/src/Web/WebStatus/Program.cs +++ b/src/Web/WebStatus/Program.cs @@ -1,5 +1,5 @@ var builder = WebApplication.CreateBuilder(args); -if (builder.Configuration.GetValue("UseVault", false)) +if (builder.Configuration.GetValue("UseVault", false)) { TokenCredential credential = new ClientSecretCredential( builder.Configuration["Vault:TenantId"], diff --git a/src/Web/WebhookClient/GlobalUsings.cs b/src/Web/WebhookClient/GlobalUsings.cs index bde3a0cfe9..a52fe97ae5 100644 --- a/src/Web/WebhookClient/GlobalUsings.cs +++ b/src/Web/WebhookClient/GlobalUsings.cs @@ -10,12 +10,10 @@ global using Microsoft.AspNetCore.Authentication.OpenIdConnect; global using Microsoft.AspNetCore.Authorization; global using Microsoft.AspNetCore.Builder; -global using Microsoft.AspNetCore.Hosting; global using Microsoft.AspNetCore.Http; global using Microsoft.AspNetCore.Mvc; global using Microsoft.Extensions.Configuration; global using Microsoft.Extensions.DependencyInjection; -global using Microsoft.Extensions.Hosting; global using Microsoft.Extensions.Logging; global using Microsoft.Extensions.Options; global using Services.Common; diff --git a/src/Web/WebhookClient/Pages/Error.cshtml.cs b/src/Web/WebhookClient/Pages/Error.cshtml.cs index b0ecf830d1..a2dbcea389 100644 --- a/src/Web/WebhookClient/Pages/Error.cshtml.cs +++ b/src/Web/WebhookClient/Pages/Error.cshtml.cs @@ -1,5 +1,5 @@ -using Microsoft.AspNetCore.Mvc.RazorPages; using System.Diagnostics; +using Microsoft.AspNetCore.Mvc.RazorPages; namespace WebhookClient.Pages { diff --git a/src/Web/WebhookClient/Pages/Index.cshtml.cs b/src/Web/WebhookClient/Pages/Index.cshtml.cs index 417913a20d..b0c5050202 100644 --- a/src/Web/WebhookClient/Pages/Index.cshtml.cs +++ b/src/Web/WebhookClient/Pages/Index.cshtml.cs @@ -1,8 +1,4 @@ using Microsoft.AspNetCore.Mvc.RazorPages; -using System.Collections.Generic; -using System.Threading.Tasks; -using WebhookClient.Models; -using WebhookClient.Services; namespace WebhookClient.Pages { diff --git a/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml.cs b/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml.cs index 85d2e25434..b28d12a6df 100644 --- a/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml.cs +++ b/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml.cs @@ -1,5 +1,5 @@ -using Microsoft.AspNetCore.Mvc.RazorPages; -using System.Net.Http.Formatting; +using System.Net.Http.Formatting; +using Microsoft.AspNetCore.Mvc.RazorPages; namespace WebhookClient.Pages { @@ -50,7 +50,7 @@ public async Task OnPost() Url = url, Token = Token }; - var response = await client.PostAsync(_options.WebhooksUrl + "/api/v1/webhooks", payload, new JsonMediaTypeFormatter()); + var response = await client.PostAsync(_options.WebhooksUrl + "/api/v1/webhooks", payload, new JsonMediaTypeFormatter()); if (response.IsSuccessStatusCode) {