Skip to content

Commit e31ebc6

Browse files
committed
2 parents 0e18ac0 + 5a1206b commit e31ebc6

File tree

8 files changed

+68
-26
lines changed

8 files changed

+68
-26
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ jobs:
1414
steps:
1515
- name: Checkout repository
1616
id: checkout_repo
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818

1919
- name: Initialize CodeQL
2020
id: init_codeql
21-
uses: github/codeql-action/init@v2
21+
uses: github/codeql-action/init@v3
2222
with:
2323
queries: security-and-quality
2424

2525
- name: Autobuild
26-
uses: github/codeql-action/autobuild@v2
26+
uses: github/codeql-action/autobuild@v3
2727

2828
- name: Perform CodeQL Analysis
2929
id: analyze_codeql
30-
uses: github/codeql-action/analyze@v2
30+
uses: github/codeql-action/analyze@v3
3131

3232
# Built with ❤ by [Pipeline Foundation](https://pipeline.foundation)

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
3838
<PackageVersion Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
3939
<PackageVersion Include="xunit" Version="2.9.3" />
40-
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0-pre.49" />
40+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
4141
<!--#if (aspire) -->
4242
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.0.0" />
4343
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.6.0" />

sample/NimblePros.SampleToDo.slnx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Solution>
2+
<Configurations>
3+
<Platform Name="Any CPU" />
4+
<Platform Name="x64" />
5+
<Platform Name="x86" />
6+
</Configurations>
7+
<Folder Name="/Solution Items/">
8+
<File Path=".editorconfig" />
9+
<File Path="CleanArchitecture.nuspec" />
10+
<File Path="Directory.Build.props" />
11+
<File Path="Directory.Packages.props" />
12+
</Folder>
13+
<Folder Name="/src/">
14+
<Project Path="src/NimblePros.SampleToDo.AspireHost/NimblePros.SampleToDo.AspireHost.csproj" />
15+
<Project Path="src/NimblePros.SampleToDo.Core/NimblePros.SampleToDo.Core.csproj" />
16+
<Project Path="src/NimblePros.SampleToDo.Infrastructure/NimblePros.SampleToDo.Infrastructure.csproj" />
17+
<Project Path="src/NimblePros.SampleToDo.ServiceDefaults/NimblePros.SampleToDo.ServiceDefaults.csproj" />
18+
<Project Path="src/NimblePros.SampleToDo.UseCases/NimblePros.SampleToDo.UseCases.csproj" />
19+
<Project Path="src/NimblePros.SampleToDo.Web/NimblePros.SampleToDo.Web.csproj" />
20+
</Folder>
21+
<Folder Name="/tests/">
22+
<Project Path="tests/NimblePros.SampleToDo.FunctionalTests/NimblePros.SampleToDo.FunctionalTests.csproj">
23+
<BuildDependency Project="src/NimblePros.SampleToDo.Web/NimblePros.SampleToDo.Web.csproj" />
24+
</Project>
25+
<Project Path="tests/NimblePros.SampleToDo.IntegrationTests/NimblePros.SampleToDo.IntegrationTests.csproj">
26+
<BuildDependency Project="src/NimblePros.SampleToDo.Infrastructure/NimblePros.SampleToDo.Infrastructure.csproj" />
27+
</Project>
28+
<Project Path="tests/NimblePros.SampleToDo.UnitTests/NimblePros.SampleToDo.UnitTests.csproj" />
29+
</Folder>
30+
</Solution>

sample/src/NimblePros.SampleToDo.Core/ContributorAggregate/Contributor.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ public class Contributor : EntityBase, IAggregateRoot
88

99
public Contributor(ContributorName name)
1010
{
11-
Name = name;
11+
Name = name;
1212
}
1313

14-
public void UpdateName(ContributorName newName)
14+
public Contributor UpdateName(ContributorName newName)
1515
{
1616
if (Name.Equals(newName)) return;
1717
Name = newName;
1818
this.RegisterDomainEvent(new ContributorNameUpdatedEvent(this));
19+
return this;
1920
}
2021
}
2122

sample/src/NimblePros.SampleToDo.Core/ProjectAggregate/Project.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class Project : EntityBase<Project, ProjectId>, IAggregateRoot
66
{
77
public ProjectName Name { get; private set; }
88

9-
private readonly List<ToDoItem> _items = new();
9+
private readonly List<ToDoItem> _items = [];
1010
public IEnumerable<ToDoItem> Items => _items.AsReadOnly();
1111
public ProjectStatus Status => _items.All(i => i.IsDone) ? ProjectStatus.Complete : ProjectStatus.InProgress;
1212

@@ -15,17 +15,19 @@ public Project(ProjectName name)
1515
Name = name;
1616
}
1717

