Skip to content

Feature: using newer c# version and primary constructors#23

Closed
ingkor wants to merge 1 commit intomasterfrom
feature/primary-constructors
Closed

Feature: using newer c# version and primary constructors#23
ingkor wants to merge 1 commit intomasterfrom
feature/primary-constructors

Conversation

@ingkor
Copy link
Collaborator

@ingkor ingkor commented Apr 24, 2025

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:

  • Replaced traditional constructors with primary constructors in GuestMessagesController and GuestMessagesCounterController, removing redundant private fields and constructor definitions. (GuestMessagesController.cs, GuestMessagesCounterController.cs) [1] [2]
  • Updated DomainEventBrokerService to use a primary constructor, eliminating private fields and simplifying dependency injection. (DomainEventBrokerService.cs)

Repository Refactoring:

  • Refactored 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:

  • Upgraded the C# language version to 13.0 in Vivarni.DDD.Core.csproj and Vivarni.DDD.Infrastructure.csproj to leverage newer language features. (Vivarni.DDD.Core.csproj, Vivarni.DDD.Infrastructure.csproj) [1] [2]

@ingkor ingkor requested review from Clivar, Copilot and vittorelli April 24, 2025 08:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

@vittorelli vittorelli closed this Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants