com.wallstop-studios.dxmessaging 2.1.0 → 2.1.2

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 (140) hide show
  1. package/.github/workflows/dotnet-tests.yml +72 -0
  2. package/.lychee.toml +4 -2
  3. package/AGENTS.md +1 -0
  4. package/Docs/Comparisons.md +4 -4
  5. package/Docs/EmitShorthands.md +2 -2
  6. package/Docs/Helpers.md +90 -75
  7. package/Docs/Install.md +2 -1
  8. package/Docs/Patterns.md +1 -1
  9. package/Docs/Performance.md +13 -11
  10. package/Docs/QuickStart.md +1 -2
  11. package/Editor/Analyzers/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  12. package/Editor/Analyzers/Microsoft.CodeAnalysis.CSharp.dll.meta +13 -2
  13. package/Editor/Analyzers/Microsoft.CodeAnalysis.dll +0 -0
  14. package/Editor/Analyzers/Microsoft.CodeAnalysis.dll.meta +11 -0
  15. package/Editor/Analyzers/System.Collections.Immutable.dll +0 -0
  16. package/Editor/Analyzers/System.Collections.Immutable.dll.meta +11 -0
  17. package/Editor/Analyzers/System.Reflection.Metadata.dll +0 -0
  18. package/Editor/Analyzers/System.Reflection.Metadata.dll.meta +13 -2
  19. package/Editor/Analyzers/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  20. package/Editor/Analyzers/System.Runtime.CompilerServices.Unsafe.dll.meta +11 -0
  21. package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
  22. package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll.meta +3 -2
  23. package/Editor/AssemblyInfo.cs +3 -0
  24. package/Editor/AssemblyInfo.cs.meta +3 -0
  25. package/Editor/CustomEditors/MessagingComponentEditor.cs +21 -0
  26. package/Editor/SetupCscRsp.cs +133 -53
  27. package/Editor/Testing/MessagingComponentEditorHarness.cs +218 -0
  28. package/Editor/Testing/MessagingComponentEditorHarness.cs.meta +3 -0
  29. package/Editor/Testing.meta +3 -0
  30. package/README.md +9 -3
  31. package/Runtime/AssemblyInfo.cs +1 -0
  32. package/Runtime/Core/Attributes/DxAutoConstructorAttribute.cs +1 -1
  33. package/Runtime/Core/Attributes/DxBroadcastMessageAttribute.cs +1 -1
  34. package/Runtime/Core/Attributes/DxOptionalParameterAttribute.cs +1 -1
  35. package/Runtime/Core/Attributes/DxTargetedMessageAttribute.cs +1 -1
  36. package/Runtime/Core/Attributes/DxUntargetedMessageAttribute.cs +1 -1
  37. package/Runtime/Core/Diagnostics/MessageEmissionData.cs +26 -11
  38. package/Runtime/Core/Extensions/MessageBusExtensions.cs +2 -2
  39. package/Runtime/Core/Extensions/MessageExtensions.cs +2 -2
  40. package/Runtime/Core/InstanceId.cs +5 -3
  41. package/Runtime/Core/MessageBus/MessageBus.cs +4 -4
  42. package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs +2 -2
  43. package/Runtime/Core/MessageBus/MessagingRegistration.cs +3 -3
  44. package/Runtime/Core/MessageHandler.cs +34 -2
  45. package/Runtime/Core/MessageRegistrationToken.cs +2 -2
  46. package/Runtime/Core/Messages/IBroadcastMessage.cs +1 -1
  47. package/Runtime/Core/Messages/ITargetedMessage.cs +1 -1
  48. package/Runtime/Core/Messages/IUntargetedMessage.cs +1 -1
  49. package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs +2 -0
  50. package/Runtime/Unity/InitialGlobalMessageBusProvider.cs +2 -0
  51. package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs +2 -0
  52. package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs +2 -0
  53. package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs +2 -0
  54. package/Runtime/Unity/MessageAwareComponent.cs +2 -0
  55. package/Runtime/Unity/MessageBusProviderHandle.cs +4 -0
  56. package/Runtime/Unity/MessagingComponent.cs +27 -7
  57. package/Runtime/Unity/MessagingComponentInstaller.cs +2 -0
  58. package/Runtime/Unity/ScriptableMessageBusProvider.cs +2 -0
  59. package/Samples~/DI/Reflex/SampleInstaller.cs +6 -6
  60. package/Samples~/DI/VContainer/SampleLifetimeScope.cs +7 -9
  61. package/Samples~/DI/Zenject/SampleInstaller.cs +6 -8
  62. package/SourceGenerators/Directory.Build.props +9 -0
  63. package/{package-lock.json.meta → SourceGenerators/Directory.Build.props.meta} +2 -2
  64. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs +19 -24
  65. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs +87 -27
  66. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.csproj +24 -4
  67. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DocsSnippetCompilationTests.cs +193 -0
  68. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DocsSnippetCompilationTests.cs.meta +11 -0
  69. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DxAutoConstructorGeneratorDiagnosticsTests.cs +69 -0
  70. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DxAutoConstructorGeneratorDiagnosticsTests.cs.meta +11 -0
  71. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DxMessageIdGeneratorDiagnosticsTests.cs +66 -0
  72. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/DxMessageIdGeneratorDiagnosticsTests.cs.meta +11 -0
  73. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/GeneratorTestUtilities.cs +155 -0
  74. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/GeneratorTestUtilities.cs.meta +11 -0
  75. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/WallstopStudios.DxMessaging.SourceGenerators.Tests.csproj +20 -0
  76. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/WallstopStudios.DxMessaging.SourceGenerators.Tests.csproj.meta +7 -0
  77. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests.meta +8 -0
  78. package/Tests/Editor/MessagingComponentEditorHarnessTests.cs +243 -0
  79. package/Tests/Editor/MessagingComponentEditorHarnessTests.cs.meta +3 -0
  80. package/Tests/Editor/MessagingComponentSerializationTests.cs +129 -0
  81. package/Tests/Editor/MessagingComponentSerializationTests.cs.meta +3 -0
  82. package/Tests/Editor/WallstopStudios.DxMessaging.Tests.Editor.asmdef +19 -0
  83. package/Tests/Editor/WallstopStudios.DxMessaging.Tests.Editor.asmdef.meta +3 -0
  84. package/Tests/Editor.meta +3 -0
  85. package/Tests/Runtime/Benchmarks/BenchmarkSession.cs +3 -0
  86. package/Tests/Runtime/Benchmarks/BenchmarkTestBase.cs +3 -0
  87. package/Tests/Runtime/Benchmarks/ComparisonPerformanceTests.cs +3 -0
  88. package/Tests/Runtime/Benchmarks/PerformanceTests.cs +137 -0
  89. package/Tests/Runtime/Core/AlternateBusTests.cs +3 -0
  90. package/Tests/Runtime/Core/BroadcastTests.cs +3 -0
  91. package/Tests/Runtime/Core/CyclicBufferTests.cs +3 -0
  92. package/Tests/Runtime/Core/DefaultBusFallbackTests.cs +5 -2
  93. package/Tests/Runtime/Core/DiagnosticsTests.cs +3 -0
  94. package/Tests/Runtime/Core/EdgeCaseTests.cs +3 -0
  95. package/Tests/Runtime/Core/EnablementTests.cs +3 -0
  96. package/Tests/Runtime/Core/Extensions/MessageExtensionsProviderTests.cs +2 -2
  97. package/Tests/Runtime/Core/GenericMessageTests.cs +3 -0
  98. package/Tests/Runtime/Core/GlobalAcceptAllTests.cs +3 -0
  99. package/Tests/Runtime/Core/InterceptorCancellationTests.cs +3 -0
  100. package/Tests/Runtime/Core/LifecycleTests.cs +3 -0
  101. package/Tests/Runtime/Core/MessageEmissionDataTests.cs +70 -0
  102. package/Tests/Runtime/Core/MessageEmissionDataTests.cs.meta +11 -0
  103. package/Tests/Runtime/Core/MessagingComponentLifecycleTests.cs +3 -0
  104. package/Tests/Runtime/Core/MessagingTestBase.cs +3 -0
  105. package/Tests/Runtime/Core/MutationDedupeTests.cs +3 -0
  106. package/Tests/Runtime/Core/MutationDestructionTests.cs +3 -0
  107. package/Tests/Runtime/Core/MutationDuringEmissionTests.cs +3 -0
  108. package/Tests/Runtime/Core/MutationGlobalAddTests.cs +3 -0
  109. package/Tests/Runtime/Core/MutationInterceptorTests.cs +3 -0
  110. package/Tests/Runtime/Core/MutationPostProcessorAcrossHandlersTests.cs +3 -0
  111. package/Tests/Runtime/Core/MutationPostProcessorMoreTests.cs +3 -0
  112. package/Tests/Runtime/Core/MutationPriorityTests.cs +3 -0
  113. package/Tests/Runtime/Core/NominalTests.cs +3 -0
  114. package/Tests/Runtime/Core/OrderingTests.cs +3 -0
  115. package/Tests/Runtime/Core/OverDeregistrationTests.cs +3 -0
  116. package/Tests/Runtime/Core/PostProcessorTests.cs +3 -0
  117. package/Tests/Runtime/Core/ReflexiveErrorTests.cs +3 -0
  118. package/Tests/Runtime/Core/ReflexiveMessageWarningTests.cs +4 -1
  119. package/Tests/Runtime/Core/ReflexiveTests.cs +3 -0
  120. package/Tests/Runtime/Core/RegistrationTests.cs +3 -0
  121. package/Tests/Runtime/Core/StringShorthandTests.cs +3 -0
  122. package/Tests/Runtime/Core/TargetedTests.cs +3 -0
  123. package/Tests/Runtime/Core/TypedShorthandTests.cs +3 -0
  124. package/Tests/Runtime/Core/UntargetedEquivalenceTests.cs +3 -0
  125. package/Tests/Runtime/Core/UntargetedPrefreezeTests.cs +14 -78
  126. package/Tests/Runtime/Core/UntargetedTests.cs +3 -0
  127. package/Tests/Runtime/Integrations/Reflex/ReflexIntegrationTests.cs +4 -1
  128. package/Tests/Runtime/Integrations/VContainer/VContainerIntegrationTests.cs +3 -0
  129. package/Tests/Runtime/Integrations/Zenject/ZenjectIntegrationTests.cs +3 -0
  130. package/Tests/Runtime/Scripts/Components/GenericMessageAwareComponent.cs +3 -0
  131. package/Tests/Runtime/Scripts/Components/ManualListenerComponent.cs +3 -0
  132. package/Tests/Runtime/Scripts/Components/ReflexiveReceiverComponent.cs +3 -0
  133. package/Tests/Runtime/TestUtilities/UnityFixtureBase.cs +3 -0
  134. package/Tests/Runtime/Unity/MessageBusProviderAssetTests.cs +3 -0
  135. package/Tests/Runtime/Unity/MessageBusProviderHandleTests.cs +87 -3
  136. package/Tests/Runtime/Unity/MessagingComponentInstallerSceneTests.cs +109 -0
  137. package/Tests/Runtime/Unity/MessagingComponentInstallerSceneTests.cs.meta +11 -0
  138. package/Tests/Runtime/Unity/MessagingComponentProviderIntegrationTests.cs +159 -17
  139. package/Tests/Runtime/WallstopStudios.DxMessaging.Tests.Runtime.csproj +20 -7
  140. package/package.json +1 -1
