Skip to content

Conversation

@danielmackay
Copy link
Member

@danielmackay danielmackay commented Dec 8, 2025

This pull request refactors several domain model classes to simplify property backing and initialization. The main change is replacing explicit private backing fields with auto-properties using the field keyword in property setters, which streamlines the code and improves compatibility with Entity Framework (EF) for object persistence.

Domain Model Refactoring

  • Replaced private backing fields with auto-properties for string properties in Hero, Power, Mission, Team, and Auditable classes. Set default values to null! and used the field keyword in property setters for cleaner initialization and EF compatibility. [1] [2] [3] [4] [5]

Code Clean-up

  • Removed unnecessary backing fields from the affected classes, further simplifying the codebase and reducing redundancy. [1] [2] [3] [4] [5]

Miscellaneous

  • Fixed a minor formatting issue in Hero.cs by removing an extraneous BOM character from the using statement.

Copy link
Contributor

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 modernizes domain model properties by refactoring from explicit backing fields to C# 13 auto-implemented properties using the field keyword. The refactoring maintains all existing validation logic while simplifying the code and taking advantage of modern C# language features available in .NET 10.

Key Changes

  • Replaced private backing fields with auto-implemented properties using the field contextual keyword in property setters
  • Maintained all validation logic in property setters using field = value instead of _backingField = value
  • Applied consistent initialization patterns with = null! for non-nullable reference types

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/WebApi/Common/Domain/Teams/Team.cs Refactored Name property to use auto-implemented property with validation
src/WebApi/Common/Domain/Teams/Mission.cs Refactored Description property to use auto-implemented property with validation
src/WebApi/Common/Domain/Heroes/Power.cs Refactored Name and PowerLevel properties to use auto-implemented properties with validation
src/WebApi/Common/Domain/Heroes/Hero.cs Refactored Name and Alias properties to use auto-implemented properties with validation; also removed BOM character
src/WebApi/Common/Domain/Base/Auditable.cs Refactored CreatedBy and UpdatedBy properties to use auto-implemented properties with validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@danielmackay danielmackay merged commit 463366b into main Dec 8, 2025
8 checks passed
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.

2 participants