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
@@ -0,0 +1,72 @@
1
+ name: dotnet-tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ - main
8
+ - develop
9
+ pull_request:
10
+ branches:
11
+ - "*"
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - name: Checkout
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Setup .NET
22
+ uses: actions/setup-dotnet@v3
23
+ with:
24
+ dotnet-version: "9.0.x"
25
+
26
+ - name: Install reportgenerator tool
27
+ run: |
28
+ dotnet tool install --global dotnet-reportgenerator-globaltool
29
+ echo "$HOME/.dotnet/tools" >> "$GITHUB_PATH"
30
+
31
+ - name: Restore
32
+ run: dotnet restore SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/WallstopStudios.DxMessaging.SourceGenerators.Tests.csproj
33
+
34
+ - name: Run generator diagnostics tests
35
+ run: >
36
+ dotnet test SourceGenerators/WallstopStudios.DxMessaging.SourceGenerators.Tests/WallstopStudios.DxMessaging.SourceGenerators.Tests.csproj
37
+ --configuration Release
38
+ --collect:"XPlat Code Coverage"
39
+
40
+ - name: Generate coverage summary
41
+ run: |
42
+ mkdir -p artifacts/coverage
43
+ reportgenerator \
44
+ -reports:".artifacts/SourceGenerators.Tests/TestResults/**/coverage.cobertura.xml" \
45
+ -targetdir:"artifacts/coverage" \
46
+ -reporttypes:"TextSummary;HtmlSummary;Cobertura"
47
+ cat artifacts/coverage/Summary.txt
48
+
49
+ - name: Upload coverage report
50
+ uses: actions/upload-artifact@v4
51
+ with:
52
+ name: generator-coverage
53
+ path: artifacts/coverage
54
+
55
+ - name: Check for TODO/FIXME markers
56
+ shell: bash
57
+ run: |
58
+ set -uo pipefail
59
+ if rg --files-with-matches "(TODO|FIXME)" \
60
+ --hidden \
61
+ --no-ignore \
62
+ -g '!.git/**' \
63
+ -g '!.artifacts/**' \
64
+ -g '!node_modules/**' \
65
+ -g '!Tests/**/TestResults/**' \
66
+ -g '!PLAN.md' \
67
+ -g '!.vs/**'; then
68
+ echo "::error::Found TODO/FIXME markers in the repository. Please resolve or suppress them."
69
+ exit 1
70
+ else
71
+ echo "No TODO/FIXME markers detected."
72
+ fi
package/.lychee.toml CHANGED
@@ -17,10 +17,12 @@ accept = ["200..=299", 429]
17
17
  # Only check web links
18
18
  scheme = ["https", "http"]
19
19
 
20
- # Ignore common local/test URLs
20
+ # Ignore endpoints that block automated clients (local hosts, CF challenges)
21
21
  exclude = [
22
22
  "^https?://localhost",
23
23
  "^http://127\\.0\\.0\\.1",
24
24
  "^https?://0\\.0\\.0\\.0",
25
- "^file://"
25
+ "^file://",
26
+ # NPM package page serves a Cloudflare JS challenge to non-browser clients; registry endpoint remains covered.
27
+ "^https://www\\.npmjs\\.com/package/com\\.wallstop-studios\\.dxmessaging$"
26
28
  ]
package/AGENTS.md CHANGED
@@ -24,6 +24,7 @@
24
24
  - Do not use underscores in function names, especially test function names.
25
25
  - Do not use regions, anywhere, ever.
26
26
  - Avoid `var` wherever possible, use expressive types.
27
+ - Do not use nullable reference types.
27
28
 
28
29
  ## Testing Guidelines
29
30
 
