From 2f6ca46ff9c68e9279e4f897148d5c7483ddffcb Mon Sep 17 00:00:00 2001 From: "Jeremy D. Miller" Date: Sat, 26 Oct 2024 15:14:59 -0500 Subject: [PATCH] Adjusted the code generation for IRevisioned Saga types --- .../Event3Handler1609469393.cs | 47 +++++++++++++++ .../IncrementA2Handler79726078.cs | 49 +++++++++++++++ .../IncrementABHandler79726094.cs | 51 ++++++++++++++++ .../IncrementAHandler1658474384.cs | 45 ++++++++++++++ .../IncrementB2Handler483010605.cs | 46 +++++++++++++++ .../IncrementBCHandler483010622.cs | 52 ++++++++++++++++ .../IncrementBHandler1255189857.cs | 48 +++++++++++++++ .../IncrementCDHandler1083073314.cs | 46 +++++++++++++++ .../IncrementCHandler1473693498.cs | 44 ++++++++++++++ .../IncrementDHandler1876978025.cs | 44 ++++++++++++++ .../IncrementMany2Handler448896552.cs | 53 +++++++++++++++++ .../IncrementManyAsyncHandler2038967698.cs | 52 ++++++++++++++++ .../IncrementManyHandler1569177634.cs | 52 ++++++++++++++++ .../LetterMessage1Handler726704086.cs | 29 +++++++++ .../LetterMessage2Handler839379855.cs | 29 +++++++++ .../Outgoing1Handler1264108911.cs | 29 +++++++++ .../RaiseAAAHandler1649029811.cs | 47 +++++++++++++++ .../RaiseAABCCHandler1413048758.cs | 55 +++++++++++++++++ .../RaiseABCHandler1483138068.cs | 55 +++++++++++++++++ .../RaiseBBCCCHandler1900945687.cs | 59 +++++++++++++++++++ .../RaiseLotsAsyncHandler89313884.cs | 45 ++++++++++++++ .../RaiseOnlyDHandler1609388090.cs | 44 ++++++++++++++ .../ResponseHandler2107844337.cs | 29 +++++++++ .../MartenTests/Saga/UserRegistrationSaga.cs | 3 +- .../Persistence/Sagas/LoadDocumentFrame.cs | 5 +- 25 files changed, 1055 insertions(+), 3 deletions(-) create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/Event3Handler1609469393.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementA2Handler79726078.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementABHandler79726094.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementAHandler1658474384.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementB2Handler483010605.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementBCHandler483010622.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementBHandler1255189857.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementCDHandler1083073314.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementCHandler1473693498.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementDHandler1876978025.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementMany2Handler448896552.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementManyAsyncHandler2038967698.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementManyHandler1569177634.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/LetterMessage1Handler726704086.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/LetterMessage2Handler839379855.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/Outgoing1Handler1264108911.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseAAAHandler1649029811.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseAABCCHandler1413048758.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseABCHandler1483138068.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseBBCCCHandler1900945687.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseLotsAsyncHandler89313884.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseOnlyDHandler1609388090.cs create mode 100644 src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/ResponseHandler2107844337.cs diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/Event3Handler1609469393.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/Event3Handler1609469393.cs new file mode 100644 index 000000000..4a2bb6d6e --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/Event3Handler1609469393.cs @@ -0,0 +1,47 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: Event3Handler1609469393 + public class Event3Handler1609469393 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public Event3Handler1609469393(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var event3 = (MartenTests.Event3)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(event3.AggregateId, cancellation).ConfigureAwait(false); + + + // The actual message execution + var outgoing1 = MartenTests.FooHandler.Handle(event3, eventStream.Aggregate); + + + // Outgoing, cascaded message + await context.EnqueueCascadingAsync(outgoing1).ConfigureAwait(false); + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: Event3Handler1609469393 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementA2Handler79726078.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementA2Handler79726078.cs new file mode 100644 index 000000000..2f974ebd3 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementA2Handler79726078.cs @@ -0,0 +1,49 @@ +// +#pragma warning disable +using Microsoft.Extensions.Logging; +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementA2Handler79726078 + public class IncrementA2Handler79726078 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Microsoft.Extensions.Logging.ILogger _logger; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementA2Handler79726078(Microsoft.Extensions.Logging.ILogger logger, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _logger = logger; + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementA2 = (MartenTests.IncrementA2)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(incrementA2.SelfLetteredAggregateId, cancellation).ConfigureAwait(false); + + if (eventStream.Aggregate == null) throw new Wolverine.Marten.UnknownAggregateException(typeof(MartenTests.SelfLetteredAggregate), incrementA2.SelfLetteredAggregateId); + var selfLetteredAggregate = new MartenTests.SelfLetteredAggregate(); + + // The actual message execution + var outgoing1 = eventStream.Aggregate.Handle(incrementA2, _logger); + + eventStream.AppendOne(outgoing1); + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementA2Handler79726078 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementABHandler79726094.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementABHandler79726094.cs new file mode 100644 index 000000000..68bd36e02 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementABHandler79726094.cs @@ -0,0 +1,51 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementABHandler79726094 + public class IncrementABHandler79726094 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementABHandler79726094(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementAB = (MartenTests.IncrementAB)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForExclusiveWriting(incrementAB.LetterAggregateId, cancellation).ConfigureAwait(false); + + + // The actual message execution + var outgoing1 = MartenTests.SpecialLetterHandler.Handle(incrementAB, eventStream.Aggregate); + + if (outgoing1 != null) + { + + // Capturing any possible events returned from the command handlers + eventStream.AppendMany(outgoing1); + + } + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementABHandler79726094 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementAHandler1658474384.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementAHandler1658474384.cs new file mode 100644 index 000000000..cac875b16 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementAHandler1658474384.cs @@ -0,0 +1,45 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementAHandler1658474384 + public class IncrementAHandler1658474384 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementAHandler1658474384(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementA = (MartenTests.IncrementA)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(incrementA.LetterAggregateId, cancellation).ConfigureAwait(false); + + var letterAggregateHandler = new MartenTests.LetterAggregateHandler(); + + // The actual message execution + var outgoing1 = letterAggregateHandler.Handle(incrementA, eventStream.Aggregate, documentSession); + + eventStream.AppendOne(outgoing1); + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementAHandler1658474384 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementB2Handler483010605.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementB2Handler483010605.cs new file mode 100644 index 000000000..a34e88b29 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementB2Handler483010605.cs @@ -0,0 +1,46 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementB2Handler483010605 + public class IncrementB2Handler483010605 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementB2Handler483010605(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementB2 = (MartenTests.IncrementB2)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(incrementB2.SelfLetteredAggregateId, cancellation).ConfigureAwait(false); + + if (eventStream.Aggregate == null) throw new Wolverine.Marten.UnknownAggregateException(typeof(MartenTests.SelfLetteredAggregate), incrementB2.SelfLetteredAggregateId); + var selfLetteredAggregate = new MartenTests.SelfLetteredAggregate(); + + // The actual message execution + var outgoing1 = await eventStream.Aggregate.Handle(incrementB2).ConfigureAwait(false); + + eventStream.AppendOne(outgoing1); + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementB2Handler483010605 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementBCHandler483010622.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementBCHandler483010622.cs new file mode 100644 index 000000000..a98cdec9b --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementBCHandler483010622.cs @@ -0,0 +1,52 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementBCHandler483010622 + public class IncrementBCHandler483010622 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementBCHandler483010622(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementBC = (MartenTests.IncrementBC)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(incrementBC.LetterAggregateId, incrementBC.Version, cancellation).ConfigureAwait(false); + + var letterAggregateHandler = new MartenTests.LetterAggregateHandler(); + + // The actual message execution + var outgoing1 = letterAggregateHandler.Handle(incrementBC, eventStream.Aggregate); + + if (outgoing1 != null) + { + + // Capturing any possible events returned from the command handlers + eventStream.AppendMany(outgoing1); + + } + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementBCHandler483010622 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementBHandler1255189857.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementBHandler1255189857.cs new file mode 100644 index 000000000..747c35175 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementBHandler1255189857.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable +using Microsoft.Extensions.Logging; +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementBHandler1255189857 + public class IncrementBHandler1255189857 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Microsoft.Extensions.Logging.ILogger _logger; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementBHandler1255189857(Microsoft.Extensions.Logging.ILogger logger, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _logger = logger; + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementB = (MartenTests.IncrementB)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(incrementB.LetterAggregateId, cancellation).ConfigureAwait(false); + + var letterAggregateHandler = new MartenTests.LetterAggregateHandler(); + + // The actual message execution + var outgoing1 = await letterAggregateHandler.Handle(incrementB, eventStream.Aggregate, _logger).ConfigureAwait(false); + + eventStream.AppendOne(outgoing1); + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementBHandler1255189857 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementCDHandler1083073314.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementCDHandler1083073314.cs new file mode 100644 index 000000000..ae02a28e6 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementCDHandler1083073314.cs @@ -0,0 +1,46 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementCDHandler1083073314 + public class IncrementCDHandler1083073314 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementCDHandler1083073314(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementCD = (MartenTests.IncrementCD)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(incrementCD.LetterAggregateId, incrementCD.Version, cancellation).ConfigureAwait(false); + + var letterAggregateHandler = new MartenTests.LetterAggregateHandler(); + + // The actual message execution + (var outgoing1, var outgoing2) = letterAggregateHandler.Handle(incrementCD, eventStream.Aggregate); + + eventStream.AppendOne(outgoing1); + eventStream.AppendOne(outgoing2); + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementCDHandler1083073314 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementCHandler1473693498.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementCHandler1473693498.cs new file mode 100644 index 000000000..5e6254aec --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementCHandler1473693498.cs @@ -0,0 +1,44 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementCHandler1473693498 + public class IncrementCHandler1473693498 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementCHandler1473693498(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementC = (MartenTests.IncrementC)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(incrementC.LetterAggregateId, cancellation).ConfigureAwait(false); + + var letterAggregateHandler = new MartenTests.LetterAggregateHandler(); + + // The actual message execution + letterAggregateHandler.Handle(incrementC, eventStream); + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementCHandler1473693498 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementDHandler1876978025.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementDHandler1876978025.cs new file mode 100644 index 000000000..8c6fed298 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementDHandler1876978025.cs @@ -0,0 +1,44 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementDHandler1876978025 + public class IncrementDHandler1876978025 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementDHandler1876978025(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementD = (MartenTests.IncrementD)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(incrementD.LetterAggregateId, cancellation).ConfigureAwait(false); + + var letterAggregateHandler = new MartenTests.LetterAggregateHandler(); + + // The actual message execution + await letterAggregateHandler.Handle(incrementD, eventStream).ConfigureAwait(false); + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementDHandler1876978025 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementMany2Handler448896552.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementMany2Handler448896552.cs new file mode 100644 index 000000000..f0881e745 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementMany2Handler448896552.cs @@ -0,0 +1,53 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementMany2Handler448896552 + public class IncrementMany2Handler448896552 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementMany2Handler448896552(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementMany2 = (MartenTests.IncrementMany2)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(incrementMany2.SelfLetteredAggregateId, cancellation).ConfigureAwait(false); + + if (eventStream.Aggregate == null) throw new Wolverine.Marten.UnknownAggregateException(typeof(MartenTests.SelfLetteredAggregate), incrementMany2.SelfLetteredAggregateId); + var selfLetteredAggregate = new MartenTests.SelfLetteredAggregate(); + + // The actual message execution + var outgoing1 = eventStream.Aggregate.Handle(incrementMany2); + + if (outgoing1 != null) + { + + // Capturing any possible events returned from the command handlers + eventStream.AppendMany(outgoing1); + + } + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementMany2Handler448896552 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementManyAsyncHandler2038967698.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementManyAsyncHandler2038967698.cs new file mode 100644 index 000000000..e8e5f7ef5 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementManyAsyncHandler2038967698.cs @@ -0,0 +1,52 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementManyAsyncHandler2038967698 + public class IncrementManyAsyncHandler2038967698 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementManyAsyncHandler2038967698(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementManyAsync = (MartenTests.IncrementManyAsync)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(incrementManyAsync.LetterAggregateId, cancellation).ConfigureAwait(false); + + var letterAggregateHandler = new MartenTests.LetterAggregateHandler(); + + // The actual message execution + var outgoing1 = await letterAggregateHandler.Handle(incrementManyAsync, eventStream.Aggregate, documentSession).ConfigureAwait(false); + + if (outgoing1 != null) + { + + // Capturing any possible events returned from the command handlers + eventStream.AppendMany(outgoing1); + + } + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementManyAsyncHandler2038967698 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementManyHandler1569177634.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementManyHandler1569177634.cs new file mode 100644 index 000000000..2fda2667c --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/IncrementManyHandler1569177634.cs @@ -0,0 +1,52 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: IncrementManyHandler1569177634 + public class IncrementManyHandler1569177634 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public IncrementManyHandler1569177634(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var incrementMany = (MartenTests.IncrementMany)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(incrementMany.LetterAggregateId, cancellation).ConfigureAwait(false); + + var letterAggregateHandler = new MartenTests.LetterAggregateHandler(); + + // The actual message execution + var outgoing1 = letterAggregateHandler.Handle(incrementMany, eventStream.Aggregate, documentSession); + + if (outgoing1 != null) + { + + // Capturing any possible events returned from the command handlers + eventStream.AppendMany(outgoing1); + + } + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: IncrementManyHandler1569177634 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/LetterMessage1Handler726704086.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/LetterMessage1Handler726704086.cs new file mode 100644 index 000000000..91b56d1f1 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/LetterMessage1Handler726704086.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable + +namespace Internal.Generated.WolverineHandlers +{ + // START: LetterMessage1Handler726704086 + public class LetterMessage1Handler726704086 : Wolverine.Runtime.Handlers.MessageHandler + { + + + public override System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var letterMessage1 = (MartenTests.LetterMessage1)context.Envelope.Message; + + + // The actual message execution + MartenTests.ResponseHandler.Handle(letterMessage1); + + return System.Threading.Tasks.Task.CompletedTask; + } + + } + + // END: LetterMessage1Handler726704086 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/LetterMessage2Handler839379855.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/LetterMessage2Handler839379855.cs new file mode 100644 index 000000000..6b50ecd97 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/LetterMessage2Handler839379855.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable + +namespace Internal.Generated.WolverineHandlers +{ + // START: LetterMessage2Handler839379855 + public class LetterMessage2Handler839379855 : Wolverine.Runtime.Handlers.MessageHandler + { + + + public override System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var letterMessage2 = (MartenTests.LetterMessage2)context.Envelope.Message; + + + // The actual message execution + MartenTests.ResponseHandler.Handle(letterMessage2); + + return System.Threading.Tasks.Task.CompletedTask; + } + + } + + // END: LetterMessage2Handler839379855 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/Outgoing1Handler1264108911.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/Outgoing1Handler1264108911.cs new file mode 100644 index 000000000..76d510674 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/Outgoing1Handler1264108911.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable + +namespace Internal.Generated.WolverineHandlers +{ + // START: Outgoing1Handler1264108911 + public class Outgoing1Handler1264108911 : Wolverine.Runtime.Handlers.MessageHandler + { + + + public override System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var outgoing1 = (MartenTests.Outgoing1)context.Envelope.Message; + + + // The actual message execution + MartenTests.Outgoing1Handler.Handle(outgoing1); + + return System.Threading.Tasks.Task.CompletedTask; + } + + } + + // END: Outgoing1Handler1264108911 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseAAAHandler1649029811.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseAAAHandler1649029811.cs new file mode 100644 index 000000000..2b79540a4 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseAAAHandler1649029811.cs @@ -0,0 +1,47 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: RaiseAAAHandler1649029811 + public class RaiseAAAHandler1649029811 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public RaiseAAAHandler1649029811(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var raiseAAA = (MartenTests.RaiseAAA)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(raiseAAA.LetterAggregateId, cancellation).ConfigureAwait(false); + + + // The actual message execution + var outgoing1 = MartenTests.RaiseLetterHandler.Handle(raiseAAA, eventStream); + + + // Outgoing, cascaded message + await context.EnqueueCascadingAsync(outgoing1).ConfigureAwait(false); + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: RaiseAAAHandler1649029811 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseAABCCHandler1413048758.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseAABCCHandler1413048758.cs new file mode 100644 index 000000000..94ff56718 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseAABCCHandler1413048758.cs @@ -0,0 +1,55 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: RaiseAABCCHandler1413048758 + public class RaiseAABCCHandler1413048758 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public RaiseAABCCHandler1413048758(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var raiseAABCC = (MartenTests.RaiseAABCC)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(raiseAABCC.LetterAggregateId, cancellation).ConfigureAwait(false); + + + // The actual message execution + (var outgoing1, var outgoing2) = MartenTests.RaiseLetterHandler.Handle(raiseAABCC, eventStream.Aggregate); + + + // Outgoing, cascaded message + await context.EnqueueCascadingAsync(outgoing1).ConfigureAwait(false); + + if (outgoing2 != null) + { + + // Capturing any possible events returned from the command handlers + eventStream.AppendMany(outgoing2); + + } + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: RaiseAABCCHandler1413048758 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseABCHandler1483138068.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseABCHandler1483138068.cs new file mode 100644 index 000000000..e503e6663 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseABCHandler1483138068.cs @@ -0,0 +1,55 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: RaiseABCHandler1483138068 + public class RaiseABCHandler1483138068 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public RaiseABCHandler1483138068(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var raiseABC = (MartenTests.RaiseABC)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(raiseABC.LetterAggregateId, cancellation).ConfigureAwait(false); + + + // The actual message execution + (var outgoing1, var outgoing2) = MartenTests.RaiseLetterHandler.Handle(raiseABC, eventStream.Aggregate); + + if (outgoing1 != null) + { + + // Capturing any possible events returned from the command handlers + eventStream.AppendMany(outgoing1); + + } + + + // Outgoing, cascaded message + await context.EnqueueCascadingAsync(outgoing2).ConfigureAwait(false); + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: RaiseABCHandler1483138068 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseBBCCCHandler1900945687.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseBBCCCHandler1900945687.cs new file mode 100644 index 000000000..ed6c631bf --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseBBCCCHandler1900945687.cs @@ -0,0 +1,59 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: RaiseBBCCCHandler1900945687 + public class RaiseBBCCCHandler1900945687 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public RaiseBBCCCHandler1900945687(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var raiseBBCCC = (MartenTests.RaiseBBCCC)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(raiseBBCCC.LetterAggregateId, cancellation).ConfigureAwait(false); + + + // The actual message execution + (var outgoing1, var outgoing2, var outgoing3) = MartenTests.RaiseLetterHandler.Handle(raiseBBCCC, eventStream.Aggregate); + + + // Outgoing, cascaded message + await context.EnqueueCascadingAsync(outgoing1).ConfigureAwait(false); + + if (outgoing2 != null) + { + + // Capturing any possible events returned from the command handlers + eventStream.AppendMany(outgoing2); + + } + + + // Outgoing, cascaded message + await context.EnqueueCascadingAsync(outgoing3).ConfigureAwait(false); + + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: RaiseBBCCCHandler1900945687 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseLotsAsyncHandler89313884.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseLotsAsyncHandler89313884.cs new file mode 100644 index 000000000..b99eab92d --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseLotsAsyncHandler89313884.cs @@ -0,0 +1,45 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: RaiseLotsAsyncHandler89313884 + public class RaiseLotsAsyncHandler89313884 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public RaiseLotsAsyncHandler89313884(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var raiseLotsAsync = (MartenTests.RaiseLotsAsync)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(raiseLotsAsync.LetterAggregateId, cancellation).ConfigureAwait(false); + + + // The actual message execution + var outgoing1 = MartenTests.RaiseLetterHandler.Handle(raiseLotsAsync, eventStream.Aggregate); + + // Apply events to Marten event stream + await foreach (var letterAggregateEvent in outgoing1) eventStream.AppendOne(letterAggregateEvent); + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: RaiseLotsAsyncHandler89313884 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseOnlyDHandler1609388090.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseOnlyDHandler1609388090.cs new file mode 100644 index 000000000..83adacdc2 --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/RaiseOnlyDHandler1609388090.cs @@ -0,0 +1,44 @@ +// +#pragma warning disable +using Wolverine.Marten.Publishing; + +namespace Internal.Generated.WolverineHandlers +{ + // START: RaiseOnlyDHandler1609388090 + public class RaiseOnlyDHandler1609388090 : Wolverine.Runtime.Handlers.MessageHandler + { + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public RaiseOnlyDHandler1609388090(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + { + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var raiseOnlyD = (MartenTests.RaiseOnlyD)context.Envelope.Message; + + await using var documentSession = _outboxedSessionFactory.OpenSession(context); + var eventStore = documentSession.Events; + + // Loading Marten aggregate + var eventStream = await eventStore.FetchForWriting(raiseOnlyD.LetterAggregateId, cancellation).ConfigureAwait(false); + + + // The actual message execution + var outgoing1 = MartenTests.RaiseLetterHandler.Handle(raiseOnlyD, eventStream.Aggregate); + + eventStream.AppendOne(outgoing1); + await documentSession.SaveChangesAsync(cancellation).ConfigureAwait(false); + } + + } + + // END: RaiseOnlyDHandler1609388090 + + +} + diff --git a/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/ResponseHandler2107844337.cs b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/ResponseHandler2107844337.cs new file mode 100644 index 000000000..36b30592b --- /dev/null +++ b/src/Persistence/MartenTests/Internal/Generated/WolverineHandlers/ResponseHandler2107844337.cs @@ -0,0 +1,29 @@ +// +#pragma warning disable + +namespace Internal.Generated.WolverineHandlers +{ + // START: ResponseHandler2107844337 + public class ResponseHandler2107844337 : Wolverine.Runtime.Handlers.MessageHandler + { + + + public override System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation) + { + // The actual message body + var response = (MartenTests.Response)context.Envelope.Message; + + + // The actual message execution + MartenTests.ResponseHandler.Handle(response); + + return System.Threading.Tasks.Task.CompletedTask; + } + + } + + // END: ResponseHandler2107844337 + + +} + diff --git a/src/Persistence/MartenTests/Saga/UserRegistrationSaga.cs b/src/Persistence/MartenTests/Saga/UserRegistrationSaga.cs index c6033a104..e41f7d854 100644 --- a/src/Persistence/MartenTests/Saga/UserRegistrationSaga.cs +++ b/src/Persistence/MartenTests/Saga/UserRegistrationSaga.cs @@ -1,8 +1,9 @@ +using Marten.Metadata; using Wolverine.Persistence.Sagas; namespace MartenTests.Saga; -public class UserRegistrationSaga : Wolverine.Saga +public class UserRegistrationSaga : Wolverine.Saga, IRevisioned { public string? Id { get; set; } diff --git a/src/Persistence/Wolverine.Marten/Persistence/Sagas/LoadDocumentFrame.cs b/src/Persistence/Wolverine.Marten/Persistence/Sagas/LoadDocumentFrame.cs index 6d625461d..e5e3a78e1 100644 --- a/src/Persistence/Wolverine.Marten/Persistence/Sagas/LoadDocumentFrame.cs +++ b/src/Persistence/Wolverine.Marten/Persistence/Sagas/LoadDocumentFrame.cs @@ -43,8 +43,9 @@ public override void GenerateCode(GeneratedMethod method, ISourceWriter writer) if (Saga.VariableType.CanBeCastTo()) { writer.WriteComment($"{Saga.VariableType.FullNameInCode()} implements {typeof(IRevisioned).FullNameInCode()}, so Wolverine will try to update based on the revision as a concurrency protection"); - writer.WriteLine($"BLOCK:if ({Saga.Usage} != null)"); - writer.WriteLine($"var {ExpectedSagaRevision} = {Saga.Usage}.{nameof(IRevisioned.Version)} + 1;"); + writer.Write($"var {ExpectedSagaRevision} = 0;"); + writer.Write($"BLOCK:if ({Saga.Usage} != null)"); + writer.Write($"{ExpectedSagaRevision} = {Saga.Usage}.{nameof(IRevisioned.Version)} + 1;"); writer.FinishBlock(); }