From f04bd59ef71f6fe64f6487bc5bd6ea4305f57ac7 Mon Sep 17 00:00:00 2001 From: Almar Aubel Date: Sat, 23 Dec 2023 08:24:25 +0100 Subject: [PATCH] refactor: Use new collection initializers (#292) * refactor(): Use collection initializers * version bump stylecop to 1.2.0-beta.556 --- .../Authorization/AuthorizationChecker.cs | 2 +- src/BuildingBlocks/Domain/Entity.cs | 2 +- .../DomainEventsDispatcher.cs | 2 +- .../EventBus/InMemoryEventBus.cs | 2 +- src/Directory.Packages.props | 2 +- .../InternalCommandsModule.cs | 2 +- .../Processing/Outbox/OutboxModule.cs | 2 +- .../ArchTests/Application/ApplicationTests.cs | 6 +-- .../Tests/ArchTests/Domain/DomainTests.cs | 10 ++--- .../Tests/ArchTests/SeedWork/TestBase.cs | 2 +- .../SeedWork/DomainEventsTestHelper.cs | 2 +- ...ngCommentingConfigurationCommandHandler.cs | 2 +- ...ngCommentingConfigurationCommandHandler.cs | 2 +- .../AddMeetingCommentCommandHandler.cs | 2 +- .../AddMeetingCommentLikeCommandHandler.cs | 2 +- .../AddReplyToMeetingCommentCommandHandler.cs | 2 +- .../EditMeetingCommentCommandHandler.cs | 2 +- .../RemoveMeetingCommentCommandHandler.cs | 2 +- .../RemoveMeetingCommentLikeCommandHandler.cs | 2 +- .../Domain/MeetingGroups/MeetingGroup.cs | 3 +- .../Meetings/Domain/Meetings/Meeting.cs | 28 ++++++------ .../Processing/Outbox/OutboxModule.cs | 2 +- .../ArchTests/Application/ApplicationTests.cs | 6 +-- .../Tests/ArchTests/Domain/DomainTests.cs | 10 ++--- .../Tests/ArchTests/SeedWork/TestBase.cs | 2 +- .../Meetings/MeetingHelper.cs | 2 +- .../MeetingGroups/MeetingGroupTests.cs | 22 ++++++---- .../SeedWork/DomainEventsTestHelper.cs | 2 +- .../ActivatePriceListItemCommandHandler.cs | 2 +- ...gePriceListItemAttributesCommandHandler.cs | 2 +- .../DeactivatePriceListItemCommandHandler.cs | 2 +- .../BuySubscriptionRenewalCommandHandler.cs | 2 +- .../Payments/Domain/SeedWork/AggregateRoot.cs | 2 +- .../AggregateStore/SqlOutboxAccessor.cs | 2 +- .../AggregateStore/SqlStreamAggregateStore.cs | 8 ++-- .../Processing/Outbox/OutboxModule.cs | 2 +- .../ArchTests/Application/ApplicationTests.cs | 6 +-- .../Tests/ArchTests/Domain/DomainTests.cs | 15 +++---- .../Tests/ArchTests/SeedWork/TestBase.cs | 2 +- .../SeedWork/DomainEventsTestHelper.cs | 2 +- .../SubscriptionPaymentTestsBase.cs | 2 +- .../SubscriptionRenewalPaymentTestsBase.cs | 2 +- .../AuthenticateCommandHandler.cs | 8 ++-- ...uthenticatedUserPermissionsQueryHandler.cs | 2 +- src/Modules/UserAccess/Domain/Users/User.cs | 3 +- .../Processing/Outbox/OutboxModule.cs | 2 +- .../ArchTests/Application/ApplicationTests.cs | 6 +-- .../Tests/ArchTests/Domain/DomainTests.cs | 10 ++--- .../Tests/ArchTests/SeedWork/TestBase.cs | 2 +- .../SeedWork/DomainEventsTestHelper.cs | 2 +- src/Tests/ArchTests/Api/ApiTests.cs | 20 ++------- src/Tests/ArchTests/Modules/ModuleTests.cs | 44 +++++++------------ src/Tests/ArchTests/SeedWork/TestBase.cs | 2 +- src/Tests/SUT/TestCases/CreateMeeting.cs | 2 +- 54 files changed, 129 insertions(+), 152 deletions(-) diff --git a/src/API/CompanyName.MyMeetings.API/Configuration/Authorization/AuthorizationChecker.cs b/src/API/CompanyName.MyMeetings.API/Configuration/Authorization/AuthorizationChecker.cs index 936e7d6d3..0f4d559d1 100644 --- a/src/API/CompanyName.MyMeetings.API/Configuration/Authorization/AuthorizationChecker.cs +++ b/src/API/CompanyName.MyMeetings.API/Configuration/Authorization/AuthorizationChecker.cs @@ -11,7 +11,7 @@ public static void CheckAllEndpoints() var assembly = typeof(Startup).Assembly; var allControllerTypes = assembly.GetTypes().Where(x => x.IsSubclassOf(typeof(ControllerBase))); - var notProtectedActionMethods = new List(); + List notProtectedActionMethods = []; foreach (var controllerType in allControllerTypes) { var controllerHasPermissionAttribute = controllerType.GetCustomAttribute(); diff --git a/src/BuildingBlocks/Domain/Entity.cs b/src/BuildingBlocks/Domain/Entity.cs index bfc9c7db1..a0158fa3d 100644 --- a/src/BuildingBlocks/Domain/Entity.cs +++ b/src/BuildingBlocks/Domain/Entity.cs @@ -20,7 +20,7 @@ public void ClearDomainEvents() /// Domain event. protected void AddDomainEvent(IDomainEvent domainEvent) { - _domainEvents ??= new List(); + _domainEvents ??= []; this._domainEvents.Add(domainEvent); } diff --git a/src/BuildingBlocks/Infrastructure/DomainEventsDispatching/DomainEventsDispatcher.cs b/src/BuildingBlocks/Infrastructure/DomainEventsDispatching/DomainEventsDispatcher.cs index f1ab0ac27..cc98577a7 100644 --- a/src/BuildingBlocks/Infrastructure/DomainEventsDispatching/DomainEventsDispatcher.cs +++ b/src/BuildingBlocks/Infrastructure/DomainEventsDispatching/DomainEventsDispatcher.cs @@ -39,7 +39,7 @@ public async Task DispatchEventsAsync() { var domainEvents = _domainEventsProvider.GetAllDomainEvents(); - var domainEventNotifications = new List>(); + List> domainEventNotifications = []; foreach (var domainEvent in domainEvents) { Type domainEvenNotificationType = typeof(IDomainEventNotification<>); diff --git a/src/BuildingBlocks/Infrastructure/EventBus/InMemoryEventBus.cs b/src/BuildingBlocks/Infrastructure/EventBus/InMemoryEventBus.cs index 64d4b0ba1..351426cca 100644 --- a/src/BuildingBlocks/Infrastructure/EventBus/InMemoryEventBus.cs +++ b/src/BuildingBlocks/Infrastructure/EventBus/InMemoryEventBus.cs @@ -28,7 +28,7 @@ public void Subscribe(IIntegrationEventHandler handler) } else { - _handlersDictionary.Add(eventType, new List { handler }); + _handlersDictionary.Add(eventType, [handler]); } } } diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 07ff07dc6..a686a92dc 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -1,6 +1,6 @@  - + diff --git a/src/Modules/Administration/Infrastructure/Configuration/Processing/InternalCommands/InternalCommandsModule.cs b/src/Modules/Administration/Infrastructure/Configuration/Processing/InternalCommands/InternalCommandsModule.cs index e30959ab0..94685fe1c 100644 --- a/src/Modules/Administration/Infrastructure/Configuration/Processing/InternalCommands/InternalCommandsModule.cs +++ b/src/Modules/Administration/Infrastructure/Configuration/Processing/InternalCommands/InternalCommandsModule.cs @@ -37,7 +37,7 @@ private void CheckMappings() x.BaseType == typeof(InternalCommandBase))) .ToList(); - List notMappedInternalCommands = new List(); + List notMappedInternalCommands = []; foreach (var internalCommand in internalCommands) { _internalCommandsMap.TryGetBySecond(internalCommand, out var name); diff --git a/src/Modules/Administration/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs b/src/Modules/Administration/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs index 05d780611..29164ddb1 100644 --- a/src/Modules/Administration/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs +++ b/src/Modules/Administration/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs @@ -40,7 +40,7 @@ private void CheckMappings() .Where(x => x.GetInterfaces().Contains(typeof(IDomainEventNotification))) .ToList(); - List notMappedNotifications = new List(); + List notMappedNotifications = []; foreach (var domainEventNotification in domainEventNotifications) { _domainNotificationsMap.TryGetBySecond(domainEventNotification, out var name); diff --git a/src/Modules/Administration/Tests/ArchTests/Application/ApplicationTests.cs b/src/Modules/Administration/Tests/ArchTests/Application/ApplicationTests.cs index d7e0387a6..b680c5e7a 100644 --- a/src/Modules/Administration/Tests/ArchTests/Application/ApplicationTests.cs +++ b/src/Modules/Administration/Tests/ArchTests/Application/ApplicationTests.cs @@ -122,7 +122,7 @@ public void InternalCommand_Should_Have_JsonConstructorAttribute() .Inherit(typeof(InternalCommandBase<>)) .GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { @@ -155,7 +155,7 @@ public void MediatR_RequestHandler_Should_NotBe_Used_Directly() .Should().ImplementInterface(typeof(IRequestHandler<>)) .GetTypes(); - List failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { bool isCommandHandler = type.GetInterfaces().Any(x => @@ -184,7 +184,7 @@ public void Command_With_Result_Should_Not_Return_Unit() .That().ImplementInterface(commandWithResultHandlerType) .GetTypes().ToList(); - var failingTypes = new List(); + List failingTypes = []; foreach (Type type in types) { Type interfaceType = type.GetInterface(commandWithResultHandlerType.Name); diff --git a/src/Modules/Administration/Tests/ArchTests/Domain/DomainTests.cs b/src/Modules/Administration/Tests/ArchTests/Domain/DomainTests.cs index e32327362..56bf93624 100644 --- a/src/Modules/Administration/Tests/ArchTests/Domain/DomainTests.cs +++ b/src/Modules/Administration/Tests/ArchTests/Domain/DomainTests.cs @@ -45,7 +45,7 @@ public void Entity_Which_Is_Not_Aggregate_Root_Cannot_Have_Public_Members() BindingFlags.Instance | BindingFlags.Static; - var failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { var publicFields = type.GetFields(bindingFlags); @@ -75,7 +75,7 @@ public void Entity_Cannot_Have_Reference_To_Other_AggregateRoot() BindingFlags.NonPublic | BindingFlags.Instance; - var failingTypes = new List(); + List failingTypes = []; foreach (var type in entityTypes) { var fields = type.GetFields(bindingFlags); @@ -112,7 +112,7 @@ public void Entity_Should_Have_Parameterless_Private_Constructor() .That() .Inherit(typeof(Entity)).GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var entityType in entityTypes) { bool hasPrivateParameterlessConstructor = false; @@ -144,7 +144,7 @@ public void Domain_Object_Should_Have_Only_Private_Constructors() .Inherit(typeof(ValueObject)) .GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var domainObjectType in domainObjectTypes) { var constructors = domainObjectType.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); @@ -167,7 +167,7 @@ public void ValueObject_Should_Have_Private_Constructor_With_Parameters_For_His_ .That() .Inherit(typeof(ValueObject)).GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var entityType in valueObjects) { bool hasExpectedConstructor = false; diff --git a/src/Modules/Administration/Tests/ArchTests/SeedWork/TestBase.cs b/src/Modules/Administration/Tests/ArchTests/SeedWork/TestBase.cs index 1f056cab8..5a2ebfd10 100644 --- a/src/Modules/Administration/Tests/ArchTests/SeedWork/TestBase.cs +++ b/src/Modules/Administration/Tests/ArchTests/SeedWork/TestBase.cs @@ -17,7 +17,7 @@ public abstract class TestBase protected static void AssertAreImmutable(IEnumerable types) { - IList failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { if (type.GetFields().Any(x => !x.IsInitOnly) || type.GetProperties().Any(x => x.CanWrite)) diff --git a/src/Modules/Administration/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs b/src/Modules/Administration/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs index 6d3fc55d7..0d5b3ca5d 100644 --- a/src/Modules/Administration/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs +++ b/src/Modules/Administration/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs @@ -8,7 +8,7 @@ public class DomainEventsTestHelper { public static List GetAllDomainEvents(Entity aggregate) { - List domainEvents = new List(); + List domainEvents = []; if (aggregate.DomainEvents != null) { diff --git a/src/Modules/Meetings/Application/MeetingCommentingConfigurations/DisableMeetingCommentingConfiguration/DisableMeetingCommentingConfigurationCommandHandler.cs b/src/Modules/Meetings/Application/MeetingCommentingConfigurations/DisableMeetingCommentingConfiguration/DisableMeetingCommentingConfigurationCommandHandler.cs index f4906ff95..bbecde706 100644 --- a/src/Modules/Meetings/Application/MeetingCommentingConfigurations/DisableMeetingCommentingConfiguration/DisableMeetingCommentingConfigurationCommandHandler.cs +++ b/src/Modules/Meetings/Application/MeetingCommentingConfigurations/DisableMeetingCommentingConfiguration/DisableMeetingCommentingConfigurationCommandHandler.cs @@ -31,7 +31,7 @@ public async Task Handle(DisableMeetingCommentingConfigurationCommand command, C var meetingCommentingConfiguration = await _meetingCommentingConfigurationRepository.GetByMeetingIdAsync(new MeetingId(command.MeetingId)); if (meetingCommentingConfiguration == null) { - throw new InvalidCommandException(new List { "Meeting commenting configuration for disabling commenting must exist." }); + throw new InvalidCommandException(["Meeting commenting configuration for disabling commenting must exist."]); } var meeting = await _meetingRepository.GetByIdAsync(new MeetingId(command.MeetingId)); diff --git a/src/Modules/Meetings/Application/MeetingCommentingConfigurations/EnableMeetingCommentingConfiguration/EnableMeetingCommentingConfigurationCommandHandler.cs b/src/Modules/Meetings/Application/MeetingCommentingConfigurations/EnableMeetingCommentingConfiguration/EnableMeetingCommentingConfigurationCommandHandler.cs index 1b11c2336..fe6a8d848 100644 --- a/src/Modules/Meetings/Application/MeetingCommentingConfigurations/EnableMeetingCommentingConfiguration/EnableMeetingCommentingConfigurationCommandHandler.cs +++ b/src/Modules/Meetings/Application/MeetingCommentingConfigurations/EnableMeetingCommentingConfiguration/EnableMeetingCommentingConfigurationCommandHandler.cs @@ -31,7 +31,7 @@ public async Task Handle(EnableMeetingCommentingConfigurationCommand command, Ca var meetingCommentingConfiguration = await _meetingCommentingConfigurationRepository.GetByMeetingIdAsync(new MeetingId(command.MeetingId)); if (meetingCommentingConfiguration == null) { - throw new InvalidCommandException(new List { "Meeting commenting configuration for enabling commenting must exist." }); + throw new InvalidCommandException(["Meeting commenting configuration for enabling commenting must exist."]); } var meeting = await _meetingRepository.GetByIdAsync(new MeetingId(command.MeetingId)); diff --git a/src/Modules/Meetings/Application/MeetingComments/AddMeetingComment/AddMeetingCommentCommandHandler.cs b/src/Modules/Meetings/Application/MeetingComments/AddMeetingComment/AddMeetingCommentCommandHandler.cs index d8fdaf791..6ec4e32eb 100644 --- a/src/Modules/Meetings/Application/MeetingComments/AddMeetingComment/AddMeetingCommentCommandHandler.cs +++ b/src/Modules/Meetings/Application/MeetingComments/AddMeetingComment/AddMeetingCommentCommandHandler.cs @@ -35,7 +35,7 @@ public async Task Handle(AddMeetingCommentCommand command, CancellationTok var meeting = await _meetingRepository.GetByIdAsync(new MeetingId(command.MeetingId)); if (meeting == null) { - throw new InvalidCommandException(new List { "Meeting for adding comment must exist." }); + throw new InvalidCommandException(["Meeting for adding comment must exist."]); } var meetingGroup = await _meetingGroupRepository.GetByIdAsync(meeting.GetMeetingGroupId()); diff --git a/src/Modules/Meetings/Application/MeetingComments/AddMeetingCommentLike/AddMeetingCommentLikeCommandHandler.cs b/src/Modules/Meetings/Application/MeetingComments/AddMeetingCommentLike/AddMeetingCommentLikeCommandHandler.cs index 083f2c1cf..e1d59a57d 100644 --- a/src/Modules/Meetings/Application/MeetingComments/AddMeetingCommentLike/AddMeetingCommentLikeCommandHandler.cs +++ b/src/Modules/Meetings/Application/MeetingComments/AddMeetingCommentLike/AddMeetingCommentLikeCommandHandler.cs @@ -32,7 +32,7 @@ public async Task Handle(AddMeetingCommentLikeCommand request, CancellationToken var meetingComment = await _meetingCommentRepository.GetByIdAsync(new MeetingCommentId(request.MeetingCommentId)); if (meetingComment == null) { - throw new InvalidCommandException(new List { "To add like the comment must exist." }); + throw new InvalidCommandException(["To add like the comment must exist."]); } var connection = _sqlConnectionFactory.GetOpenConnection(); diff --git a/src/Modules/Meetings/Application/MeetingComments/AddMeetingCommentReply/AddReplyToMeetingCommentCommandHandler.cs b/src/Modules/Meetings/Application/MeetingComments/AddMeetingCommentReply/AddReplyToMeetingCommentCommandHandler.cs index 567c58544..4322c905f 100644 --- a/src/Modules/Meetings/Application/MeetingComments/AddMeetingCommentReply/AddReplyToMeetingCommentCommandHandler.cs +++ b/src/Modules/Meetings/Application/MeetingComments/AddMeetingCommentReply/AddReplyToMeetingCommentCommandHandler.cs @@ -30,7 +30,7 @@ public async Task Handle(AddReplyToMeetingCommentCommand command, Cancella var meetingComment = await _meetingCommentRepository.GetByIdAsync(new MeetingCommentId(command.InReplyToCommentId)); if (meetingComment == null) { - throw new InvalidCommandException(new List { "To create reply the comment must exist." }); + throw new InvalidCommandException(["To create reply the comment must exist."]); } var meeting = await _meetingRepository.GetByIdAsync(meetingComment.GetMeetingId()); diff --git a/src/Modules/Meetings/Application/MeetingComments/EditMeetingComment/EditMeetingCommentCommandHandler.cs b/src/Modules/Meetings/Application/MeetingComments/EditMeetingComment/EditMeetingCommentCommandHandler.cs index 274537445..e594d5be4 100644 --- a/src/Modules/Meetings/Application/MeetingComments/EditMeetingComment/EditMeetingCommentCommandHandler.cs +++ b/src/Modules/Meetings/Application/MeetingComments/EditMeetingComment/EditMeetingCommentCommandHandler.cs @@ -27,7 +27,7 @@ public async Task Handle(EditMeetingCommentCommand command, CancellationToken ca var meetingComment = await _meetingCommentRepository.GetByIdAsync(new MeetingCommentId(command.MeetingCommentId)); if (meetingComment == null) { - throw new InvalidCommandException(new List { "Meeting comment for editing must exist." }); + throw new InvalidCommandException(["Meeting comment for editing must exist."]); } var meetingCommentingConfiguration = await _meetingCommentingConfigurationRepository.GetByMeetingIdAsync(meetingComment.GetMeetingId()); diff --git a/src/Modules/Meetings/Application/MeetingComments/RemoveMeetingComment/RemoveMeetingCommentCommandHandler.cs b/src/Modules/Meetings/Application/MeetingComments/RemoveMeetingComment/RemoveMeetingCommentCommandHandler.cs index 69fd622a8..6007609d3 100644 --- a/src/Modules/Meetings/Application/MeetingComments/RemoveMeetingComment/RemoveMeetingCommentCommandHandler.cs +++ b/src/Modules/Meetings/Application/MeetingComments/RemoveMeetingComment/RemoveMeetingCommentCommandHandler.cs @@ -27,7 +27,7 @@ public async Task Handle(RemoveMeetingCommentCommand command, CancellationToken var meetingComment = await _meetingCommentRepository.GetByIdAsync(new MeetingCommentId(command.MeetingCommentId)); if (meetingComment == null) { - throw new InvalidCommandException(new List { "Meeting comment for removing must exist." }); + throw new InvalidCommandException(["Meeting comment for removing must exist."]); } var meeting = await _meetingRepository.GetByIdAsync(meetingComment.GetMeetingId()); diff --git a/src/Modules/Meetings/Application/MeetingComments/RemoveMeetingCommentLike/RemoveMeetingCommentLikeCommandHandler.cs b/src/Modules/Meetings/Application/MeetingComments/RemoveMeetingCommentLike/RemoveMeetingCommentLikeCommandHandler.cs index 0f48d150b..b6bf7b136 100644 --- a/src/Modules/Meetings/Application/MeetingComments/RemoveMeetingCommentLike/RemoveMeetingCommentLikeCommandHandler.cs +++ b/src/Modules/Meetings/Application/MeetingComments/RemoveMeetingCommentLike/RemoveMeetingCommentLikeCommandHandler.cs @@ -22,7 +22,7 @@ public async Task Handle(RemoveMeetingCommentLikeCommand command, CancellationTo var commentLike = await _meetingMemberCommentLikesRepository.GetAsync(_memberContext.MemberId, new MeetingCommentId(command.MeetingCommentId)); if (commentLike == null) { - throw new InvalidCommandException(new List { "Meeting comment like for removing must exist." }); + throw new InvalidCommandException(["Meeting comment like for removing must exist."]); } commentLike.Remove(); diff --git a/src/Modules/Meetings/Domain/MeetingGroups/MeetingGroup.cs b/src/Modules/Meetings/Domain/MeetingGroups/MeetingGroup.cs index d6a9c2111..160513058 100644 --- a/src/Modules/Meetings/Domain/MeetingGroups/MeetingGroup.cs +++ b/src/Modules/Meetings/Domain/MeetingGroups/MeetingGroup.cs @@ -52,8 +52,7 @@ private MeetingGroup(MeetingGroupProposalId meetingGroupProposalId, string name, this.AddDomainEvent(new MeetingGroupCreatedDomainEvent(this.Id, creatorId)); - this._members = new List(); - this._members.Add(MeetingGroupMember.CreateNew(this.Id, this._creatorId, MeetingGroupMemberRole.Organizer)); + this._members = [MeetingGroupMember.CreateNew(this.Id, this._creatorId, MeetingGroupMemberRole.Organizer)]; } public void EditGeneralAttributes(string name, string description, MeetingGroupLocation location) diff --git a/src/Modules/Meetings/Domain/Meetings/Meeting.cs b/src/Modules/Meetings/Domain/Meetings/Meeting.cs index 98a27e764..4c02fe77a 100644 --- a/src/Modules/Meetings/Domain/Meetings/Meeting.cs +++ b/src/Modules/Meetings/Domain/Meetings/Meeting.cs @@ -11,9 +11,15 @@ namespace CompanyName.MyMeetings.Modules.Meetings.Domain.Meetings { public class Meeting : Entity, IAggregateRoot { - public MeetingId Id { get; private set; } + private readonly MeetingGroupId _meetingGroupId; + + private readonly List _attendees; + + private readonly List _notAttendees; + + private readonly List _waitlistMembers; - private MeetingGroupId _meetingGroupId; + public MeetingId Id { get; private set; } private string _title; @@ -23,12 +29,6 @@ public class Meeting : Entity, IAggregateRoot private MeetingLocation _location; - private List _attendees; - - private List _notAttendees; - - private List _waitlistMembers; - private MeetingLimits _meetingLimits; private Term _rsvpTerm; @@ -51,9 +51,9 @@ public class Meeting : Entity, IAggregateRoot private Meeting() { - _attendees = new List(); - _notAttendees = new List(); - _waitlistMembers = new List(); + _attendees = []; + _notAttendees = []; + _waitlistMembers = []; } internal static Meeting CreateNew( @@ -106,9 +106,9 @@ private Meeting( _creatorId = creatorId; _createDate = SystemClock.Now; - _attendees = new List(); - _notAttendees = new List(); - _waitlistMembers = new List(); + _attendees = []; + _notAttendees = []; + _waitlistMembers = []; this.AddDomainEvent(new MeetingCreatedDomainEvent(this.Id)); var rsvpDate = SystemClock.Now; diff --git a/src/Modules/Meetings/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs b/src/Modules/Meetings/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs index a8f00ab49..9e175c1f5 100644 --- a/src/Modules/Meetings/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs +++ b/src/Modules/Meetings/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs @@ -40,7 +40,7 @@ private void CheckMappings() .Where(x => x.GetInterfaces().Contains(typeof(IDomainEventNotification))) .ToList(); - List notMappedNotifications = new List(); + List notMappedNotifications = []; foreach (var domainEventNotification in domainEventNotifications) { _domainNotificationsMap.TryGetBySecond(domainEventNotification, out var name); diff --git a/src/Modules/Meetings/Tests/ArchTests/Application/ApplicationTests.cs b/src/Modules/Meetings/Tests/ArchTests/Application/ApplicationTests.cs index bf97cbc2a..aff28e81d 100644 --- a/src/Modules/Meetings/Tests/ArchTests/Application/ApplicationTests.cs +++ b/src/Modules/Meetings/Tests/ArchTests/Application/ApplicationTests.cs @@ -122,7 +122,7 @@ public void InternalCommand_Should_Have_Constructor_With_JsonConstructorAttribut .Inherit(typeof(InternalCommandBase<>)) .GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { @@ -155,7 +155,7 @@ public void MediatR_RequestHandler_Should_NotBe_Used_Directly() .Should().ImplementInterface(typeof(IRequestHandler<>)) .GetTypes(); - List failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { bool isCommandHandler = type.GetInterfaces().Any(x => @@ -184,7 +184,7 @@ public void Command_With_Result_Should_Not_Return_Unit() .That().ImplementInterface(commandWithResultHandlerType) .GetTypes().ToList(); - var failingTypes = new List(); + List failingTypes = []; foreach (Type type in types) { Type interfaceType = type.GetInterface(commandWithResultHandlerType.Name); diff --git a/src/Modules/Meetings/Tests/ArchTests/Domain/DomainTests.cs b/src/Modules/Meetings/Tests/ArchTests/Domain/DomainTests.cs index e10ec8ff7..ae76fed8e 100644 --- a/src/Modules/Meetings/Tests/ArchTests/Domain/DomainTests.cs +++ b/src/Modules/Meetings/Tests/ArchTests/Domain/DomainTests.cs @@ -45,7 +45,7 @@ public void Entity_Which_Is_Not_Aggregate_Root_Cannot_Have_Public_Members() BindingFlags.Instance | BindingFlags.Static; - var failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { var publicFields = type.GetFields(bindingFlags); @@ -75,7 +75,7 @@ public void Entity_Cannot_Have_Reference_To_Other_AggregateRoot() BindingFlags.NonPublic | BindingFlags.Instance; - var failingTypes = new List(); + List failingTypes = []; foreach (var type in entityTypes) { var fields = type.GetFields(bindingFlags); @@ -112,7 +112,7 @@ public void Entity_Should_Have_Parameterless_Private_Constructor() .That() .Inherit(typeof(Entity)).GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var entityType in entityTypes) { bool hasPrivateParameterlessConstructor = false; @@ -144,7 +144,7 @@ public void Domain_Object_Should_Have_Only_Private_Constructors() .Inherit(typeof(ValueObject)) .GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var domainObjectType in domainObjectTypes) { var constructors = domainObjectType.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); @@ -167,7 +167,7 @@ public void ValueObject_Should_Have_Private_Constructor_With_Parameters_For_His_ .That() .Inherit(typeof(ValueObject)).GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var entityType in valueObjects) { bool hasExpectedConstructor = false; diff --git a/src/Modules/Meetings/Tests/ArchTests/SeedWork/TestBase.cs b/src/Modules/Meetings/Tests/ArchTests/SeedWork/TestBase.cs index 45dd0efc3..85e76109c 100644 --- a/src/Modules/Meetings/Tests/ArchTests/SeedWork/TestBase.cs +++ b/src/Modules/Meetings/Tests/ArchTests/SeedWork/TestBase.cs @@ -17,7 +17,7 @@ public abstract class TestBase protected static void AssertAreImmutable(IEnumerable types) { - IList failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { if (type.GetFields().Any(x => !x.IsInitOnly) || type.GetProperties().Any(x => x.CanWrite)) diff --git a/src/Modules/Meetings/Tests/IntegrationTests/Meetings/MeetingHelper.cs b/src/Modules/Meetings/Tests/IntegrationTests/Meetings/MeetingHelper.cs index 26091b5f0..9d173a5ec 100644 --- a/src/Modules/Meetings/Tests/IntegrationTests/Meetings/MeetingHelper.cs +++ b/src/Modules/Meetings/Tests/IntegrationTests/Meetings/MeetingHelper.cs @@ -54,7 +54,7 @@ await meetingsModule.ExecuteCommandAsync( null, null, null, - new List { executionContext.UserId })); + [executionContext.UserId])); return meetingId; } diff --git a/src/Modules/Meetings/Tests/UnitTests/MeetingGroups/MeetingGroupTests.cs b/src/Modules/Meetings/Tests/UnitTests/MeetingGroups/MeetingGroupTests.cs index 9252903d3..8cdda3ab4 100644 --- a/src/Modules/Meetings/Tests/UnitTests/MeetingGroups/MeetingGroupTests.cs +++ b/src/Modules/Meetings/Tests/UnitTests/MeetingGroups/MeetingGroupTests.cs @@ -119,7 +119,7 @@ public void CreateMeeting_WhenGroupIsNotPayed_IsNotPossible() 0, Term.NoTerm, MoneyValue.Undefined, - new List(), + [], creatorId); }); } @@ -142,7 +142,7 @@ public void CreateMeeting_WhenCreatorIsMemberOfGroupAndHostsAreNotDefined_IsSucc 0, Term.NoTerm, MoneyValue.Undefined, - new List(), + [], definedProposalMemberId); AssertPublishedDomainEvent(meeting); @@ -156,9 +156,11 @@ public void CreateMeeting_WhenHostsAreDefinedAndTheyAreGroupMembers_DefinedHosts meetingGroup.SetExpirationDate(DateTime.UtcNow.AddDays(1)); var hostOne = new MemberId(Guid.NewGuid()); var hostTwo = new MemberId(Guid.NewGuid()); - List hosts = new List(); - hosts.Add(hostOne); - hosts.Add(hostTwo); + List hosts = + [ + hostOne, + hostTwo + ]; meetingGroup.JoinToGroupMember(hostOne); meetingGroup.JoinToGroupMember(hostTwo); @@ -193,9 +195,11 @@ public void CreateMeeting_WhenHostsAreDefinedAndTheyAreNotGroupMembers_BreaksMee meetingGroup.SetExpirationDate(DateTime.UtcNow.AddDays(1)); var hostOne = new MemberId(Guid.NewGuid()); var hostTwo = new MemberId(Guid.NewGuid()); - List hosts = new List(); - hosts.Add(hostOne); - hosts.Add(hostTwo); + List hosts = + [ + hostOne, + hostTwo + ]; AssertBrokenRule(() => { @@ -236,7 +240,7 @@ public void CreateMeeting_WhenCreatorIsNotMemberOfGroup_BreaksMeetingHostMustBeA 0, Term.NoTerm, MoneyValue.Undefined, - new List(), + [], creatorId); }); } diff --git a/src/Modules/Meetings/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs b/src/Modules/Meetings/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs index d7409090d..def7502fc 100644 --- a/src/Modules/Meetings/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs +++ b/src/Modules/Meetings/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs @@ -8,7 +8,7 @@ public class DomainEventsTestHelper { public static List GetAllDomainEvents(Entity aggregate) { - List domainEvents = new List(); + List domainEvents = []; if (aggregate.DomainEvents != null) { diff --git a/src/Modules/Payments/Application/PriceListItems/ActivatePriceListItem/ActivatePriceListItemCommandHandler.cs b/src/Modules/Payments/Application/PriceListItems/ActivatePriceListItem/ActivatePriceListItemCommandHandler.cs index ec5f77141..b271454dc 100644 --- a/src/Modules/Payments/Application/PriceListItems/ActivatePriceListItem/ActivatePriceListItemCommandHandler.cs +++ b/src/Modules/Payments/Application/PriceListItems/ActivatePriceListItem/ActivatePriceListItemCommandHandler.cs @@ -20,7 +20,7 @@ public async Task Handle(ActivatePriceListItemCommand command, CancellationToken if (priceListItem == null) { - throw new InvalidCommandException(new List { "Pricelist item for activation must exist." }); + throw new InvalidCommandException(["Pricelist item for activation must exist."]); } priceListItem.Activate(); diff --git a/src/Modules/Payments/Application/PriceListItems/ChangePriceListItemAttributes/ChangePriceListItemAttributesCommandHandler.cs b/src/Modules/Payments/Application/PriceListItems/ChangePriceListItemAttributes/ChangePriceListItemAttributesCommandHandler.cs index 303f26a46..f47c24019 100644 --- a/src/Modules/Payments/Application/PriceListItems/ChangePriceListItemAttributes/ChangePriceListItemAttributesCommandHandler.cs +++ b/src/Modules/Payments/Application/PriceListItems/ChangePriceListItemAttributes/ChangePriceListItemAttributesCommandHandler.cs @@ -21,7 +21,7 @@ public async Task Handle(ChangePriceListItemAttributesCommand command, Cancellat if (priceListItem == null) { - throw new InvalidCommandException(new List { "Pricelist item for changing must exist." }); + throw new InvalidCommandException(["Pricelist item for changing must exist."]); } priceListItem.ChangeAttributes( diff --git a/src/Modules/Payments/Application/PriceListItems/DeactivatePriceListItem/DeactivatePriceListItemCommandHandler.cs b/src/Modules/Payments/Application/PriceListItems/DeactivatePriceListItem/DeactivatePriceListItemCommandHandler.cs index de51e13bb..320c4fede 100644 --- a/src/Modules/Payments/Application/PriceListItems/DeactivatePriceListItem/DeactivatePriceListItemCommandHandler.cs +++ b/src/Modules/Payments/Application/PriceListItems/DeactivatePriceListItem/DeactivatePriceListItemCommandHandler.cs @@ -20,7 +20,7 @@ public async Task Handle(DeactivatePriceListItemCommand command, CancellationTok if (priceListItem == null) { - throw new InvalidCommandException(new List { "Pricelist item for deactivation must exist." }); + throw new InvalidCommandException(["Pricelist item for deactivation must exist."]); } priceListItem.Deactivate(); diff --git a/src/Modules/Payments/Application/Subscriptions/BuySubscriptionRenewal/BuySubscriptionRenewalCommandHandler.cs b/src/Modules/Payments/Application/Subscriptions/BuySubscriptionRenewal/BuySubscriptionRenewalCommandHandler.cs index b3418fee7..2c0d5fbc2 100644 --- a/src/Modules/Payments/Application/Subscriptions/BuySubscriptionRenewal/BuySubscriptionRenewalCommandHandler.cs +++ b/src/Modules/Payments/Application/Subscriptions/BuySubscriptionRenewal/BuySubscriptionRenewalCommandHandler.cs @@ -37,7 +37,7 @@ public async Task Handle(BuySubscriptionRenewalCommand command, Cancellati if (subscription == null) { - throw new InvalidCommandException(new List { "Subscription for renewal must exist." }); + throw new InvalidCommandException(["Subscription for renewal must exist."]); } var subscriptionRenewalPayment = SubscriptionRenewalPayment.Buy( diff --git a/src/Modules/Payments/Domain/SeedWork/AggregateRoot.cs b/src/Modules/Payments/Domain/SeedWork/AggregateRoot.cs index a34987804..5e8047db1 100644 --- a/src/Modules/Payments/Domain/SeedWork/AggregateRoot.cs +++ b/src/Modules/Payments/Domain/SeedWork/AggregateRoot.cs @@ -19,7 +19,7 @@ protected void AddDomainEvent(IDomainEvent @event) protected AggregateRoot() { - _domainEvents = new List(); + _domainEvents = []; Version = -1; } diff --git a/src/Modules/Payments/Infrastructure/AggregateStore/SqlOutboxAccessor.cs b/src/Modules/Payments/Infrastructure/AggregateStore/SqlOutboxAccessor.cs index afd9d5096..528e2df21 100644 --- a/src/Modules/Payments/Infrastructure/AggregateStore/SqlOutboxAccessor.cs +++ b/src/Modules/Payments/Infrastructure/AggregateStore/SqlOutboxAccessor.cs @@ -13,7 +13,7 @@ public class SqlOutboxAccessor : IOutbox public SqlOutboxAccessor(ISqlConnectionFactory sqlConnectionFactory) { _sqlConnectionFactory = sqlConnectionFactory; - _messages = new List(); + _messages = []; } public void Add(OutboxMessage message) diff --git a/src/Modules/Payments/Infrastructure/AggregateStore/SqlStreamAggregateStore.cs b/src/Modules/Payments/Infrastructure/AggregateStore/SqlStreamAggregateStore.cs index 7afef2d28..091ee780e 100644 --- a/src/Modules/Payments/Infrastructure/AggregateStore/SqlStreamAggregateStore.cs +++ b/src/Modules/Payments/Infrastructure/AggregateStore/SqlStreamAggregateStore.cs @@ -19,9 +19,9 @@ public class SqlStreamAggregateStore : IAggregateStore public SqlStreamAggregateStore( ISqlConnectionFactory sqlConnectionFactory, IStreamStore streamStore) { - _appendedChanges = new List(); + _appendedChanges = []; - _aggregatesToSave = new List(); + _aggregatesToSave = []; _streamStore = streamStore; } @@ -43,7 +43,7 @@ public async Task Load(AggregateId aggregateId) { var streamId = GetStreamId(aggregateId); - IList domainEvents = new List(); + List domainEvents = []; ReadStreamPage readStreamPage; int position = StreamVersion.Start; int take = 100; @@ -109,7 +109,7 @@ private NewStreamMessage[] CreateStreamMessages( T aggregate) where T : AggregateRoot { - List newStreamMessages = new List(); + List newStreamMessages = []; var domainEvents = aggregate.GetDomainEvents(); diff --git a/src/Modules/Payments/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs b/src/Modules/Payments/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs index 224ab25f0..33a8c340a 100644 --- a/src/Modules/Payments/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs +++ b/src/Modules/Payments/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs @@ -39,7 +39,7 @@ private void CheckMappings() .Where(x => x.GetInterfaces().Contains(typeof(IDomainEventNotification))) .ToList(); - List notMappedNotifications = new List(); + List notMappedNotifications = []; foreach (var domainEventNotification in domainEventNotifications) { _domainNotificationsMap.TryGetBySecond(domainEventNotification, out var name); diff --git a/src/Modules/Payments/Tests/ArchTests/Application/ApplicationTests.cs b/src/Modules/Payments/Tests/ArchTests/Application/ApplicationTests.cs index a9939eea6..61b053ad5 100644 --- a/src/Modules/Payments/Tests/ArchTests/Application/ApplicationTests.cs +++ b/src/Modules/Payments/Tests/ArchTests/Application/ApplicationTests.cs @@ -122,7 +122,7 @@ public void InternalCommand_Should_Have_JsonConstructorAttribute() .Inherit(typeof(InternalCommandBase<>)) .GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { @@ -155,7 +155,7 @@ public void MediatR_RequestHandler_Should_NotBe_Used_Directly() .Should().ImplementInterface(typeof(IRequestHandler<>)) .GetTypes(); - List failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { bool isCommandHandler = type.GetInterfaces().Any(x => @@ -184,7 +184,7 @@ public void Command_With_Result_Should_Not_Return_Unit() .That().ImplementInterface(commandWithResultHandlerType) .GetTypes().ToList(); - var failingTypes = new List(); + List failingTypes = []; foreach (Type type in types) { Type interfaceType = type.GetInterface(commandWithResultHandlerType.Name); diff --git a/src/Modules/Payments/Tests/ArchTests/Domain/DomainTests.cs b/src/Modules/Payments/Tests/ArchTests/Domain/DomainTests.cs index d635c9e30..c7d445d96 100644 --- a/src/Modules/Payments/Tests/ArchTests/Domain/DomainTests.cs +++ b/src/Modules/Payments/Tests/ArchTests/Domain/DomainTests.cs @@ -46,7 +46,7 @@ public void Entity_Which_Is_Not_Aggregate_Root_Cannot_Have_Public_Members() BindingFlags.Instance | BindingFlags.Static; - var failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { var publicFields = type.GetFields(bindingFlags); @@ -76,7 +76,7 @@ public void Entity_Cannot_Have_Reference_To_Other_AggregateRoot() BindingFlags.NonPublic | BindingFlags.Instance; - var failingTypes = new List(); + List failingTypes = []; foreach (var type in entityTypes) { var fields = type.GetFields(bindingFlags); @@ -113,7 +113,7 @@ public void Entity_Should_Have_Parameterless_Private_Constructor() .That() .Inherit(typeof(Entity)).GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var entityType in entityTypes) { bool hasPrivateParameterlessConstructor = false; @@ -145,7 +145,7 @@ public void Domain_Object_Should_Have_Only_Private_Constructors() .Inherit(typeof(ValueObject)) .GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var domainObjectType in domainObjectTypes) { var constructors = domainObjectType.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); @@ -164,10 +164,7 @@ public void Domain_Object_Should_Have_Only_Private_Constructors() [Test] public void ValueObject_Should_Have_Private_Constructor_With_Parameters_For_His_State() { - List excludedFromCheck = new List - { - typeof(PriceList) - }; + List excludedFromCheck = [typeof(PriceList)]; var valueObjects = Types.InAssembly(DomainAssembly) .That() @@ -176,7 +173,7 @@ public void ValueObject_Should_Have_Private_Constructor_With_Parameters_For_His_ .Where(x => !excludedFromCheck.Contains(x)) .ToList(); - var failingTypes = new List(); + List failingTypes = []; foreach (var entityType in valueObjects) { bool hasExpectedConstructor = false; diff --git a/src/Modules/Payments/Tests/ArchTests/SeedWork/TestBase.cs b/src/Modules/Payments/Tests/ArchTests/SeedWork/TestBase.cs index fb7ce3e66..376bcc660 100644 --- a/src/Modules/Payments/Tests/ArchTests/SeedWork/TestBase.cs +++ b/src/Modules/Payments/Tests/ArchTests/SeedWork/TestBase.cs @@ -17,7 +17,7 @@ public abstract class TestBase protected static void AssertAreImmutable(IEnumerable types) { - IList failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { if (type.GetFields().Any(x => !x.IsInitOnly) || type.GetProperties().Any(x => x.CanWrite)) diff --git a/src/Modules/Payments/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs b/src/Modules/Payments/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs index e0837b756..b0887b04d 100644 --- a/src/Modules/Payments/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs +++ b/src/Modules/Payments/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs @@ -8,7 +8,7 @@ public class DomainEventsTestHelper { public static List GetAllDomainEvents(Entity aggregate) { - List domainEvents = new List(); + List domainEvents = []; if (aggregate.DomainEvents != null) { diff --git a/src/Modules/Payments/Tests/UnitTests/SubscriptionPayments/SubscriptionPaymentTestsBase.cs b/src/Modules/Payments/Tests/UnitTests/SubscriptionPayments/SubscriptionPaymentTestsBase.cs index 7d03b0813..3697ce25b 100644 --- a/src/Modules/Payments/Tests/UnitTests/SubscriptionPayments/SubscriptionPaymentTestsBase.cs +++ b/src/Modules/Payments/Tests/UnitTests/SubscriptionPayments/SubscriptionPaymentTestsBase.cs @@ -47,7 +47,7 @@ private PriceList CreatePriceList() MoneyValue.Of(60, "PLN"), PriceListItemCategory.New); - var priceListItems = new List { priceListItem }; + List priceListItems = [priceListItem]; var priceList = PriceList.Create(priceListItems, new DirectValueFromPriceListPricingStrategy(priceListItems)); return priceList; diff --git a/src/Modules/Payments/Tests/UnitTests/SubscriptionRenewalPayments/SubscriptionRenewalPaymentTestsBase.cs b/src/Modules/Payments/Tests/UnitTests/SubscriptionRenewalPayments/SubscriptionRenewalPaymentTestsBase.cs index e575eab94..2bcf2bb59 100644 --- a/src/Modules/Payments/Tests/UnitTests/SubscriptionRenewalPayments/SubscriptionRenewalPaymentTestsBase.cs +++ b/src/Modules/Payments/Tests/UnitTests/SubscriptionRenewalPayments/SubscriptionRenewalPaymentTestsBase.cs @@ -47,7 +47,7 @@ private PriceList CreatePriceList() MoneyValue.Of(60, "PLN"), PriceListItemCategory.Renewal); - var priceListItems = new List { priceListItem }; + List priceListItems = [priceListItem]; var priceList = PriceList.Create(priceListItems, new DirectValueFromPriceListPricingStrategy(priceListItems)); return priceList; diff --git a/src/Modules/UserAccess/Application/Authentication/Authenticate/AuthenticateCommandHandler.cs b/src/Modules/UserAccess/Application/Authentication/Authenticate/AuthenticateCommandHandler.cs index 0b9208394..ce4ed9aed 100644 --- a/src/Modules/UserAccess/Application/Authentication/Authenticate/AuthenticateCommandHandler.cs +++ b/src/Modules/UserAccess/Application/Authentication/Authenticate/AuthenticateCommandHandler.cs @@ -51,9 +51,11 @@ public async Task Handle(AuthenticateCommand request, Canc return new AuthenticationResult("Incorrect login or password"); } - user.Claims = new List(); - user.Claims.Add(new Claim(CustomClaimTypes.Name, user.Name)); - user.Claims.Add(new Claim(CustomClaimTypes.Email, user.Email)); + user.Claims = + [ + new Claim(CustomClaimTypes.Name, user.Name), + new Claim(CustomClaimTypes.Email, user.Email) + ]; return new AuthenticationResult(user); } diff --git a/src/Modules/UserAccess/Application/Authorization/GetAuthenticatedUserPermissions/GetAuthenticatedUserPermissionsQueryHandler.cs b/src/Modules/UserAccess/Application/Authorization/GetAuthenticatedUserPermissions/GetAuthenticatedUserPermissionsQueryHandler.cs index 4daffd4e1..4f23ee794 100644 --- a/src/Modules/UserAccess/Application/Authorization/GetAuthenticatedUserPermissions/GetAuthenticatedUserPermissionsQueryHandler.cs +++ b/src/Modules/UserAccess/Application/Authorization/GetAuthenticatedUserPermissions/GetAuthenticatedUserPermissionsQueryHandler.cs @@ -24,7 +24,7 @@ public async Task> Handle(GetAuthenticatedUserPermission { if (!_executionContextAccessor.IsAvailable) { - return new List(); + return []; } var connection = _sqlConnectionFactory.GetOpenConnection(); diff --git a/src/Modules/UserAccess/Domain/Users/User.cs b/src/Modules/UserAccess/Domain/Users/User.cs index 769483579..a26b01f92 100644 --- a/src/Modules/UserAccess/Domain/Users/User.cs +++ b/src/Modules/UserAccess/Domain/Users/User.cs @@ -90,8 +90,7 @@ private User( _isActive = true; - _roles = new List(); - _roles.Add(role); + _roles = [role]; this.AddDomainEvent(new UserCreatedDomainEvent(this.Id)); } diff --git a/src/Modules/UserAccess/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs b/src/Modules/UserAccess/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs index d2d67df78..0c84fa946 100644 --- a/src/Modules/UserAccess/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs +++ b/src/Modules/UserAccess/Infrastructure/Configuration/Processing/Outbox/OutboxModule.cs @@ -40,7 +40,7 @@ private void CheckMappings() .Where(x => x.GetInterfaces().Contains(typeof(IDomainEventNotification))) .ToList(); - List notMappedNotifications = new List(); + List notMappedNotifications = []; foreach (var domainEventNotification in domainEventNotifications) { _domainNotificationsMap.TryGetBySecond(domainEventNotification, out var name); diff --git a/src/Modules/UserAccess/Tests/ArchTests/Application/ApplicationTests.cs b/src/Modules/UserAccess/Tests/ArchTests/Application/ApplicationTests.cs index d0463569b..7d005a1a0 100644 --- a/src/Modules/UserAccess/Tests/ArchTests/Application/ApplicationTests.cs +++ b/src/Modules/UserAccess/Tests/ArchTests/Application/ApplicationTests.cs @@ -122,7 +122,7 @@ public void InternalCommand_Should_Have_JsonConstructorAttribute() .Inherit(typeof(InternalCommandBase<>)) .GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { @@ -155,7 +155,7 @@ public void MediatR_RequestHandler_Should_NotBe_Used_Directly() .Should().ImplementInterface(typeof(IRequestHandler<>)) .GetTypes(); - List failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { bool isCommandHandler = type.GetInterfaces().Any(x => @@ -184,7 +184,7 @@ public void Command_With_Result_Should_Not_Return_Unit() .That().ImplementInterface(commandWithResultHandlerType) .GetTypes().ToList(); - var failingTypes = new List(); + List failingTypes = []; foreach (Type type in types) { Type interfaceType = type.GetInterface(commandWithResultHandlerType.Name); diff --git a/src/Modules/UserAccess/Tests/ArchTests/Domain/DomainTests.cs b/src/Modules/UserAccess/Tests/ArchTests/Domain/DomainTests.cs index 161941196..0c72c1f96 100644 --- a/src/Modules/UserAccess/Tests/ArchTests/Domain/DomainTests.cs +++ b/src/Modules/UserAccess/Tests/ArchTests/Domain/DomainTests.cs @@ -45,7 +45,7 @@ public void Entity_Which_Is_Not_Aggregate_Root_Cannot_Have_Public_Members() BindingFlags.Instance | BindingFlags.Static; - var failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { var publicFields = type.GetFields(bindingFlags); @@ -75,7 +75,7 @@ public void Entity_Cannot_Have_Reference_To_Other_AggregateRoot() BindingFlags.NonPublic | BindingFlags.Instance; - var failingTypes = new List(); + List failingTypes = []; foreach (var type in entityTypes) { var fields = type.GetFields(bindingFlags); @@ -112,7 +112,7 @@ public void Entity_Should_Have_Parameterless_Private_Constructor() .That() .Inherit(typeof(Entity)).GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var entityType in entityTypes) { bool hasPrivateParameterlessConstructor = false; @@ -144,7 +144,7 @@ public void Domain_Object_Should_Have_Only_Private_Constructors() .Inherit(typeof(ValueObject)) .GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var domainObjectType in domainObjectTypes) { var constructors = domainObjectType.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); @@ -167,7 +167,7 @@ public void ValueObject_Should_Have_Private_Constructor_With_Parameters_For_His_ .That() .Inherit(typeof(ValueObject)).GetTypes(); - var failingTypes = new List(); + List failingTypes = []; foreach (var entityType in valueObjects) { bool hasExpectedConstructor = false; diff --git a/src/Modules/UserAccess/Tests/ArchTests/SeedWork/TestBase.cs b/src/Modules/UserAccess/Tests/ArchTests/SeedWork/TestBase.cs index 58feb086f..e2408df92 100644 --- a/src/Modules/UserAccess/Tests/ArchTests/SeedWork/TestBase.cs +++ b/src/Modules/UserAccess/Tests/ArchTests/SeedWork/TestBase.cs @@ -17,7 +17,7 @@ public abstract class TestBase protected static void AssertAreImmutable(IEnumerable types) { - IList failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { if (type.GetFields().Any(x => !x.IsInitOnly) || type.GetProperties().Any(x => x.CanWrite)) diff --git a/src/Modules/UserAccess/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs b/src/Modules/UserAccess/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs index ee6b1c113..5c306a46b 100644 --- a/src/Modules/UserAccess/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs +++ b/src/Modules/UserAccess/Tests/UnitTests/SeedWork/DomainEventsTestHelper.cs @@ -8,7 +8,7 @@ public class DomainEventsTestHelper { public static List GetAllDomainEvents(Entity aggregate) { - List domainEvents = new List(); + List domainEvents = []; if (aggregate.DomainEvents != null) { diff --git a/src/Tests/ArchTests/Api/ApiTests.cs b/src/Tests/ArchTests/Api/ApiTests.cs index 5dff9458a..e389bd97d 100644 --- a/src/Tests/ArchTests/Api/ApiTests.cs +++ b/src/Tests/ArchTests/Api/ApiTests.cs @@ -10,10 +10,7 @@ public class ApiTests : TestBase [Test] public void AdministrationApi_DoesNotHaveDependency_ToOtherModules() { - var otherModules = new List - { - MeetingsNamespace, PaymentsNamespace, UserAccessNamespace - }; + List otherModules = [MeetingsNamespace, PaymentsNamespace, UserAccessNamespace]; var result = Types.InAssembly(ApiAssembly) .That() .ResideInNamespace("CompanyName.MyMeetings.API.Modules.Administration") @@ -27,10 +24,7 @@ public void AdministrationApi_DoesNotHaveDependency_ToOtherModules() [Test] public void MeetingsApi_DoesNotHaveDependency_ToOtherModules() { - var otherModules = new List - { - AdministrationNamespace, PaymentsNamespace, UserAccessNamespace - }; + List otherModules = [AdministrationNamespace, PaymentsNamespace, UserAccessNamespace]; var result = Types.InAssembly(ApiAssembly) .That() .ResideInNamespace("CompanyName.MyMeetings.API.Modules.Meetings") @@ -44,10 +38,7 @@ public void MeetingsApi_DoesNotHaveDependency_ToOtherModules() [Test] public void PaymentsApi_DoesNotHaveDependency_ToOtherModules() { - var otherModules = new List - { - AdministrationNamespace, MeetingsNamespace, UserAccessNamespace - }; + List otherModules = [AdministrationNamespace, MeetingsNamespace, UserAccessNamespace]; var result = Types.InAssembly(ApiAssembly) .That() .ResideInNamespace("CompanyName.MyMeetings.API.Modules.Payments") @@ -61,10 +52,7 @@ public void PaymentsApi_DoesNotHaveDependency_ToOtherModules() [Test] public void UserAccessApi_DoesNotHaveDependency_ToOtherModules() { - var otherModules = new List - { - AdministrationNamespace, MeetingsNamespace, PaymentsNamespace - }; + List otherModules = [AdministrationNamespace, MeetingsNamespace, PaymentsNamespace]; var result = Types.InAssembly(ApiAssembly) .That() .ResideInNamespace("CompanyName.MyMeetings.API.Modules.UserAccess") diff --git a/src/Tests/ArchTests/Modules/ModuleTests.cs b/src/Tests/ArchTests/Modules/ModuleTests.cs index 23cef5bb8..8634b9d11 100644 --- a/src/Tests/ArchTests/Modules/ModuleTests.cs +++ b/src/Tests/ArchTests/Modules/ModuleTests.cs @@ -24,16 +24,13 @@ public class ModuleTests : TestBase [Test] public void AdministrationModule_DoesNotHave_Dependency_On_Other_Modules() { - var otherModules = new List - { - MeetingsNamespace, PaymentsNamespace, UserAccessNamespace - }; - List administrationAssemblies = new List - { + List otherModules = [MeetingsNamespace, PaymentsNamespace, UserAccessNamespace]; + List administrationAssemblies = + [ typeof(IAdministrationModule).Assembly, typeof(MeetingGroupLocation).Assembly, typeof(AdministrationContext).Assembly - }; + ]; var result = Types.InAssemblies(administrationAssemblies) .That() @@ -50,16 +47,13 @@ public void AdministrationModule_DoesNotHave_Dependency_On_Other_Modules() [Test] public void MeetingsModule_DoesNotHave_Dependency_On_Other_Modules() { - var otherModules = new List - { - AdministrationNamespace, PaymentsNamespace, UserAccessNamespace - }; - List meetingsAssemblies = new List - { + List otherModules = [AdministrationNamespace, PaymentsNamespace, UserAccessNamespace]; + List meetingsAssemblies = + [ typeof(IMeetingsModule).Assembly, typeof(Meeting).Assembly, typeof(MeetingsContext).Assembly - }; + ]; var result = Types.InAssemblies(meetingsAssemblies) .That() @@ -76,16 +70,13 @@ public void MeetingsModule_DoesNotHave_Dependency_On_Other_Modules() [Test] public void PaymentsModule_DoesNotHave_Dependency_On_Other_Modules() { - var otherModules = new List - { - AdministrationNamespace, MeetingsNamespace, UserAccessNamespace - }; - List paymentsAssemblies = new List - { + List otherModules = [AdministrationNamespace, MeetingsNamespace, UserAccessNamespace]; + List paymentsAssemblies = + [ typeof(IPaymentsModule).Assembly, typeof(MeetingFee).Assembly, typeof(PaymentsStartup).Assembly - }; + ]; var result = Types.InAssemblies(paymentsAssemblies) .That() @@ -102,16 +93,13 @@ public void PaymentsModule_DoesNotHave_Dependency_On_Other_Modules() [Test] public void UserAccessModule_DoesNotHave_Dependency_On_Other_Modules() { - var otherModules = new List - { - AdministrationNamespace, MeetingsNamespace, PaymentsNamespace - }; - List userAccessAssemblies = new List - { + List otherModules = [AdministrationNamespace, MeetingsNamespace, PaymentsNamespace]; + List userAccessAssemblies = + [ typeof(IUserAccessModule).Assembly, typeof(User).Assembly, typeof(UserAccessContext).Assembly - }; + ]; var result = Types.InAssemblies(userAccessAssemblies) .That() diff --git a/src/Tests/ArchTests/SeedWork/TestBase.cs b/src/Tests/ArchTests/SeedWork/TestBase.cs index 7efa7aea8..65fd76703 100644 --- a/src/Tests/ArchTests/SeedWork/TestBase.cs +++ b/src/Tests/ArchTests/SeedWork/TestBase.cs @@ -19,7 +19,7 @@ public abstract class TestBase protected static void AssertAreImmutable(IEnumerable types) { - IList failingTypes = new List(); + List failingTypes = []; foreach (var type in types) { if (type.GetFields().Any(x => !x.IsInitOnly) || type.GetProperties().Any(x => x.CanWrite)) diff --git a/src/Tests/SUT/TestCases/CreateMeeting.cs b/src/Tests/SUT/TestCases/CreateMeeting.cs index 93574ac93..fd2edf217 100644 --- a/src/Tests/SUT/TestCases/CreateMeeting.cs +++ b/src/Tests/SUT/TestCases/CreateMeeting.cs @@ -65,7 +65,7 @@ await TestPaymentsManager.BuySubscription( null, 0, null, - new List()); + []); var attendeeUserId = await UsersFactory.GivenUser( UserAccessModule,