@@ -4,7 +4,7 @@ namespace DxMessaging.Core.Extensions
4
4
  using DxMessaging.Core;
5
5
  using DxMessaging.Core.MessageBus;
6
6
  using DxMessaging.Core.Messages;
7
- #if UNITY_2017_1_OR_NEWER
7
+ #if UNITY_2021_3_OR_NEWER
8
8
  using UnityEngine;
9
9
  #endif
10
10
 
@@ -98,7 +98,7 @@ namespace DxMessaging.Core.Extensions
98
98
  message.EmitBroadcast(source, messageBus);
99
99
  }
100
100
 
101
- #if UNITY_2017_1_OR_NEWER
101
+ #if UNITY_2021_3_OR_NEWER
102
102
  public static void EmitGameObjectTargeted<TMessage>(
103
103
  this IMessageBus messageBus,
104
104
  GameObject target,
@@ -37,7 +37,7 @@ namespace DxMessaging.Core.Extensions
37
37
  /// </example>
38
38
  public static class MessageExtensions
39
39
  {
40
- #if UNITY_2017_1_OR_NEWER
40
+ #if UNITY_2021_3_OR_NEWER
41
41
  /// <summary>
42
42
  /// Emits a TargetedMessage of the given type.
43
43
  /// </summary>
@@ -395,7 +395,7 @@ namespace DxMessaging.Core.Extensions
395
395
  resolvedBus.SourcedBroadcast(ref source, ref message);
396
396
  }
397
397
 
398
- #if UNITY_2017_1_OR_NEWER
398
+ #if UNITY_2021_3_OR_NEWER
399
399
  /// <summary>
400
400
  /// Emits a BroadcastMessage of the given type.
401
401
  /// </summary>
@@ -30,7 +30,7 @@ namespace DxMessaging.Core
30
30
 
31
31
  private readonly int _id;
32
32
 
33
- #if UNITY_2017_1_OR_NEWER
33
+ #if UNITY_2021_3_OR_NEWER
34
34
  // ReSharper disable once InconsistentNaming
35
35
  public readonly UnityEngine.Object Object;
36
36
  #endif
@@ -38,10 +38,12 @@ namespace DxMessaging.Core
38
38
  public InstanceId(int id)
39
39
  {
40
40
  _id = id;
41
+ #if UNITY_2021_3_OR_NEWER
41
42
  Object = null;
43
+ #endif
42
44
  }
43
45
 
44
- #if UNITY_2017_1_OR_NEWER
46
+ #if UNITY_2021_3_OR_NEWER
45
47
  private InstanceId(UnityEngine.Object unityObject)
46
48
  {
47
49
  _id = unityObject.GetInstanceID();
@@ -81,7 +83,7 @@ namespace DxMessaging.Core
81
83
 
82
84
  public override string ToString()
83
85
  {
84
- #if UNITY_2017_1_OR_NEWER
86
+ #if UNITY_2021_3_OR_NEWER
85
87
  UnityEngine.Object instance = Object;
86
88
  string objectName = instance == null ? string.Empty : instance.name;
87
89
  return new { Id = _id, Name = objectName }.ToString();
@@ -12,7 +12,7 @@ namespace DxMessaging.Core.MessageBus
12
12
  using Helper;
13
13
  using Messages;
14
14
  using static IMessageBus;
15
- #if UNITY_2017_1_OR_NEWER
15
+ #if UNITY_2021_3_OR_NEWER
16
16
  using UnityEngine;
17
17
  #endif
18
18
 
@@ -167,7 +167,7 @@ namespace DxMessaging.Core.MessageBus
167
167
  Dictionary<MethodSignatureKey, Action<MonoBehaviour, object[]>>
168
168
  > _methodCache = new();
169
169
 
170
- #if UNITY_2017_1_OR_NEWER
170
+ #if UNITY_2021_3_OR_NEWER
171
171
  private readonly HashSet<MonoBehaviour> _recipientCache = new();
172
172
  private readonly List<MonoBehaviour> _componentCache = new();
173
173
  #endif
@@ -1144,7 +1144,7 @@ namespace DxMessaging.Core.MessageBus
1144
1144
  );
1145
1145
  }
1146
1146
  }
