From 20c1ce5eefb7ec8fbb0fa564f19bfe656b84dcd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=A4fele?= Date: Wed, 30 Oct 2024 18:39:05 +0100 Subject: [PATCH] Make sure StreamAction.AddEvent also sets the event ID, just as AddEvents already does This fixes #3533. --- src/Marten/Events/StreamAction.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Marten/Events/StreamAction.cs b/src/Marten/Events/StreamAction.cs index a4c46e24c3..b7fa58113b 100644 --- a/src/Marten/Events/StreamAction.cs +++ b/src/Marten/Events/StreamAction.cs @@ -114,17 +114,11 @@ protected StreamAction(Guid id, string key, StreamActionType actionType) internal StreamAction AddEvents(IReadOnlyList events) { - _events.AddRange(events); + _events.EnsureCapacity(_events.Count + events.Count); foreach (var @event in events) { - if (@event.Id == Guid.Empty) - { - @event.Id = CombGuidIdGeneration.NewGuid(); - } - - @event.StreamId = Id; - @event.StreamKey = Key; + AddEvent(@event); } return this; @@ -132,6 +126,11 @@ internal StreamAction AddEvents(IReadOnlyList events) internal StreamAction AddEvent(IEvent @event) { + if (@event.Id == Guid.Empty) + { + @event.Id = CombGuidIdGeneration.NewGuid(); + } + @event.StreamId = Id; @event.StreamKey = Key;