@@ -34,10 +34,10 @@ These sections are auto-updated by the PlayMode comparison benchmarks in `Tests/
34
34
 
35
35
  | Message Tech | Operations / Second | Allocations? |
36
36
  | ---------------------------------- | ------------------- | ------------ |
37
- | DxMessaging (Untargeted) - No-Copy | 14,902,000 | No |
38
- | UniRx MessageBroker | 18,026,000 | No |
39
- | MessagePipe (Global) | 96,978,000 | No |
40
- | Zenject SignalBus | 2,520,000 | Yes |
37
+ | DxMessaging (Untargeted) - No-Copy | 14,734,000 | No |
38
+ | UniRx MessageBroker | 18,044,000 | No |
39
+ | MessagePipe (Global) | 97,774,000 | No |
40
+ | Zenject SignalBus | 2,600,000 | Yes |
41
41
 
42
42
  ### Comparisons (macOS)
43
43
 
@@ -70,10 +70,10 @@ public sealed class ScoreReporter
70
70
  }
71
71
 
72
72
  [DxUntargetedMessage]
73
- public readonly struct ScoreChanged
73
+ [DxAutoConstructor]
74
+ public readonly partial struct ScoreChanged
74
75
  {
75
76
  public readonly int Value;
76
- public ScoreChanged(int value) => Value = value;
77
77
  }
78
78
  ```
79
79
 
package/Docs/Helpers.md CHANGED
@@ -186,34 +186,32 @@ public readonly partial struct ComplexMessage
186
186
 
187
187
  ## Why Use Attributes Instead of Manual Implementation
188
188
 
189
- ### Manual Way (Verbose, Error-Prone)
189
+ ### Attribute Definition (Clean, Automatic)
190
190
 
191
191
  ```csharp
192
- public readonly struct Heal : ITargetedMessage<Heal>
192
+ [DxTargetedMessage]
193
+ [DxAutoConstructor]
194
+ public readonly partial struct Heal
193
195
  {
194
196
  public readonly int amount;
195
-
196
- // You write this yourself (boring!)
197
- public Heal(int amount)
198
- {
199
- this.amount = amount;
200
- }
201
-
202
- // Required plumbing (easy to mess up!)
203
- public Type MessageType => typeof(Heal);
204
197
  }
205
198
  ```
206
199
 
207
- ### Attribute Way (Clean, Automatic)
200
+ ### What the generator emits (for reference)
208
201
 
209
202
  ```csharp
210
- [DxTargetedMessage]
211
- [DxAutoConstructor]
212
- public readonly partial struct Heal
203
+ // Auto-generated by DxMessaging (no need to hand-write this)
204
+ public readonly partial struct Heal : ITargetedMessage<Heal>
213
205
  {
214
206
  public readonly int amount;
207
+
208
+ public Heal(int amount)
209
+ {
210
+ this.amount = amount;
211
+ }
212
+
213
+ public Type MessageType => typeof(Heal);
215
214
  }
216
- // Constructor and plumbing generated automatically!
217
215
  ```
218
216
 
219
217
  #### Benefits
@@ -223,14 +221,28 @@ public readonly partial struct Heal
223
221
  - ✅ **Cleaner** - Focus on data, not boilerplate
224
222
  - ✅ **Refactor-safe** - Add field? Constructor updates automatically!
225
223
 
226
- ## Complete Example: Before & After
224
+ ## Complete Example: Attribute Definition vs Generated Output
227
225
 
228
- ### Before (Manual - 20 lines)
226
+ ### Attribute Definition (8 lines)
229
227
 
230
228
  ```csharp
231
- using DxMessaging.Core.Messages;
229
+ using DxMessaging.Core.Attributes;
232
230
 
233
- public readonly struct PlayerDamaged : IBroadcastMessage<PlayerDamaged>
231
+ [DxBroadcastMessage]
232
+ [DxAutoConstructor]
233
+ public readonly partial struct PlayerDamaged
234
+ {
235
+ public readonly int amount;
236
+ public readonly string damageType;
237
+ public readonly GameObject source;
238
+ }
239
+ ```
240
+
241
+ ### Generated Output (20 lines you never write)
242
+
243
+ ```csharp
244
+ // Auto-generated by DxMessaging (for reference only)
245
+ public readonly partial struct PlayerDamaged : IBroadcastMessage<PlayerDamaged>
234
246
  {
235
247
  public readonly int amount;
236
248
  public readonly string damageType;
@@ -247,65 +259,76 @@ public readonly struct PlayerDamaged : IBroadcastMessage<PlayerDamaged>
247
259
  }
248
260
  ```
249
261
 
250
- ### After (Attributes - 9 lines!)
262
+ ### Result
251
263
 
252
- ```csharp
253
- using DxMessaging.Core.Attributes;
264
+ - ✅ Same functionality
265
+ - ✅ Less code to maintain
266
+ - ✅ Automatically updates when you add/remove fields
267
+ - ✅ Works for class messages too
268
+ - ✅ Zero effort once you mark the struct partial
254
269
 
255
- [DxBroadcastMessage]
270
+ ## Advanced: Manual Implementation (When Attributes Aren't Enough)
271
+
272
+ Attributes cover almost every scenario. If you intentionally drop `[DxTargetedMessage]`, `[DxUntargetedMessage]`, or `[DxBroadcastMessage]`, you'll need to hand-write the interface implementations and constructors shown in the “generated output” examples. Keep the attributes unless you have a very specific data-backed reason not to.
273
+
274
+ ### Generic Message Interfaces (Zero-Boxing for Structs)
275
+
276
+ `readonly struct` messages marked with the attributes already implement the generic interfaces, so emissions stay allocation-free. You get the same performance characteristics as the manual approach without writing any plumbing.
277
+
278
+ ```csharp
279
+ [DxTargetedMessage]
256
280
  [DxAutoConstructor]
257
- public readonly partial struct PlayerDamaged
281
+ public readonly partial struct Heal
258
282
  {
259
283
  public readonly int amount;
260
- public readonly string damageType;
261
- public readonly GameObject source;
262
284
  }
263
285
  ```
264
286
 
265
- **Result:** Same functionality, 55% less code, zero boilerplate!
287
+ ### "Do I HAVE to use attributes?"
266
288
 
267
- ## Advanced: Manual Implementation (When Attributes Aren't Enough)
289
+ Technically no—but without them you must write the constructor, interface implementation, and `MessageType` property yourself (for speed, you can optionally leave this off, but it might box on certain call paths). Leaving the attributes on keeps everything consistent for the whole team.
268
290
 
269
- Sometimes you might want full control and skip source generators. You can implement interfaces manually:
291
+ ```csharp
292
+ [DxUntargetedMessage]
293
+ [DxAutoConstructor]
294
+ public readonly partial struct MyMsg { }
295
+ ```
270
296
 
271
- ### Generic Message Interfaces (Zero-Boxing for Structs)
297
+ ### "What if I want custom constructor logic?"
272
298
 
273
- **For performance-critical code**, implement the generic interfaces directly:
299
+ Keep the attributes and add a factory/helper so you still benefit from the generated constructor:
274
300
 
275
301
  ```csharp
276
- using DxMessaging.Core.Messages;
277
-
278
- public readonly struct Heal : ITargetedMessage<Heal>
302
+ [DxUntargetedMessage]
303
+ [DxAutoConstructor]
304
+ public readonly partial struct ComplexMessage
279
305
  {
280
- public readonly int amount;
306
+ public readonly int value;
281
307
 
282
- public Heal(int amount)
308
+ public static ComplexMessage FromRaw(int rawValue)
283
309
  {
284
- this.amount = amount;
310
+ int clamped = Math.Clamp(rawValue, 0, 100);
311
+ return new ComplexMessage(clamped);
285
312
  }
286
-
287
- // Required for IMessage
288
- public Type MessageType => typeof(Heal);
289
313
  }
290
314
  ```
291
315
 
292
- #### Why use generics?
316
+ If you truly must write a custom constructor, drop `[DxAutoConstructor]` for that type but keep the `[DxUntargetedMessage]`/`[DxTargetedMessage]` attribute so the interface plumbing stays consistent.
293
317
 
294
- - Avoids boxing structs (important for performance)
295
- - Provides stable `MessageType` without `GetType()` calls
296
- - Same performance as attribute-based approach
318
+ ### "Can I mix attribute-based and manual messages?"
297
319
 
298
- ##### When to use
320
+ Yes. Attribute-driven messages happily coexist with string messages and any manual implementations you already have. You can migrate gradually by converting one message at a time:
299
321
 
300
- - Hot path messages (sent/received every frame)
301
- - Very large structs where boxing matters
302
- - When you want explicit control
303
-
304
- ###### When to use attributes
322
+ ```csharp
323
+ [DxUntargetedMessage]
324
+ [DxAutoConstructor]
325
+ public readonly partial struct MessageA
326
+ {
327
+ public readonly int value;
328
+ }
305
329
 
