Skip to content

Commit

Permalink
Adding an EntityBase overload for Vogen Ids
Browse files Browse the repository at this point in the history
Minor cleanup
Updated packages
  • Loading branch information
ardalis committed Oct 18, 2024
1 parent 30a851a commit ffd1153
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
14 changes: 7 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<ItemGroup>
<PackageVersion Include="Ardalis.GuardClauses" Version="4.6.0" />
<PackageVersion Include="Ardalis.Specification" Version="8.0.0" />
<PackageVersion Include="coverlet.collector" Version="3.2.0" />
<PackageVersion Include="FluentAssertions" Version="6.11.0" />
<PackageVersion Include="MediatR" Version="12.3.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="FluentAssertions" Version="6.12.1" />
<PackageVersion Include="MediatR" Version="12.4.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>
</Project>
6 changes: 4 additions & 2 deletions src/Ardalis.SharedKernel/Ardalis.SharedKernel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
<RepositoryUrl>https://github.com/ardalis/Ardalis.SharedKernel</RepositoryUrl>
<PackageTags>DDD;Shared Kernel;SharedKernel;Domain-Driven Design;Repository;Specification;ValueObject;Value Object;Ardalis;Clean;Clean Architecture;Clean Architecture Template</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<Version>1.6.0</Version>
<Version>2.1.0</Version>
<PackageReleaseNotes>
* Updated to latest NuGet Package Versions
* Updated packages
* Added default to TId property initializer
* Added another EntityBase overload to work with Vogen value objects
</PackageReleaseNotes>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Expand Down
15 changes: 14 additions & 1 deletion src/Ardalis.SharedKernel/EntityBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,18 @@ public abstract class EntityBase : HasDomainEventsBase
public abstract class EntityBase<TId> : HasDomainEventsBase
where TId : struct, IEquatable<TId>
{
public TId Id { get; set; }
public TId Id { get; set; } = default!;
}

/// <summary>
/// For use with Vogen or similar tools for generating code for
/// strongly typed Ids.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TId"></typeparam>
public abstract class EntityBase<T, TId> : HasDomainEventsBase
where T : EntityBase<T, TId>
{
public TId Id { get; set; } = default!;
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void AddTestDomainEvent()
}

[Fact]
public async void CallsPublishAndClearDomainEvents()
public async Task CallsPublishAndClearDomainEvents()
{
// Arrange
var mediatorMock = new Mock<IMediator>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void AddTestDomainEvent()
}

[Fact]
public async void CallsPublishAndClearDomainEvents()
public async Task CallsPublishAndClearDomainEvents()
{
// Arrange
var mediatorMock = new Mock<IMediator>();
Expand Down

0 comments on commit ffd1153

Please sign in to comment.