com.wallstop-studios.dxmessaging 2.1.1 → 2.1.3

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 (158) hide show
  1. package/.github/workflows/dotnet-tests.yml +72 -0
  2. package/.lychee.toml +4 -2
  3. package/AGENTS.md +13 -12
  4. package/Docs/Comparisons.md +5 -5
  5. package/Docs/Install.md +2 -1
  6. package/Docs/InterceptorsAndOrdering.md +1 -1
  7. package/Docs/Performance.md +15 -13
  8. package/Docs/QuickReference.md +1 -1
  9. package/Docs/Reference.md +5 -5
  10. package/Editor/Analyzers/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  11. package/Editor/Analyzers/Microsoft.CodeAnalysis.CSharp.dll.meta +13 -2
  12. package/Editor/Analyzers/Microsoft.CodeAnalysis.dll +0 -0
  13. package/Editor/Analyzers/Microsoft.CodeAnalysis.dll.meta +11 -0
  14. package/Editor/Analyzers/System.Collections.Immutable.dll +0 -0
  15. package/Editor/Analyzers/System.Collections.Immutable.dll.meta +11 -0
  16. package/Editor/Analyzers/System.Reflection.Metadata.dll +0 -0
  17. package/Editor/Analyzers/System.Reflection.Metadata.dll.meta +13 -2
  18. package/Editor/Analyzers/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  19. package/Editor/Analyzers/System.Runtime.CompilerServices.Unsafe.dll.meta +11 -0
  20. package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
  21. package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll.meta +3 -2
  22. package/Editor/AssemblyInfo.cs +3 -0
  23. package/Editor/AssemblyInfo.cs.meta +3 -0
  24. package/Editor/CustomEditors/MessagingComponentEditor.cs +24 -0
  25. package/Editor/DxMessagingEditorInitializer.cs +58 -1
  26. package/Editor/DxMessagingMenu.cs +38 -0
  27. package/Editor/DxMessagingMenu.cs.meta +11 -0
  28. package/Editor/DxMessagingSceneBuildProcessor.cs +81 -0
  29. package/Editor/DxMessagingSceneBuildProcessor.cs.meta +11 -0
  30. package/Editor/Settings/DxMessagingSettings.cs +37 -6
  31. package/Editor/Settings/DxMessagingSettingsProvider.cs +45 -7
  32. package/Editor/SetupCscRsp.cs +133 -53
  33. package/Editor/Testing/MessagingComponentEditorHarness.cs +218 -0
  34. package/Editor/Testing/MessagingComponentEditorHarness.cs.meta +3 -0
  35. package/Editor/Testing.meta +3 -0
  36. package/README.md +10 -4
  37. package/Runtime/AssemblyInfo.cs +1 -0
  38. package/Runtime/Core/Attributes/DxOptionalParameterAttribute.cs +52 -0
  39. package/Runtime/Core/DataStructure/CyclicBuffer.cs +16 -0
  40. package/Runtime/Core/Diagnostics/MessageEmissionData.cs +27 -12
  41. package/Runtime/Core/Diagnostics/MessageRegistrationType.cs +62 -0
  42. package/Runtime/Core/DxMessagingStaticState.cs +108 -0
  43. package/Runtime/Core/DxMessagingStaticState.cs.meta +11 -0
  44. package/Runtime/Core/Extensions/IListExtensions.cs +24 -0
  45. package/Runtime/Core/Extensions/MessageBusExtensions.cs +144 -2
  46. package/Runtime/Core/Extensions/MessageExtensions.cs +2 -2
  47. package/Runtime/Core/Helper/MessageCache.cs +16 -0
  48. package/Runtime/Core/Helper/MessageHelperIndexer.cs +77 -0
  49. package/Runtime/Core/InstanceId.cs +91 -3
  50. package/Runtime/Core/MessageBus/DiagnosticsTarget.cs +31 -0
  51. package/Runtime/Core/MessageBus/DiagnosticsTarget.cs.meta +11 -0
  52. package/Runtime/Core/MessageBus/IMessageBus.cs +44 -16
  53. package/Runtime/Core/MessageBus/MessageBus.cs +96 -25
  54. package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs +46 -2
  55. package/Runtime/Core/MessageBus/MessagingRegistration.cs +63 -5
  56. package/Runtime/Core/MessageBus/RegistrationLog.cs +10 -0
  57. package/Runtime/Core/MessageHandler.cs +141 -8
  58. package/Runtime/Core/MessageRegistrationHandle.cs +59 -0
  59. package/Runtime/Core/MessageRegistrationToken.cs +20 -4
  60. package/Runtime/Core/Messages/ReflexiveMessage.cs +38 -0
  61. package/Runtime/Core/MessagingDebug.cs +16 -1
  62. package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs +6 -0
  63. package/Runtime/Unity/DxMessagingRuntimeInitializer.cs +19 -0
  64. package/Runtime/Unity/DxMessagingRuntimeInitializer.cs.meta +11 -0
  65. package/Runtime/Unity/InitialGlobalMessageBusProvider.cs +6 -0
  66. package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs +19 -0
  67. package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs +10 -0
  68. package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs +14 -0
  69. package/Runtime/Unity/MessageAwareComponent.cs +2 -0
  70. package/Runtime/Unity/MessageBusProviderHandle.cs +4 -0
  71. package/Runtime/Unity/MessagingComponent.cs +109 -0
  72. package/Runtime/Unity/MessagingComponentInstaller.cs +2 -0
  73. package/Runtime/Unity/ScriptableMessageBusProvider.cs +2 -0
  74. package/Samples~/DI/README.md +13 -13
  75. package/Samples~/Mini Combat/README.md +15 -15
  76. package/Samples~/Mini Combat/Walkthrough.md +12 -12
  77. package/Samples~/UI Buttons + Inspector/README.md +4 -4
  78. package/SourceGenerators/Directory.Build.props +9 -0
  79. package/{Tests/Runtime/WallstopStudios.DxMessaging.Tests.Runtime.csproj.meta → SourceGenerators/Directory.Build.props.meta} +1 -1
  80. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs +23 -24
  81. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs +91 -27
  82. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.csproj +24 -4
  83. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DocsSnippetCompilationTests.cs +193 -0
  84. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DocsSnippetCompilationTests.cs.meta +11 -0
  85. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DxAutoConstructorGeneratorDiagnosticsTests.cs +69 -0
  86. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DxAutoConstructorGeneratorDiagnosticsTests.cs.meta +11 -0
  87. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DxMessageIdGeneratorDiagnosticsTests.cs +66 -0
  88. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DxMessageIdGeneratorDiagnosticsTests.cs.meta +11 -0
  89. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/GeneratorTestUtilities.cs +155 -0
  90. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/GeneratorTestUtilities.cs.meta +11 -0
  91. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/WallstopStudios.DxMessaging.SourceGenerators.Tests.csproj +20 -0
  92. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/WallstopStudios.DxMessaging.SourceGenerators.Tests.csproj.meta +7 -0
  93. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests.meta +8 -0
  94. package/Tests/Editor/MessagingComponentEditorHarnessTests.cs +243 -0
  95. package/Tests/Editor/MessagingComponentEditorHarnessTests.cs.meta +3 -0
  96. package/Tests/Editor/MessagingComponentSerializationTests.cs +129 -0
  97. package/Tests/Editor/MessagingComponentSerializationTests.cs.meta +3 -0
  98. package/Tests/Editor/WallstopStudios.DxMessaging.Tests.Editor.asmdef +19 -0
  99. package/Tests/Editor/WallstopStudios.DxMessaging.Tests.Editor.asmdef.meta +3 -0
  100. package/Tests/Editor.meta +3 -0
  101. package/Tests/Runtime/Benchmarks/BenchmarkSession.cs +3 -0
  102. package/Tests/Runtime/Benchmarks/BenchmarkTestBase.cs +3 -0
  103. package/Tests/Runtime/Benchmarks/ComparisonPerformanceTests.cs +3 -0
  104. package/Tests/Runtime/Benchmarks/PerformanceTests.cs +137 -0
  105. package/Tests/Runtime/Core/AlternateBusTests.cs +3 -0
  106. package/Tests/Runtime/Core/BroadcastTests.cs +3 -0
  107. package/Tests/Runtime/Core/CyclicBufferTests.cs +3 -0
  108. package/Tests/Runtime/Core/DefaultBusFallbackTests.cs +5 -2
  109. package/Tests/Runtime/Core/DiagnosticsTests.cs +6 -3
  110. package/Tests/Runtime/Core/DxMessagingStaticStateTests.cs +69 -0
  111. package/Tests/Runtime/Core/DxMessagingStaticStateTests.cs.meta +11 -0
  112. package/Tests/Runtime/Core/EdgeCaseTests.cs +3 -0
  113. package/Tests/Runtime/Core/EnablementTests.cs +3 -0
  114. package/Tests/Runtime/Core/Extensions/MessageExtensionsProviderTests.cs +2 -2
  115. package/Tests/Runtime/Core/GenericMessageTests.cs +3 -0
  116. package/Tests/Runtime/Core/GlobalAcceptAllTests.cs +3 -0
  117. package/Tests/Runtime/Core/InterceptorCancellationTests.cs +3 -0
  118. package/Tests/Runtime/Core/LifecycleTests.cs +3 -0
  119. package/Tests/Runtime/Core/MessageEmissionDataTests.cs +70 -0
  120. package/Tests/Runtime/Core/MessageEmissionDataTests.cs.meta +11 -0
  121. package/Tests/Runtime/Core/MessagingComponentLifecycleTests.cs +3 -0
  122. package/Tests/Runtime/Core/MessagingTestBase.cs +3 -0
  123. package/Tests/Runtime/Core/MutationDedupeTests.cs +3 -0
  124. package/Tests/Runtime/Core/MutationDestructionTests.cs +3 -0
  125. package/Tests/Runtime/Core/MutationDuringEmissionTests.cs +3 -0
  126. package/Tests/Runtime/Core/MutationGlobalAddTests.cs +3 -0
  127. package/Tests/Runtime/Core/MutationInterceptorTests.cs +3 -0
  128. package/Tests/Runtime/Core/MutationPostProcessorAcrossHandlersTests.cs +3 -0
  129. package/Tests/Runtime/Core/MutationPostProcessorMoreTests.cs +3 -0
  130. package/Tests/Runtime/Core/MutationPriorityTests.cs +3 -0
  131. package/Tests/Runtime/Core/NominalTests.cs +3 -0
  132. package/Tests/Runtime/Core/OrderingTests.cs +3 -0
  133. package/Tests/Runtime/Core/OverDeregistrationTests.cs +3 -0
  134. package/Tests/Runtime/Core/PostProcessorTests.cs +3 -0
  135. package/Tests/Runtime/Core/ReflexiveErrorTests.cs +3 -0
  136. package/Tests/Runtime/Core/ReflexiveMessageWarningTests.cs +4 -1
  137. package/Tests/Runtime/Core/ReflexiveTests.cs +3 -0
  138. package/Tests/Runtime/Core/RegistrationTests.cs +3 -0
  139. package/Tests/Runtime/Core/StringShorthandTests.cs +3 -0
  140. package/Tests/Runtime/Core/TargetedTests.cs +3 -0
  141. package/Tests/Runtime/Core/TypedShorthandTests.cs +3 -0
  142. package/Tests/Runtime/Core/UntargetedEquivalenceTests.cs +3 -0
  143. package/Tests/Runtime/Core/UntargetedPrefreezeTests.cs +14 -78
  144. package/Tests/Runtime/Core/UntargetedTests.cs +3 -0
  145. package/Tests/Runtime/Integrations/Reflex/ReflexIntegrationTests.cs +4 -1
  146. package/Tests/Runtime/Integrations/VContainer/VContainerIntegrationTests.cs +3 -0
  147. package/Tests/Runtime/Integrations/Zenject/ZenjectIntegrationTests.cs +3 -0
  148. package/Tests/Runtime/Scripts/Components/GenericMessageAwareComponent.cs +3 -0
  149. package/Tests/Runtime/Scripts/Components/ManualListenerComponent.cs +3 -0
  150. package/Tests/Runtime/Scripts/Components/ReflexiveReceiverComponent.cs +3 -0
  151. package/Tests/Runtime/TestUtilities/UnityFixtureBase.cs +3 -0
  152. package/Tests/Runtime/Unity/MessageBusProviderAssetTests.cs +3 -0
  153. package/Tests/Runtime/Unity/MessageBusProviderHandleTests.cs +87 -3
  154. package/Tests/Runtime/Unity/MessagingComponentInstallerSceneTests.cs +109 -0
  155. package/Tests/Runtime/Unity/MessagingComponentInstallerSceneTests.cs.meta +11 -0
  156. package/Tests/Runtime/Unity/MessagingComponentProviderIntegrationTests.cs +159 -17
  157. package/package.json +1 -1
  158. package/Tests/Runtime/WallstopStudios.DxMessaging.Tests.Runtime.csproj +0 -7
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: aa2a8eed3f943a2419acdc40a9da37c0
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,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -87,3 +88,5 @@ namespace DxMessaging.Tests.Runtime.Core
87
88
  }
