com.wallstop-studios.dxmessaging 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +286 -0
  2. package/Editor/Analyzers/BaseCallLogMessageParser.cs.meta +3 -3
  3. package/Editor/Analyzers/BaseCallReportAggregator.cs.meta +3 -3
  4. package/Editor/Analyzers/DxMessagingConsoleHarvester.cs.meta +3 -3
  5. package/Editor/CustomEditors/MessageAwareComponentFallbackEditor.cs.meta +3 -3
  6. package/Editor/CustomEditors/MessageAwareComponentInspectorOverlay.cs.meta +3 -3
  7. package/Editor/DxMessagingMenu.cs.meta +3 -3
  8. package/Editor/DxMessagingSceneBuildProcessor.cs.meta +3 -3
  9. package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs +2 -3
  10. package/Editor/Settings/DxMessagingBaseCallIgnoreSync.cs.meta +3 -3
  11. package/Editor/SetupCscRsp.cs +232 -163
  12. package/README.md +1 -1
  13. package/Runtime/Analyzers.meta +8 -0
  14. package/Runtime/Core/Attributes/DxIgnoreMissingBaseCallAttribute.cs.meta +3 -3
  15. package/Runtime/Core/DxMessagingStaticState.cs.meta +3 -3
  16. package/Runtime/Core/Extensions/MessageBusExtensions.cs.meta +3 -3
  17. package/Runtime/Core/Extensions/MessageExtensions.cs.meta +3 -3
  18. package/Runtime/Core/IMessage.cs.meta +3 -3
  19. package/Runtime/Core/InstanceId.cs.meta +3 -3
  20. package/Runtime/Core/Internal/TypedSlots.cs +42 -0
  21. package/Runtime/Core/MessageBus/DiagnosticsTarget.cs.meta +3 -3
  22. package/Runtime/Core/MessageBus/GlobalMessageBusProvider.cs.meta +3 -3
  23. package/Runtime/Core/MessageBus/IMessageBus.cs +63 -28
  24. package/Runtime/Core/MessageBus/IMessageBus.cs.meta +3 -3
  25. package/Runtime/Core/MessageBus/IMessageBusProvider.cs.meta +3 -3
  26. package/Runtime/Core/MessageBus/IMessageRegistrationBuilder.cs.meta +3 -3
  27. package/Runtime/Core/MessageBus/MessageBus.cs +548 -474
  28. package/Runtime/Core/MessageBus/MessageBus.cs.meta +3 -3
  29. package/Runtime/Core/MessageBus/MessageBusRebindMode.cs.meta +3 -3
  30. package/Runtime/Core/MessageBus/MessageBusRegistration.cs +207 -0
  31. package/Runtime/Core/MessageBus/MessageBusRegistration.cs.meta +11 -0
  32. package/Runtime/Core/MessageBus/MessageRegistrationBuilder.cs.meta +3 -3
  33. package/Runtime/Core/MessageBus/MessagingRegistration.cs.meta +3 -3
  34. package/Runtime/Core/MessageBus/RegistrationLog.cs.meta +3 -3
  35. package/Runtime/Core/MessageHandler.cs +1210 -394
  36. package/Runtime/Core/MessageHandler.cs.meta +3 -3
  37. package/Runtime/Core/MessageRegistrationHandle.cs.meta +3 -3
  38. package/Runtime/Core/MessageRegistrationToken.cs +1296 -819
  39. package/Runtime/Core/MessageRegistrationToken.cs.meta +3 -3
  40. package/Runtime/Core/Messages/IBroadcastMessage.cs.meta +3 -3
  41. package/Runtime/Core/Messages/ITargetedMessage.cs.meta +3 -3
  42. package/Runtime/Core/Messages/IUntargetedMessage.cs.meta +3 -3
  43. package/Runtime/Core/Messages/SourcedStringMessage.cs.meta +3 -3
  44. package/Runtime/Core/MessagingDebug.cs.meta +3 -3
  45. package/Runtime/Unity/CurrentGlobalMessageBusProvider.cs.meta +3 -3
  46. package/Runtime/Unity/DxMessagingRuntimeInitializer.cs.meta +3 -3
  47. package/Runtime/Unity/InitialGlobalMessageBusProvider.cs.meta +3 -3
  48. package/Runtime/Unity/Integrations/Reflex/ReflexRegistrationInstaller.cs.meta +3 -3
  49. package/Runtime/Unity/Integrations/VContainer/VContainerRegistrationExtensions.cs.meta +3 -3
  50. package/Runtime/Unity/Integrations/Zenject/ZenjectRegistrationInstaller.cs.meta +3 -3
  51. package/Runtime/Unity/MessageAwareComponent.cs.meta +3 -3
  52. package/Runtime/Unity/MessageBusProviderHandle.cs.meta +3 -3
  53. package/Runtime/Unity/MessagingComponent.cs.meta +3 -3
  54. package/Runtime/Unity/MessagingComponentInstaller.cs.meta +3 -3
  55. package/Runtime/Unity/ScriptableMessageBusProvider.cs.meta +3 -3
  56. package/Samples~/DI/Reflex/SampleInstaller.cs.meta +3 -3
  57. package/Samples~/DI/VContainer/SampleLifetimeScope.cs.meta +3 -3
  58. package/Samples~/DI/Zenject/SampleInstaller.cs.meta +3 -3
  59. package/Samples~/Mini Combat/Boot.cs.meta +3 -3
  60. package/Samples~/Mini Combat/Enemy.cs.meta +3 -3
  61. package/Samples~/Mini Combat/Messages.cs.meta +3 -3
  62. package/Samples~/Mini Combat/Player.cs.meta +3 -3
  63. package/Samples~/Mini Combat/UIOverlay.cs.meta +3 -3
  64. package/Samples~/UI Buttons + Inspector/DiagnosticsEnabler.cs.meta +3 -3
  65. package/Samples~/UI Buttons + Inspector/Messages.cs.meta +3 -3
  66. package/Samples~/UI Buttons + Inspector/MessagingObserver.cs.meta +3 -3
  67. package/Samples~/UI Buttons + Inspector/UIButtonEmitter.cs.meta +3 -3
  68. package/SourceGenerators/Directory.Build.props +5 -5
  69. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/DxAutoConstructorGenerator.cs.meta +3 -3
  70. package/SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.csproj +12 -11
  71. package/package.json +6 -3
  72. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  73. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.CSharp.dll.meta +0 -0
  74. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.dll +0 -0
  75. /package/{Editor → Runtime}/Analyzers/Microsoft.CodeAnalysis.dll.meta +0 -0
  76. /package/{Editor → Runtime}/Analyzers/System.Collections.Immutable.dll +0 -0
  77. /package/{Editor → Runtime}/Analyzers/System.Collections.Immutable.dll.meta +0 -0
  78. /package/{Editor → Runtime}/Analyzers/System.Reflection.Metadata.dll +0 -0
  79. /package/{Editor → Runtime}/Analyzers/System.Reflection.Metadata.dll.meta +0 -0
  80. /package/{Editor → Runtime}/Analyzers/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  81. /package/{Editor → Runtime}/Analyzers/System.Runtime.CompilerServices.Unsafe.dll.meta +0 -0
  82. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll +0 -0
  83. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.Analyzer.dll.meta +0 -0
  84. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll +0 -0
  85. /package/{Editor → Runtime}/Analyzers/WallstopStudios.DxMessaging.SourceGenerators.dll.meta +0 -0
