com.wallstop-studios.dxmessaging 3.0.1 → 3.2.0

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 (148) hide show
  1. package/CHANGELOG.md +497 -2
  2. package/Editor/Analyzers/BaseCallLogMessageParser.cs.meta +3 -3
  3. package/Editor/Analyzers/BaseCallReportAggregator.cs.meta +3 -3
  4. package/Editor/Analyzers/DxMessagingConsoleHarvester.cs +69 -62
  5. package/Editor/Analyzers/DxMessagingConsoleHarvester.cs.meta +3 -3
  6. package/Editor/AssemblyInfo.cs.meta +9 -1
  7. package/Editor/CustomEditors/MessageAwareComponentFallbackEditor.cs.meta +3 -3
  8. package/Editor/CustomEditors/MessageAwareComponentInspectorOverlay.cs +24 -15
  9. package/Editor/CustomEditors/MessageAwareComponentInspectorOverlay.cs.meta +3 -3
  10. package/Editor/CustomEditors/MessagingComponentEditor.cs.meta +9 -1
  11. package/Editor/DxMessagingEditorIdle.cs +62 -0
  12. package/{Runtime/Core/Internal/TypedDispatchLinkIndex.cs.meta → Editor/DxMessagingEditorIdle.cs.meta} +1 -1
  13. package/Editor/DxMessagingEditorInitializer.cs +112 -15
  14. package/Editor/DxMessagingEditorInitializer.cs.meta +9 -1
  15. package/Editor/DxMessagingEditorLog.cs +32 -0
  16. package/Editor/DxMessagingEditorLog.cs.meta +11 -0
  17. package/Editor/DxMessagingMenu.cs.meta +3 -3
  18. package/Editor/DxMessagingSceneBuildProcessor.cs.meta +3 -3
  19. package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs +137 -15
  20. package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs.meta +3 -3
  21. package/Editor/Settings/DxMessagingSettings.cs +92 -31
  22. package/Editor/Settings/DxMessagingSettings.cs.meta +9 -1
  23. package/Editor/Settings/DxMessagingSettingsProvider.cs.meta +9 -1
  24. package/Editor/SetupCscRsp.cs +539 -304
  25. package/Editor/SetupCscRsp.cs.meta +9 -1
  26. package/Editor/Testing/MessagingComponentEditorHarness.cs +1 -1
  27. package/Editor/Testing/MessagingComponentEditorHarness.cs.meta +9 -1
  28. package/README.md +17 -18
  29. package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.CSharp.dll.meta +3 -3
  30. package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.dll.meta +3 -3
  31. package/{Editor → Runtime}/Analyzers/System.Collections.Immutable.dll.meta +3 -3
  32. package/{Editor → Runtime}/Analyzers/System.Reflection.Metadata.dll.meta +3 -3
  33. package/{Editor → Runtime}/Analyzers/System.Runtime.CompilerServices.Unsafe.dll.meta +3 -3
  34. package/Runtime/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll +0 -0
  35. package/Runtime/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll.meta +46 -0
  36. package/Runtime/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
  37. package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll.meta +2 -2
  38. package/Runtime/Analyzers.meta +8 -0
  39. package/Runtime/AssemblyInfo.cs.meta +9 -1
  40. package/Runtime/Core/Attributes/DxAutoConstructorAttribute.cs.meta +9 -1
  41. package/Runtime/Core/Attributes/DxBroadcastMessageAttribute.cs.meta +9 -1
  42. package/Runtime/Core/Attributes/DxIgnoreMissingBaseCallAttribute.cs.meta +3 -3
  43. package/Runtime/Core/Attributes/DxOptionalParameterAttribute.cs +2 -4
  44. package/Runtime/Core/Attributes/DxOptionalParameterAttribute.cs.meta +9 -1
  45. package/Runtime/Core/Attributes/DxTargetedMessageAttribute.cs.meta +9 -1
  46. package/Runtime/Core/Attributes/DxUntargetedMessageAttribute.cs.meta +9 -1
  47. package/Runtime/Core/Attributes/Il2CppSetOptionAttribute.cs +56 -0
  48. package/Runtime/Core/Attributes/Il2CppSetOptionAttribute.cs.meta +11 -0
  49. package/Runtime/Core/DataStructure/CyclicBuffer.cs +44 -26
  50. package/Runtime/Core/DataStructure/CyclicBuffer.cs.meta +9 -1
  51. package/Runtime/Core/Diagnostics/MessageEmissionData.cs.meta +9 -1
  52. package/Runtime/Core/Diagnostics/MessageRegistrationData.cs.meta +9 -1
  53. package/Runtime/Core/Diagnostics/MessageRegistrationType.cs.meta +9 -1
  54. package/Runtime/Core/DxMessagingStaticState.cs.meta +3 -3
  55. package/Runtime/Core/Extensions/EnumExtensions.cs +6 -5
  56. package/Runtime/Core/Extensions/EnumExtensions.cs.meta +9 -1
  57. package/Runtime/Core/Extensions/IListExtensions.cs.meta +9 -1
  58. package/Runtime/Core/Extensions/MessageBusExtensions.cs.meta +3 -3
  59. package/Runtime/Core/Extensions/MessageExtensions.cs +0 -60
  60. package/Runtime/Core/Extensions/MessageExtensions.cs.meta +3 -3
  61. package/Runtime/Core/Helper/MessageCache.cs.meta +9 -1
  62. package/Runtime/Core/Helper/MessageHelperIndexer.cs.meta +9 -1
  63. package/Runtime/Core/IMessage.cs.meta +3 -3
  64. package/Runtime/Core/InstanceId.cs +25 -1
  65. package/Runtime/Core/InstanceId.cs.meta +3 -3
  66. package/Runtime/Core/Internal/DxUnsafe.cs +60 -0
  67. package/Runtime/Core/Internal/DxUnsafe.cs.meta +11 -0
  68. package/Runtime/Core/Internal/FlatDispatch.cs +198 -0
  69. package/Runtime/Core/Internal/FlatDispatch.cs.meta +11 -0
  70. package/Runtime/Core/Internal/TypedSlots.cs +47 -21
  71. package/Runtime/Core/MessageBus/DiagnosticsTarget.cs.meta +3 -3
  72. package/Runtime/Core/MessageBus/GlobalMessageBusProvider.cs.meta +3 -3
  73. package/Runtime/Core/MessageBus/IMessageBus.cs +75 -40
  74. package/Runtime/Core/MessageBus/IMessageBus.cs.meta +3 -3
  75. package/Runtime/Core/MessageBus/IMessageBusProvider.cs.meta +3 -3
  76. package/Runtime/Core/MessageBus/IMessageRegistrationBuilder.cs +1 -0
  77. package/Runtime/Core/MessageBus/IMessageRegistrationBuilder.cs.meta +3 -3
  78. package/Runtime/Core/MessageBus/Internal/BusSlots.cs +7 -6
  79. package/Runtime/Core/MessageBus/MessageBus.cs +2864 -3413
  80. package/Runtime/Core/MessageBus/MessageBus.cs.meta +3 -3
  81. package/Runtime/Core/MessageBus/MessageBusRebindMode.cs.meta +3 -3
  82. package/Runtime/Core/MessageBus/MessageBusRegistration.cs +207 -0
  83. package/Runtime/Core/MessageBus/MessageBusRegistration.cs.meta +11 -0
  84. package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs +187 -14
  85. package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs.meta +3 -3
  86. package/Runtime/Core/MessageBus/MessagingRegistration.cs.meta +3 -3
  87. package/Runtime/Core/MessageBus/RegistrationLog.cs.meta +3 -3
  88. package/Runtime/Core/MessageHandler.cs +2206 -1510
  89. package/Runtime/Core/MessageHandler.cs.meta +3 -3
  90. package/Runtime/Core/MessageRegistrationHandle.cs.meta +3 -3
  91. package/Runtime/Core/MessageRegistrationToken.cs +1667 -812
  92. package/Runtime/Core/MessageRegistrationToken.cs.meta +3 -3
  93. package/Runtime/Core/Messages/GlobalStringMessage.cs.meta +9 -1
  94. package/Runtime/Core/Messages/IBroadcastMessage.cs.meta +3 -3
  95. package/Runtime/Core/Messages/ITargetedMessage.cs.meta +3 -3
  96. package/Runtime/Core/Messages/IUntargetedMessage.cs.meta +3 -3
  97. package/Runtime/Core/Messages/ReflexiveMessage.cs.meta +9 -1
  98. package/Runtime/Core/Messages/SourcedStringMessage.cs.meta +3 -3
  99. package/Runtime/Core/Messages/StringMessage.cs.meta +9 -1
  100. package/Runtime/Core/MessagingDebug.cs.meta +3 -3
  101. package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs.meta +3 -3
  102. package/Runtime/Unity/DxMessagingRuntimeInitializer.cs.meta +3 -3
  103. package/Runtime/Unity/InitialGlobalMessageBusProvider.cs.meta +3 -3
  104. package/Runtime/Unity/Integrations/Reflex/AssemblyInfo.cs.meta +9 -1
  105. package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs.meta +3 -3
  106. package/Runtime/Unity/Integrations/VContainer/AssemblyInfo.cs.meta +9 -1
  107. package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs.meta +3 -3
  108. package/Runtime/Unity/Integrations/Zenject/AssemblyInfo.cs.meta +9 -1
  109. package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs.meta +3 -3
  110. package/Runtime/Unity/MessageAwareComponent.cs +46 -1
  111. package/Runtime/Unity/MessageAwareComponent.cs.meta +3 -3
  112. package/Runtime/Unity/MessageBusProviderHandle.cs.meta +3 -3
  113. package/Runtime/Unity/MessagingComponent.cs +43 -10
  114. package/Runtime/Unity/MessagingComponent.cs.meta +3 -3
  115. package/Runtime/Unity/MessagingComponentInstaller.cs.meta +3 -3
  116. package/Runtime/Unity/ScriptableMessageBusProvider.cs.meta +3 -3
  117. package/Runtime/WallstopStudios.DxMessaging.asmdef +1 -1
  118. package/Samples~/DI/README.md +7 -7
  119. package/Samples~/DI/Reflex/SampleInstaller.cs.meta +3 -3
  120. package/Samples~/DI/VContainer/SampleLifetimeScope.cs.meta +3 -3
  121. package/Samples~/DI/Zenject/SampleInstaller.cs.meta +3 -3
  122. package/Samples~/Mini Combat/Boot.cs.meta +3 -3
  123. package/Samples~/Mini Combat/Enemy.cs.meta +3 -3
  124. package/Samples~/Mini Combat/Messages.cs.meta +3 -3
  125. package/Samples~/Mini Combat/Player.cs.meta +3 -3
  126. package/Samples~/Mini Combat/UIOverlay.cs.meta +3 -3
  127. package/Samples~/UI Buttons + Inspector/DiagnosticsEnabler.cs.meta +3 -3
  128. package/Samples~/UI Buttons + Inspector/Messages.cs.meta +3 -3
  129. package/Samples~/UI Buttons + Inspector/MessagingObserver.cs.meta +3 -3
  130. package/Samples~/UI Buttons + Inspector/UIButtonEmitter.cs.meta +3 -3
  131. package/SourceGenerators/Directory.Build.props +50 -3
  132. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs +96 -63
  133. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs.meta +3 -3
  134. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs +745 -87
  135. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs.meta +9 -1
  136. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.csproj +40 -46
  137. package/SourceGenerators/global.json +7 -0
  138. package/SourceGenerators/global.json.meta +7 -0
  139. package/package.json +30 -40
  140. package/Editor/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll +0 -0
  141. package/Editor/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll.meta +0 -33
  142. package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
  143. package/Runtime/Core/Internal/TypedDispatchLinkIndex.cs +0 -51
  144. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  145. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.dll +0 -0
  146. /package/{Editor → Runtime}/Analyzers/System.Collections.Immutable.dll +0 -0
  147. /package/{Editor → Runtime}/Analyzers/System.Reflection.Metadata.dll +0 -0
  148. /package/{Editor → Runtime}/Analyzers/System.Runtime.CompilerServices.Unsafe.dll +0 -0