88
89
  }
89
90
  }
91
+
92
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System;
@@ -206,3 +207,5 @@ namespace DxMessaging.Tests.Runtime.Core
206
207
  }
207
208
  }
208
209
  }
210
+
211
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -96,3 +97,5 @@ namespace DxMessaging.Tests.Runtime.Core
96
97
  }
97
98
  }
98
99
  }
100
+
101
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -432,3 +433,5 @@ namespace DxMessaging.Tests.Runtime.Core
432
433
  }
433
434
  }
434
435
  }
436
+
437
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -2019,3 +2020,5 @@ namespace DxMessaging.Tests.Runtime.Core
2019
2020
  }
2020
2021
  }
2021
2022
  }
2023
+
2024
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -97,3 +98,5 @@ namespace DxMessaging.Tests.Runtime.Core
97
98
  }
98
99
  }
99
100
  }
101
+
102
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -185,3 +186,5 @@ namespace DxMessaging.Tests.Runtime.Core
185
186
  }
186
187
  }
187
188
  }
189
+
190
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -104,3 +105,5 @@ namespace DxMessaging.Tests.Runtime.Core
104
105
  }
105
106
  }
106
107
  }
108
+
109
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -112,3 +113,5 @@ namespace DxMessaging.Tests.Runtime.Core
112
113
  }
113
114
  }
114
115
  }
116
+
117
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -114,3 +115,5 @@ namespace DxMessaging.Tests.Runtime.Core
114
115
  }
115
116
  }
116
117
  }
118
+
119
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System;
@@ -1732,3 +1733,5 @@ namespace DxMessaging.Tests.Runtime.Core
1732
1733
  }
1733
1734
  }
1734
1735
  }
1736
+
1737
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -1927,3 +1928,5 @@ namespace DxMessaging.Tests.Runtime.Core
1927
1928
  }
1928
1929
  }
1929
1930
  }
1931
+
1932
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System;
@@ -123,3 +124,5 @@ namespace DxMessaging.Tests.Runtime.Core
123
124
  }
124
125
  }
125
126
  }
127
+
128
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System;
@@ -1234,3 +1235,5 @@ namespace DxMessaging.Tests.Runtime.Core
1234
1235
  }
1235
1236
  }
1236
1237
  }
1238
+
1239
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -38,3 +39,5 @@ namespace DxMessaging.Tests.Runtime.Core
38
39
  }
39
40
  }
40
41
  }
42
+
43
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System;
@@ -18,7 +19,7 @@ namespace DxMessaging.Tests.Runtime.Core
18
19
  public IEnumerator LogsWarningOncePerBus()