1147
- #if UNITY_2017_1_OR_NEWER
1147
+ #if UNITY_2021_3_OR_NEWER
1148
1148
  ref ReflexiveMessage reflexiveMessage = ref Unsafe.As<TMessage, ReflexiveMessage>(
1149
1149
  ref typedMessage
1150
1150
  );
@@ -4152,7 +4152,7 @@ namespace DxMessaging.Core.MessageBus
4152
4152
  }
4153
4153
  }
4154
4154
 
4155
- #if UNITY_2017_1_OR_NEWER
4155
+ #if UNITY_2021_3_OR_NEWER
4156
4156
  private static Action<MonoBehaviour, object[]> CompileMethodAction(MethodInfo methodInfo)
4157
4157
  {
4158
4158
  ParameterExpression componentParameter = Expression.Parameter(
@@ -41,7 +41,7 @@ namespace DxMessaging.Core.MessageBus
41
41
  /// </summary>
42
42
  public InstanceId? Owner { get; set; }
43
43
 
44
- #if UNITY_2017_1_OR_NEWER
44
+ #if UNITY_2021_3_OR_NEWER
45
45
  /// <summary>
46
46
  /// Unity object to treat as the owner. Overrides <see cref="Owner"/> when supplied.
47
47
  /// </summary>
@@ -314,7 +314,7 @@ namespace DxMessaging.Core.MessageBus
314
314
 
315
315
  private static InstanceId ResolveOwner(MessageRegistrationBuildOptions options)
316
316
  {
317
- #if UNITY_2017_1_OR_NEWER
317
+ #if UNITY_2021_3_OR_NEWER
318
318
  if (options.UnityOwner != null)
319
319
  {
320
320
  if (options.UnityOwner is UnityEngine.GameObject gameObject)
@@ -58,7 +58,7 @@ namespace DxMessaging.Core.MessageBus
58
58
  /// </summary>
59
59
  public readonly RegistrationMethod registrationMethod;
60
60
 
61
- #if UNITY_2017_1_OR_NEWER
61
+ #if UNITY_2021_3_OR_NEWER
62
62
  /// <summary>
63
63
  /// Unity time of the registration
64
64
  /// </summary>
@@ -83,7 +83,7 @@ namespace DxMessaging.Core.MessageBus
83
83
  this.type = type;
84
84
  this.registrationType = registrationType;
85
85
  this.registrationMethod = registrationMethod;
86
- #if UNITY_2017_1_OR_NEWER
86
+ #if UNITY_2021_3_OR_NEWER
87
87
  time = UnityEngine.Time.time;
88
88
  #endif
89
89
  }
@@ -92,7 +92,7 @@ namespace DxMessaging.Core.MessageBus
92
92
  {
93
93
  return new
94
94
  {
95
- #if UNITY_2017_1_OR_NEWER
95
+ #if UNITY_2021_3_OR_NEWER
96
96
  time,
97
97
  #endif
98
98
  id,
@@ -502,7 +502,7 @@ namespace DxMessaging.Core
502
502
  /// <note>
503
503
  /// Ideally, this would be something like a Dictionary[T, Handler[T]], but that can't be done with C#s type system.
504
504
  /// </note>
505
- private readonly List<MessageCache<object>> _handlersByTypeByMessageBus;
505
+ internal readonly List<MessageCache<object>> _handlersByTypeByMessageBus;
506
506
  private IMessageBus _defaultMessageBus;
507
507
 
508
508
  /// <summary>
@@ -1934,6 +1934,33 @@ namespace DxMessaging.Core
1934
1934
  return false;
1935
1935
  }
1936
1936
 
1937
+ internal int GetUntargetedPostProcessingPrefreezeCount<T>(
1938
+ IMessageBus messageBus,
1939
+ int priority
1940
+ )
1941
+ where T : IMessage
1942
+ {
1943
+ if (
1944
+ !GetHandlerForType(messageBus, out TypedHandler<T> handler)
1945
+ || handler._untargetedPostProcessingFastHandlers == null
1946
+ )
1947
+ {
1948
+ return 0;
1949
+ }
1950
+
1951
+ if (
1952
+ handler._untargetedPostProcessingFastHandlers.TryGetValue(
1953
+ priority,
1954
+ out HandlerActionCache<FastHandler<T>> cache
1955
+ )
1956
+ )
1957
+ {
1958
+ return cache.prefreezeInvocationCount;
1959
+ }
1960
+
1961
+ return 0;
1962
+ }
1963
+
1937
1964
  private sealed class HandlerActionCache<T>
1938
1965
  {
1939
1966
  internal readonly struct Entry
@@ -3673,7 +3700,12 @@ namespace DxMessaging.Core
3673
3700
  {
3674
3701
  List<TU> list = actionCache.cache;
3675
3702
  list.Clear();
3676
- foreach (var kvp in actionCache.entries)
3703
+ foreach (
3704
+ KeyValuePair<
3705
+ TU,
3706
+ HandlerActionCache<TU>.Entry
3707
+ > kvp in actionCache.entries
3708
+ )
3677
3709
  {
3678
3710
  list.Add(kvp.Value.handler);
3679
3711
  }
@@ -166,7 +166,7 @@ namespace DxMessaging.Core
166
166
  );
167
167
  }
168
168
 
169
- #if UNITY_2017_1_OR_NEWER
169
+ #if UNITY_2021_3_OR_NEWER
170
170
  /// <summary>
171
171
  /// Stages a registration to accept targeted messages of type <typeparamref name="T"/> directed at the given GameObject.
172
172
  /// </summary>
@@ -1024,7 +1024,7 @@ namespace DxMessaging.Core
1024
1024
  );
1025
1025
  }
1026
1026
 
1027
- #if UNITY_2017_1_OR_NEWER
1027
+ #if UNITY_2021_3_OR_NEWER
1028
1028
  /// <summary>
1029
1029
  /// Stages a registration to accept broadcast messages of type <typeparamref name="T"/> from a given source.
1030
1030
  /// </summary>
@@ -25,7 +25,7 @@ namespace DxMessaging.Core.Messages
25
25
  /// // Attribute + auto constructor
26
26
  /// [DxMessaging.Core.Attributes.DxBroadcastMessage]
27
27
  /// [DxMessaging.Core.Attributes.DxAutoConstructor]
28
- /// public readonly struct PickedUpItem { public readonly int itemId; }
28
+ /// public readonly partial struct PickedUpItem { public readonly int itemId; }
29
29
  /// </code>
30
30
  /// </example>
31
31
  public interface IBroadcastMessage : IMessage { }
@@ -26,7 +26,7 @@ namespace DxMessaging.Core.Messages
26
26
  /// // Attribute form with auto constructor
27
27
  /// [DxMessaging.Core.Attributes.DxTargetedMessage]
28
28
  /// [DxMessaging.Core.Attributes.DxAutoConstructor]
29
- /// public readonly struct EquipWeapon { public readonly int weaponId; }
29
+ /// public readonly partial struct EquipWeapon { public readonly int weaponId; }
30
30
  /// </code>
31
31
  /// </example>
32
32
  public interface ITargetedMessage : IMessage { }
@@ -26,7 +26,7 @@ namespace DxMessaging.Core.Messages
26
26
  /// // Or with attribute + DxAutoConstructor
27
27
  /// [DxMessaging.Core.Attributes.DxUntargetedMessage]
28
28
  /// [DxMessaging.Core.Attributes.DxAutoConstructor]
29
- /// public readonly struct WorldRegenerated { public readonly int seed; }
29
+ /// public readonly partial struct WorldRegenerated { public readonly int seed; }
30
30
  /// </code>
31
31
  /// </example>
32
32
  public interface IUntargetedMessage : IMessage { }
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Unity
2
3
  {
3
4
  using DxMessaging.Core;
@@ -29,3 +30,4 @@ namespace DxMessaging.Unity
29
30
  }
30
31
  }
31
32
  }