306
- - 99% of cases (they generate the same code!)
307
- - Cleaner, less boilerplate
308
- - Easier to maintain
330
+ // Existing manual message types keep working alongside attribute-driven ones.
331
+ ```
309
332
 
310
333
  ## Extension Methods (Emit Helpers)
311
334
 
@@ -549,50 +572,42 @@ public readonly partial struct MyMessage : IUntargetedMessage<MyMessage>
549
572
 
550
573
  ### "What if I want custom constructor logic?"
551
574
 
552
- Use manual implementation:
575
+ Keep the attributes and wrap the generated constructor with a helper so you can inject custom logic without losing the source-generated plumbing:
553
576
 
554
577
  ```csharp
555
- public readonly struct ComplexMessage : IUntargetedMessage<ComplexMessage>
578
+ [DxUntargetedMessage]
579
+ [DxAutoConstructor]
580
+ public readonly partial struct ComplexMessage
556
581
  {
557
582
  public readonly int value;
558
583
 
559
- public ComplexMessage(int rawValue)
584
+ public static ComplexMessage FromRaw(int rawValue)
560
585
  {
561
- // Custom logic
562
- value = Math.Clamp(rawValue, 0, 100);
586
+ int clamped = Math.Clamp(rawValue, 0, 100);
587
+ return new ComplexMessage(clamped);
563
588
  }
564
-
565
- public Type MessageType => typeof(ComplexMessage);
566
589
  }
567
590
  ```
568
591
 
592
+ If you truly need to hand-craft the constructor, drop `[DxAutoConstructor]` for that specific type but keep the `[DxUntargetedMessage]`/`[DxTargetedMessage]` attribute so the interface implementation is still generated.
593
+
569
594
  ### "Do attributes affect runtime performance?"
570
595
 
571
596
  **No!** Source generation happens at **compile time**. Generated code is identical to hand-written code. Zero runtime overhead.
572
597
 
573
598
  ### "Can I mix attributes and manual implementation?"
574
599
 
575
- **Not on the same type**, but you can have:
576
-
577
- - Some messages using attributes
578
- - Other messages using manual implementation
579
- - Mix and match across your codebase
600
+ Yes. Attribute-driven messages happily coexist with any legacy manual messages or string messages you already emit. Convert types gradually—one message at a time:
580
601
 
581
602
  ```csharp
582
- // Message A: Attributes
583
603
  [DxUntargetedMessage]
584
604
  [DxAutoConstructor]
585
- public readonly partial struct MessageA { public readonly int value; }
586
-
587
- // Message B: Manual
588
- public readonly struct MessageB : IUntargetedMessage<MessageB>
605
+ public readonly partial struct MessageA
589
606
  {
590
607
  public readonly int value;
591
- public MessageB(int value) { this.value = value; }
592
- public Type MessageType => typeof(MessageB);
593
608
  }
594
609
 
595
- // Both work perfectly together!
610
+ // Existing manual messages keep working alongside attribute-driven ones.
596
611
  ```
597
612
 
598
613
  ## Troubleshooting Source Generators
@@ -609,7 +624,7 @@ public readonly struct MessageB : IUntargetedMessage<MessageB>
609
624
  ##### Fix
610
625
 
611
626
  ```csharp
612
- // ❌ Missing partial
627
+ // ❌ Missing partial, will not compile
613
628
  [DxAutoConstructor]
614
629
  public readonly struct MyMsg { }
615
630
 
package/Docs/Install.md CHANGED
@@ -9,7 +9,8 @@ This page helps you install DxMessaging into a Unity 2021.3+ project using the U
9
9
  - Unity Package Manager > Add package from git URL...
10
10
  - Paste:
11
11
 
12
- ```text
12
+ ```bash
13
+ # Unity UPM: Add package from git URL...
13
14
  https://github.com/wallstop/DxMessaging.git
14
15
  ```
15
16
 
package/Docs/Patterns.md CHANGED
@@ -874,7 +874,7 @@ public class GameEvent : ScriptableObject
874
874
 
875
875
  // DxMessaging message (modern, type-safe)
876
876
  [DxUntargetedMessage]
877
- public readonly struct SceneTransitionRequested { }
877
+ public readonly partial struct SceneTransitionRequested { }
878
878
 
879
879
  // Bridge: SOA Event → DxMessaging
880
880
  public class SOAEventBridge : MonoBehaviour
@@ -12,17 +12,19 @@ See also: `Docs/DesignAndArchitecture.md#performance-optimizations` for design d
12
12
 
