com.wallstop-studios.dxmessaging 2.2.0 → 3.1.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.
- package/CHANGELOG.md +315 -67
- package/CHANGELOG.md.meta +7 -7
- package/Editor/Analyzers/BaseCallIlInspector.cs +277 -0
- package/Editor/Analyzers/BaseCallIlInspector.cs.meta +11 -0
- package/Editor/Analyzers/BaseCallLogMessageParser.cs +295 -0
- package/Editor/Analyzers/BaseCallLogMessageParser.cs.meta +11 -0
- package/Editor/Analyzers/BaseCallReportAggregator.cs +308 -0
- package/Editor/Analyzers/BaseCallReportAggregator.cs.meta +11 -0
- package/Editor/Analyzers/BaseCallTypeScanner.cs +110 -0
- package/Editor/Analyzers/BaseCallTypeScanner.cs.meta +11 -0
- package/Editor/Analyzers/BaseCallTypeScannerCore.cs +562 -0
- package/Editor/Analyzers/BaseCallTypeScannerCore.cs.meta +11 -0
- package/Editor/Analyzers/DxMessagingConsoleHarvester.cs +1129 -0
- package/Editor/Analyzers/DxMessagingConsoleHarvester.cs.meta +11 -0
- package/Editor/Analyzers/Microsoft.CodeAnalysis.CSharp.dll.meta +44 -44
- package/Editor/Analyzers/Microsoft.CodeAnalysis.dll.meta +44 -44
- package/Editor/Analyzers/System.Collections.Immutable.dll.meta +44 -44
- package/Editor/Analyzers/System.Reflection.Metadata.dll.meta +44 -44
- package/Editor/Analyzers/System.Runtime.CompilerServices.Unsafe.dll.meta +44 -44
- package/Editor/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll +0 -0
- package/Editor/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll.meta +46 -0
- package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
- package/Editor/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll.meta +72 -72
- package/Editor/Analyzers.meta +8 -8
- package/Editor/AssemblyInfo.cs.meta +11 -3
- package/Editor/CustomEditors/MessageAwareComponentFallbackEditor.cs +81 -0
- package/Editor/CustomEditors/MessageAwareComponentFallbackEditor.cs.meta +11 -0
- package/Editor/CustomEditors/MessageAwareComponentInspectorOverlay.cs +429 -0
- package/Editor/CustomEditors/MessageAwareComponentInspectorOverlay.cs.meta +11 -0
- package/Editor/CustomEditors/MessagingComponentEditor.cs +1 -1
- package/Editor/CustomEditors/MessagingComponentEditor.cs.meta +11 -3
- package/Editor/CustomEditors.meta +2 -2
- package/Editor/DxMessagingEditorIdle.cs +62 -0
- package/Editor/DxMessagingEditorIdle.cs.meta +11 -0
- package/Editor/DxMessagingEditorInitializer.cs +112 -15
- package/Editor/DxMessagingEditorInitializer.cs.meta +11 -3
- package/Editor/DxMessagingEditorLog.cs +32 -0
- package/Editor/DxMessagingEditorLog.cs.meta +11 -0
- package/Editor/DxMessagingMenu.cs.meta +11 -11
- package/Editor/DxMessagingSceneBuildProcessor.cs.meta +11 -11
- package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs +313 -0
- package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs.meta +11 -0
- package/Editor/Settings/DxMessagingSettings.cs +261 -11
- package/Editor/Settings/DxMessagingSettings.cs.meta +11 -3
- package/Editor/Settings/DxMessagingSettingsProvider.cs +50 -33
- package/Editor/Settings/DxMessagingSettingsProvider.cs.meta +11 -3
- package/Editor/Settings.meta +2 -2
- package/Editor/SetupCscRsp.cs +406 -39
- package/Editor/SetupCscRsp.cs.meta +11 -3
- package/Editor/Testing/MessagingComponentEditorHarness.cs +2 -2
- package/Editor/Testing/MessagingComponentEditorHarness.cs.meta +11 -3
- package/Editor/Testing.meta +3 -3
- package/Editor/WallstopStudios.DxMessaging.Editor.asmdef +14 -14
- package/Editor/WallstopStudios.DxMessaging.Editor.asmdef.meta +7 -7
- package/Editor.meta +8 -8
- package/LICENSE.md +9 -9
- package/LICENSE.md.meta +7 -7
- package/README.md +940 -900
- package/README.md.meta +7 -7
- package/Runtime/AssemblyInfo.cs +4 -0
- package/Runtime/AssemblyInfo.cs.meta +11 -3
- package/Runtime/Core/Attributes/DxAutoConstructorAttribute.cs.meta +11 -3
- package/Runtime/Core/Attributes/DxBroadcastMessageAttribute.cs.meta +11 -3
- package/Runtime/Core/Attributes/DxIgnoreMissingBaseCallAttribute.cs +26 -0
- package/Runtime/Core/Attributes/DxIgnoreMissingBaseCallAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/DxOptionalParameterAttribute.cs +2 -4
- package/Runtime/Core/Attributes/DxOptionalParameterAttribute.cs.meta +11 -3
- package/Runtime/Core/Attributes/DxTargetedMessageAttribute.cs.meta +11 -3
- package/Runtime/Core/Attributes/DxUntargetedMessageAttribute.cs.meta +11 -3
- package/Runtime/Core/Attributes/Il2CppSetOptionAttribute.cs +56 -0
- package/Runtime/Core/Attributes/Il2CppSetOptionAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes.meta +2 -2
- package/Runtime/Core/Configuration/DxMessagingRuntimeSettings.cs +195 -0
- package/Runtime/Core/Configuration/DxMessagingRuntimeSettings.cs.meta +11 -0
- package/Runtime/Core/Configuration/DxMessagingRuntimeSettingsProvider.cs +179 -0
- package/Runtime/Core/Configuration/DxMessagingRuntimeSettingsProvider.cs.meta +11 -0
- package/Runtime/Core/Configuration.meta +9 -0
- package/Runtime/Core/DataStructure/CyclicBuffer.cs +46 -28
- package/Runtime/Core/DataStructure/CyclicBuffer.cs.meta +11 -3
- package/Runtime/Core/DataStructure.meta +2 -2
- package/Runtime/Core/Diagnostics/MessageEmissionData.cs.meta +11 -3
- package/Runtime/Core/Diagnostics/MessageRegistrationData.cs.meta +11 -3
- package/Runtime/Core/Diagnostics/MessageRegistrationType.cs.meta +11 -3
- package/Runtime/Core/Diagnostics.meta +2 -2
- package/Runtime/Core/DxMessagingStaticState.cs +19 -0
- package/Runtime/Core/DxMessagingStaticState.cs.meta +11 -11
- package/Runtime/Core/Extensions/EnumExtensions.cs +6 -5
- package/Runtime/Core/Extensions/EnumExtensions.cs.meta +11 -3
- package/Runtime/Core/Extensions/IListExtensions.cs.meta +11 -3
- package/Runtime/Core/Extensions/MessageBusExtensions.cs.meta +12 -12
- package/Runtime/Core/Extensions/MessageExtensions.cs +0 -60
- package/Runtime/Core/Extensions/MessageExtensions.cs.meta +11 -11
- package/Runtime/Core/Extensions.meta +8 -8
- package/Runtime/Core/Helper/MessageCache.cs +32 -0
- package/Runtime/Core/Helper/MessageCache.cs.meta +11 -3
- package/Runtime/Core/Helper/MessageHelperIndexer.cs.meta +11 -3
- package/Runtime/Core/Helper.meta +2 -2
- package/Runtime/Core/IMessage.cs +3 -3
- package/Runtime/Core/IMessage.cs.meta +11 -11
- package/Runtime/Core/InstanceId.cs +25 -1
- package/Runtime/Core/InstanceId.cs.meta +11 -11
- package/Runtime/Core/Internal/DxUnsafe.cs +60 -0
- package/Runtime/Core/Internal/DxUnsafe.cs.meta +11 -0
- package/Runtime/Core/Internal/FlatDispatch.cs +198 -0
- package/Runtime/Core/Internal/FlatDispatch.cs.meta +11 -0
- package/Runtime/Core/Internal/TypedGlobalSlotIndex.cs +38 -0
- package/Runtime/Core/Internal/TypedGlobalSlotIndex.cs.meta +11 -0
- package/Runtime/Core/Internal/TypedSlotIndex.cs +81 -0
- package/Runtime/Core/Internal/TypedSlotIndex.cs.meta +11 -0
- package/Runtime/Core/Internal/TypedSlots.cs +597 -0
- package/Runtime/Core/Internal/TypedSlots.cs.meta +11 -0
- package/Runtime/Core/Internal.meta +9 -0
- package/Runtime/Core/MessageBus/DiagnosticsTarget.cs.meta +11 -11
- package/Runtime/Core/MessageBus/GlobalMessageBusProvider.cs.meta +11 -11
- package/Runtime/Core/MessageBus/IMessageBus.cs +189 -15
- package/Runtime/Core/MessageBus/IMessageBus.cs.meta +11 -11
- package/Runtime/Core/MessageBus/IMessageBusProvider.cs.meta +11 -11
- package/Runtime/Core/MessageBus/IMessageRegistrationBuilder.cs +1 -0
- package/Runtime/Core/MessageBus/IMessageRegistrationBuilder.cs.meta +11 -11
- package/Runtime/Core/MessageBus/Internal/BusContextIndex.cs +16 -0
- package/Runtime/Core/MessageBus/Internal/BusContextIndex.cs.meta +11 -0
- package/Runtime/Core/MessageBus/Internal/BusSinkIndex.cs +40 -0
- package/Runtime/Core/MessageBus/Internal/BusSinkIndex.cs.meta +11 -0
- package/Runtime/Core/MessageBus/Internal/BusSlots.cs +719 -0
- package/Runtime/Core/MessageBus/Internal/BusSlots.cs.meta +11 -0
- package/Runtime/Core/MessageBus/Internal/DispatchKind.cs +38 -0
- package/Runtime/Core/MessageBus/Internal/DispatchKind.cs.meta +11 -0
- package/Runtime/Core/MessageBus/Internal/DispatchPhase.cs +20 -0
- package/Runtime/Core/MessageBus/Internal/DispatchPhase.cs.meta +11 -0
- package/Runtime/Core/MessageBus/Internal/DispatchVariant.cs +28 -0
- package/Runtime/Core/MessageBus/Internal/DispatchVariant.cs.meta +11 -0
- package/Runtime/Core/MessageBus/Internal/IEvictableSlot.cs +48 -0
- package/Runtime/Core/MessageBus/Internal/IEvictableSlot.cs.meta +11 -0
- package/Runtime/Core/MessageBus/Internal/ISweepable.cs +15 -0
- package/Runtime/Core/MessageBus/Internal/ISweepable.cs.meta +11 -0
- package/Runtime/Core/MessageBus/Internal/RegistrationMethodAxes.cs +222 -0
- package/Runtime/Core/MessageBus/Internal/RegistrationMethodAxes.cs.meta +11 -0
- package/Runtime/Core/MessageBus/Internal/SlotKey.cs +192 -0
- package/Runtime/Core/MessageBus/Internal/SlotKey.cs.meta +11 -0
- package/Runtime/Core/MessageBus/Internal.meta +9 -0
- package/Runtime/Core/MessageBus/MessageBus.cs +5366 -3838
- package/Runtime/Core/MessageBus/MessageBus.cs.meta +11 -11
- package/Runtime/Core/MessageBus/MessageBusRebindMode.cs.meta +11 -11
- package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs +187 -14
- package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs.meta +11 -11
- package/Runtime/Core/MessageBus/MessagingRegistration.cs.meta +11 -11
- package/Runtime/Core/MessageBus/RegistrationLog.cs.meta +11 -11
- package/Runtime/Core/MessageBus.meta +8 -8
- package/Runtime/Core/MessageHandler.cs +2399 -1042
- package/Runtime/Core/MessageHandler.cs.meta +11 -11
- package/Runtime/Core/MessageRegistrationHandle.cs.meta +11 -11
- package/Runtime/Core/MessageRegistrationToken.cs +429 -44
- package/Runtime/Core/MessageRegistrationToken.cs.meta +11 -11
- package/Runtime/Core/Messages/GlobalStringMessage.cs.meta +11 -3
- package/Runtime/Core/Messages/IBroadcastMessage.cs.meta +11 -11
- package/Runtime/Core/Messages/ITargetedMessage.cs.meta +11 -11
- package/Runtime/Core/Messages/IUntargetedMessage.cs.meta +11 -11
- package/Runtime/Core/Messages/ReflexiveMessage.cs.meta +11 -3
- package/Runtime/Core/Messages/SourcedStringMessage.cs.meta +11 -11
- package/Runtime/Core/Messages/StringMessage.cs.meta +11 -3
- package/Runtime/Core/Messages.meta +8 -8
- package/Runtime/Core/MessagingDebug.cs.meta +11 -11
- package/Runtime/Core/Pooling/CollectionPool.cs +266 -0
- package/Runtime/Core/Pooling/CollectionPool.cs.meta +11 -0
- package/Runtime/Core/Pooling/CollectionPoolDiagnostics.cs +30 -0
- package/Runtime/Core/Pooling/CollectionPoolDiagnostics.cs.meta +11 -0
- package/Runtime/Core/Pooling/DxPools.cs +157 -0
- package/Runtime/Core/Pooling/DxPools.cs.meta +11 -0
- package/Runtime/Core/Pooling/EvictionPlayerLoopHook.cs +106 -0
- package/Runtime/Core/Pooling/EvictionPlayerLoopHook.cs.meta +11 -0
- package/Runtime/Core/Pooling/IDxMessagingClock.cs +18 -0
- package/Runtime/Core/Pooling/IDxMessagingClock.cs.meta +11 -0
- package/Runtime/Core/Pooling/PoolDiagnosticsSnapshot.cs +55 -0
- package/Runtime/Core/Pooling/PoolDiagnosticsSnapshot.cs.meta +11 -0
- package/Runtime/Core/Pooling/StopwatchClock.cs +27 -0
- package/Runtime/Core/Pooling/StopwatchClock.cs.meta +11 -0
- package/Runtime/Core/Pooling/UnityRealtimeClock.cs +31 -0
- package/Runtime/Core/Pooling/UnityRealtimeClock.cs.meta +11 -0
- package/Runtime/Core/Pooling.meta +9 -0
- package/Runtime/Core.meta +8 -8
- package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs.meta +12 -12
- package/Runtime/Unity/DxMessagingRuntimeInitializer.cs.meta +11 -11
- package/Runtime/Unity/InitialGlobalMessageBusProvider.cs.meta +12 -12
- package/Runtime/Unity/Integrations/Reflex/AssemblyInfo.cs.meta +11 -3
- package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs +73 -0
- package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs.meta +11 -11
- package/Runtime/Unity/Integrations/Reflex/WallstopStudios.DxMessaging.Reflex.asmdef +20 -20
- package/Runtime/Unity/Integrations/Reflex/WallstopStudios.DxMessaging.Reflex.asmdef.meta +7 -7
- package/Runtime/Unity/Integrations/Reflex.meta +8 -8
- package/Runtime/Unity/Integrations/VContainer/AssemblyInfo.cs.meta +11 -3
- package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs +109 -1
- package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs.meta +11 -11
- package/Runtime/Unity/Integrations/VContainer/WallstopStudios.DxMessaging.VContainer.asmdef +30 -30
- package/Runtime/Unity/Integrations/VContainer/WallstopStudios.DxMessaging.VContainer.asmdef.meta +7 -7
- package/Runtime/Unity/Integrations/VContainer.meta +8 -8
- package/Runtime/Unity/Integrations/Zenject/AssemblyInfo.cs.meta +11 -3
- package/Runtime/Unity/Integrations/Zenject/WallstopStudios.DxMessaging.Zenject.asmdef +30 -30
- package/Runtime/Unity/Integrations/Zenject/WallstopStudios.DxMessaging.Zenject.asmdef.meta +7 -7
- package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs +79 -1
- package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs.meta +11 -11
- package/Runtime/Unity/Integrations/Zenject.meta +8 -8
- package/Runtime/Unity/Integrations.meta +8 -8
- package/Runtime/Unity/MessageAwareComponent.cs +74 -0
- package/Runtime/Unity/MessageAwareComponent.cs.meta +11 -11
- package/Runtime/Unity/MessageBusProviderHandle.cs.meta +12 -12
- package/Runtime/Unity/MessagingComponent.cs +43 -10
- package/Runtime/Unity/MessagingComponent.cs.meta +11 -11
- package/Runtime/Unity/MessagingComponentInstaller.cs.meta +12 -12
- package/Runtime/Unity/ScriptableMessageBusProvider.cs.meta +12 -12
- package/Runtime/Unity.meta +8 -8
- package/Runtime/WallstopStudios.DxMessaging.asmdef +14 -14
- package/Runtime/WallstopStudios.DxMessaging.asmdef.meta +7 -7
- package/Runtime.meta +8 -8
- package/Samples~/DI/Prefabs/MessagingInstallerSample.prefab +98 -98
- package/Samples~/DI/Prefabs/MessagingInstallerSample.prefab.meta +7 -7
- package/Samples~/DI/Prefabs.meta +8 -8
- package/Samples~/DI/Providers/GlobalMessageBusProvider.asset +14 -14
- package/Samples~/DI/Providers/GlobalMessageBusProvider.asset.meta +8 -8
- package/Samples~/DI/Providers/InitialGlobalMessageBusProvider.asset +14 -14
- package/Samples~/DI/Providers/InitialGlobalMessageBusProvider.asset.meta +8 -8
- package/Samples~/DI/Providers.meta +8 -8
- package/Samples~/DI/README.md +51 -51
- package/Samples~/DI/README.md.meta +7 -7
- package/Samples~/DI/Reflex/SampleInstaller.cs +7 -0
- package/Samples~/DI/Reflex/SampleInstaller.cs.meta +11 -11
- package/Samples~/DI/Reflex.meta +8 -8
- package/Samples~/DI/VContainer/SampleLifetimeScope.cs +6 -1
- package/Samples~/DI/VContainer/SampleLifetimeScope.cs.meta +11 -11
- package/Samples~/DI/VContainer.meta +8 -8
- package/Samples~/DI/Zenject/SampleInstaller.cs +8 -0
- package/Samples~/DI/Zenject/SampleInstaller.cs.meta +11 -11
- package/Samples~/DI/Zenject.meta +8 -8
- package/Samples~/DI.meta +8 -8
- package/Samples~/Mini Combat/Boot.cs.meta +11 -11
- package/Samples~/Mini Combat/Enemy.cs.meta +11 -11
- package/Samples~/Mini Combat/Messages.cs.meta +11 -11
- package/Samples~/Mini Combat/Player.cs.meta +11 -11
- package/Samples~/Mini Combat/README.md +324 -323
- package/Samples~/Mini Combat/README.md.meta +7 -7
- package/Samples~/Mini Combat/UIOverlay.cs.meta +11 -11
- package/Samples~/Mini Combat/Walkthrough.md +430 -430
- package/Samples~/Mini Combat/Walkthrough.md.meta +7 -7
- package/Samples~/Mini Combat/WallstopStudios.DxMessaging.MiniCombat.Sample.asmdef +13 -13
- package/Samples~/Mini Combat/WallstopStudios.DxMessaging.MiniCombat.Sample.asmdef.meta +7 -7
- package/Samples~/Mini Combat.meta +8 -8
- package/Samples~/UI Buttons + Inspector/DiagnosticsEnabler.cs.meta +11 -11
- package/Samples~/UI Buttons + Inspector/Messages.cs.meta +11 -11
- package/Samples~/UI Buttons + Inspector/MessagingObserver.cs.meta +11 -11
- package/Samples~/UI Buttons + Inspector/README.md +210 -209
- package/Samples~/UI Buttons + Inspector/README.md.meta +7 -7
- package/Samples~/UI Buttons + Inspector/UIButtonEmitter.cs.meta +11 -11
- package/Samples~/UI Buttons + Inspector/WallstopStudios.DxMessaging.UIButtons.Sample.asmdef +13 -13
- package/Samples~/UI Buttons + Inspector/WallstopStudios.DxMessaging.UIButtons.Sample.asmdef.meta +7 -7
- package/Samples~/UI Buttons + Inspector.meta +8 -8
- package/SourceGenerators/Directory.Build.props +50 -3
- package/SourceGenerators/Directory.Build.props.meta +7 -7
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs +96 -63
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs.meta +11 -11
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs +745 -87
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxMessageIdGenerator.cs.meta +11 -3
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.csproj +39 -46
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.csproj.meta +7 -7
- package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.meta +8 -8
- package/SourceGenerators/global.json +7 -0
- package/SourceGenerators/global.json.meta +7 -0
- package/SourceGenerators.meta +8 -8
- package/Third Party Notices.md +3 -3
- package/Third Party Notices.md.meta +7 -7
- package/package.json +102 -92
- package/package.json.meta +7 -7
|
@@ -2,22 +2,127 @@
|
|
|
2
2
|
namespace DxMessaging.Unity.Integrations.VContainer
|
|
3
3
|
{
|
|
4
4
|
#if VCONTAINER_PRESENT
|
|
5
|
+
using System;
|
|
5
6
|
using global::VContainer;
|
|
6
7
|
using Core.MessageBus;
|
|
8
|
+
using Core.Pooling;
|
|
7
9
|
|
|
8
10
|
/// <summary>
|
|
9
|
-
/// Provides convenience extension methods for wiring
|
|
11
|
+
/// Provides convenience extension methods for wiring DxMessaging services inside
|
|
12
|
+
/// VContainer scopes. The helper covers the bus registration as well as the
|
|
13
|
+
/// <see cref="IMessageRegistrationBuilder"/> binding so consumers do not have to
|
|
14
|
+
/// drive VContainer reflection-based constructor selection on internal types.
|
|
10
15
|
/// </summary>
|
|
11
16
|
public static class VContainerRegistrationExtensions
|
|
12
17
|
{
|
|
18
|
+
/// <summary>
|
|
19
|
+
/// Registers a <see cref="MessageBus"/> exposed as itself and
|
|
20
|
+
/// <see cref="IMessageBus"/> using an explicit factory backed by the
|
|
21
|
+
/// parameterless <see cref="MessageBus"/> constructor. VContainer's
|
|
22
|
+
/// <c>TypeAnalyzer</c> scans both public and non-public constructors using
|
|
23
|
+
/// <c>BindingFlags.Public | BindingFlags.NonPublic</c>, so the bare
|
|
24
|
+
/// <c>Register<MessageBus>(Lifetime.Singleton).As<IMessageBus>()</c>
|
|
25
|
+
/// pattern would still latch onto a clock-taking private overload whose
|
|
26
|
+
/// <see cref="IDxMessagingClock"/> dependency is not registered. Always prefer this
|
|
27
|
+
/// helper. Calling this helper alongside a bare bus registration raises a
|
|
28
|
+
/// <c>VContainerException</c> at <see cref="IContainerBuilder.Build"/> time.
|
|
29
|
+
/// </summary>
|
|
30
|
+
/// <param name="builder">Container builder receiving the registration.</param>
|
|
31
|
+
/// <param name="lifetime">Lifetime to assign to the registration. Defaults to <see cref="Lifetime.Singleton"/>.</param>
|
|
32
|
+
/// <returns>The underlying registration builder for further chaining.</returns>
|
|
33
|
+
public static RegistrationBuilder RegisterDxMessagingBus(
|
|
34
|
+
this IContainerBuilder builder,
|
|
35
|
+
Lifetime lifetime = Lifetime.Singleton
|
|
36
|
+
)
|
|
37
|
+
{
|
|
38
|
+
if (builder == null)
|
|
39
|
+
{
|
|
40
|
+
throw new ArgumentNullException(nameof(builder));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return builder
|
|
44
|
+
.Register<MessageBus>(CreateMessageBus, lifetime)
|
|
45
|
+
.As(typeof(MessageBus), typeof(IMessageBus));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// <summary>
|
|
49
|
+
/// Registers a <see cref="MessageBus"/> exposed as itself and
|
|
50
|
+
/// <see cref="IMessageBus"/> using the supplied factory. Use this overload when
|
|
51
|
+
/// callers need to inject a custom <see cref="IDxMessagingClock"/> (for example a
|
|
52
|
+
/// deterministic test clock) or configure eviction options through
|
|
53
|
+
/// <see cref="MessageBus.CreateForInternalUse"/>.
|
|
54
|
+
/// </summary>
|
|
55
|
+
/// <param name="builder">Container builder receiving the registration.</param>
|
|
56
|
+
/// <param name="factory">Delegate that constructs the <see cref="MessageBus"/> instance using the resolver.</param>
|
|
57
|
+
/// <param name="lifetime">Lifetime to assign to the registration. Defaults to <see cref="Lifetime.Singleton"/>.</param>
|
|
58
|
+
/// <returns>The underlying registration builder for further chaining.</returns>
|
|
59
|
+
public static RegistrationBuilder RegisterDxMessagingBus(
|
|
60
|
+
this IContainerBuilder builder,
|
|
61
|
+
Func<IObjectResolver, MessageBus> factory,
|
|
62
|
+
Lifetime lifetime = Lifetime.Singleton
|
|
63
|
+
)
|
|
64
|
+
{
|
|
65
|
+
if (builder == null)
|
|
66
|
+
{
|
|
67
|
+
throw new ArgumentNullException(nameof(builder));
|
|
68
|
+
}
|
|
69
|
+
if (factory == null)
|
|
70
|
+
{
|
|
71
|
+
throw new ArgumentNullException(nameof(factory));
|
|
72
|
+
}
|
|
73
|
+
return builder
|
|
74
|
+
.Register<MessageBus>(factory, lifetime)
|
|
75
|
+
.As(typeof(MessageBus), typeof(IMessageBus));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/// <summary>
|
|
79
|
+
/// Registers a <see cref="MessageBus"/> exposed as itself and
|
|
80
|
+
/// <see cref="IMessageBus"/> using the supplied <see cref="IDxMessagingClock"/>.
|
|
81
|
+
/// Builds the bus through <see cref="MessageBus.CreateForInternalUse"/>, which
|
|
82
|
+
/// is visible to the integration assembly via <c>InternalsVisibleTo</c>.
|
|
83
|
+
/// </summary>
|
|
84
|
+
/// <param name="builder">Container builder receiving the registration.</param>
|
|
85
|
+
/// <param name="clock">Clock implementation injected into the bus. Must not be null.</param>
|
|
86
|
+
/// <param name="lifetime">Lifetime to assign to the registration. Defaults to <see cref="Lifetime.Singleton"/>.</param>
|
|
87
|
+
/// <returns>The underlying registration builder for further chaining.</returns>
|
|
88
|
+
public static RegistrationBuilder RegisterDxMessagingBus(
|
|
89
|
+
this IContainerBuilder builder,
|
|
90
|
+
IDxMessagingClock clock,
|
|
91
|
+
Lifetime lifetime = Lifetime.Singleton
|
|
92
|
+
)
|
|
93
|
+
{
|
|
94
|
+
if (builder == null)
|
|
95
|
+
{
|
|
96
|
+
throw new ArgumentNullException(nameof(builder));
|
|
97
|
+
}
|
|
98
|
+
if (clock == null)
|
|
99
|
+
{
|
|
100
|
+
throw new ArgumentNullException(nameof(clock));
|
|
101
|
+
}
|
|
102
|
+
return builder
|
|
103
|
+
.Register<MessageBus>(_ => MessageBus.CreateForInternalUse(clock), lifetime)
|
|
104
|
+
.As(typeof(MessageBus), typeof(IMessageBus));
|
|
105
|
+
}
|
|
106
|
+
|
|
13
107
|
/// <summary>
|
|
14
108
|
/// Registers <see cref="IMessageRegistrationBuilder"/> as a transient service backed by the scoped message bus.
|
|
15
109
|
/// </summary>
|
|
110
|
+
/// <param name="builder">Container builder receiving the registration.</param>
|
|
16
111
|
public static void RegisterMessageRegistrationBuilder(this IContainerBuilder builder)
|
|
17
112
|
{
|
|
113
|
+
if (builder == null)
|
|
114
|
+
{
|
|
115
|
+
throw new ArgumentNullException(nameof(builder));
|
|
116
|
+
}
|
|
117
|
+
|
|
18
118
|
builder.Register<IMessageRegistrationBuilder>(CreateBuilder, Lifetime.Transient);
|
|
19
119
|
}
|
|
20
120
|
|
|
121
|
+
private static MessageBus CreateMessageBus(IObjectResolver resolver)
|
|
122
|
+
{
|
|
123
|
+
return new MessageBus();
|
|
124
|
+
}
|
|
125
|
+
|
|
21
126
|
private static IMessageRegistrationBuilder CreateBuilder(IObjectResolver resolver)
|
|
22
127
|
{
|
|
23
128
|
if (resolver.TryResolve(out IMessageBusProvider provider))
|
|
@@ -28,6 +133,9 @@ namespace DxMessaging.Unity.Integrations.VContainer
|
|
|
28
133
|
return new MessageRegistrationBuilder(new ResolverMessageBusProvider(resolver));
|
|
29
134
|
}
|
|
30
135
|
|
|
136
|
+
/// <summary>
|
|
137
|
+
/// Wraps a VContainer <see cref="IObjectResolver"/> as an <see cref="IMessageBusProvider"/>.
|
|
138
|
+
/// </summary>
|
|
31
139
|
public sealed class ResolverMessageBusProvider : IMessageBusProvider
|
|
32
140
|
{
|
|
33
141
|
private readonly IObjectResolver _resolver;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 494e388075f84aeda9266a0e57f8a05d
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 494e388075f84aeda9266a0e57f8a05d
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "WallstopStudios.DxMessaging.VContainer",
|
|
3
|
-
"rootNamespace": "DxMessaging.Unity.Integrations.VContainer",
|
|
4
|
-
"references": ["WallstopStudios.DxMessaging", "VContainer", "VContainer.Unity"],
|
|
5
|
-
"includePlatforms": [],
|
|
6
|
-
"excludePlatforms": [],
|
|
7
|
-
"allowUnsafeCode": false,
|
|
8
|
-
"overrideReferences": false,
|
|
9
|
-
"precompiledReferences": [],
|
|
10
|
-
"autoReferenced": true,
|
|
11
|
-
"defineConstraints": ["VCONTAINER_PRESENT"],
|
|
12
|
-
"versionDefines": [
|
|
13
|
-
{
|
|
14
|
-
"name": "jp.cysharp.vcontainer",
|
|
15
|
-
"expression": "0.0.1",
|
|
16
|
-
"define": "VCONTAINER_PRESENT"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"name": "jp.hadashikick.vcontainer",
|
|
20
|
-
"expression": "0.0.1",
|
|
21
|
-
"define": "VCONTAINER_PRESENT"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"name": "VContainer",
|
|
25
|
-
"expression": "0.0.1",
|
|
26
|
-
"define": "VCONTAINER_PRESENT"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"noEngineReferences": false
|
|
30
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "WallstopStudios.DxMessaging.VContainer",
|
|
3
|
+
"rootNamespace": "DxMessaging.Unity.Integrations.VContainer",
|
|
4
|
+
"references": ["WallstopStudios.DxMessaging", "VContainer", "VContainer.Unity"],
|
|
5
|
+
"includePlatforms": [],
|
|
6
|
+
"excludePlatforms": [],
|
|
7
|
+
"allowUnsafeCode": false,
|
|
8
|
+
"overrideReferences": false,
|
|
9
|
+
"precompiledReferences": [],
|
|
10
|
+
"autoReferenced": true,
|
|
11
|
+
"defineConstraints": ["VCONTAINER_PRESENT"],
|
|
12
|
+
"versionDefines": [
|
|
13
|
+
{
|
|
14
|
+
"name": "jp.cysharp.vcontainer",
|
|
15
|
+
"expression": "0.0.1",
|
|
16
|
+
"define": "VCONTAINER_PRESENT"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "jp.hadashikick.vcontainer",
|
|
20
|
+
"expression": "0.0.1",
|
|
21
|
+
"define": "VCONTAINER_PRESENT"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "VContainer",
|
|
25
|
+
"expression": "0.0.1",
|
|
26
|
+
"define": "VCONTAINER_PRESENT"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"noEngineReferences": false
|
|
30
|
+
}
|
package/Runtime/Unity/Integrations/VContainer/WallstopStudios.DxMessaging.VContainer.asmdef.meta
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 2583d1d4ebd847faba751e3be6bf5b20
|
|
3
|
-
AssemblyDefinitionImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
userData:
|
|
6
|
-
assetBundleName:
|
|
7
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 2583d1d4ebd847faba751e3be6bf5b20
|
|
3
|
+
AssemblyDefinitionImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
userData:
|
|
6
|
+
assetBundleName:
|
|
7
|
+
assetBundleVariant:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 4d890fb7cb4f49e18fd9fbac12d5040c
|
|
3
|
-
folderAsset: yes
|
|
4
|
-
DefaultImporter:
|
|
5
|
-
externalObjects: {}
|
|
6
|
-
userData:
|
|
7
|
-
assetBundleName:
|
|
8
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 4d890fb7cb4f49e18fd9fbac12d5040c
|
|
3
|
+
folderAsset: yes
|
|
4
|
+
DefaultImporter:
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
userData:
|
|
7
|
+
assetBundleName:
|
|
8
|
+
assetBundleVariant:
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: ec21f9c7970043fe88177114708ef79e
|
|
3
|
-
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: ec21f9c7970043fe88177114708ef79e
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "WallstopStudios.DxMessaging.Zenject",
|
|
3
|
-
"rootNamespace": "DxMessaging.Unity.Integrations.Zenject",
|
|
4
|
-
"references": ["WallstopStudios.DxMessaging", "Zenject"],
|
|
5
|
-
"includePlatforms": [],
|
|
6
|
-
"excludePlatforms": [],
|
|
7
|
-
"allowUnsafeCode": false,
|
|
8
|
-
"overrideReferences": false,
|
|
9
|
-
"precompiledReferences": [],
|
|
10
|
-
"autoReferenced": true,
|
|
11
|
-
"defineConstraints": ["ZENJECT_PRESENT"],
|
|
12
|
-
"versionDefines": [
|
|
13
|
-
{
|
|
14
|
-
"name": "com.extenject.zenject",
|
|
15
|
-
"expression": "0.0.1",
|
|
16
|
-
"define": "ZENJECT_PRESENT"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"name": "com.modesttree.zenject",
|
|
20
|
-
"expression": "0.0.1",
|
|
21
|
-
"define": "ZENJECT_PRESENT"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"name": "com.svermeulen.extenject",
|
|
25
|
-
"expression": "0.0.1",
|
|
26
|
-
"define": "ZENJECT_PRESENT"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"noEngineReferences": false
|
|
30
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "WallstopStudios.DxMessaging.Zenject",
|
|
3
|
+
"rootNamespace": "DxMessaging.Unity.Integrations.Zenject",
|
|
4
|
+
"references": ["WallstopStudios.DxMessaging", "Zenject"],
|
|
5
|
+
"includePlatforms": [],
|
|
6
|
+
"excludePlatforms": [],
|
|
7
|
+
"allowUnsafeCode": false,
|
|
8
|
+
"overrideReferences": false,
|
|
9
|
+
"precompiledReferences": [],
|
|
10
|
+
"autoReferenced": true,
|
|
11
|
+
"defineConstraints": ["ZENJECT_PRESENT"],
|
|
12
|
+
"versionDefines": [
|
|
13
|
+
{
|
|
14
|
+
"name": "com.extenject.zenject",
|
|
15
|
+
"expression": "0.0.1",
|
|
16
|
+
"define": "ZENJECT_PRESENT"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "com.modesttree.zenject",
|
|
20
|
+
"expression": "0.0.1",
|
|
21
|
+
"define": "ZENJECT_PRESENT"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "com.svermeulen.extenject",
|
|
25
|
+
"expression": "0.0.1",
|
|
26
|
+
"define": "ZENJECT_PRESENT"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"noEngineReferences": false
|
|
30
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 5c2f6b45062a4c07a599dd8bcbac2bb4
|
|
3
|
-
AssemblyDefinitionImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
userData:
|
|
6
|
-
assetBundleName:
|
|
7
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 5c2f6b45062a4c07a599dd8bcbac2bb4
|
|
3
|
+
AssemblyDefinitionImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
userData:
|
|
6
|
+
assetBundleName:
|
|
7
|
+
assetBundleVariant:
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
namespace DxMessaging.Unity.Integrations.Zenject
|
|
3
3
|
{
|
|
4
4
|
#if ZENJECT_PRESENT
|
|
5
|
-
using
|
|
5
|
+
using System;
|
|
6
6
|
using Core.MessageBus;
|
|
7
|
+
using Core.Pooling;
|
|
8
|
+
using global::Zenject;
|
|
7
9
|
|
|
8
10
|
/// <summary>
|
|
9
11
|
/// Optional installer that exposes <see cref="IMessageRegistrationBuilder"/> using the scoped Zenject container.
|
|
@@ -64,6 +66,82 @@ namespace DxMessaging.Unity.Integrations.Zenject
|
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
}
|
|
69
|
+
|
|
70
|
+
/// <summary>
|
|
71
|
+
/// Provides convenience helpers for wiring a <see cref="MessageBus"/> into Zenject containers.
|
|
72
|
+
/// Zenject's <c>BindInterfacesAndSelfTo</c> defaults to selecting the public parameterless
|
|
73
|
+
/// constructor, so today the bare <c>Container.BindInterfacesAndSelfTo<MessageBus>().AsSingle()</c>
|
|
74
|
+
/// pattern resolves correctly. Behaviour is version-sensitive: future Zenject releases that
|
|
75
|
+
/// broaden constructor scanning could pick a non-public clock-taking overload whose
|
|
76
|
+
/// dependency is not registered, mirroring the VContainer failure mode -- always prefer the
|
|
77
|
+
/// helper below for clarity and forward compatibility. Calling this helper alongside an
|
|
78
|
+
/// existing bare bind raises a Zenject binding-conflict exception when the container is
|
|
79
|
+
/// validated.
|
|
80
|
+
/// </summary>
|
|
81
|
+
public static class ZenjectRegistrationExtensions
|
|
82
|
+
{
|
|
83
|
+
/// <summary>
|
|
84
|
+
/// Binds a singleton <see cref="MessageBus"/> exposed as <see cref="IMessageBus"/> using
|
|
85
|
+
/// an explicit method, sidestepping reflection-based constructor selection.
|
|
86
|
+
/// </summary>
|
|
87
|
+
/// <param name="container">Container receiving the registration.</param>
|
|
88
|
+
public static void BindDxMessagingBus(this DiContainer container)
|
|
89
|
+
{
|
|
90
|
+
if (container == null)
|
|
91
|
+
{
|
|
92
|
+
throw new ArgumentNullException(nameof(container));
|
|
93
|
+
}
|
|
94
|
+
container
|
|
95
|
+
.BindInterfacesAndSelfTo<MessageBus>()
|
|
96
|
+
.FromMethod(_ => new MessageBus())
|
|
97
|
+
.AsSingle();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// <summary>
|
|
101
|
+
/// Binds a singleton <see cref="MessageBus"/> exposed as <see cref="IMessageBus"/> using
|
|
102
|
+
/// the supplied factory. Allows callers to inject a custom <see cref="IDxMessagingClock"/>
|
|
103
|
+
/// via <see cref="MessageBus.CreateForInternalUse"/>.
|
|
104
|
+
/// </summary>
|
|
105
|
+
/// <param name="container">Container receiving the registration.</param>
|
|
106
|
+
/// <param name="factory">Delegate that constructs the <see cref="MessageBus"/> instance using the inject context.</param>
|
|
107
|
+
public static void BindDxMessagingBus(
|
|
108
|
+
this DiContainer container,
|
|
109
|
+
Func<InjectContext, MessageBus> factory
|
|
110
|
+
)
|
|
111
|
+
{
|
|
112
|
+
if (container == null)
|
|
113
|
+
{
|
|
114
|
+
throw new ArgumentNullException(nameof(container));
|
|
115
|
+
}
|
|
116
|
+
if (factory == null)
|
|
117
|
+
{
|
|
118
|
+
throw new ArgumentNullException(nameof(factory));
|
|
119
|
+
}
|
|
120
|
+
container.BindInterfacesAndSelfTo<MessageBus>().FromMethod(factory).AsSingle();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/// <summary>
|
|
124
|
+
/// Binds a singleton <see cref="MessageBus"/> exposed as <see cref="IMessageBus"/> using
|
|
125
|
+
/// the supplied <see cref="IDxMessagingClock"/>.
|
|
126
|
+
/// </summary>
|
|
127
|
+
/// <param name="container">Container receiving the registration.</param>
|
|
128
|
+
/// <param name="clock">Clock implementation injected into the bus. Must not be null.</param>
|
|
129
|
+
public static void BindDxMessagingBus(this DiContainer container, IDxMessagingClock clock)
|
|
130
|
+
{
|
|
131
|
+
if (container == null)
|
|
132
|
+
{
|
|
133
|
+
throw new ArgumentNullException(nameof(container));
|
|
134
|
+
}
|
|
135
|
+
if (clock == null)
|
|
136
|
+
{
|
|
137
|
+
throw new ArgumentNullException(nameof(clock));
|
|
138
|
+
}
|
|
139
|
+
container
|
|
140
|
+
.BindInterfacesAndSelfTo<MessageBus>()
|
|
141
|
+
.FromMethod(_ => MessageBus.CreateForInternalUse(clock))
|
|
142
|
+
.AsSingle();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
67
145
|
#endif
|
|
68
146
|
}
|
|
69
147
|
#endif
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 1f5d2f7d6c9b4bb9bb5d9ce1f2e4763c
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 1f5d2f7d6c9b4bb9bb5d9ce1f2e4763c
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 6f2c8f2b1b0b4f618d4f2711d8f6ac2b
|
|
3
|
-
folderAsset: yes
|
|
4
|
-
DefaultImporter:
|
|
5
|
-
externalObjects: {}
|
|
6
|
-
userData:
|
|
7
|
-
assetBundleName:
|
|
8
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 6f2c8f2b1b0b4f618d4f2711d8f6ac2b
|
|
3
|
+
folderAsset: yes
|
|
4
|
+
DefaultImporter:
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
userData:
|
|
7
|
+
assetBundleName:
|
|
8
|
+
assetBundleVariant:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: d4cc934a94a46b849bd0ce328eba12be
|
|
3
|
-
folderAsset: yes
|
|
4
|
-
DefaultImporter:
|
|
5
|
-
externalObjects: {}
|
|
6
|
-
userData:
|
|
7
|
-
assetBundleName:
|
|
8
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: d4cc934a94a46b849bd0ce328eba12be
|
|
3
|
+
folderAsset: yes
|
|
4
|
+
DefaultImporter:
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
userData:
|
|
7
|
+
assetBundleName:
|
|
8
|
+
assetBundleVariant:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#if UNITY_2021_3_OR_NEWER
|
|
2
2
|
namespace DxMessaging.Unity
|
|
3
3
|
{
|
|
4
|
+
using System;
|
|
4
5
|
using Core;
|
|
5
6
|
using Core.MessageBus;
|
|
6
7
|
using Core.Messages;
|
|
@@ -18,6 +19,8 @@ namespace DxMessaging.Unity
|
|
|
18
19
|
/// - <see cref="Awake"/> creates the token and calls <see cref="RegisterMessageHandlers"/>.
|
|
19
20
|
/// - <see cref="OnEnable"/>/<see cref="OnDisable"/> enable/disable the token when
|
|
20
21
|
/// <see cref="MessageRegistrationTiedToEnableStatus"/> is true.
|
|
22
|
+
/// - <see cref="OnEnable"/> can additionally re-create a released token when
|
|
23
|
+
/// <see cref="ReregisterOnEnableAfterRelease"/> is overridden to true.
|
|
21
24
|
/// - <see cref="OnDestroy"/> disables the token and releases references.
|
|
22
25
|
/// </remarks>
|
|
23
26
|
/// <example>
|
|
@@ -60,6 +63,25 @@ namespace DxMessaging.Unity
|
|
|
60
63
|
/// </summary>
|
|
61
64
|
protected virtual bool MessageRegistrationTiedToEnableStatus => true;
|
|
62
65
|
|
|
66
|
+
/// <summary>
|
|
67
|
+
/// Controls whether enabling this component re-creates its registration token and replays
|
|
68
|
+
/// <see cref="RegisterMessageHandlers"/> after the token was released (for example via
|
|
69
|
+
/// <see cref="MessagingComponent.Release"/>).
|
|
70
|
+
/// </summary>
|
|
71
|
+
/// <remarks>
|
|
72
|
+
/// Default <c>false</c>: once released, the component stays unregistered across
|
|
73
|
+
/// enable/disable cycles until <see cref="MessagingComponent.Create"/> is invoked manually.
|
|
74
|
+
/// Override to return <c>true</c> to opt into automatic recovery on the next enable:
|
|
75
|
+
/// if no live token exists, a fresh one is created and <see cref="RegisterMessageHandlers"/>
|
|
76
|
+
/// replays exactly once; if a manual <see cref="MessagingComponent.Create"/> already minted
|
|
77
|
+
/// a fresh token since the release, that token is adopted as-is (the manual creator owns
|
|
78
|
+
/// staging, so nothing is replayed and nothing double-stages).
|
|
79
|
+
/// When <see cref="MessageRegistrationTiedToEnableStatus"/> is false, the recovery still
|
|
80
|
+
/// re-creates and stages but does NOT enable the new token; call
|
|
81
|
+
/// <see cref="MessageRegistrationToken.Enable"/> yourself, exactly as for the original token.
|
|
82
|
+
/// </remarks>
|
|
83
|
+
protected virtual bool ReregisterOnEnableAfterRelease => false;
|
|
84
|
+
|
|
63
85
|
/// <summary>
|
|
64
86
|
/// If true, registers demo handlers for <see cref="Core.Messages.StringMessage"/> and
|
|
65
87
|
/// <see cref="Core.Messages.GlobalStringMessage"/>. Override and return <c>false</c> to disable.
|
|
@@ -71,6 +93,15 @@ namespace DxMessaging.Unity
|
|
|
71
93
|
protected IMessageBusProvider _configuredMessageBusProvider;
|
|
72
94
|
protected MessageBusProviderHandle _configuredMessageBusProviderHandle;
|
|
73
95
|
|
|
96
|
+
#if UNITY_EDITOR || DEBUG
|
|
97
|
+
// G6: latch the OnEnable self-check log to fire at most once per component instance.
|
|
98
|
+
// [NonSerialized] keeps the latch from being saved into the scene; every fresh
|
|
99
|
+
// instance starts with the latch clear and gets at most one breadcrumb if it really is
|
|
100
|
+
// missing the base.Awake() call.
|
|
101
|
+
[NonSerialized]
|
|
102
|
+
private bool _selfCheckLogged;
|
|
103
|
+
#endif
|
|
104
|
+
|
|
74
105
|
/// <summary>
|
|
75
106
|
/// Creates the <see cref="MessagingComponent"/>, token, and calls <see cref="RegisterMessageHandlers"/>.
|
|
76
107
|
/// </summary>
|
|
@@ -128,13 +159,56 @@ namespace DxMessaging.Unity
|
|
|
128
159
|
|
|
129
160
|
/// <summary>
|
|
130
161
|
/// Enables the token if <see cref="MessageRegistrationTiedToEnableStatus"/> is true.
|
|
162
|
+
/// When <see cref="ReregisterOnEnableAfterRelease"/> is true and the token was released,
|
|
163
|
+
/// a fresh token is created and <see cref="RegisterMessageHandlers"/> replays first.
|
|
131
164
|
/// </summary>
|
|
132
165
|
protected virtual void OnEnable()
|
|
133
166
|
{
|
|
167
|
+
if (
|
|
168
|
+
ReregisterOnEnableAfterRelease
|
|
169
|
+
&& _messageRegistrationToken != null
|
|
170
|
+
&& _messagingComponent != null
|
|
171
|
+
)
|
|
172
|
+
{
|
|
173
|
+
if (_messagingComponent.TryGetToken(this, out MessageRegistrationToken liveToken))
|
|
174
|
+
{
|
|
175
|
+
// A manual MessagingComponent.Create(this) between the release and
|
|
176
|
+
// this enable minted a fresh token the field does not know about;
|
|
177
|
+
// adopt it so Token/Enable() operate on the live registration. The
|
|
178
|
+
// manual creator owns staging in that case, so RegisterMessageHandlers
|
|
179
|
+
// is NOT replayed here (no double-staging).
|
|
180
|
+
_messageRegistrationToken = liveToken;
|
|
181
|
+
}
|
|
182
|
+
else
|
|
183
|
+
{
|
|
184
|
+
_messageRegistrationToken = _messagingComponent.Create(this);
|
|
185
|
+
RegisterMessageHandlers();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
134
189
|
if (MessageRegistrationTiedToEnableStatus)
|
|
135
190
|
{
|
|
136
191
|
_messageRegistrationToken?.Enable();
|
|
137
192
|
}
|
|
193
|
+
#if UNITY_EDITOR || DEBUG
|
|
194
|
+
// G6: belt-and-braces self-check. If we got here without a registration token, the
|
|
195
|
+
// most common cause is a subclass that overrode Awake without calling base.Awake();
|
|
196
|
+
// the analyzer DXMSG006 catches this at compile time but only if the project loads
|
|
197
|
+
// the analyzer DLL (e.g. user has disabled analyzers, opened the project on a Unity
|
|
198
|
+
// version that does not load the DLL, or the analyzer suppressed via attribute /
|
|
199
|
+
// ignore list). We surface a one-time-per-instance LogError so the failure mode is
|
|
200
|
+
// not silent. Gated on UNITY_EDITOR || DEBUG so release builds pay zero cost.
|
|
201
|
+
if (_messageRegistrationToken == null && !_selfCheckLogged)
|
|
202
|
+
{
|
|
203
|
+
_selfCheckLogged = true;
|
|
204
|
+
Debug.LogError(
|
|
205
|
+
$"[DxMessaging] {GetType().Name} appears to be missing a base.Awake() call; "
|
|
206
|
+
+ "no registration token exists, so this component will not receive messages. "
|
|
207
|
+
+ "See https://github.com/Ambiguous-Interactive/DxMessaging/blob/master/docs/reference/analyzers.md#dxmsg006-missing-base-call",
|
|
208
|
+
this
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
#endif
|
|
138
212
|
}
|
|
139
213
|
|
|
140
214
|
/// <summary>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: f0743aa54f7a37f4c985cf9b55f68279
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: f0743aa54f7a37f4c985cf9b55f68279
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|