File tree Expand file tree Collapse file tree 6 files changed +22
-35
lines changed
Expand file tree Collapse file tree 6 files changed +22
-35
lines changed Original file line number Diff line number Diff line change 1717 <!-- Disable "must have curly braces for if/else" -->
1818 <NoWarn >$(NoWarn);IDE0011</NoWarn >
1919
20- <!-- Disable "auto property warning" TODO: Remove after fields are introduced -->
21- <NoWarn >$(NoWarn);IDE0032</NoWarn >
22-
2320 </PropertyGroup >
2421</Project >
Original file line number Diff line number Diff line change @@ -9,32 +9,30 @@ public abstract class Auditable : IAuditable
99 public const int UpdatedByMaxLength = 128 ;
1010
1111 private const string SystemUser = "System" ;
12- private string _createdBy = null ! ;
13- private string ? _updatedBy ;
1412
1513 public DateTimeOffset CreatedAt { get ; private set ; }
1614
1715 public string CreatedBy
1816 {
19- get => _createdBy ;
17+ get ;
2018 private set
2119 {
2220 ThrowIfNullOrWhiteSpace ( value , nameof ( CreatedBy ) ) ;
2321 ThrowIfGreaterThan ( value . Length , CreatedByMaxLength , nameof ( CreatedBy ) ) ;
24- _createdBy = value ;
22+ field = value ;
2523 }
26- }
24+ } = null ! ;
2725
2826 public DateTimeOffset ? UpdatedAt { get ; private set ; }
2927
3028 public string ? UpdatedBy
3129 {
32- get => _updatedBy ;
30+ get ;
3331 private set
3432 {
3533 ThrowIfNullOrWhiteSpace ( value , nameof ( UpdatedBy ) ) ;
3634 ThrowIfGreaterThan ( value . Length , UpdatedByMaxLength , nameof ( UpdatedBy ) ) ;
37- _updatedBy = value ;
35+ field = value ;
3836 }
3937 }
4038
Original file line number Diff line number Diff line change @@ -13,30 +13,27 @@ public class Hero : AggregateRoot<HeroId>
1313
1414 private readonly List < Power > _powers = [ ] ;
1515
16- private string _name = null ! ;
17- private string _alias = null ! ;
18-
1916 public string Name
2017 {
21- get => _name ;
18+ get ;
2219 set
2320 {
2421 ThrowIfNullOrWhiteSpace ( value , nameof ( Name ) ) ;
2522 ThrowIfGreaterThan ( value . Length , NameMaxLength , nameof ( Name ) ) ;
26- _name = value ;
23+ field = value ;
2724 }
28- }
25+ } = null ! ;
2926
3027 public string Alias
3128 {
32- get => _alias ;
29+ get ;
3330 set
3431 {
3532 ThrowIfNullOrWhiteSpace ( value , nameof ( Alias ) ) ;
3633 ThrowIfGreaterThan ( value . Length , AliasMaxLength , nameof ( Alias ) ) ;
37- _alias = value ;
34+ field = value ;
3835 }
39- }
36+ } = null ! ;
4037
4138 public int PowerLevel { get ; private set ; }
4239 public TeamId ? TeamId { get ; private set ; }
Original file line number Diff line number Diff line change @@ -4,30 +4,27 @@ public record Power : IValueObject
44{
55 public const int NameMaxLength = 50 ;
66
7- private string _name = null ! ;
8- private int _powerLevel ;
9-
107 // Private setters needed for EF
118 public string Name
129 {
13- get => _name ;
10+ get ;
1411 private set
1512 {
1613 ThrowIfNullOrWhiteSpace ( value , nameof ( Name ) ) ;
1714 ThrowIfGreaterThan ( value . Length , NameMaxLength , nameof ( Name ) ) ;
18- _name = value ;
15+ field = value ;
1916 }
20- }
17+ } = null ! ;
2118
2219 // Private setters needed for EF
2320 public int PowerLevel
2421 {
25- get => _powerLevel ;
22+ get ;
2623 private set
2724 {
2825 ThrowIfLessThan ( value , 1 , nameof ( PowerLevel ) ) ;
2926 ThrowIfGreaterThan ( value , 10 , nameof ( PowerLevel ) ) ;
30- _powerLevel = value ;
27+ field = value ;
3128 }
3229 }
3330
Original file line number Diff line number Diff line change 66
77public class Mission : Entity < MissionId >
88{
9- private string _description = null ! ;
109 public const int DescriptionMaxLength = 500 ;
1110
1211 public string Description
1312 {
14- get => _description ;
13+ get ;
1514 private set
1615 {
1716 ThrowIfNullOrWhiteSpace ( value , nameof ( Description ) ) ;
1817 ThrowIfGreaterThan ( value . Length , DescriptionMaxLength , nameof ( Description ) ) ;
19- _description = value ;
18+ field = value ;
2019 }
21- }
20+ } = null ! ;
2221
2322 public MissionStatus Status { get ; private set ; }
2423
Original file line number Diff line number Diff line change @@ -10,21 +10,20 @@ public class Team : AggregateRoot<TeamId>
1010{
1111 public const int NameMaxLength = 100 ;
1212
13- private string _name = null ! ;
1413 private readonly List < Hero > _heroes = [ ] ;
1514 private readonly List < Mission > _missions = [ ] ;
1615 private Mission ? CurrentMission => _missions . FirstOrDefault ( m => m . Status == MissionStatus . InProgress ) ;
1716
1817 public string Name
1918 {
20- get => _name ;
19+ get ;
2120 private set
2221 {
2322 ThrowIfNullOrWhiteSpace ( value , nameof ( Name ) ) ;
2423 ThrowIfGreaterThan ( value . Length , NameMaxLength , nameof ( Name ) ) ;
25- _name = value ;
24+ field = value ;
2625 }
27- }
26+ } = null ! ;
2827
2928 public int TotalPowerLevel { get ; private set ; }
3029 public TeamStatus Status { get ; private set ; }
You can’t perform that action at this time.
0 commit comments