diff options
author | Rory& <root@rory.gay> | 2024-05-20 06:58:46 +0200 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-05-20 06:58:46 +0200 |
commit | 33ad8793abec263eccfa29cb51e23e4dcfc246ab (patch) | |
tree | e1a70f2f145f0827501e1ad26971fa0bf51e8945 /LibMatrix/StateEvent.cs | |
parent | Log unrecognised types (diff) | |
download | LibMatrix-33ad8793abec263eccfa29cb51e23e4dcfc246ab.tar.xz |
Log warning if registering a duplicate type
Diffstat (limited to 'LibMatrix/StateEvent.cs')
-rw-r--r-- | LibMatrix/StateEvent.cs | 6 |
1 files changed, 5 insertions, 1 deletions
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<string, Type>(), (dict, type) => { var attrs = type.GetCustomAttributes<MatrixEventAttribute>(); - 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(); |