diff --git a/src/EventSourcingTests/removing_protected_information.cs b/src/EventSourcingTests/removing_protected_information.cs index 8aaca8f880..cc03146e6f 100644 --- a/src/EventSourcingTests/removing_protected_information.cs +++ b/src/EventSourcingTests/removing_protected_information.cs @@ -53,8 +53,8 @@ public void match_exactly_on_event_type_when_record() theEvents.TryMask(@event).ShouldBeTrue(); - started.FirstName.ShouldBe("John"); - started.LastName.ShouldBe("****"); + @event.Data.FirstName.ShouldBe("John"); + @event.Data.LastName.ShouldBe("****"); } [Fact] diff --git a/src/Marten/Events/EventGraph.Masking.cs b/src/Marten/Events/EventGraph.Masking.cs index b252cbcda6..69612e191b 100644 --- a/src/Marten/Events/EventGraph.Masking.cs +++ b/src/Marten/Events/EventGraph.Masking.cs @@ -83,9 +83,9 @@ public FuncMasker(Func masking) public bool TryMask(IEvent @event) { - if (@event is IEvent e) + if (@event is Event e) { - e.WithData(_masking(e.Data)); + e.Data = _masking(e.Data); return true; } diff --git a/src/Marten/Events/IEventStoreOptions.cs b/src/Marten/Events/IEventStoreOptions.cs index 08a0cb5bd2..277671cdf7 100644 --- a/src/Marten/Events/IEventStoreOptions.cs +++ b/src/Marten/Events/IEventStoreOptions.cs @@ -352,9 +352,18 @@ public IEventStoreOptions Upcast( /// for an event type "T" or series of event types that can be cast /// to "T" /// - /// + /// Action to mask the current object /// void AddMaskingRuleForProtectedInformation(Action action); + + /// + /// Register a policy for how to remove or mask protected information + /// for an event type "T" or series of event types that can be cast + /// to "T" + /// + /// Function to replace the event with a masked event + /// + void AddMaskingRuleForProtectedInformation(Func func); } }