@@ -297,8 +297,11 @@ namespace DxMessaging.Core.MessageBus
297
297
  /// <typeparam name="T">Specific type of UntargetedMessages to register for.</typeparam>
298
298
  /// <param name="messageHandler">MessageHandler to register to accept UntargetedMessages of the specified type.</param>
299
299
  /// <param name="priority">Priority at which to run; lower runs earlier.</param>
300
- /// <returns>The deregistration action. Invoke when the handler no longer wants to receive messages.</returns>
301
- Action RegisterUntargeted<T>(MessageHandler messageHandler, int priority = 0)
300
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop receiving messages.</returns>
301
+ MessageBusRegistration RegisterUntargeted<T>(
302
+ MessageHandler messageHandler,
303
+ int priority = 0
304
+ )
302
305
  where T : IUntargetedMessage;
303
306
 
304
307
  /// <summary>
@@ -308,7 +311,7 @@ namespace DxMessaging.Core.MessageBus
308
311
  /// <param name="target">Target of messages to listen for.</param>
309
312
  /// <param name="messageHandler">MessageHandler to register the TargetedMessages of the specified type.</param>
310
313
  /// <param name="priority">Priority at which to run; lower runs earlier.</param>
311
- /// <returns>The deregistration action. Invoke when the handler no longer wants to receive the messages.</returns>
314
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop receiving the messages.</returns>
312
315
  /// <remarks>
