Feature: using newer c# version and primary constructors#23
Closed
Feature: using newer c# version and primary constructors#23
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors several components to adopt C# 13 primary constructor patterns while updating dependency injection and language version settings. Key changes include:
- Transitioning to primary constructors in repository, service, and controller classes.
- Removing redundant fields and simplifying constructor signatures.
- Upgrading the C# language version for improved language feature utilization.
Reviewed Changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Vivarni.DDD.Infrastructure/Repositories/GenericRepository.cs | Refactored to use a primary constructor and simplified dependency injection. |
| src/Vivarni.DDD.Infrastructure/DomainEvents/DomainEventBrokerService.cs | Updated to leverage a primary constructor for event broker initialization. |
| sample/Vivarni.Example.API/Controllers/GuestMessagesCounterController.cs | Simplified constructor to inject repository dependency directly. |
| sample/Vivarni.Example.API/Controllers/GuestMessagesController.cs | Refactored to use primary constructors and updated repository dependency usage. |
Files not reviewed (2)
- src/Vivarni.DDD.Core/Vivarni.DDD.Core.csproj: Language not supported
- src/Vivarni.DDD.Infrastructure/Vivarni.DDD.Infrastructure.csproj: Language not supported
Comments suppressed due to low confidence (2)
sample/Vivarni.Example.API/Controllers/GuestMessagesController.cs:10
- [nitpick] Consider renaming the parameter 'repositoryBase' to a more descriptive name such as 'guestMessageRepository' to clearly indicate its purpose.
public class GuestMessagesController(IGenericRepository<GuestMessage> repositoryBase) : ControllerBase
src/Vivarni.DDD.Infrastructure/Repositories/GenericRepository.cs:27
- [nitpick] Consider renaming 'ctx' to 'dbContext' for improved clarity and consistency in the codebase.
private readonly DbContext ctx;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several refactorings and improvements across multiple files, primarily focusing on simplifying constructor usage, updating language versions, and improving maintainability. Key changes include switching to primary constructors for several classes, updating the C# language version to 13.0, and refactoring repository and service classes to use more concise and consistent patterns.
Refactoring for Constructor Simplification:
GuestMessagesControllerandGuestMessagesCounterController, removing redundant private fields and constructor definitions. (GuestMessagesController.cs,GuestMessagesCounterController.cs) [1] [2]DomainEventBrokerServiceto use a primary constructor, eliminating private fields and simplifying dependency injection. (DomainEventBrokerService.cs)Repository Refactoring:
GenericRepository<T>to use a primary constructor and replaced private fields with constructor parameters. Updated method calls to use local variables (ctx,logger,cacheProvider) instead of private fields. (GenericRepository.cs) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]Language Version Updates:
Vivarni.DDD.Core.csprojandVivarni.DDD.Infrastructure.csprojto leverage newer language features. (Vivarni.DDD.Core.csproj,Vivarni.DDD.Infrastructure.csproj) [1] [2]