19
20
  {
20
21
  List<(LogLevel level, string message)> logs = new();
21
- var previousLogFunction = MessagingDebug.LogFunction;
22
+ Action<LogLevel, string> previousLogFunction = MessagingDebug.LogFunction;
22
23
  try
23
24
  {
24
25
  MessagingDebug.LogFunction = (level, message) => logs.Add((level, message));
@@ -84,3 +85,5 @@ namespace DxMessaging.Tests.Runtime.Core
84
85
  }
85
86
  }
86
87
  }
88
+
89
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -168,3 +169,5 @@ namespace DxMessaging.Tests.Runtime.Core
168
169
  }
169
170
  }
170
171
  }
172
+
173
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System;
@@ -1264,3 +1265,5 @@ namespace DxMessaging.Tests.Runtime.Core
1264
1265
  }
1265
1266
  }
1266
1267
  }
1268
+
1269
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -96,3 +97,5 @@ namespace DxMessaging.Tests.Runtime.Core
96
97
  }
97
98
  }
98
99
  }
100
+
101
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -886,3 +887,5 @@ namespace DxMessaging.Tests.Runtime.Core
886
887
  }
887
888
  }
888
889
  }
890
+
891
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System;
@@ -228,3 +229,5 @@ namespace DxMessaging.Tests.Runtime.Core
228
229
  }