13
13
  ## Windows
14
14
 
15
- | Message Tech | Operations / Second | Allocations? |
16
- | ---------------------------------- | ------------------- | ------------ |
17
- | Unity | 2,490,000 | Yes |
18
- | DxMessaging (GameObject) - Normal | 8,520,000 | No |
19
- | DxMessaging (Component) - Normal | 8,542,000 | No |
20
- | DxMessaging (GameObject) - No-Copy | 9,426,000 | No |
21
- | DxMessaging (Component) - No-Copy | 9,552,000 | No |
22
- | DxMessaging (Untargeted) - No-Copy | 14,900,000 | No |
23
- | Reflexive (One Argument) | 2,832,000 | No |
24
- | Reflexive (Two Arguments) | 2,348,000 | No |
25
- | Reflexive (Three Arguments) | 2,364,000 | No |
15
+ | Message Tech | Operations / Second | Allocations? |
16
+ | ------------------------------------------ | ------------------- | ------------ |
17
+ | Unity | 2,564,000 | Yes |
18
+ | DxMessaging (GameObject) - Normal | 8,476,000 | No |
19
+ | DxMessaging (Component) - Normal | 8,474,000 | No |
20
+ | DxMessaging (GameObject) - No-Copy | 9,418,000 | No |
21
+ | DxMessaging (Component) - No-Copy | 9,536,000 | No |
22
+ | DxMessaging (Untargeted) - No-Copy | 14,736,000 | No |
23
+ | DxMessaging (Untargeted) - Interceptors | 6,618,000 | No |
24
+ | DxMessaging (Untargeted) - Post-Processors | 5,244,000 | No |
25
+ | Reflexive (One Argument) | 2,828,000 | No |
26
+ | Reflexive (Two Arguments) | 2,360,000 | No |
27
+ | Reflexive (Three Arguments) | 2,358,000 | No |
26
28
 
27
29
  ## macOS
28
30
 
@@ -60,8 +60,7 @@ public readonly partial struct TookDamage
60
60
  public readonly int amount;
61
61
  }
62
62
 
63
- // Performance option: generic interfaces on structs (zero boxing)
64
- // public readonly struct Heal : ITargetedMessage<Heal> { public readonly int amount; public Heal(int amount) { this.amount = amount; } }
63
+ // Performance option: keep [DxTargetedMessage] on a readonly struct to stay zero-boxing friendly, and drop [DxAutoConstructor] only if you need custom constructor logic.
65
64
 
66
65
  // Optional parameters with custom defaults
67
66
  [DxTargetedMessage]
@@ -11,15 +11,26 @@ PluginImporter:
11
11
  isExplicitlyReferenced: 0
12
12
  validateReferences: 1
13
13
  platformData:
14
+ - first:
15
+ : Any
16
+ second:
17
+ enabled: 0
18
+ settings:
19
+ Exclude Editor: 0
20
+ Exclude Linux64: 1
21
+ Exclude OSXUniversal: 1
22
+ Exclude WebGL: 1
23
+ Exclude Win: 1
24
+ Exclude Win64: 1
14
25
  - first:
15
26
  Any:
16
27
  second:
17
- enabled: 1
28
+ enabled: 0
18
29
  settings: {}
19
30
  - first:
20
31
  Editor: Editor
21
32
  second:
22
- enabled: 0
33
+ enabled: 1
23
34
  settings:
24
35
  DefaultValueInitialized: true
25
36
  - first:
@@ -11,6 +11,17 @@ PluginImporter:
11
11
  isExplicitlyReferenced: 0
12
12
  validateReferences: 1
13
13
  platformData:
14
+ - first:
15
+ : Any
16
+ second:
17
+ enabled: 0
18
+ settings:
19
+ Exclude Editor: 0
20
+ Exclude Linux64: 1
21
+ Exclude OSXUniversal: 1
22
+ Exclude WebGL: 1
23
+ Exclude Win: 1
24
+ Exclude Win64: 1
14
25
  - first:
15
26
  Any:
16
27
  second:
@@ -11,6 +11,17 @@ PluginImporter:
11
11
  isExplicitlyReferenced: 0
12
12
  validateReferences: 1
13
13
  platformData:
14
+ - first:
15
+ : Any
16
+ second:
17
+ enabled: 0
18
+ settings:
19
+ Exclude Editor: 0
20
+ Exclude Linux64: 1
21
+ Exclude OSXUniversal: 1
22
+ Exclude WebGL: 1
23
+ Exclude Win: 1
24
+ Exclude Win64: 1
14
25
  - first:
15
26
  Any:
16
27
  second:
@@ -11,15 +11,26 @@ PluginImporter:
11
11
  isExplicitlyReferenced: 0
12
12
  validateReferences: 1
13
13
  platformData:
14
+ - first:
15
+ : Any
16
+ second:
17
+ enabled: 0
18
+ settings:
19
+ Exclude Editor: 0
20
+ Exclude Linux64: 1
21
+ Exclude OSXUniversal: 1
22
+ Exclude WebGL: 1
23
+ Exclude Win: 1
24
+ Exclude Win64: 1
14
25
  - first:
15
26
  Any:
16
27
  second:
17
- enabled: 1
28
+ enabled: 0
18
29
  settings: {}
19
30
  - first:
20
31
  Editor: Editor
21
32
  second:
22
- enabled: 0
33
+ enabled: 1
23
34
  settings:
24
35
  DefaultValueInitialized: true
25
36
  - first:
@@ -11,6 +11,17 @@ PluginImporter:
11
11
  isExplicitlyReferenced: 0
12
12
  validateReferences: 1
13
13
  platformData:
14
+ - first:
15
+ : Any
16
+ second:
17
+ enabled: 0
18
+ settings:
19
+ Exclude Editor: 0
20
+ Exclude Linux64: 1
21
+ Exclude OSXUniversal: 1
22
+ Exclude WebGL: 1
23
+ Exclude Win: 1
24
+ Exclude Win64: 1
14
25
  - first:
15
26
  Any:
16
27
  second:
@@ -18,9 +18,10 @@ PluginImporter:
18
18
  second:
19
19
  enabled: 0
20
20
  settings:
21
- Exclude Editor: 1
21
+ Exclude Editor: 0
22
22
  Exclude Linux64: 1
23
23
  Exclude OSXUniversal: 1
24
+ Exclude WebGL: 1
24
25
  Exclude Win: 1
25
26
  Exclude Win64: 1
26
27
  - first:
@@ -31,7 +32,7 @@ PluginImporter:
31
32
  - first:
32
33
  Editor: Editor
33
34
  second:
34
- enabled: 0
35
+ enabled: 1
35
36
  settings:
36
37
  CPU: AnyCPU
37
38
  DefaultValueInitialized: true
@@ -0,0 +1,3 @@
1
+ using System.Runtime.CompilerServices;
2
+
3
+ [assembly: InternalsVisibleTo("WallstopStudios.DxMessaging.Tests.Editor")]
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 55bb3ae7ef064633b5fe4b17ce29f8cc
3
+ timeCreated: 1761880591
@@ -7,6 +7,7 @@ namespace DxMessaging.Editor.CustomEditors
7
7
  using Core.Diagnostics;
8
8
  using Core.MessageBus;
9
9
  using Core.Messages;
10
+ using DxMessaging.Editor.Testing;
10
11
  using Unity;
11
12
  using UnityEditor;
12
13
  using UnityEngine;
@@ -66,6 +67,26 @@ namespace DxMessaging.Editor.CustomEditors
66
67
  return;
67
68
  }
68
69
 
70
+ MessagingComponentInspectorState inspectorState =
71
+ MessagingComponentEditorHarness.Capture(component);
72
+ ProviderDiagnosticsView providerDiagnostics = inspectorState.ProviderDiagnostics;
73
+
74
+ if (providerDiagnostics.SerializedProviderMissingWarning)
75
+ {
76
+ EditorGUILayout.HelpBox(
77
+ "Auto-configure serialized provider is enabled, but no provider asset is assigned.",
78
+ MessageType.Warning
79
+ );
80
+ }
81
+
82
+ if (providerDiagnostics.SerializedProviderNullBusWarning)
83
+ {
84
+ EditorGUILayout.HelpBox(
85
+ "The serialized provider resolved without returning a message bus. Verify the provider implementation.",
86
+ MessageType.Warning
87
+ );
88
+ }
89
+
69
90
  if (component._registeredListeners.Count == 0)
70
91
  {
71
92
  EditorGUILayout.LabelField("No listeners registered.");