From acb3c0819e99269b051f5a210e50b7a7e1253772 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Thu, 11 Jun 2026 09:47:28 +0700 Subject: [PATCH 1/2] Improve exception details and refactor unused method in change types --- src/SIL.Harmony/Changes/CreateChange.cs | 5 ++++- src/SIL.Harmony/Changes/EditChange.cs | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/SIL.Harmony/Changes/CreateChange.cs b/src/SIL.Harmony/Changes/CreateChange.cs index 6127449..85a2660 100644 --- a/src/SIL.Harmony/Changes/CreateChange.cs +++ b/src/SIL.Harmony/Changes/CreateChange.cs @@ -1,9 +1,12 @@ +using Microsoft.EntityFrameworkCore.Infrastructure; + namespace SIL.Harmony.Changes; public abstract class CreateChange(Guid entityId) : Change(entityId) where T : class { public override ValueTask ApplyChange(T entity, IChangeContext context) { - throw new NotSupportedException($"type {GetType().Name} does not support ApplyChange, because it inherits from {nameof(CreateChange)}, this means it must be called with a new Guid and not one from an existing entity"); + //won't be called because it's skipped by the base class for CreateChange + return default; } } diff --git a/src/SIL.Harmony/Changes/EditChange.cs b/src/SIL.Harmony/Changes/EditChange.cs index cdb0a24..0ae6113 100644 --- a/src/SIL.Harmony/Changes/EditChange.cs +++ b/src/SIL.Harmony/Changes/EditChange.cs @@ -1,3 +1,5 @@ +using Microsoft.EntityFrameworkCore.Infrastructure; + namespace SIL.Harmony.Changes; public abstract class EditChange(Guid entityId) : Change(entityId) @@ -6,6 +8,6 @@ public abstract class EditChange(Guid entityId) : Change(entityId) public override ValueTask NewEntity(Commit commit, IChangeContext context) { throw new NotSupportedException( - $"type {GetType().Name} does not support NewEntity, because it inherits from {nameof(EditChange)}, this means it must be called with a from an existing entity, not a newly generated one"); + $"type {GetType().ShortDisplayName()} does not support NewEntity, because it inherits from {nameof(EditChange)}, this means it must be called with a from an existing entity, not a newly generated one. CommitId: {commit.Id}, EntityId: {EntityId}"); } } From da07c47416f09b694696e18725b03b8ab6e4ef17 Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Thu, 11 Jun 2026 13:21:09 +0200 Subject: [PATCH 2/2] Fix grammar in EditChange NewEntity exception message Co-Authored-By: Claude Fable 5 --- src/SIL.Harmony/Changes/EditChange.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SIL.Harmony/Changes/EditChange.cs b/src/SIL.Harmony/Changes/EditChange.cs index 0ae6113..8dbbe6b 100644 --- a/src/SIL.Harmony/Changes/EditChange.cs +++ b/src/SIL.Harmony/Changes/EditChange.cs @@ -8,6 +8,6 @@ public abstract class EditChange(Guid entityId) : Change(entityId) public override ValueTask NewEntity(Commit commit, IChangeContext context) { throw new NotSupportedException( - $"type {GetType().ShortDisplayName()} does not support NewEntity, because it inherits from {nameof(EditChange)}, this means it must be called with a from an existing entity, not a newly generated one. CommitId: {commit.Id}, EntityId: {EntityId}"); + $"type {GetType().ShortDisplayName()} does not support NewEntity, because it inherits from {nameof(EditChange)}, this means it must be called with an existing entity, not a newly generated one. CommitId: {commit.Id}, EntityId: {EntityId}"); } }