229
230
  }
230
231
  }
232
+
233
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  // ReSharper disable AccessToModifiedClosure
2
3
  namespace DxMessaging.Tests.Runtime.Core
3
4
  {
@@ -168,3 +169,5 @@ namespace DxMessaging.Tests.Runtime.Core
168
169
  }
169
170
  }
170
171
  }
172
+
173
+ #endif
@@ -1,10 +1,6 @@
1
1
  namespace DxMessaging.Tests.Runtime.Core
2
2
  {
3
- using System;
4
- using System.Collections.Generic;
5
- using System.Reflection;
6
3
  using DxMessaging.Core;
7
- using DxMessaging.Core.Helper;
8
4
  using DxMessaging.Core.MessageBus;
9
5
  using DxMessaging.Tests.Runtime.Scripts.Messages;
10
6
  using NUnit.Framework;
@@ -27,88 +23,28 @@ namespace DxMessaging.Tests.Runtime.Core
27
23
 
28
24
  token.Enable();
29
25
 
30
- object cache = GetUntargetedPostProcessingFastCache(
31
- handler,
32
- messageBus,
33
- typeof(SimpleUntargetedMessage),
34
- priority: 0
35
- );
36
-
37
26
  SimpleUntargetedMessage message = new();
38
27
  messageBus.UntargetedBroadcast(ref message);
39
28
  Assert.AreEqual(1, postProcessCount);
40
- Assert.AreEqual(1, GetPrefreezeInvocationCount(cache));
29
+ Assert.AreEqual(
30
+ 1,
31
+ handler.GetUntargetedPostProcessingPrefreezeCount<SimpleUntargetedMessage>(
32
+ messageBus,
33
+ priority: 0
34
+ )
35
+ );
41
36
 
42
37
  messageBus.UntargetedBroadcast(ref message);
43
38
  Assert.AreEqual(2, postProcessCount);
44
- Assert.AreEqual(2, GetPrefreezeInvocationCount(cache));
45
-
46
- token.Disable();
47
- }
48
-
49
- private static object GetUntargetedPostProcessingFastCache(
50
- MessageHandler handler,
51
- MessageBus messageBus,
52
- Type messageType,
53
- int priority
54
- )
55
- {
56
- FieldInfo handlersField = typeof(MessageHandler).GetField(
57
- "_handlersByTypeByMessageBus",
58
- BindingFlags.NonPublic | BindingFlags.Instance
39
+ Assert.AreEqual(
40
+ 2,
41
+ handler.GetUntargetedPostProcessingPrefreezeCount<SimpleUntargetedMessage>(
42
+ messageBus,
43
+ priority: 0
44
+ )
59
45
  );
60
- Assert.IsNotNull(handlersField);
61
- var handlersByBus = (List<MessageCache<object>>)handlersField.GetValue(handler);
62
- Assert.IsNotNull(handlersByBus);
63
-
64
- MessageCache<object> cacheByType = handlersByBus[
65
- messageBus.RegisteredGlobalSequentialIndex
66
- ];
67
- MethodInfo getOrAddMethod = typeof(MessageCache<object>)
68
- .GetMethod(nameof(MessageCache<object>.GetOrAdd))
69
- ?.MakeGenericMethod(messageType);
70
- Assert.IsNotNull(getOrAddMethod);
71
-
72
- object typedHandler = getOrAddMethod.Invoke(cacheByType, null);
73
- Assert.IsNotNull(typedHandler);
74
46
 
75
- FieldInfo fastHandlersField = typedHandler
76
- .GetType()
77
- .GetField(
78
- "_untargetedPostProcessingFastHandlers",
79
- BindingFlags.NonPublic | BindingFlags.Instance
80
- );
81
- Assert.IsNotNull(fastHandlersField);
82
-
83
- object fastHandlers = fastHandlersField.GetValue(typedHandler);
84
- Assert.IsNotNull(fastHandlers);
85
-
86
- return GetDictionaryValue(fastHandlers, priority);
87
- }
88
-
89
- private static object GetDictionaryValue(object dictionary, int key)
90
- {
91
- MethodInfo tryGetValue = dictionary
92
- .GetType()
93
- .GetMethod("TryGetValue", BindingFlags.Public | BindingFlags.Instance);
94
- Assert.IsNotNull(tryGetValue);
95
-
96
- object[] args = { key, null };
97
- bool found = (bool)tryGetValue.Invoke(dictionary, args);
98
- Assert.IsTrue(found, $"Failed to locate cache for priority {key}.");
99
- return args[1];
100
- }
101
-
102
- private static int GetPrefreezeInvocationCount(object handlerCache)
103
- {
104
- FieldInfo countField = handlerCache
105
- .GetType()
106
- .GetField(
107
- "prefreezeInvocationCount",
108
- BindingFlags.NonPublic | BindingFlags.Instance
109
- );
110
- Assert.IsNotNull(countField);
111
- return (int)countField.GetValue(handlerCache);
47
+ token.Disable();
112
48
  }
113
49
  }