33
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Unity
2
3
  {
3
4
  using DxMessaging.Core;
@@ -36,3 +37,4 @@ namespace DxMessaging.Unity
36
37
  }
37
38
  }
38
39
  }
40
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Unity.Integrations.Reflex
2
3
  {
3
4
  #if REFLEX_PRESENT
@@ -71,3 +72,4 @@ namespace DxMessaging.Unity.Integrations.Reflex
71
72
  }
72
73
  #endif
73
74
  }
75
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Unity.Integrations.VContainer
2
3
  {
3
4
  #if VCONTAINER_PRESENT
@@ -44,3 +45,4 @@ namespace DxMessaging.Unity.Integrations.VContainer
44
45
  }
45
46
  #endif
46
47
  }
48
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Unity.Integrations.Zenject
2
3
  {
3
4
  #if ZENJECT_PRESENT
@@ -53,3 +54,4 @@ namespace DxMessaging.Unity.Integrations.Zenject
53
54
  }
54
55
  #endif
55
56
  }
57
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Unity
2
3
  {
3
4
  using Core;
@@ -273,3 +274,4 @@ namespace DxMessaging.Unity
273
274
  }
274
275
  }
275
276
  }
277
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Unity
2
3
  {
3
4
  using System;
@@ -18,6 +19,8 @@ namespace DxMessaging.Unity
18
19
  [NonSerialized]
19
20
  private IMessageBusProvider _runtimeProvider;
20
21
 
22
+ internal ScriptableMessageBusProvider SerializedProvider => _provider;
23
+
21
24
  /// <summary>
22
25
  /// Initializes a new instance referencing the supplied provider asset.
23
26
  /// </summary>
@@ -95,3 +98,4 @@ namespace DxMessaging.Unity
95
98
  }