@@ -1,3 +1,11 @@
1
1
  fileFormatVersion: 2
2
2
  guid: 7d8dbf8640e24846bf35fb18a1b7c504
3
- timeCreated: 1749671893
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,3 +1,11 @@
1
1
  fileFormatVersion: 2
2
2
  guid: 8eafaabae0f549ec82f67ea18be788e1
3
- timeCreated: 1749672335
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,3 +1,11 @@
1
1
  fileFormatVersion: 2
2
2
  guid: 01598791b01241caabfecea4c1f5880d
3
- timeCreated: 1749672447
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,3 +1,11 @@
1
1
  fileFormatVersion: 2
2
2
  guid: 7d393cfbb3c8429d83af17a737fdaf0e
3
- timeCreated: 1749672471
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:
@@ -2,6 +2,7 @@ namespace DxMessaging.Core.Extensions
2
2
  {
3
3
  using System;
4
4
  using System.Runtime.CompilerServices;
5
+ using DxMessaging.Core.Internal;
5
6
 
6
7
  internal static class EnumExtensions
7
8
  {
@@ -26,12 +27,12 @@ namespace DxMessaging.Core.Extensions
26
27
  {
27
28
  try
28
29
  {
29
- return Unsafe.SizeOf<T>() switch
30
+ return DxUnsafe.SizeOf<T>() switch
30
31
  {
31
- 1 => Unsafe.As<T, byte>(ref value),
32
- 2 => Unsafe.As<T, ushort>(ref value),
33
- 4 => Unsafe.As<T, uint>(ref value),
34
- 8 => Unsafe.As<T, ulong>(ref value),
32
+ 1 => DxUnsafe.As<T, byte>(ref value),
33
+ 2 => DxUnsafe.As<T, ushort>(ref value),
34
+ 4 => DxUnsafe.As<T, uint>(ref value),
35
+ 8 => DxUnsafe.As<T, ulong>(ref value),
35
36
  _ => null,
36
37
  };
37
38
  }
@@ -1,3 +1,11 @@
1
1
  fileFormatVersion: 2
2
2
  guid: f01ee914d7634a69a85f86bb02f2f07e
3
- timeCreated: 1745162639
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,3 +1,11 @@
1
1
  fileFormatVersion: 2
2
2
  guid: f6956caef19744a0b0d96215d4e5154a
3
- timeCreated: 1749671953
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -6,7 +6,7 @@ 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:
12
12
 
@@ -79,12 +79,6 @@ namespace DxMessaging.Core.Extensions
79
79
  {
80
80
  InstanceId targetId = target;
81
81
  IMessageBus resolvedBus = ResolveMessageBus(messageBus, messageBusProvider);
82
- if (typeof(TMessage) == typeof(ITargetedMessage))
83
- {
84
- resolvedBus.UntypedTargetedBroadcast(targetId, message);
85
- return;
86
- }
87
-
88
82
  resolvedBus.TargetedBroadcast(ref targetId, ref message);
89
83
  }
90
84
 
@@ -129,12 +123,6 @@ namespace DxMessaging.Core.Extensions
129
123
  {
130
124
  InstanceId targetId = target;
131
125
  IMessageBus resolvedBus = ResolveMessageBus(messageBus, messageBusProvider);
132
- if (typeof(TMessage) == typeof(ITargetedMessage))
133
- {
134
- resolvedBus.UntypedTargetedBroadcast(targetId, message);
135
- return;
136
- }
137
-
138
126
  resolvedBus.TargetedBroadcast(ref targetId, ref message);
139
127
  }
140
128
  #endif
@@ -178,12 +166,6 @@ namespace DxMessaging.Core.Extensions
178
166
  where TMessage : struct, ITargetedMessage
179
167
  {
180
168
  IMessageBus resolvedBus = ResolveMessageBus(messageBus, messageBusProvider);
181
- if (typeof(TMessage) == typeof(ITargetedMessage))
182
- {
183
- resolvedBus.UntypedTargetedBroadcast(target, message);
184
- return;
185
- }
186
-
187
169
  resolvedBus.TargetedBroadcast(ref target, ref message);
188
170
  }
189
171
 
@@ -259,12 +241,6 @@ namespace DxMessaging.Core.Extensions
259
241
  where TMessage : struct, IUntargetedMessage
260
242
  {
261
243
  IMessageBus resolvedBus = ResolveMessageBus(messageBus, messageBusProvider);
262
- if (typeof(TMessage) == typeof(IUntargetedMessage))
263
- {
264
- resolvedBus.UntypedUntargetedBroadcast(message);
265
- return;
266
- }
267
-
268
244
  resolvedBus.UntargetedBroadcast(ref message);
269
245
  }
270
246
 
@@ -296,12 +272,6 @@ namespace DxMessaging.Core.Extensions
296
272
  where TMessage : struct, IUntargetedMessage
297
273
  {
298
274
  IMessageBus resolvedBus = ResolveMessageBus(messageBus, messageBusProvider);
299
- if (typeof(TMessage) == typeof(IUntargetedMessage))
300
- {
301
- resolvedBus.UntypedUntargetedBroadcast(message);
302
- return;
303
- }
304
-
305
275
  resolvedBus.UntargetedBroadcast(ref message);
306
276
  }
307
277
 
@@ -341,12 +311,6 @@ namespace DxMessaging.Core.Extensions
341
311
  where TMessage : struct, ITargetedMessage
342
312
  {
343
313
  IMessageBus resolvedBus = ResolveMessageBus(messageBus, messageBusProvider);
344
- if (typeof(TMessage) == typeof(ITargetedMessage))
345
- {
346
- resolvedBus.UntypedTargetedBroadcast(target, message);
347
- return;
348
- }
349
-
350
314
  resolvedBus.TargetedBroadcast(ref target, ref message);
351
315
  }
352
316
 
@@ -386,12 +350,6 @@ namespace DxMessaging.Core.Extensions
386
350
  where TMessage : struct, IBroadcastMessage
387
351
  {
388
352
  IMessageBus resolvedBus = ResolveMessageBus(messageBus, messageBusProvider);
389
- if (typeof(TMessage) == typeof(ITargetedMessage))
390
- {
391
- resolvedBus.UntypedSourcedBroadcast(source, message);
392
- return;
393
- }
394
-
395
353
  resolvedBus.SourcedBroadcast(ref source, ref message);
396
354
  }
397
355
 
@@ -437,12 +395,6 @@ namespace DxMessaging.Core.Extensions
437
395
  {
438
396
  InstanceId sourceId = source;
439
397
  IMessageBus resolvedBus = ResolveMessageBus(messageBus, messageBusProvider);
440
- if (typeof(TMessage) == typeof(IBroadcastMessage))
441
- {
442
- resolvedBus.UntypedSourcedBroadcast(sourceId, message);
443
- return;
444
- }
445
-
446
398
  resolvedBus.SourcedBroadcast(ref sourceId, ref message);
447
399
  }
448
400
 
@@ -487,12 +439,6 @@ namespace DxMessaging.Core.Extensions
487
439
  {
488
440
  InstanceId sourceId = source;
489
441
  IMessageBus resolvedBus = ResolveMessageBus(messageBus, messageBusProvider);
490
- if (typeof(TMessage) == typeof(IBroadcastMessage))
491
- {
492
- resolvedBus.UntypedSourcedBroadcast(sourceId, message);
493
- return;
494
- }
495
-
496
442
  resolvedBus.SourcedBroadcast(ref sourceId, ref message);
497
443
  }
498
444
  #endif
@@ -536,12 +482,6 @@ namespace DxMessaging.Core.Extensions
536
482
  where TMessage : struct, IBroadcastMessage
537
483
  {
538
484
  IMessageBus resolvedBus = ResolveMessageBus(messageBus, messageBusProvider);
539
- if (typeof(TMessage) == typeof(IBroadcastMessage))
540
- {
541
- resolvedBus.UntypedSourcedBroadcast(source, message);
542
- return;
543
- }
544
-
545
485
  resolvedBus.SourcedBroadcast(ref source, ref message);
546
486
  }
547
487
 
@@ -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:
@@ -1,3 +1,11 @@
1
1
  fileFormatVersion: 2
2
2
  guid: 23cb3bf7f25d479c862736482ee96fa7
3
- timeCreated: 1745102344
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,3 +1,11 @@
1
1
  fileFormatVersion: 2
2
2
  guid: 612c352c3d984a3486ac4b19bb69fa37
3
- timeCreated: 1745101032
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:
@@ -50,10 +50,34 @@ namespace DxMessaging.Core
50
50
  #if UNITY_2021_3_OR_NEWER
51
51
  private InstanceId(UnityEngine.Object unityObject)
52
52
  {
53
- _id = unityObject.GetInstanceID();
53
+ _id = StableId(unityObject);
54
54
  Object = unityObject;
55
55
  }
56
56
 
57
+ /// <summary>
58
+ /// Returns the stable per-object integer identity used as the dispatch key.
59
+ /// Unity 6 is migrating object identity to the 64-bit <c>EntityId</c>:
60
+ /// <c>GetInstanceID()</c> is deprecated and becomes a compile error in Unity 6.5,
61
+ /// and successive raw accessors (the <c>EntityId</c>-to-<c>int</c> cast, then
62
+ /// <c>GetRawData()</c>) have each been deprecated in turn. On Unity 6.4+ this reads
63
+ /// the non-deprecated <c>EntityId.ToULong(...)</c> and keeps its low 32 bits --
64
+ /// exactly the integer the legacy <c>GetInstanceID()</c> returned (verified on 6.4
65
+ /// across GameObject/Component/ScriptableObject). Older Unity keeps
66
+ /// <c>GetInstanceID()</c> (valid, warning-only there, never the 6.5 error). The
67
+ /// 32-bit dispatch key is identical either way; only the (non-deprecated) source
68
+ /// differs. The gate is the host-verified 6.4 rather than 6.2 because the exact
69
+ /// accessor that is non-deprecated has shifted across Unity 6 minors.
70
+ /// </summary>
71
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
72
+ internal static int StableId(UnityEngine.Object unityObject)
73
+ {
74
+ #if UNITY_6000_4_OR_NEWER
75
+ return unchecked((int)UnityEngine.EntityId.ToULong(unityObject.GetEntityId()));
76
+ #else
77
+ return unityObject.GetInstanceID();
78
+ #endif
79
+ }
80
+
57
81
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
58
82
  /// <summary>
59
83
  /// Converts a <see cref="UnityEngine.GameObject"/> reference into an <see cref="InstanceId"/>.
@@ -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,60 @@
1
+ namespace DxMessaging.Core.Internal
2
+ {
3
+ using System.Runtime.CompilerServices;
4
+ // Qualified with global:: because this assembly also declares a DxMessaging.Unity
5
+ // namespace; an unqualified "using Unity.Collections..." would bind to
6
+ // DxMessaging.Unity.Collections and fail to resolve.
7
+ using global::Unity.Collections.LowLevel.Unsafe;
8
+
9
+ /// <summary>
10
+ /// Reinterpret-cast helpers used by the hot dispatch path. Each method wraps a Unity
11
+ /// <see cref="UnsafeUtility"/> intrinsic, which resolves in both the Editor and every
12
+ /// player build (Mono and IL2CPP, including the .NET Standard 2.0 profile) without an
13
+ /// external precompiled assembly.
14
+ /// </summary>
15
+ /// <remarks>
16
+ /// These are drop-in replacements for the corresponding
17
+ /// <c>System.Runtime.CompilerServices.Unsafe</c> members. That type is supplied by the
18
+ /// Editor but is absent from player builds, so referencing it compiled in the Editor yet
19
+ /// failed standalone IL2CPP compilation. <see cref="UnsafeUtility"/> ships inside
20
+ /// <c>UnityEngine.CoreModule</c> on every supported platform, so routing through it keeps
21
+ /// the zero-allocation reinterpret behavior while removing the unresolved dependency.
22
+ /// The wrapped intrinsics are pure IL (no internal-call transition), so this indirection
23
+ /// is free once inlined.
24
+ /// </remarks>
25
+ internal static class DxUnsafe
26
+ {
27
+ /// <summary>
28
+ /// Reinterprets a managed reference to <typeparamref name="TFrom"/> as a reference to
29
+ /// <typeparamref name="TTo"/> in place, without copying or boxing. Callers guarantee the
30
+ /// reinterpretation is valid for the concrete runtime layout.
31
+ /// </summary>
32
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
33
+ internal static ref TTo As<TFrom, TTo>(ref TFrom source)
34
+ {
35
+ return ref UnsafeUtility.As<TFrom, TTo>(ref source);
36
+ }
37
+
38
+ /// <summary>
39
+ /// Reinterprets a reference-typed instance as <typeparamref name="TTo"/> without a type
40
+ /// check. Callers guarantee the runtime type, mirroring the prior unchecked
41
+ /// <c>Unsafe.As&lt;T&gt;(object)</c> usage.
42
+ /// </summary>
43
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
44
+ internal static TTo As<TTo>(object value)
45
+ where TTo : class
46
+ {
47
+ return UnsafeUtility.As<object, TTo>(ref value);
48
+ }
49
+
50
+ /// <summary>
51
+ /// Returns the size in bytes of <typeparamref name="T"/>.
52
+ /// </summary>
53
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
54
+ internal static int SizeOf<T>()
55
+ where T : struct
56
+ {
57
+ return UnsafeUtility.SizeOf<T>();
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: ee766f9071484d4296892a84523a9aaa
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,198 @@
1
+ namespace DxMessaging.Core.Internal
2
+ {
3
+ using System;
4
+ using System.Buffers;
5
+ using System.Collections.Generic;
6
+ using DxMessaging.Core;
7
+
8
+ /// <summary>
9
+ /// One fully-resolved dispatch entry for slots whose delegates do NOT
10
+ /// receive the routing context (untargeted handle/post, and the
11
+ /// context-keyed Default-variant targeted/broadcast slots, where the
12
+ /// target/source is the routing key rather than a delegate parameter):
13
+ /// the owning <see cref="MessageHandler"/> (for the single live
14
+ /// <c>active</c> check) plus the final invocable delegate, resolved at
15
+ /// snapshot-build time. Steady-state dispatch over an array of these is
16
+ /// a single field read, one branch, and a direct delegate invocation per
17
+ /// entry - no dispatch link, no generation guard, no per-priority
18
+ /// dictionary lookup, and no type test.
19
+ /// </summary>
20
+ /// <typeparam name="TMessage">Concrete message type of the dispatch slot.</typeparam>
21
+ internal readonly struct FlatDispatchEntry<TMessage>
22
+ where TMessage : IMessage
23
+ {
24
+ public FlatDispatchEntry(
25
+ MessageHandler handler,
26
+ MessageHandler.FastHandler<TMessage> invoker
27
+ )
28
+ {
29
+ this.handler = handler;
30
+ this.invoker = invoker;
31
+ }
32
+
33
+ public readonly MessageHandler handler;
34
+ public readonly MessageHandler.FastHandler<TMessage> invoker;
35
+ }
36
+
37
+ /// <summary>
38
+ /// One fully-resolved dispatch entry for the WithoutContext
39
+ /// targeted/broadcast slots, whose delegates DO receive the routing
40
+ /// context (target/source <see cref="InstanceId"/>) as a parameter.
41
+ /// Mirrors <see cref="FlatDispatchEntry{TMessage}"/> with the
42
+ /// context-carrying delegate shape.
43
+ /// </summary>
44
+ /// <typeparam name="TMessage">Concrete message type of the dispatch slot.</typeparam>
45
+ internal readonly struct ContextFlatDispatchEntry<TMessage>
46
+ where TMessage : IMessage
47
+ {
48
+ public ContextFlatDispatchEntry(
49
+ MessageHandler handler,
50
+ MessageHandler.FastHandlerWithContext<TMessage> invoker
51
+ )
52
+ {
53
+ this.handler = handler;
54
+ this.invoker = invoker;
55
+ }
56
+
57
+ public readonly MessageHandler handler;
58
+ public readonly MessageHandler.FastHandlerWithContext<TMessage> invoker;
59
+ }
60
+
61
+ /// <summary>
62
+ /// Non-generic erasure base so the non-generic
63
+ /// <c>MessageBus.DispatchSnapshot</c> can carry and release a typed flat
64
+ /// entry array without knowing the closed message type (or the entry
65
+ /// shape). The snapshot's pooled-release path calls <see cref="Release"/>
66
+ /// exactly once per snapshot teardown; the typed holder returns its array
67
+ /// to the per-closed-generic pool.
68
+ /// </summary>
69
+ internal abstract class FlatDispatchArray
70
+ {
71
+ internal abstract void Release();
72
+ }
73
+
74
+ /// <summary>
75
+ /// Shared pooled-holder implementation for flat dispatch arrays: a pooled
76
+ /// entry array (rented from <see cref="ArrayPool{T}"/>) plus a small
77
+ /// per-closed-generic holder stack so registration-churn rebuilds
78
+ /// allocate nothing in steady state. Concrete holders
79
+ /// (<see cref="FlatDispatch{TMessage}"/>,
80
+ /// <see cref="ContextFlatDispatch{TMessage}"/>) only pick the entry
81
+ /// shape; all lifecycle logic lives here so the pool/lock/cap/released
82
+ /// pattern exists exactly once.
83
+ /// </summary>
84
+ /// <remarks>
85
+ /// Lifecycle mirrors the snapshot that owns the holder: the array is
86
+ /// frozen for the duration of any emission that acquired it (mutations
87
+ /// mark the owning DispatchState dirty and are observed by the NEXT
88
+ /// emission's rebuild), and it is released back to the pool only through
89
+ /// <c>DispatchSnapshot.Release()</c>. The <c>_released</c> flag guards
90
+ /// the holder against double-release (which would seat the same holder
91
+ /// in the pool twice and corrupt later rents): DEBUG builds assert,
92
+ /// release builds no-op the second call.
93
+ /// </remarks>
94
+ /// <typeparam name="TEntry">Resolved entry struct stored in the array.</typeparam>
95
+ /// <typeparam name="THolder">Concrete holder type (CRTP, for typed pooling).</typeparam>
96
+ internal abstract class PooledFlatDispatch<TEntry, THolder> : FlatDispatchArray
97
+ where THolder : PooledFlatDispatch<TEntry, THolder>, new()
98
+ {
99
+ private static readonly ArrayPool<TEntry> EntryPool = ArrayPool<TEntry>.Shared;
100
+
101
+ // Cold-path pool (rebuild/teardown only); the lock is uncontended in
102
+ // practice but keeps the holder pool safe if multiple buses are ever
103
+ // driven from different threads.
104
+ private static readonly Stack<THolder> HolderPool = new();
105
+ private static readonly object HolderPoolLock = new();
106
+ private const int MaxRetainedHolders = 64;
107
+
108
+ internal TEntry[] entries = Array.Empty<TEntry>();
109
+ internal int count;
110
+
111
+ // True while the holder is parked in (or eligible for) the pool;
112
+ // false while it is owned by a live DispatchSnapshot. Guards the
113
+ // rent/release lifecycle against double-release and rent-of-live.
114
+ private bool _released = true;
115
+
116
+ internal static THolder Rent(int capacity)
117
+ {
118
+ THolder holder = null;
119
+ lock (HolderPoolLock)
120
+ {
121
+ if (0 < HolderPool.Count)
122
+ {
123
+ holder = HolderPool.Pop();
124
+ }
125
+ }
126
+
127
+ holder ??= new THolder();
128
+ System.Diagnostics.Debug.Assert(
129
+ holder._released,
130
+ "PooledFlatDispatch.Rent returned a holder that is still owned by a live "
131
+ + "snapshot; a Release() was skipped or the pool was corrupted."
132
+ );
133
+ holder._released = false;
134
+ holder.entries = 0 < capacity ? EntryPool.Rent(capacity) : Array.Empty<TEntry>();
135
+ holder.count = 0;
136
+ return holder;
137
+ }
138
+
139
+ internal sealed override void Release()
140
+ {
141
+ if (_released)
142
+ {
143
+ System.Diagnostics.Debug.Assert(
144
+ false,
145
+ "PooledFlatDispatch.Release called twice on the same holder; the owning "
146
+ + "DispatchSnapshot must release its flat array exactly once."
147
+ );
148
+ return;
149
+ }
150
+
151
+ _released = true;
152
+ TEntry[] localEntries = entries;
153
+ int localCount = count;
154
+ entries = Array.Empty<TEntry>();
155
+ count = 0;
156
+ if (0 < localEntries.Length)
157
+ {
158
+ Array.Clear(localEntries, 0, localCount);
159
+ EntryPool.Return(localEntries);
160
+ }
161
+
162
+ lock (HolderPoolLock)
163
+ {
164
+ if (HolderPool.Count < MaxRetainedHolders)
165
+ {
166
+ HolderPool.Push((THolder)this);
167
+ }
168
+ }
169
+ }
170
+ }
171
+
172
+ /// <summary>
173
+ /// Pooled flat array of resolved entries for one
174
+ /// (bus, message-type[, context], phase) dispatch snapshot whose
175
+ /// delegates take only the message: untargeted handle/post and the
176
+ /// context-keyed (Default variant) targeted/broadcast handle/post slots.
177
+ /// Built at snapshot-build time by walking the bus priority buckets
178
+ /// ascending, then each bucket's MessageHandlers in bus insertion order,
179
+ /// then each handler's fast entries followed by its default entries
180
+ /// (both in first-registration order), so a plain forward iteration
181
+ /// reproduces the documented dispatch order exactly.
182
+ /// </summary>
183
+ /// <typeparam name="TMessage">Concrete message type of the dispatch slot.</typeparam>
184
+ internal sealed class FlatDispatch<TMessage>
185
+ : PooledFlatDispatch<FlatDispatchEntry<TMessage>, FlatDispatch<TMessage>>
186
+ where TMessage : IMessage { }
187
+
188
+ /// <summary>
189
+ /// Pooled flat array of resolved entries for one (bus, message-type,
190
+ /// phase) dispatch snapshot of a WithoutContext targeted/broadcast slot,
191
+ /// whose delegates receive the routing <see cref="InstanceId"/> alongside
192
+ /// the message. Build order matches <see cref="FlatDispatch{TMessage}"/>.
193
+ /// </summary>
194
+ /// <typeparam name="TMessage">Concrete message type of the dispatch slot.</typeparam>
195
+ internal sealed class ContextFlatDispatch<TMessage>
196
+ : PooledFlatDispatch<ContextFlatDispatchEntry<TMessage>, ContextFlatDispatch<TMessage>>
197
+ where TMessage : IMessage { }
198
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: a21a4ac4e7dd4fd4839dc6de875e24d8
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: