·
8 commits
to refs/heads/master
since this release
Changelog
Added
- New Roslyn base-call analyzer (
MessageAwareComponentBaseCallAnalyzer) that flagsMessageAwareComponentsubclasses whose lifecycle overrides forget to invokebase.Awake(),base.OnEnable(),base.OnDisable(),base.OnDestroy(), orbase.RegisterMessageHandlers(). Introduces diagnosticsDXMSG006(missing base call),DXMSG007(lifecycle method hidden withnew),DXMSG008(opt-out marker),DXMSG009(method implicitly hides a lifecycle method withoutoverride/new), andDXMSG010(base.{method}()chains into an override that does not reachMessageAwareComponent). DXMSG006's diagnostic message is now per-method: each guarded method emits a sentence describing the runtime consequence (registration token never created, handlers not re-enabled, memory leak, etc.) so users immediately see what breaks. The inspector overlay HelpBox renders the same per-method sentences. Severity is tunable per project via.editorconfig(e.g.dotnet_diagnostic.DXMSG006.severity = error). Ships as a separateWallstopStudios.DxMessaging.Analyzer.dlldeployed alongside the existing source-generator DLL bySetupCscRspso it loads under both Unity 2021's Roslyn 3.8 analyzer host and newer Unity versions. Diagnostic help links now open the current analyzer reference page in the DxMessaging repository. - Runtime self-check breadcrumb on
MessageAwareComponent:OnEnablenow logs a one-timeDebug.LogErrorper instance when the registration token is null, with a link to the DXMSG006 reference. Gated onUNITY_EDITOR || DEBUG, so release builds pay no cost. Catches the case where the analyzer DLL was disabled or did not run, surfacing the silent failure as a loud editor error instead. - New public
[DxIgnoreMissingBaseCall]attribute (DxMessaging.Core.Attributes) for source-level opt-out of the base-call analyzer. Applied to a class, every guarded lifecycle method on that class is exempt; applied to a single method, only that method is exempt. The analyzer still emits an Info-levelDXMSG008at the suppression site so opt-outs remain auditable, and the inspector overlay's snapshot honours the same scoping (method-level suppresses only the annotated method, type-level opts out the entire type). Not inherited -- derived classes must opt out explicitly. - New inspector overlay (
MessageAwareComponentInspectorOverlay) for everyMessageAwareComponentsubclass: missing-base-call warnings reported by the analyzer or harvested from the Unity console are surfaced as a HelpBox in the inspector header without clobbering user-defined[CustomEditor]s (the overlay hooksEditor.finishedDefaultHeaderGUI). The overlay restores the previous session's report immediately on Unity Editor startup (loaded fromLibrary/DxMessaging/baseCallReport.json) instead of waiting for the first post-reload scan to complete; the HelpBox is annotated(cached from previous session -- refreshing...)until the first scan refreshes it. A companion fallback editor (MessageAwareComponentFallbackEditor) hosts the overlay for subclasses with no other custom editor and renders the body viaDrawDefaultInspector()so subclasses with no serialized fields no longer leave an empty vertical gap below the inspector header. - New DxMessaging project-wide settings asset (
DxMessagingSettings, stored atAssets/Editor/DxMessagingSettings.asset) accessible from Unity's Project Settings. Controls diagnostics targets applied toIMessageBus.GlobalDiagnosticsTargets, the editor message buffer size, the domain-reload warning suppression, the base-call analyzer toggle, the project-wide base-call ignore list, and the optional Unity console bridge that feeds the inspector overlay. - New
docs/reference/analyzers.mdreference page documenting everyDXMSG###diagnostic the package emits, with severity, source generator/analyzer, trigger conditions, message text, and code samples for each. Added to the Reference section of the documentation site navigation. - Added
llms.txtplus README onboarding guidance so users can connect AI assistants with accurate DxMessaging package context. - Test-suite hardening: parameterized scenario fixture (
MessageScenario,MessageScenarios,ScenarioHarness,AllocationAssertions) underTests/Runtime/TestUtilities/enabling kind-parameterized tests. - Behavioural gap closures:
HandlerExceptionTests,ReentrantEmissionTests,NullAndInvalidInputTests,SingleThreadContractTestspinning exception-in-handler, re-entrancy, null-input, and threading contracts. AllocationMatrixTestscovering zero-GC dispatch across kinds, interceptors, post-processors, diagnostics, and priority-based dispatch.- Expanded coverage now pins source-generator and analyzer behaviour that users rely on: generic / record struct / nested partial / nullable annotation cases for
DxMessageIdGenerator;[DxOptionalParameter]permutations and DXMSG005 boundary cases forDxAutoConstructorGenerator; positive opt-out cases forDxIgnoreMissingBaseCallAttribute. No runtime API change. - Three new public read-only registration counters on
IMessageBus:RegisteredInterceptors,RegisteredPostProcessors, andRegisteredGlobalAcceptAll. Lets diagnostic and leak-check tooling distinguish interceptor / post-processor / global accept-all leaks from regular handler leaks, and lets external monitors aggregate the bus's registration footprint without reflecting on internals.MessageBusaggregates the counters on each read by walking the per-message-type caches; consumers polling these properties in tight loops should snapshot at region boundaries. - Runtime memory-reclamation foundations:
DxMessagingRuntimeSettingsloads fromResources/DxMessagingRuntimeSettingsand hot-reloads eviction cadence, enablement, trim opt-out, and pool-cap changes without recreating the bus. Pooled internal collections and typed/bus slot registries preserve existing dispatch APIs while making empty handler and interceptor slots reclaimable.IMessageBus.Trim(force)andMessageHandler.TrimAll(force)reset dirty empty slots and trim shared pools on demand,OccupiedTypeSlots/OccupiedTargetSlotsexpose the retained bus and dirty typed-handler slot footprint for diagnostics, and idle sweeps run from emits and Unity's PlayerLoop. New user-facing reference and tuning docs ship atdocs/reference/runtime-settings.md(per-setting reference table) anddocs/guides/memory-reclamation.md(forced trim, idle sweep, and pool tuning narrative). - New explicit-factory registration helpers across all three DI integrations:
VContainerRegistrationExtensions.RegisterDxMessagingBus,ReflexRegistrationExtensions.AddDxMessagingBus, andZenjectRegistrationExtensions.BindDxMessagingBus. Each helper exposes the bus under both the concreteMessageBuscontract and theIMessageBusinterface, accepts an overloadable lifetime where the container supports it, accepts a user-suppliedFunc<TResolver, MessageBus>factory, and accepts anIDxMessagingClockoverload that constructs the bus through the new internal-onlyMessageBus.CreateForInternalUsefactory so test-side clocks (for exampleFakeClock) can be injected through the container. The VContainer helper registers both contracts in one registration call, avoiding VContainer environments where chained.AsSelf().As<IMessageBus>()drops the concrete contract and fails withNo such registration of type: DxMessaging.Core.MessageBus.MessageBus; the DI samples either call the helper directly or document the corresponding helper preference for their container shape.
Changed
- Mutation tests now exercise every messaging kind (Untargeted/Targeted/Broadcast) via a single parameterized fixture (
[ValueSource(MessageScenarios.AllKinds)]) acrossMutationDuringEmissionTests,MutationInterceptorTests, andMutationDestructionTests. Users get tighter cross-kind parity guarantees; no runtime API change. (~720 lines of duplication removed; test count preserved.) - Renamed
UntargetedTests,TargetedTests,BroadcastTeststoEmitUntargetedSpecificTests,EmitTargetedSpecificTests,EmitBroadcastSpecificTeststo clarify that kind-common tests live inEmitTestsand kind-specific tests live in the renamed files. (Test-suite hardening is test-only; noRuntime/behavior was modified.) - Documentation now warns up front that
MessageAwareComponentsubclasses must callbase.Awake(),base.OnEnable(),base.OnDisable(),base.OnDestroy(), andbase.RegisterMessageHandlers()from any override; admonitions added to the Quick Start, Getting Started Guide, Visual Guide, README, FAQ, and Troubleshooting pages all link toDXMSG006(issue #195).
Fixed
- Cross-priority deregistration during in-flight emit no longer drops handlers from the current dispatch.
- Previously, when a handler at one priority removed a handler at a later priority of the same emission, the later priority's typed-handler stack was rebuilt from the now-mutated registry on first touch and the scheduled-for-removal handler was silently skipped, breaking the documented "frozen handler list per emission" contract.
- This affected sourced-broadcast, broadcast-without-source, and targeted-without-targeting dispatch (the targeted/untargeted paths already pre-froze every bucket up-front).
- The bus now pre-freezes every priority bucket's typed-handler caches up-front for every dispatch surface (sourced-broadcast, broadcast-without-source, targeted-without-targeting) and uses the per-emission snapshot count for the dispatch-loop early-out.
- The sourced-broadcast and broadcast-without-source dispatch loops also no longer short-circuit on the live
cache.handlers.Count == 0when the per-emission snapshot still holds the deregistered handler. - Post-processor prefreeze no longer takes a single-bucket/single-entry fast-path that skipped pre-freezing per-MessageHandler post-processor caches; a regular handler that registers a new post-processor on the same MessageHandler+priority during its own callback now sees the new post-processor on the next emission, not the in-flight one.
- The same fix extends to cross-
MessageHandlerpost-processor dispatch: the inner per-handlerRunFastHandlersoverload used byTargetedWithoutTargeting/BroadcastWithoutSourcepost-processors now consults the per-emission snapshot list directly instead of bailing on the livecache.entriescount, so a siblingMessageHandlerremoving a not-yet-dispatched post-processor no longer silently skips the snapshot-pinned invocation. RegisterGlobalAcceptAll(HandleGlobalUntargeted/HandleGlobalTargeted/HandleGlobalBroadcast) is intentionally NOT covered by this fix. The bus's global accept-all dispatch path prefreezes lazily per-entry inside the dispatch loop, so a siblingMessageHandlerthat removes another's global registration mid-emit causes the removed handler to be skipped on the in-flight emission. The behavior is pinned byMutationPostProcessorAcrossHandlersTests.RemoveOtherGlobalAcceptAllAcrossHandlersDuringDispatch; if a future change introduces upfront global-handler prefreeze, that test must be updated to expect the snapshot semantics that the per-kind paths already provide.
DxMessagingStaticState.Resetis now race-safe against deferred deregistrations. Previously, when a message-aware component was destroyed but its disable callback had not yet run (Unity defers Object.Destroy to end of frame) and Reset ran in between, the deferred token teardown would log spurious "Received over-deregistration of {type} for {handler}" errors against the user's Unity console. The bus now stamps each captured deregister closure with a generation counter and silently no-ops closures captured before a Reset. Applied uniformly across every register entry point (untargeted, targeted, broadcast, GlobalAcceptAll, and all three interceptor kinds). The same race-safety guarantee is now propagated to user-installed custom global buses viaMessageBus.BumpResetGeneration(), whichDxMessagingStaticState.Resetinvokes on the active global bus when it differs from the built-in default; the custom bus's sinks are intentionally left intact to avoid clobbering state the user installed it to preserve. User code is unaffected except that previously-spurious error logs disappear.MessageRegistrationToken.RemoveRegistration(handle)no longer leaks the staged registration entry, so aDisable()/Enable()cycle afterRemoveRegistrationno longer silently re-registers the removed handler. The fix also drops the matching metadata and call-count entries so diagnostic mode does not accumulate stale handles.- Resolved issue #204 (build artifacts and orphaned
.metafiles leaking into the npm tarball) and prevented its regression:scripts/validate-npm-meta.jsnow runsvalidateNoBuildArtifactsInTarball(rejectsbin/,obj/,*.pdb,*.tmp,*.csproj.user,.vs/,.idea/,*.suo, and*.DotSettings.userpaths in the tarball) andvalidatePublishedFilesArePairedWithMetas(every shipped Unity-relevant file has its.metaneighbour and every shipped directory has its directory.meta), wired intoprepackand thevalidate-npm-metaworkflow so the next publish cannot reintroduce the regression.
Pull Requests
- Bump release (3.0.1) (#207) Eli Pinkerton (@wallstop)
- Fix CI (#206) Eli Pinkerton (@wallstop)
- Feature: Custom GC, Packaging + Doc Improvements (#205) Eli Pinkerton (@wallstop)
- Feature: More test and Enhanced Documentation (#201) Eli Pinkerton (@wallstop)
- Feature: Enhance tests, fix various bus freezing bugs (#200) Eli Pinkerton (@wallstop)
- Feature: Unity Method Inspector Checks (#199) Eli Pinkerton (@wallstop)
- chore(dependabot): prefer larger area-grouped Dependabot PRs (#189) Eli Pinkerton (@wallstop)
- Delete .github/workflows/update-dotnet-tools.yml (#175) Eli Pinkerton (@wallstop)
- Fix duplicate CSC.rsp entries from stale package cache versions (#174) @copilot-swe-agent[bot]
- Add NPM package meta file validation and standardize line endings (#173) @copilot-swe-agent[bot]
- feat: Add llms.txt for AI agent integration (#171) @copilot-swe-agent[bot]
- Add CSharpier formatting check to CI/CD (#172) @copilot-swe-agent[bot]
- Fix changelog display in Unity Package Manager with raw GitHub URL (#170) @copilot-swe-agent[bot]
Contributors
@Copilot, Dependabot (@dependabot)[bot], Eli Pinkerton (@wallstop), copilot-swe-agent[bot] and dependabot[bot]