From 33ad8793abec263eccfa29cb51e23e4dcfc246ab Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 20 May 2024 06:58:46 +0200 Subject: Log warning if registering a duplicate type --- LibMatrix/StateEvent.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LibMatrix/StateEvent.cs b/LibMatrix/StateEvent.cs index e3de7e6..81ee3fe 100644 --- a/LibMatrix/StateEvent.cs +++ b/LibMatrix/StateEvent.cs @@ -19,7 +19,11 @@ public class StateEvent { new Dictionary(), (dict, type) => { var attrs = type.GetCustomAttributes(); - foreach (var attr in attrs) dict[attr.EventName] = type; + foreach (var attr in attrs) { + if (dict.TryGetValue(attr.EventName, out var existing)) + Console.WriteLine($"Duplicate event type '{attr.EventName}' registered for types '{existing.Name}' and '{type.Name}'"); + dict[attr.EventName] = type; + } return dict; }).OrderBy(x => x.Key).ToFrozenDictionary(); -- cgit 1.4.1