96
99
  }
97
100
  }
101
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Unity
2
3
  {
3
4
  using System;
@@ -44,6 +45,20 @@ namespace DxMessaging.Unity
44
45
  internal readonly Dictionary<MonoBehaviour, MessageRegistrationToken> _registeredListeners =
45
46
  new();
46
47
 
48
+ internal bool AutoConfigureSerializedProviderOnAwake =>
49
+ autoConfigureSerializedProviderOnAwake;
50
+
51
+ internal bool HasRuntimeProvider => _messageBusProvider != null;
52
+
53
+ internal bool HasMessageBusOverride => _messageBusOverride != null;
54
+
55
+ internal bool HasSerializedProvider => _serializedProviderHandle.TryGetProvider(out _);
56
+
57
+ internal MessageBusProviderHandle SerializedProviderHandle => _serializedProviderHandle;
58
+
59
+ internal ScriptableMessageBusProvider SerializedProviderAsset =>
60
+ _serializedProviderHandle.SerializedProvider;
61
+
47
62
  /// <summary>
48
63
  /// Creates a <see cref="IMessageRegistrationBuilder"/> aligned with this component's configured bus or provider.
49
64
  /// </summary>
@@ -72,10 +87,10 @@ namespace DxMessaging.Unity
72
87
  throw new ArgumentNullException(nameof(listener));
73
88
  }
74
89
 
75
- if (gameObject.GetInstanceID() != listener.gameObject.GetInstanceID())
90
+ if (gameObject != listener.gameObject)
76
91
  {
77
92
  throw new ArgumentException(
78
- $"Cannot create a RegistrationToken without an valid owner. {listener.gameObject.GetInstanceID()}."
93
+ $"Cannot create a RegistrationToken without a mismatched owner. {listener.gameObject} != existing {gameObject}."
79
94
  );
80
95
  }
81
96
 
@@ -86,11 +101,15 @@ namespace DxMessaging.Unity
86
101
  )
87
102
  )
88
103
  {
89
- MessagingDebug.Log(
90
- LogLevel.Warn,
91
- "Ignoring double RegistrationToken request for {0}.",
92
- listener
93
- );
104
+ if (MessagingDebug.enabled)
105
+ {
106
+ MessagingDebug.Log(
107
+ LogLevel.Warn,
108
+ "Ignoring double RegistrationToken request for {0}.",
109
+ listener
110
+ );
111
+ }
112
+
94
113
  return createdToken;
95
114
  }
96
115
 
@@ -309,3 +328,4 @@ namespace DxMessaging.Unity
309
328
  }
310
329
  }
311
330
  }
331
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Unity
2
3
  {
3
4
  using System.Collections.Generic;
@@ -118,3 +119,4 @@ namespace DxMessaging.Unity
118
119
  }
