diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e41c44f..5965848 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: branches: [ "main" ] env: - PACKAGE_VERSION: 0.2.0 + PACKAGE_VERSION: 0.2.1 jobs: diff --git a/Demos/ToDoList.Domain/Events/TaskLists/TaskCompletedStatusUpdated.cs b/Demos/ToDoList.Domain/Events/TaskLists/TaskCompletedStatusUpdated.cs index 122027c..546f50b 100644 --- a/Demos/ToDoList.Domain/Events/TaskLists/TaskCompletedStatusUpdated.cs +++ b/Demos/ToDoList.Domain/Events/TaskLists/TaskCompletedStatusUpdated.cs @@ -2,4 +2,8 @@ namespace ToDoList.Domain.Events.TaskLists; -public record TaskCompletedStatusUpdpated(Guid TaskListId, Guid TaskId, bool IsCompleted) : Event; \ No newline at end of file +public record TaskCompletedStatusUpdpated( + Guid TaskListId, + Guid Id, + bool IsCompleted) +: Event(Id); \ No newline at end of file diff --git a/Demos/ToDoList.Domain/Events/TaskLists/TaskListNameUpdated.cs b/Demos/ToDoList.Domain/Events/TaskLists/TaskListNameUpdated.cs index 0244e23..14a2ddc 100644 --- a/Demos/ToDoList.Domain/Events/TaskLists/TaskListNameUpdated.cs +++ b/Demos/ToDoList.Domain/Events/TaskLists/TaskListNameUpdated.cs @@ -5,4 +5,4 @@ namespace ToDoList.Domain.Events.TaskLists; public record TaskListNameUpdated( Guid Id, string NewName -) : Event; \ No newline at end of file +) : Event(Id); \ No newline at end of file diff --git a/Demos/ToDoList.Domain/Events/TaskLists/TaskTitleUpdated.cs b/Demos/ToDoList.Domain/Events/TaskLists/TaskTitleUpdated.cs index a052415..5a05bae 100644 --- a/Demos/ToDoList.Domain/Events/TaskLists/TaskTitleUpdated.cs +++ b/Demos/ToDoList.Domain/Events/TaskLists/TaskTitleUpdated.cs @@ -6,4 +6,4 @@ public record TaskTitleUpdated( Guid? TaskListId, Guid Id, string NewTitle -) : Event; \ No newline at end of file +) : Event(Id); \ No newline at end of file diff --git a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAddressChanged.cs b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAddressChanged.cs index a1a61aa..b399d2e 100644 --- a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAddressChanged.cs +++ b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAddressChanged.cs @@ -3,6 +3,7 @@ namespace ToDoList.Domain.Events.UserAccounts; public record UserAccountEmailAddressChanged( + Guid Id, Guid UserAccountId, string NewEmail -) : Event; \ No newline at end of file +) : Event(Id); \ No newline at end of file diff --git a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAddressConfirmed.cs b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAddressConfirmed.cs index dcbd195..0b10e20 100644 --- a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAddressConfirmed.cs +++ b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAddressConfirmed.cs @@ -3,5 +3,6 @@ namespace ToDoList.Domain.Events.UserAccounts; public record UserAccountEmailAddressConfirmed( + Guid Id, Guid UserAccountId -) : Event; \ No newline at end of file +) : Event(Id); \ No newline at end of file diff --git a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAssigned.cs b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAssigned.cs index dbe50e3..9569e27 100644 --- a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAssigned.cs +++ b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailAssigned.cs @@ -3,6 +3,7 @@ namespace ToDoList.Domain.Events.UserAccounts; public record UserAccountEmailAssigned( + Guid Id, Guid UserAccountId, string EmailAddress -) : Event; \ No newline at end of file +) : Event(Id); \ No newline at end of file diff --git a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailRegistered.cs b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailRegistered.cs index acd90db..84b404a 100644 --- a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailRegistered.cs +++ b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountEmailRegistered.cs @@ -1,7 +1,8 @@ using CloudFabric.EventSourcing.EventStore; +using ToDoList.Domain.Utilities.Extensions; namespace ToDoList.Domain.Events.UserAccounts; public record UserAccountEmailRegistered( string EmailAddress -) : Event; \ No newline at end of file +) : Event(EmailAddress.HashGuid()); \ No newline at end of file diff --git a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountPasswordUpdated.cs b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountPasswordUpdated.cs index d657beb..baa7b93 100644 --- a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountPasswordUpdated.cs +++ b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountPasswordUpdated.cs @@ -2,4 +2,7 @@ namespace ToDoList.Domain.Events.UserAccounts; -public record UserAccountPasswordUpdated(string NewHashedPassword) : Event; \ No newline at end of file +public record UserAccountPasswordUpdated( + Guid Id, + string NewHashedPassword +) : Event(Id); \ No newline at end of file diff --git a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountRegistered.cs b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountRegistered.cs index 28e1b0b..40a19f0 100644 --- a/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountRegistered.cs +++ b/Demos/ToDoList.Domain/Events/UserAccounts/UserAccountRegistered.cs @@ -6,4 +6,4 @@ public record UserAccountRegistered( Guid Id, string FirstName, string HashedPassword -) : Event; \ No newline at end of file +) : Event(Id); \ No newline at end of file diff --git a/Demos/ToDoList.Domain/UserAccount.cs b/Demos/ToDoList.Domain/UserAccount.cs index ac4b5a3..765f46c 100644 --- a/Demos/ToDoList.Domain/UserAccount.cs +++ b/Demos/ToDoList.Domain/UserAccount.cs @@ -26,7 +26,7 @@ public UserAccount(Guid id, string firstName, string hashedPassword) public void UpdatePassword(string newHashedPassword) { - Apply(new UserAccountPasswordUpdated(newHashedPassword)); + Apply(new UserAccountPasswordUpdated(Id, newHashedPassword)); } #region Event Handlers diff --git a/Demos/ToDoList.Domain/UserAccountEmailAddress.cs b/Demos/ToDoList.Domain/UserAccountEmailAddress.cs index 01f96ad..54a470e 100644 --- a/Demos/ToDoList.Domain/UserAccountEmailAddress.cs +++ b/Demos/ToDoList.Domain/UserAccountEmailAddress.cs @@ -29,17 +29,17 @@ public UserAccountEmailAddress(string emailAddress) : base() } public void ChangeEmailAddress(string newEmail) { - Apply(new UserAccountEmailAddressChanged(UserAccountId, newEmail)); + Apply(new UserAccountEmailAddressChanged(Id, UserAccountId, newEmail)); } public void ConfirmEmailAddress() { - Apply(new UserAccountEmailAddressConfirmed(UserAccountId)); + Apply(new UserAccountEmailAddressConfirmed(Id, UserAccountId)); } public void AssignUserAccount(Guid userAccountId) { - Apply(new UserAccountEmailAssigned(userAccountId, EmailAddress)); + Apply(new UserAccountEmailAssigned(Id, userAccountId, EmailAddress)); } #region Event Handlers @@ -53,7 +53,7 @@ public void On(UserAccountEmailRegistered @event) public void On(UserAccountEmailAssigned @event) { - UserAccountId = @event.AggregateId; + UserAccountId = @event.UserAccountId; } public void On(UserAccountEmailAddressChanged @event) diff --git a/Demos/ToDoList.Domain/Utilities/Extensions/StringExtensions.cs b/Demos/ToDoList.Domain/Utilities/Extensions/StringExtensions.cs new file mode 100644 index 0000000..bb6abca --- /dev/null +++ b/Demos/ToDoList.Domain/Utilities/Extensions/StringExtensions.cs @@ -0,0 +1,18 @@ +using System.Text; + +namespace ToDoList.Domain.Utilities.Extensions; + +public static class StringExtensions +{ + public static Guid HashGuid(this string str) + { + // Super fast non-cryptographic hash function: + // https://cyan4973.github.io/xxHash/ + // 128 version is used because that's what Guid uses for it's value + var hash = new System.IO.Hashing.XxHash128(); + + hash.Append(Encoding.UTF8.GetBytes(str)); + + return new Guid(hash.GetCurrentHash()); + } +}