313
316
  /// To preserve frozen dispatch snapshots during in-flight emissions, the per-MessageHandler
314
317
  /// typed-cache for <c>(target, priority)</c> is NOT removed when the last registration at
@@ -319,7 +322,7 @@ namespace DxMessaging.Core.MessageBus
319
322
  /// at every spawned GameObject) should prefer <see cref="RegisterTargetedWithoutTargeting{T}"/>
320
323
  /// or recycle MessageHandlers to avoid unbounded inner-dictionary growth.
321
324
  /// </remarks>
322
- Action RegisterTargeted<T>(
325
+ MessageBusRegistration RegisterTargeted<T>(
323
326
  InstanceId target,
324
327
  MessageHandler messageHandler,
325
328
  int priority = 0
@@ -333,8 +336,11 @@ namespace DxMessaging.Core.MessageBus
333
336
  /// <typeparam name="T">Specific type of TargetedMessages to register for.</typeparam>
334
337
  /// <param name="messageHandler">MessageHandler to register to accept all TargetedMessages of the specified type.</param>
335
338
  /// <param name="priority">Priority at which to run; lower runs earlier.</param>
336
- /// <returns>The deregistration action. Invoke when the handler no longer wants to receive messages.</returns>
337
- Action RegisterTargetedWithoutTargeting<T>(MessageHandler messageHandler, int priority = 0)
339
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop receiving messages.</returns>
340
+ MessageBusRegistration RegisterTargetedWithoutTargeting<T>(
341
+ MessageHandler messageHandler,
342
+ int priority = 0
343
+ )
338
344
  where T : ITargetedMessage;
339
345
 
340
346
  /// <summary>
@@ -344,7 +350,7 @@ namespace DxMessaging.Core.MessageBus
344
350
  /// <param name="source">InstanceId of the source for BroadcastMessages to listen to.</param>
345
351
  /// <param name="messageHandler">MessageHandler to register to accept BroadcastMessages.</param>
346
352
  /// <param name="priority"></param>
347
- /// <returns>The deregistration action. Should be invoked when the handler no longer wants to receive messages.</returns>
353
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop receiving messages.</returns>
348
354
  /// <remarks>
349
355
  /// To preserve frozen dispatch snapshots during in-flight emissions, the per-MessageHandler
350
356
  /// typed-cache for <c>(source, priority)</c> is NOT removed when the last registration at
@@ -355,7 +361,7 @@ namespace DxMessaging.Core.MessageBus
355
361
  /// every spawned GameObject) should prefer <see cref="RegisterSourcedBroadcastWithoutSource{T}"/>
356
362
  /// or recycle MessageHandlers to avoid unbounded inner-dictionary growth.
357
363
  /// </remarks>
358
- Action RegisterSourcedBroadcast<T>(
364
+ MessageBusRegistration RegisterSourcedBroadcast<T>(
359
365
  InstanceId source,
360
366
  MessageHandler messageHandler,
361
367
  int priority = 0
@@ -369,8 +375,8 @@ namespace DxMessaging.Core.MessageBus
369
375
  /// <typeparam name="T">Type of the BroadcastMessage to register.</typeparam>
370
376
  /// <param name="messageHandler">MessageHandler to register to accept BroadcastMessages.</param>
371
377
  /// <param name="priority"></param>
372
- /// <returns>The deregistration action. Should be invoked when the handler no longer wants to receive messages.</returns>
373
- Action RegisterSourcedBroadcastWithoutSource<T>(
378
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop receiving messages.</returns>
379
+ MessageBusRegistration RegisterSourcedBroadcastWithoutSource<T>(
374
380
  MessageHandler messageHandler,
375
381
  int priority = 0
376
382
  )
@@ -381,8 +387,8 @@ namespace DxMessaging.Core.MessageBus
381
387
  /// It doesn't matter if the message is Targeted or Untargeted, this MessageHandler will be invoked for it.
382
388
  /// </summary>
383
389
  /// <param name="messageHandler">MessageHandler to register to accept all messages.</param>
384
- /// <returns>The deregistration action. Should be invoked when the handler no longer wants to receive messages.</returns>
385
- Action RegisterGlobalAcceptAll(MessageHandler messageHandler);
390
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop receiving messages.</returns>
391
+ MessageBusRegistration RegisterGlobalAcceptAll(MessageHandler messageHandler);
386
392
 
387
393
  /// <summary>
388
394
  /// Registers the specified MessageHandler and transformer function as an interceptor for Messages of type T.
@@ -407,8 +413,8 @@ namespace DxMessaging.Core.MessageBus
407
413
  /// Calling the returned deregistration action removes the interceptor from dispatch, but
408
414
  /// the delegate reference may remain until the final deregistration of that interceptor.
409
415
  /// </remarks>
410
- /// <returns>The deregistration action. Should be invoked when the handler no longer wants to intercept messages.</returns>
411
- Action RegisterUntargetedInterceptor<T>(
416
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop intercepting messages.</returns>
417
+ MessageBusRegistration RegisterUntargetedInterceptor<T>(
412
418
  UntargetedInterceptor<T> interceptor,
413
419
  int priority = 0
414
420
  )
@@ -437,8 +443,11 @@ namespace DxMessaging.Core.MessageBus
437
443
  /// Calling the returned deregistration action removes the interceptor from dispatch, but
438
444
  /// the delegate reference may remain until the final deregistration of that interceptor.
439
445
  /// </remarks>
440
- /// <returns>The deregistration action. Should be invoked when the handler no longer wants to intercept messages.</returns>
441
- Action RegisterTargetedInterceptor<T>(TargetedInterceptor<T> interceptor, int priority = 0)
446
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop intercepting messages.</returns>
447
+ MessageBusRegistration RegisterTargetedInterceptor<T>(
448
+ TargetedInterceptor<T> interceptor,
449
+ int priority = 0
450
+ )
442
451
  where T : ITargetedMessage;
443
452
 
444
453
  /// <summary>
@@ -464,8 +473,8 @@ namespace DxMessaging.Core.MessageBus
464
473
  /// Calling the returned deregistration action removes the interceptor from dispatch, but
465
474
  /// the delegate reference may remain until the final deregistration of that interceptor.
466
475
  /// </remarks>
467
- /// <returns>The deregistration action. Should be invoked when the handler no longer wants to intercept messages.</returns>
468
- Action RegisterBroadcastInterceptor<T>(
476
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop intercepting messages.</returns>
477
+ MessageBusRegistration RegisterBroadcastInterceptor<T>(
469
478
  BroadcastInterceptor<T> interceptor,
470
479
  int priority = 0
471
480
  )
@@ -478,8 +487,11 @@ namespace DxMessaging.Core.MessageBus
478
487
  /// <typeparam name="T">Type of UntargetedMessage to post-process.</typeparam>
479
488
  /// <param name="messageHandler">MessageHandler to post-process messages for.</param>
480
489
  /// <param name="priority">Priority of the interceptor to run at. Handlers run in order of priority from low -> high.</param>
481
- /// <returns>The deregistration action. Should be invoked when the handler no longer wants to post-process messages.</returns>
482
- Action RegisterUntargetedPostProcessor<T>(MessageHandler messageHandler, int priority = 0)
490
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop post-processing messages.</returns>
491
+ MessageBusRegistration RegisterUntargetedPostProcessor<T>(
492
+ MessageHandler messageHandler,
493
+ int priority = 0
494
+ )
483
495
  where T : IUntargetedMessage;
484
496
 
485
497
  /// <summary>
@@ -490,8 +502,8 @@ namespace DxMessaging.Core.MessageBus
490
502
  /// <param name="target">Target of messages to listen for.</param>
491
503
  /// <param name="messageHandler">MessageHandler to post-process messages for.</param>
492
504
  /// <param name="priority">Priority of the interceptor to run at. Handlers run in order of priority from low -> high.</param>
493
- /// <returns>The deregistration action. Should be invoked when the handler no longer wants to post-process messages.</returns>
494
- Action RegisterTargetedPostProcessor<T>(
505
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop post-processing messages.</returns>
506
+ MessageBusRegistration RegisterTargetedPostProcessor<T>(
495
507
  InstanceId target,
496
508
  MessageHandler messageHandler,
497
509
  int priority = 0
@@ -505,8 +517,8 @@ namespace DxMessaging.Core.MessageBus
505
517
  /// <typeparam name="T">Type of TargetedMessage to post-process.</typeparam>
506
518
  /// <param name="messageHandler">MessageHandler to post-process messages for.</param>
507
519
  /// <param name="priority">Priority of the interceptor to run at. Handlers run in order of priority from low -> high.</param>
508
- /// <returns>The deregistration action. Should be invoked when the handler no longer wants to post-process messages.</returns>
509
- Action RegisterTargetedWithoutTargetingPostProcessor<T>(
520
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop post-processing messages.</returns>
521
+ MessageBusRegistration RegisterTargetedWithoutTargetingPostProcessor<T>(
510
522
  MessageHandler messageHandler,
511
523
  int priority = 0
512
524
  )
@@ -520,8 +532,8 @@ namespace DxMessaging.Core.MessageBus
520
532
  /// <param name="source">Source of messages to listen for.</param>
521
533
  /// <param name="messageHandler">MessageHandler to post-process messages for.</param>
522
534
  /// <param name="priority">Priority of the interceptor to run at. Handlers run in order of priority from low -> high.</param>
523
- /// <returns>The deregistration action. Should be invoked when the handler no longer wants to post-process messages.</returns>
524
- Action RegisterBroadcastPostProcessor<T>(
535
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop post-processing messages.</returns>
536
+ MessageBusRegistration RegisterBroadcastPostProcessor<T>(
525
537
  InstanceId source,
526
538
  MessageHandler messageHandler,
527
539
  int priority = 0
@@ -535,13 +547,36 @@ namespace DxMessaging.Core.MessageBus
535
547
  /// <typeparam name="T">Type of TargetedMessage to post-process.</typeparam>
536
548
  /// <param name="messageHandler">MessageHandler to post-process messages for.</param>
537
549
  /// <param name="priority">Priority of the interceptor to run at. Handlers run in order of priority from low -> high.</param>
538
- /// <returns>The deregistration action. Should be invoked when the handler no longer wants to post-process messages.</returns>
539
- Action RegisterBroadcastWithoutSourcePostProcessor<T>(
550
+ /// <returns>An opaque registration handle. Pass it to <see cref="Deregister{T}"/> with the same T to stop post-processing messages.</returns>
551
+ MessageBusRegistration RegisterBroadcastWithoutSourcePostProcessor<T>(
540
552
  MessageHandler messageHandler,
541
553
  int priority = 0
542
554
  )
543
555
  where T : IBroadcastMessage;
544
556
 
557
+ /// <summary>
558
+ /// Undoes a registration produced by any of the <c>Register*</c> methods.
559
+ /// </summary>
560
+ /// <remarks>
561
+ /// <para>
562
+ /// Pass the <see cref="MessageBusRegistration"/> returned by the matching
563
+ /// <c>Register*</c> call, using the SAME <typeparamref name="T"/> you registered with
564
+ /// (for <see cref="RegisterGlobalAcceptAll"/>, any <c>T : IMessage</c> such as
565
+ /// <see cref="Messages.IMessage"/> is accepted, since the global slot is not type-keyed).
566
+ /// </para>
567
+ /// <para>
568
+ /// Deregistration is idempotent at the handle level only in the sense that a handle that
569
+ /// has outlived a reset/domain-reload, or a <see cref="MessageBusRegistration.None"/> /
570
+ /// foreign handle, is a silent no-op. Calling it twice for the same live registration is a
571
+ /// genuine over-deregistration and is logged (matching the pre-v4 behaviour of invoking
572
+ /// the returned deregistration action twice).
573
+ /// </para>
574
+ /// </remarks>
575
+ /// <typeparam name="T">The message type the registration was created for.</typeparam>
576
+ /// <param name="registration">The handle returned by the originating <c>Register*</c> call.</param>
577
+ void Deregister<T>(in MessageBusRegistration registration)
578
+ where T : IMessage;
579
+
545
580
  /// <summary>
546
581
  /// Broadcasts an Untargeted message to all listeners registered to this bus.
547
582
  /// </summary>
@@ -6,6 +6,6 @@ MonoImporter:
6
6
  defaultReferences: []
7
7
  executionOrder: 0
8
8
  icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -6,6 +6,6 @@ MonoImporter:
6
6
  defaultReferences: []
7
7
  executionOrder: 0
8
8
  icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -6,6 +6,6 @@ MonoImporter:
6
6
  defaultReferences: []
7
7
  executionOrder: 0
8
8
  icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: