Skip to content

Commit ce31b52

Browse files
committed
refactor: consolidate command namespaces and enforce stricter aggregate immutability
1 parent a686d64 commit ce31b52

19 files changed

Lines changed: 314 additions & 301 deletions

File tree

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<LangVersion>latest</LangVersion>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7-
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
7+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
88
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
99
</PropertyGroup>
1010

src/ApiService/BookStore.ApiService.Analyzers/BookStore.ApiService.Analyzers.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
7+
<NoWarn>$(NoWarn);RS2008</NoWarn>
78
</PropertyGroup>
89

910
<ItemGroup>

src/ApiService/BookStore.ApiService/Aggregates/AuthorAggregate.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ namespace BookStore.ApiService.Aggregates;
44

55
public class AuthorAggregate
66
{
7-
public Guid Id { get; set; }
8-
public string Name { get; set; } = string.Empty;
9-
public string? Biography { get; set; }
10-
public bool IsDeleted { get; set; }
7+
public Guid Id { get; private set; }
8+
public string Name { get; private set; } = string.Empty;
9+
public string? Biography { get; private set; }
10+
public bool IsDeleted { get; private set; }
1111

1212
// Marten uses this for rehydration
1313
void Apply(AuthorAdded @event)

src/ApiService/BookStore.ApiService/Aggregates/BookAggregate.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ namespace BookStore.ApiService.Aggregates;
55

66
public class BookAggregate
77
{
8-
public Guid Id { get; set; }
9-
public string Title { get; set; } = string.Empty;
10-
public string? Isbn { get; set; }
11-
public string? Description { get; set; }
12-
public DateOnly? PublicationDate { get; set; }
13-
public Guid? PublisherId { get; set; }
14-
public List<Guid> AuthorIds { get; set; } = [];
15-
public List<Guid> CategoryIds { get; set; } = [];
16-
public bool IsDeleted { get; set; }
8+
public Guid Id { get; private set; }
9+
public string Title { get; private set; } = string.Empty;
10+
public string? Isbn { get; private set; }
11+
public string? Description { get; private set; }
12+
public DateOnly? PublicationDate { get; private set; }
13+
public Guid? PublisherId { get; private set; }
14+
public List<Guid> AuthorIds { get; private set; } = [];
15+
public List<Guid> CategoryIds { get; private set; } = [];
16+
public bool IsDeleted { get; private set; }
1717

1818
// Marten uses this for rehydration
1919
void Apply(BookAdded @event)

src/ApiService/BookStore.ApiService/Aggregates/CategoryAggregate.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ namespace BookStore.ApiService.Aggregates;
44

55
public class CategoryAggregate
66
{
7-
public Guid Id { get; set; }
8-
public string Name { get; set; } = string.Empty;
9-
public string? Description { get; set; }
10-
public Dictionary<string, CategoryTranslation> Translations { get; set; } = [];
11-
public bool IsDeleted { get; set; }
7+
public Guid Id { get; private set; }
8+
public string Name { get; private set; } = string.Empty;
9+
public string? Description { get; private set; }
10+
public Dictionary<string, CategoryTranslation> Translations { get; private set; } = [];
11+
public bool IsDeleted { get; private set; }
1212

1313
// Marten uses this for rehydration
1414
void Apply(CategoryAdded @event)

src/ApiService/BookStore.ApiService/Aggregates/PublisherAggregate.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ namespace BookStore.ApiService.Aggregates;
44

55
public class PublisherAggregate
66
{
7-
public Guid Id { get; set; }
8-
public string Name { get; set; } = string.Empty;
9-
public bool IsDeleted { get; set; }
7+
public Guid Id { get; private set; }
8+
public string Name { get; private set; } = string.Empty;
9+
public bool IsDeleted { get; private set; }
1010

1111
// Marten uses this for rehydration
1212
void Apply(PublisherAdded @event)

src/ApiService/BookStore.ApiService/Commands/Authors/AuthorCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BookStore.ApiService.Commands.Authors;
1+
namespace BookStore.ApiService.Commands;
22

33
/// <summary>
44
/// Command to create a new author

src/ApiService/BookStore.ApiService/Commands/Books/BookCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BookStore.ApiService.Commands.Books;
1+
namespace BookStore.ApiService.Commands;
22

33
/// <summary>
44
/// Command to create a new book

src/ApiService/BookStore.ApiService/Commands/Categories/CategoryCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BookStore.ApiService.Commands.Categories;
1+
namespace BookStore.ApiService.Commands;
22

33
/// <summary>
44
/// Command to create a new category

src/ApiService/BookStore.ApiService/Commands/Publishers/PublisherCommands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace BookStore.ApiService.Commands.Publishers;
1+
namespace BookStore.ApiService.Commands;
22

33
/// <summary>
44
/// Command to create a new publisher

0 commit comments

Comments
 (0)