119
120
  }
120
121
  }
122
+ #endif
@@ -1,3 +1,4 @@
1
+ #if UNITY_2021_3_OR_NEWER
1
2
  namespace DxMessaging.Unity
2
3
  {
3
4
  using DxMessaging.Core.MessageBus;
@@ -12,3 +13,4 @@ namespace DxMessaging.Unity
12
13
  public abstract IMessageBus Resolve();
13
14
  }
14
15
  }
16
+ #endif
@@ -2,6 +2,7 @@
2
2
  namespace DxMessaging.Samples.DI.Reflex
3
3
  {
4
4
  using DxMessaging.Core;
5
+ using DxMessaging.Core.Attributes;
5
6
  using DxMessaging.Core.MessageBus;
6
7
  using DxMessaging.Core.Messages;
7
8
  using DxMessaging.Unity.Integrations.Reflex;
@@ -61,14 +62,13 @@ namespace DxMessaging.Samples.DI.Reflex
61
62
  }
62
63
  }
63
64
 
64
- private readonly struct PlayerAlert : IBroadcastMessage
65
+ [DxBroadcastMessage]
66
+ [DxAutoConstructor]
67
+ private readonly partial struct PlayerAlert
65
68
  {
66
- public PlayerAlert(InstanceId source)
67
- {
68
- Source = source;
69
- }
69
+ public readonly InstanceId source;
70
70
 
71
- public InstanceId Source { get; }
71
+ public InstanceId Source => source;
72
72
  }
73
73
  }
74
74
  }
@@ -2,9 +2,9 @@
2
2
  namespace DxMessaging.Samples.DI.VContainer
3
3
  {
4
4
  using System;
5
- using Core.Attributes;
6
- using Core.Extensions;
7
- using Core.MessageBus;
5
+ using DxMessaging.Core.Attributes;
6
+ using DxMessaging.Core.Extensions;
7
+ using DxMessaging.Core.MessageBus;
8
8
  using DxMessaging.Unity.Integrations.VContainer;
9
9
  using UnityEngine;
10
10
  using VContainer;
@@ -25,14 +25,12 @@ namespace DxMessaging.Samples.DI.VContainer
25
25
  }
26
26
 
27
27
  [DxUntargetedMessage]
28
- private readonly struct ScoreUpdated
28
+ [DxAutoConstructor]
29
+ private readonly partial struct ScoreUpdated
29
30
  {
30
- public readonly int Value;
31
+ public readonly int value;
31
32
 
32
- public ScoreUpdated(int value)
33
- {
34
- Value = value;
35
- }
33
+ public int Value => value;
36
34
  }
37
35
 
38
36
  private sealed class ScoreboardService : IStartable, ITickable, IDisposable
@@ -2,8 +2,8 @@
2
2
  namespace DxMessaging.Samples.DI.Zenject
3
3
  {
4
4
  using System;
5
- using Core.Attributes;
6
- using Core.MessageBus;
5
+ using DxMessaging.Core.Attributes;
6
+ using DxMessaging.Core.MessageBus;
7
7
  using UnityEngine;
8
8
  using Zenject;
9
9
 
@@ -20,14 +20,12 @@ namespace DxMessaging.Samples.DI.Zenject
20
20
  }
21
21
 
22
22
  [DxUntargetedMessage]
23
- private readonly struct PlayerSpawned
23
+ [DxAutoConstructor]
24
+ private readonly partial struct PlayerSpawned
24
25
  {
25
- public readonly string PlayerName;
26
+ public readonly string playerName;
26
27
 
27
- public PlayerSpawned(string playerName)
28
- {
29
- PlayerName = playerName;
30
- }
28
+ public string PlayerName => playerName;
31
29
  }
32
30
 
33
31
  private sealed class PlayerSpawnTracker : IInitializable, IDisposable
@@ -0,0 +1,9 @@
1
+ <Project>
2
+ <PropertyGroup Condition="'$(MSBuildProjectName)' == 'WallstopStudios.DxMessaging.SourceGenerators.Tests'">
3
+ <SolutionDir Condition="'$(SolutionDir)' == ''">$(MSBuildThisFileDirectory)..\</SolutionDir>
4
+ <ArtifactsRoot>$(SolutionDir).artifacts/SourceGenerators.Tests/</ArtifactsRoot>
5
+ <IntermediateOutputPath>$(ArtifactsRoot)obj/$(Configuration)/</IntermediateOutputPath>
6
+ <OutputPath>$(ArtifactsRoot)bin/$(Configuration)/</OutputPath>
7
+ <VSTestResultsDirectory>$(ArtifactsRoot)TestResults/</VSTestResultsDirectory>
8
+ </PropertyGroup>
9
+ </Project>
@@ -1,6 +1,6 @@
1
1
  fileFormatVersion: 2
2
- guid: 6c3d7e44fbd165847a830ad23b17aeb7
3
- TextScriptImporter:
2
+ guid: 5b80e1cf4c3c72a43bbd48e4667f00f7
3
+ DefaultImporter:
4
4
  externalObjects: {}
5
5
  userData:
6
6
  assetBundleName: