Repository navigation
fix(hottesting): give mocked view models a messenger - #3214
Merged
Merged
Conversation
- Create passed default! for every constructor parameter, so a model calling messenger.Observe(...) in its constructor threw ArgumentNullException and got no mock - Pass a fresh WeakReferenceMessenger for a parameter typed CommunityToolkit.Mvvm.Messaging.IMessenger, matched by symbol; typed default otherwise - Nothing naming the toolkit is emitted when the compilation does not reference it - Fixture NoteModel observes a state on its messenger; the mocked input reaches a derived feed - Generator tests pin the emitted argument and a same-named IMessenger left null-injected Co-Authored-By: Claude Opus 5.5 <[email protected]>
- rules.md (MOCK0001) and testing.md no longer say every parameter is null-injected - Spec 013 architecture notes the messenger argument; history gains a v18 entry Co-Authored-By: Claude Opus 5.5 <[email protected]>
- a parameter typed IMessenger? also gets a fresh messenger, cast to IMessenger - the messenger test no longer claims a state input's own value is not swapped, which stops being true once state inputs are swapped where they are read Co-Authored-By: Claude Opus 5.5 <[email protected]>
- spec 013 architecture and history v18: Create passes typed defaults, and the R1 guard on CtorDependency(Eager=true) is still not built, so other eager parameters still throw - rules.md and testing.md: the messenger goes to a parameter typed IMessenger Co-Authored-By: Claude Opus 5.5 <[email protected]>
rajamatt
marked this pull request as ready for review
October 13, 2026 16:39
dr1rrb
approved these changes
Oct 13, 2026
dr1rrb
left a comment
Member
There was a problem hiding this comment.
Approving: the fix works, and the new tests fail on main and pass here.
➡️ Medium: 2 medium, 1 low.
The main concern is design rather than correctness: handling one specific third-party type (IMessenger) inside the mock generator is a special case that does not scale to the other eagerly used ctor dependencies, which spec 013 R1 already plans to cover through [CtorDependency(Eager = true)]. Please mark it as a stopgap in the spec.
- Record the messenger special case as a stopgap until R1.
- Keep one generator test without
CommunityToolkit.Mvvm. - Qualify
IMessengerinrules.mdandtesting.md.
kazo0
approved these changes
Oct 14, 2026
- Run() references CommunityToolkit.Mvvm only when a test opts in, so the generator tests stand for a consumer without the toolkit again - a compilation without the toolkit, even with its own IMessenger, gets a mock that names nothing from it - the messenger tests opt in Co-Authored-By: Claude Opus 5.5 <[email protected]>
- spec 013 architecture and history v18: the messenger is a stopgap until R1, not a list of known types; R1 can make a fresh messenger the default of an IMessenger argument - the generator's CtorArgument says not to add other known types - rules.md and testing.md: every parameter typed CommunityToolkit.Mvvm.Messaging.IMessenger Co-Authored-By: Claude Opus 5.5 <[email protected]>
rajamatt
enabled auto-merge
October 14, 2026 17:27
1 of 4 tasks
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
Contributor
Author
|
@Mergifyio backport servicing/7.4 |
✅ Backports have been createdDetails
|
This was referenced Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue (If applicable): related to https://github.com/unoplatform/studio.live/issues/4074
PR Type
What is the current behavior?
{Vm}Mock.Createpasses a typeddefault!for every constructor parameter. The MVUX messaging pattern observes a messenger in the model's constructor (messenger.Observe(Items, x => x.Id)), so for such a modelCreatethrowsArgumentNullException(parametermessenger) fromIMessengerExtensions.Register, and the model gets no mock at all.What is the new behavior?
Createpasses a freshWeakReferenceMessengerfor a constructor parameter typedCommunityToolkit.Mvvm.Messaging.IMessenger, matched by symbol. Every other parameter keeps its typed default.WeakReferenceMessengeris what the messaging docs register;Observecreates is owned by the state, so it goes away with the view-model.Reviewer's guide
FeedsMockGenerator.CtorArgument.Given_GeneratedMock.When_ModelObservesAMessengerInItsCtor_Then_CreateSucceedsAndInputFlowsfails onmainwith theArgumentNullException;Given_FeedsMockGenerator.When_CtorTakesAMessenger_Then_CreatePassesAFreshOnepins the emitted argument;When_CtorTakesAnotherTypeNamedIMessenger_Then_CreateNullInjectsItguards the match by symbol, not by name.MockingAppfixture now references Messaging, andUno.HotTesting.Reactive.Testsreferences CommunityToolkit.Mvvm.rules.md,testing.md, and spec 013 (architecture, history v18).main, a mocked state input isn't swapped on the state itself. That is a separate fix.PR Checklist
Uno.Extensions.Reactive.Tests, 1470 pass, 19 skipped;Uno.HotTesting.Reactive.Tests, 36 pass).Other information
servicing/7.4, so the backport should be clean.ILogger<T>→NullLogger<T>.Instance.🤖 Generated with Claude Code