18-
public void AddItem(ToDoItem newItem)
18+
public Project AddItem(ToDoItem newItem)
1919
{
2020
Guard.Against.Null(newItem);
2121
_items.Add(newItem);
2222

2323
var newItemAddedEvent = new NewItemAddedEvent(this, newItem);
2424
base.RegisterDomainEvent(newItemAddedEvent);
25+
return this;
2526
}
2627

27-
public void UpdateName(ProjectName newName)
28+
public Project UpdateName(ProjectName newName)
2829
{
2930
Name = newName;
31+
return this;
3032
}
3133
}

sample/src/NimblePros.SampleToDo.Core/ProjectAggregate/ToDoItem.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,31 @@ public ToDoItem(Priority priority)
2020

2121
public Priority Priority { get; private set; }
2222

23-
24-
public void MarkComplete()
23+
public ToDoItem MarkComplete()
2524
{
2625
if (!IsDone)
2726
{
2827
IsDone = true;
2928

3029
RegisterDomainEvent(new ToDoItemCompletedEvent(this));
3130
}
31+
return this;
3232
}
3333

34-
public void AddContributor(int contributorId)
34+
public ToDoItem AddContributor(int contributorId)
3535
{
3636
Guard.Against.Null(contributorId);
3737
ContributorId = contributorId;
3838

3939
var contributorAddedToItem = new ContributorAddedToItemEvent(this, contributorId);
4040
base.RegisterDomainEvent(contributorAddedToItem);
41+
return this;
4142
}
4243

43-
public void RemoveContributor()
44+
public ToDoItem RemoveContributor()
4445
{
4546
ContributorId = null;
47+
return this;
4648
}
4749

4850
public override string ToString()

src/Clean.Architecture.Core/ContributorAggregate/Contributor.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
namespace Clean.Architecture.Core.ContributorAggregate;
22

3-
public class Contributor(string name) : EntityBase, IAggregateRoot
3+
public class Contributor : EntityBase, IAggregateRoot
44
{
5-
// Example of validating primary constructor inputs
6-
// See: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/primary-constructors#initialize-base-class
7-
public string Name { get; private set; } = Guard.Against.NullOrEmpty(name, nameof(name));
5+
public Contributor(string name)
6+
{
7+
UpdateName(name); // TODO: Replace with value object and use primary constructor to populate field.
8+
}
9+
public string Name { get; private set; } = default!;
810
public ContributorStatus Status { get; private set; } = ContributorStatus.NotSet;
911
public PhoneNumber? PhoneNumber { get; private set; }
12+
public Contributor SetPhoneNumber(string phoneNumber)
13+
{
14+
PhoneNumber = new PhoneNumber(string.Empty, phoneNumber, string.Empty);
15+
return this;
16+
}
1017

11-
public void SetPhoneNumber(string phoneNumber) => PhoneNumber = new PhoneNumber(string.Empty, phoneNumber, string.Empty);
12-
13-
public void UpdateName(string newName) => Name = Guard.Against.NullOrEmpty(newName, nameof(newName));
18+
public Contributor UpdateName(string newName)
19+
{
20+
Name = Guard.Against.NullOrEmpty(newName, nameof(newName));
21+
return this;
22+
}
1423
}
1524

16-
public class PhoneNumber(string countryCode,
17-
string number,
18-
string? extension) : ValueObject
25+
public class PhoneNumber(string countryCode, string number, string? extension) : ValueObject
1926
{
2027
public string CountryCode { get; private set; } = countryCode;
2128
public string Number { get; private set; } = number;

src/Clean.Architecture.Web/Configurations/MiddlewareConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ static async Task SeedDatabase(WebApplication app)
3636
try
3737
{
3838
var context = services.GetRequiredService<AppDbContext>();
39-
// context.Database.Migrate();
40-
context.Database.EnsureCreated();
39+
// await context.Database.MigrateAsync();
40+
await context.Database.EnsureCreatedAsync();
4141
await SeedData.InitializeAsync(context);
4242
}
4343
catch (Exception ex)

0 commit comments

Comments
 (0)