114
50
  }
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Core
2
3
  {
3
4
  using System.Collections;
@@ -270,3 +271,5 @@ namespace DxMessaging.Tests.Runtime.Core
270
271
  }
271
272
  }
272
273
  }
274
+
275
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Reflex
2
3
  {
3
4
  #if REFLEX_PRESENT
@@ -93,7 +94,7 @@ namespace DxMessaging.Tests.Runtime.Reflex
93
94
 
94
95
  Container container = TrackDisposable(builder.Build());
95
96
 
96
- var concrete =
97
+ DxMessagingRegistrationInstaller.ContainerMessageRegistrationBuilder concrete =
97
98
  container.Resolve<DxMessagingRegistrationInstaller.ContainerMessageRegistrationBuilder>();
98
99
  Assert.IsNotNull(
99
100
  concrete,
@@ -160,3 +161,5 @@ namespace DxMessaging.Tests.Runtime.Reflex
160
161
  }
161
162
  #endif
162
163
  }
164
+
165
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.VContainer
2
3
  {
3
4
  #if VCONTAINER_PRESENT
@@ -138,3 +139,5 @@ namespace DxMessaging.Tests.Runtime.VContainer
138
139
  }
139
140
  #endif
140
141
  }
142
+
143
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Zenject
2
3
  {
3
4
  #if ZENJECT_PRESENT
@@ -138,3 +139,5 @@ namespace DxMessaging.Tests.Runtime.Zenject
138
139
  }
139
140
  #endif
140
141
  }
142
+
143
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Scripts.Components
2
3
  {
3
4
  using DxMessaging.Unity;
@@ -16,3 +17,5 @@ namespace DxMessaging.Tests.Runtime.Scripts.Components
16
17
  }
17
18
  }
18
19
  }
20
+
21
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Scripts.Components
2
3
  {
3
4
  using DxMessaging.Core;
@@ -20,3 +21,5 @@ namespace DxMessaging.Tests.Runtime.Scripts.Components
20
21
  }
21
22
  }
22
23
  }
24
+
25
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Scripts.Components
2
3
  {
3
4
  using UnityEngine;
@@ -12,3 +13,5 @@ namespace DxMessaging.Tests.Runtime.Scripts.Components
12
13
  }
13
14
  }
14
15
  }
16
+
17
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime
2
3
  {
3
4
  using System;
@@ -62,3 +63,5 @@ namespace DxMessaging.Tests.Runtime
62
63
  }
63
64
  }
64
65
  }
66
+
67
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Unity
2
3
  {
3
4
  using DxMessaging.Core;
@@ -55,3 +56,5 @@ namespace DxMessaging.Tests.Runtime.Unity
55
56
  }
56
57
  }
57
58
  }
59
+
60
+ #endif
@@ -1,5 +1,7 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Tests.Runtime.Unity
2
3
  {
4
+ using System.Collections.Generic;
3
5
  using DxMessaging.Core.MessageBus;
4
6
  using DxMessaging.Unity;
5
7
  using NUnit.Framework;
@@ -8,6 +10,29 @@ namespace DxMessaging.Tests.Runtime.Unity
8
10
  [TestFixture]
9
11
  public sealed class MessageBusProviderHandleTests
10
12
  {
13
+ private readonly List<Object> _objectsToDestroy = new();
14
+
15
+ [SetUp]
16
+ public void SetUp()
17
+ {
18
+ _objectsToDestroy.Clear();
19
+ }
20
+
21
+ [TearDown]
22
+ public void TearDown()
23
+ {
24
+ for (int i = 0; i < _objectsToDestroy.Count; ++i)
25
+ {
26
+ Object obj = _objectsToDestroy[i];
27
+ if (obj != null)
28
+ {
29
+ Object.DestroyImmediate(obj);
30
+ }
31
+ }
32
+
33
+ _objectsToDestroy.Clear();
34
+ }
35
+
11
36
  [Test]
12
37
  public void TryGetProviderReturnsRuntimeProvider()
13
38
  {
@@ -29,13 +54,12 @@ namespace DxMessaging.Tests.Runtime.Unity
29
54
  ScriptableObject.CreateInstance<TestScriptableMessageBusProvider>();
30
55
  providerAsset.Configure(new MessageBus());
31
56
  MessageBusProviderHandle handle = new(providerAsset);
57
+ TrackForCleanup(providerAsset);
32
58
 
33
59
  bool resolved = handle.TryGetProvider(out IMessageBusProvider provider);
34
60
 
35
61
  Assert.IsTrue(resolved);
36
62
  Assert.AreSame(providerAsset, provider);
37
-
38
- Object.DestroyImmediate(providerAsset);
39
63
  }
40
64
 
41
65
  [Test]
@@ -55,6 +79,7 @@ namespace DxMessaging.Tests.Runtime.Unity
55
79
  ScriptableObject.CreateInstance<TestScriptableMessageBusProvider>();
56
80
  providerAsset.Configure(new MessageBus());
57
81
  MessageBusProviderHandle handle = new(providerAsset);
82
+ TrackForCleanup(providerAsset);
58
83
 
59
84
  HandleWrapper wrapper = new() { Handle = handle };
60
85
  string json = JsonUtility.ToJson(wrapper);
@@ -64,8 +89,57 @@ namespace DxMessaging.Tests.Runtime.Unity
64
89
 
65
90
  Assert.IsTrue(resolved);
66
91
  Assert.AreSame(providerAsset, provider);
92
+ }
93
+
94
+ [Test]
95
+ public void WithRuntimeProviderOverridesSerializedProvider()
96
+ {
97
+ MessageBus serializedBus = new();
98
+ TestScriptableMessageBusProvider providerAsset =
99
+ ScriptableObject.CreateInstance<TestScriptableMessageBusProvider>();
100
+ providerAsset.Configure(serializedBus);
101
+ MessageBusProviderHandle handle = new(providerAsset);
102
+ TrackForCleanup(providerAsset);
103
+
104
+ MessageBus runtimeBus = new();
105
+ TestMessageBusProvider runtimeProvider = new(runtimeBus);
106
+ MessageBusProviderHandle runtimeHandle = handle.WithRuntimeProvider(runtimeProvider);
107
+
108
+ Assert.IsTrue(runtimeHandle.TryGetProvider(out IMessageBusProvider provider));
109
+ Assert.AreSame(runtimeProvider, provider);
110
+ Assert.AreSame(runtimeBus, runtimeHandle.ResolveBus());
67
111
 
68
- Object.DestroyImmediate(providerAsset);
112
+ // Original handle should remain associated with the serialized provider asset.
113
+ Assert.IsTrue(handle.TryGetProvider(out IMessageBusProvider serializedProvider));
114
+ Assert.AreSame(providerAsset, serializedProvider);
115
+ Assert.AreSame(serializedBus, handle.ResolveBus());
116
+ }
117
+
118
+ [Test]
119
+ public void RuntimeProviderIsNotSerialized()
120
+ {
121
+ MessageBus serializedBus = new();
122
+ TestScriptableMessageBusProvider providerAsset =
123
+ ScriptableObject.CreateInstance<TestScriptableMessageBusProvider>();
124
+ providerAsset.Configure(serializedBus);
125
+ MessageBusProviderHandle handle = new(providerAsset);
126
+ TrackForCleanup(providerAsset);
127
+
128
+ MessageBus runtimeBus = new();
129
+ TestMessageBusProvider runtimeProvider = new(runtimeBus);
130
+ handle = handle.WithRuntimeProvider(runtimeProvider);
131
+
132
+ HandleWrapper wrapper = new() { Handle = handle };
133
+ string json = JsonUtility.ToJson(wrapper);
134
+ HandleWrapper deserialized = JsonUtility.FromJson<HandleWrapper>(json);
135
+
136
+ Assert.IsTrue(deserialized.Handle.TryGetProvider(out IMessageBusProvider provider));
137
+ Assert.AreSame(
138
+ providerAsset,
139
+ provider,
140
+ "Serialized handle should resolve the asset provider."
141
+ );
142
+ Assert.AreSame(serializedBus, deserialized.Handle.ResolveBus());
69
143
  }
70
144
 
71
145
  private sealed class TestMessageBusProvider : IMessageBusProvider
@@ -83,6 +157,14 @@ namespace DxMessaging.Tests.Runtime.Unity
83
157
  }
84
158
  }
85
159
 
160
+ private void TrackForCleanup(Object unityObject)
161
+ {
162
+ if (unityObject != null)
163
+ {
164
+ _objectsToDestroy.Add(unityObject);
165
+ }
166
+ }
167
+
86
168
  [System.Serializable]
87
169
  private struct HandleWrapper
88
170
  {
@@ -105,3 +187,5 @@ namespace DxMessaging.Tests.Runtime.Unity
105
187
  }
106
188
  }
107
189
  }
190
+
191
+ #endif