com.wallstop-studios.dxmessaging 3.1.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/Editor/Analyzers/BaseCallLogMessageParser.cs.meta +3 -3
  3. package/Editor/Analyzers/BaseCallReportAggregator.cs.meta +3 -3
  4. package/Editor/Analyzers/DxMessagingConsoleHarvester.cs +8 -8
  5. package/Editor/Analyzers/DxMessagingConsoleHarvester.cs.meta +3 -3
  6. package/Editor/CustomEditors/MessageAwareComponentFallbackEditor.cs +171 -13
  7. package/Editor/CustomEditors/MessageAwareComponentFallbackEditor.cs.meta +3 -3
  8. package/Editor/CustomEditors/MessageAwareComponentInspectorOverlay.cs +391 -96
  9. package/Editor/CustomEditors/MessageAwareComponentInspectorOverlay.cs.meta +3 -3
  10. package/Editor/CustomEditors/MessageAwareComponentInspectorView.cs +279 -0
  11. package/Editor/CustomEditors/MessageAwareComponentInspectorView.cs.meta +11 -0
  12. package/Editor/DxMessagingEditorPalette.cs +66 -0
  13. package/Editor/DxMessagingEditorPalette.cs.meta +11 -0
  14. package/Editor/DxMessagingEditorTheme.cs +200 -0
  15. package/Editor/DxMessagingEditorTheme.cs.meta +11 -0
  16. package/Editor/DxMessagingMenu.cs.meta +3 -3
  17. package/Editor/DxMessagingSceneBuildProcessor.cs.meta +3 -3
  18. package/Editor/Icons/dxmessaging-icon-256.png +0 -0
  19. package/Editor/Icons/dxmessaging-icon-256.png.meta +156 -0
  20. package/Editor/Icons/dxmessaging-icon-32.png +0 -0
  21. package/Editor/Icons/dxmessaging-icon-32.png.meta +156 -0
  22. package/Editor/Icons/dxmessaging-icon-48.png +0 -0
  23. package/Editor/Icons/dxmessaging-icon-48.png.meta +156 -0
  24. package/Editor/Icons.meta +8 -0
  25. package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs +2 -3
  26. package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs.meta +3 -3
  27. package/Editor/Settings/DxMessagingSettingsProvider.cs +368 -33
  28. package/Editor/SetupCscRsp.cs +232 -163
  29. package/Editor/Testing/MessagingComponentEditorHarness.cs +11 -4
  30. package/Editor/Theme/DxMessagingTheme.uss +255 -0
  31. package/Editor/Theme/DxMessagingTheme.uss.meta +11 -0
  32. package/Editor/Theme/DxTokens.uss +90 -0
  33. package/Editor/Theme/DxTokens.uss.meta +11 -0
  34. package/Editor/Theme.meta +8 -0
  35. package/Editor/Windows/DxMessagingFlowGraphWindow.cs +5513 -0
  36. package/Editor/Windows/DxMessagingFlowGraphWindow.cs.meta +11 -0
  37. package/Editor/Windows/DxMessagingMessageMonitorWindow.cs +2288 -0
  38. package/Editor/Windows/DxMessagingMessageMonitorWindow.cs.meta +11 -0
  39. package/Editor/Windows.meta +8 -0
  40. package/README.md +84 -35
  41. package/Runtime/Analyzers.meta +8 -0
  42. package/Runtime/AssemblyInfo.cs +1 -0
  43. package/Runtime/Core/Attributes/DxIgnoreMissingBaseCallAttribute.cs.meta +3 -3
  44. package/Runtime/Core/Diagnostics/MessageEmissionData.cs +29 -1
  45. package/Runtime/Core/DxMessagingStaticState.cs.meta +3 -3
  46. package/Runtime/Core/Extensions/MessageBusExtensions.cs.meta +3 -3
  47. package/Runtime/Core/Extensions/MessageExtensions.cs +4 -5
  48. package/Runtime/Core/Extensions/MessageExtensions.cs.meta +3 -3
  49. package/Runtime/Core/Helper/MessageCache.cs +56 -23
  50. package/Runtime/Core/IMessage.cs.meta +3 -3
  51. package/Runtime/Core/InstanceId.cs.meta +3 -3
  52. package/Runtime/Core/Internal/FlatDispatch.cs +32 -0
  53. package/Runtime/Core/Internal/TypedSlots.cs +45 -7
  54. package/Runtime/Core/MessageBus/DiagnosticsTarget.cs.meta +3 -3
  55. package/Runtime/Core/MessageBus/GlobalMessageBusProvider.cs.meta +3 -3
  56. package/Runtime/Core/MessageBus/IMessageBus.cs +63 -28
  57. package/Runtime/Core/MessageBus/IMessageBus.cs.meta +3 -3
  58. package/Runtime/Core/MessageBus/IMessageBusProvider.cs.meta +3 -3
  59. package/Runtime/Core/MessageBus/IMessageRegistrationBuilder.cs.meta +3 -3
  60. package/Runtime/Core/MessageBus/MessageBus.cs +1135 -626
  61. package/Runtime/Core/MessageBus/MessageBus.cs.meta +3 -3
  62. package/Runtime/Core/MessageBus/MessageBusRebindMode.cs.meta +3 -3
  63. package/Runtime/Core/MessageBus/MessageBusRegistration.cs +207 -0
  64. package/Runtime/Core/MessageBus/MessageBusRegistration.cs.meta +11 -0
  65. package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs.meta +3 -3
  66. package/Runtime/Core/MessageBus/MessagingRegistration.cs.meta +3 -3
  67. package/Runtime/Core/MessageBus/RegistrationLog.cs +25 -12
  68. package/Runtime/Core/MessageBus/RegistrationLog.cs.meta +3 -3
  69. package/Runtime/Core/MessageHandler.cs +1886 -1082
  70. package/Runtime/Core/MessageHandler.cs.meta +3 -3
  71. package/Runtime/Core/MessageRegistrationHandle.cs +19 -5
  72. package/Runtime/Core/MessageRegistrationHandle.cs.meta +3 -3
  73. package/Runtime/Core/MessageRegistrationToken.cs +1932 -895
  74. package/Runtime/Core/MessageRegistrationToken.cs.meta +3 -3
  75. package/Runtime/Core/Messages/IBroadcastMessage.cs.meta +3 -3
  76. package/Runtime/Core/Messages/ITargetedMessage.cs.meta +3 -3
  77. package/Runtime/Core/Messages/IUntargetedMessage.cs.meta +3 -3
  78. package/Runtime/Core/Messages/SourcedStringMessage.cs.meta +3 -3
  79. package/Runtime/Core/MessagingDebug.cs.meta +3 -3
  80. package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs.meta +3 -3
  81. package/Runtime/Unity/DxMessagingRuntimeInitializer.cs.meta +3 -3
  82. package/Runtime/Unity/InitialGlobalMessageBusProvider.cs.meta +3 -3
  83. package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs.meta +3 -3
  84. package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs.meta +3 -3
  85. package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs.meta +3 -3
  86. package/Runtime/Unity/MessageAwareComponent.cs.meta +3 -3
  87. package/Runtime/Unity/MessageBusProviderHandle.cs.meta +3 -3
  88. package/Runtime/Unity/MessagingComponent.cs.meta +3 -3
  89. package/Runtime/Unity/MessagingComponentInstaller.cs.meta +3 -3
  90. package/Runtime/Unity/ScriptableMessageBusProvider.cs.meta +3 -3
  91. package/Samples~/DI/Reflex/SampleInstaller.cs.meta +3 -3
  92. package/Samples~/DI/VContainer/SampleLifetimeScope.cs.meta +3 -3
  93. package/Samples~/DI/Zenject/SampleInstaller.cs.meta +3 -3
  94. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.cs +173 -0
  95. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.cs.meta +11 -0
  96. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.unity +424 -0
  97. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingExerciser.unity.meta +7 -0
  98. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingReceiver.cs +185 -0
  99. package/Samples~/Diagnostics Tooling Exerciser/DiagnosticsToolingReceiver.cs.meta +11 -0
  100. package/Samples~/Diagnostics Tooling Exerciser/Messages.cs +46 -0
  101. package/Samples~/Diagnostics Tooling Exerciser/Messages.cs.meta +11 -0
  102. package/Samples~/Diagnostics Tooling Exerciser/README.md +53 -0
  103. package/Samples~/Diagnostics Tooling Exerciser/README.md.meta +7 -0
  104. package/Samples~/Diagnostics Tooling Exerciser/WallstopStudios.DxMessaging.DiagnosticsToolingExerciser.Sample.asmdef +13 -0
  105. package/Samples~/Diagnostics Tooling Exerciser/WallstopStudios.DxMessaging.DiagnosticsToolingExerciser.Sample.asmdef.meta +7 -0
  106. package/Samples~/Diagnostics Tooling Exerciser.meta +8 -0
  107. package/Samples~/Mini Combat/Boot.cs.meta +3 -3
  108. package/Samples~/Mini Combat/Enemy.cs.meta +3 -3
  109. package/Samples~/Mini Combat/Messages.cs.meta +3 -3
  110. package/Samples~/Mini Combat/Player.cs.meta +3 -3
  111. package/Samples~/Mini Combat/README.md +1 -1
  112. package/Samples~/Mini Combat/UIOverlay.cs.meta +3 -3
  113. package/Samples~/Mini Combat/Walkthrough.md +3 -3
  114. package/Samples~/UI Buttons + Inspector/DiagnosticsEnabler.cs.meta +3 -3
  115. package/Samples~/UI Buttons + Inspector/Messages.cs.meta +3 -3
  116. package/Samples~/UI Buttons + Inspector/MessagingObserver.cs.meta +3 -3
  117. package/Samples~/UI Buttons + Inspector/UIButtonEmitter.cs.meta +3 -3
  118. package/SourceGenerators/Directory.Build.props +5 -5
  119. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs.meta +3 -3
  120. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.csproj +12 -11
  121. package/docs/images/DxMessaging-banner.svg +79 -0
  122. package/docs/images/DxMessaging-banner.svg.meta +53 -0
  123. package/docs/images.meta +8 -0
  124. package/docs.meta +8 -0
  125. package/package.json +17 -5
  126. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  127. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.CSharp.dll.meta +0 -0
  128. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.dll +0 -0
  129. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.dll.meta +0 -0
  130. /package/{Editor → Runtime}/Analyzers/System.Collections.Immutable.dll +0 -0
  131. /package/{Editor → Runtime}/Analyzers/System.Collections.Immutable.dll.meta +0 -0
  132. /package/{Editor → Runtime}/Analyzers/System.Reflection.Metadata.dll +0 -0
  133. /package/{Editor → Runtime}/Analyzers/System.Reflection.Metadata.dll.meta +0 -0
  134. /package/{Editor → Runtime}/Analyzers/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  135. /package/{Editor → Runtime}/Analyzers/System.Runtime.CompilerServices.Unsafe.dll.meta +0 -0
  136. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll +0 -0
  137. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll.meta +0 -0
  138. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
  139. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll.meta +0 -0
@@ -6,6 +6,6 @@ MonoImporter:
6
6
  defaultReferences: []
7
7
  executionOrder: 0
8
8
  icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -6,6 +6,6 @@ MonoImporter:
6
6
  defaultReferences: []
7
7
  executionOrder: 0
8
8
  icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,207 @@
1
+ namespace DxMessaging.Core.MessageBus
2
+ {
3
+ using System;
4
+ using System.Runtime.CompilerServices;
5
+
6
+ /// <summary>
7
+ /// Opaque subscription handle returned by the <see cref="IMessageBus"/> registration
8
+ /// methods (replacing the deregistration <see cref="Action"/> returned prior to v4).
9
+ /// </summary>
10
+ /// <remarks>
11
+ /// <para>
12
+ /// Hand the handle back to <see cref="IMessageBus.Deregister{T}"/> with the SAME
13
+ /// <c>T</c> you registered with to undo the registration. It is an opaque value token:
14
+ /// copy it freely, but do NOT inspect or persist its internals. Handles are
15
+ /// process-local, single-thread, and NOT serializable; a handle is meaningless after a
16
+ /// domain reload (its captured generation no longer matches, so deregistration becomes a
17
+ /// silent no-op) and is not portable across <see cref="IMessageBus"/> implementations.
18
+ /// </para>
19
+ /// <para>
20
+ /// The <c>default</c> value is the <see cref="None"/> sentinel; deregistering it is a
21
+ /// no-op. Custom <see cref="IMessageBus"/> implementers that do not wrap
22
+ /// <see cref="MessageBus"/> mint their own handles via the
23
+ /// <see cref="MessageBusRegistration(long, object)"/> constructor and read them back in
24
+ /// their own <see cref="IMessageBus.Deregister{T}"/> override (see <see cref="ExternalId"/>
25
+ /// / <see cref="ExternalState"/>).
26
+ /// </para>
27
+ /// </remarks>
28
+ public readonly struct MessageBusRegistration : IEquatable<MessageBusRegistration>
29
+ {
30
+ /// <summary>
31
+ /// Discriminates which bus store a handle deregisters from. The interceptor stores are
32
+ /// split because all three interceptor registrars log a single
33
+ /// <see cref="RegistrationMethod.Interceptor"/>, so <see cref="method"/> cannot pick
34
+ /// among them; the registering site (which knows the category) stamps the kind.
35
+ /// </summary>
36
+ internal enum Kind : byte
37
+ {
38
+ None = 0,
39
+ Handler,
40
+ UntargetedInterceptor,
41
+ TargetedInterceptor,
42
+ BroadcastInterceptor,
43
+ GlobalAcceptAll,
44
+ External,
45
+ }
46
+
47
+ /// <summary><see cref="Kind.None"/> =&gt; an invalid/empty handle; deregistration no-ops.</summary>
48
+ internal readonly Kind kind;
49
+
50
+ /// <summary>
51
+ /// Sink/scalar-vs-keyed discriminator AND the <see cref="RegistrationLog"/> row key for
52
+ /// the <see cref="Kind.Handler"/> shape. Unused (default) for the other kinds.
53
+ /// </summary>
54
+ internal readonly RegistrationMethod method;
55
+
56
+ /// <summary>The priority the handler/interceptor was registered at.</summary>
57
+ internal readonly int priority;
58
+
59
+ /// <summary>The <c>_resetGeneration</c> snapshot (reset/domain-reload guard, all kinds).</summary>
60
+ internal readonly long generation;
61
+
62
+ /// <summary>The <c>_globalSlotSweepGeneration</c> snapshot (<see cref="Kind.GlobalAcceptAll"/> only).</summary>
63
+ internal readonly long sweepGeneration;
64
+
65
+ /// <summary>
66
+ /// A unique per-registration stamp (the bus tick at registration time). It does NOT
67
+ /// participate in deregistration (the sink is re-resolved without it); its sole purpose is
68
+ /// to make two handles from distinct <c>Register*</c> calls compare UNEQUAL even when they
69
+ /// bump the same handler's refcount (same generation/caches/payload/priority/method). This
70
+ /// preserves the pre-v4 semantics where each registration returned a distinct deregistration
71
+ /// delegate, so handles remain safe to store in a set/map keyed by value.
72
+ /// </summary>
73
+ internal readonly long sequence;
74
+
75
+ /// <summary>
76
+ /// The captured identity anchor for the over-deregistration / stale-after-sweep checks:
77
+ /// the per-type <c>HandlerCache</c> (<see cref="Kind.Handler"/>) or the
78
+ /// <c>InterceptorCache</c> (interceptor kinds). Unused for
79
+ /// <see cref="Kind.GlobalAcceptAll"/> (reads the live global slot) and
80
+ /// <see cref="Kind.External"/>.
81
+ /// </summary>
82
+ internal readonly object capturedPrimary;
83
+
84
+ /// <summary>
85
+ /// The keyed (<see cref="Kind.Handler"/> targeted/broadcast) per-type context map captured
86
+ /// by identity; null otherwise.
87
+ /// </summary>
88
+ internal readonly object capturedSecondary;
89
+
90
+ /// <summary>
91
+ /// The deregistration payload: the <see cref="MessageHandler"/>
92
+ /// (<see cref="Kind.Handler"/> / <see cref="Kind.GlobalAcceptAll"/>), the interceptor
93
+ /// delegate (interceptor kinds), or the caller's external state
94
+ /// (<see cref="Kind.External"/>).
95
+ /// </summary>
96
+ internal readonly object payload;
97
+
98
+ /// <summary>
99
+ /// The keyed (<see cref="Kind.Handler"/> targeted/broadcast) target/source; <c>default</c>
100
+ /// otherwise (so no <c>UnityEngine.Object</c> is pinned for non-keyed kinds).
101
+ /// </summary>
102
+ internal readonly InstanceId context;
103
+
104
+ internal MessageBusRegistration(
105
+ Kind kind,
106
+ RegistrationMethod method,
107
+ int priority,
108
+ long generation,
109
+ long sweepGeneration,
110
+ long sequence,
111
+ object capturedPrimary,
112
+ object capturedSecondary,
113
+ object payload,
114
+ InstanceId context
115
+ )
116
+ {
117
+ this.kind = kind;
118
+ this.method = method;
119
+ this.priority = priority;
120
+ this.generation = generation;
121
+ this.sweepGeneration = sweepGeneration;
122
+ this.sequence = sequence;
123
+ this.capturedPrimary = capturedPrimary;
124
+ this.capturedSecondary = capturedSecondary;
125
+ this.payload = payload;
126
+ this.context = context;
127
+ }
128
+
129
+ /// <summary>
130
+ /// Mints an opaque handle for a custom (non-wrapping) <see cref="IMessageBus"/>
131
+ /// implementer. Pack any state required to deregister into
132
+ /// <paramref name="externalState"/> and an id into <paramref name="externalId"/>; read
133
+ /// them back via <see cref="ExternalId"/> / <see cref="ExternalState"/> in your own
134
+ /// <see cref="IMessageBus.Deregister{T}"/>. The built-in <see cref="MessageBus"/> treats
135
+ /// such a handle as a no-op (it owns no store for it).
136
+ /// </summary>
137
+ public MessageBusRegistration(long externalId, object externalState)
138
+ : this(
139
+ Kind.External,
140
+ default,
141
+ 0,
142
+ externalId,
143
+ 0L,
144
+ 0L,
145
+ null,
146
+ null,
147
+ externalState,
148
+ default
149
+ ) { }
150
+
151
+ /// <summary>The invalid/empty handle. Deregistering it is a silent no-op.</summary>
152
+ public static readonly MessageBusRegistration None = default;
153
+
154
+ /// <summary>True when this handle represents a live registration (not <see cref="None"/>).</summary>
155
+ public bool IsValid => kind != Kind.None;
156
+
157
+ /// <summary>The external id supplied to <see cref="MessageBusRegistration(long, object)"/>; 0 for non-external handles.</summary>
158
+ public long ExternalId => kind == Kind.External ? generation : 0L;
159
+
160
+ /// <summary>The external state supplied to <see cref="MessageBusRegistration(long, object)"/>; null for non-external handles.</summary>
161
+ public object ExternalState => kind == Kind.External ? payload : null;
162
+
163
+ /// <inheritdoc />
164
+ public bool Equals(MessageBusRegistration other) =>
165
+ kind == other.kind
166
+ && method == other.method
167
+ && priority == other.priority
168
+ && generation == other.generation
169
+ && sweepGeneration == other.sweepGeneration
170
+ && sequence == other.sequence
171
+ && ReferenceEquals(capturedPrimary, other.capturedPrimary)
172
+ && ReferenceEquals(capturedSecondary, other.capturedSecondary)
173
+ && ReferenceEquals(payload, other.payload)
174
+ && context.Equals(other.context);
175
+
176
+ /// <inheritdoc />
177
+ public override bool Equals(object obj) =>
178
+ obj is MessageBusRegistration other && Equals(other);
179
+
180
+ /// <inheritdoc />
181
+ public override int GetHashCode()
182
+ {
183
+ // Reference-IDENTITY hashes for the captured refs keep parity with the
184
+ // ReferenceEquals comparisons in Equals: RuntimeHelpers.GetHashCode is the identity
185
+ // hash, so it stays consistent regardless of any virtual GetHashCode override (e.g.
186
+ // MessageHandler hashes by owner, and delegates by target/method) and avoids the
187
+ // unnecessary collisions those overrides would introduce. (null -> 0.)
188
+ int hash = (int)kind;
189
+ hash = (hash * 397) ^ (int)method;
190
+ hash = (hash * 397) ^ priority;
191
+ hash = (hash * 397) ^ generation.GetHashCode();
192
+ hash = (hash * 397) ^ sweepGeneration.GetHashCode();
193
+ hash = (hash * 397) ^ sequence.GetHashCode();
194
+ hash = (hash * 397) ^ RuntimeHelpers.GetHashCode(capturedPrimary);
195
+ hash = (hash * 397) ^ RuntimeHelpers.GetHashCode(capturedSecondary);
196
+ hash = (hash * 397) ^ RuntimeHelpers.GetHashCode(payload);
197
+ hash = (hash * 397) ^ context.GetHashCode();
198
+ return hash;
199
+ }
200
+
201
+ public static bool operator ==(MessageBusRegistration left, MessageBusRegistration right) =>
202
+ left.Equals(right);
203
+
204
+ public static bool operator !=(MessageBusRegistration left, MessageBusRegistration right) =>
205
+ !left.Equals(right);
206
+ }
207
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: e338348e96eeef44da30f7ff7f55e5fe
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -6,6 +6,6 @@ MonoImporter:
6
6
  defaultReferences: []
7
7
  executionOrder: 0
8
8
  icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -6,6 +6,6 @@ MonoImporter:
6
6
  defaultReferences: []
7
7
  executionOrder: 0
8
8
  icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -14,9 +14,10 @@ namespace DxMessaging.Core.MessageBus
14
14
  /// </remarks>
15
15
  public sealed class RegistrationLog
16
16
  {
17
- public IReadOnlyList<MessagingRegistration> Registrations => _finalizedRegistrations;
17
+ public IReadOnlyList<MessagingRegistration> Registrations =>
18
+ _finalizedRegistrations ??= new List<MessagingRegistration>();
18
19
 
19
- private readonly List<MessagingRegistration> _finalizedRegistrations;
20
+ private List<MessagingRegistration> _finalizedRegistrations;
20
21
 
21
22
  public bool Enabled
22
23
  {
@@ -35,7 +36,6 @@ namespace DxMessaging.Core.MessageBus
35
36
  public RegistrationLog(bool enabled = false)
36
37
  {
37
38
  _enabled = enabled;
38
- _finalizedRegistrations = new List<MessagingRegistration>();
39
39
  }
40
40
 
41
41
  /// <summary>
@@ -48,7 +48,7 @@ namespace DxMessaging.Core.MessageBus
48
48
  {
49
49
  return;
50
50
  }
51
- _finalizedRegistrations.Add(registration);
51
+ (_finalizedRegistrations ??= new List<MessagingRegistration>()).Add(registration);
52
52
  }
53
53
 
54
54
  /// <summary>
@@ -58,9 +58,15 @@ namespace DxMessaging.Core.MessageBus
58
58
  /// <returns>All registrations for the provided InstanceId.</returns>
59
59
  public IEnumerable<MessagingRegistration> GetRegistrations(InstanceId instanceId)
60
60
  {
61
- for (int i = 0; i < _finalizedRegistrations.Count; ++i)
61
+ List<MessagingRegistration> registrations = _finalizedRegistrations;
62
+ if (registrations == null)
62
63
  {
63
- MessagingRegistration registration = _finalizedRegistrations[i];
64
+ yield break;
65
+ }
66
+
67
+ for (int i = 0; i < registrations.Count; ++i)
68
+ {
69
+ MessagingRegistration registration = registrations[i];
64
70
  if (registration.id == instanceId)
65
71
  {
66
72
  yield return registration;
@@ -75,7 +81,8 @@ namespace DxMessaging.Core.MessageBus
75
81
  /// <returns>The string representing all logged MessagingRegistrations.</returns>
76
82
  public string ToString(Func<MessagingRegistration, string> serializer)
77
83
  {
78
- if (_finalizedRegistrations.Count == 0)
84
+ List<MessagingRegistration> finalizedRegistrations = _finalizedRegistrations;
85
+ if (finalizedRegistrations == null || finalizedRegistrations.Count == 0)
79
86
  {
80
87
  return "[]";
81
88
  }
@@ -84,13 +91,13 @@ namespace DxMessaging.Core.MessageBus
84
91
 
85
92
  StringBuilder registrations = new();
86
93
  _ = registrations.Append('[');
87
- for (int i = 0; i < _finalizedRegistrations.Count; ++i)
94
+ for (int i = 0; i < finalizedRegistrations.Count; ++i)
88
95
  {
89
96
  if (0 < i)
90
97
  {
91
98
  _ = registrations.Append(", ");
92
99
  }
93
- MessagingRegistration finalizedRegistration = _finalizedRegistrations[i];
100
+ MessagingRegistration finalizedRegistration = finalizedRegistrations[i];
94
101
  string prettyFinalizedRegistration = serializer(finalizedRegistration);
95
102
  _ = registrations.Append(prettyFinalizedRegistration);
96
103
  }
@@ -114,14 +121,20 @@ namespace DxMessaging.Core.MessageBus
114
121
  /// <returns>Number of MessagingRegistrations removed.</returns>
115
122
  public int Clear(Predicate<MessagingRegistration> shouldRemove = null)
116
123
  {
124
+ List<MessagingRegistration> finalizedRegistrations = _finalizedRegistrations;
125
+ if (finalizedRegistrations == null)
126
+ {
127
+ return 0;
128
+ }
129
+
117
130
  if (shouldRemove == null)
118
131
  {
119
- int currentCount = _finalizedRegistrations.Count;
120
- _finalizedRegistrations.Clear();
132
+ int currentCount = finalizedRegistrations.Count;
133
+ finalizedRegistrations.Clear();
121
134
  return currentCount;
122
135
  }
123
136
 
124
- return _finalizedRegistrations.RemoveAll(shouldRemove);
137
+ return finalizedRegistrations.RemoveAll(shouldRemove);
125
138
  }
126
139
  }
127
140
  }
@@ -6,6 +6,6 @@ MonoImporter:
6
6
  defaultReferences: []
7
7
  executionOrder: 0
8
8
  icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: