Skip to content

Commit f7414db

Browse files
Jen-Unoclaude
andcommitted
refactor(unocrm): one file per class in Presentation/MockData
CrmPageMocks.cs stacked the Dashboard, Pipeline and Leads mocks into one file named after the folder rather than a type — the file every new mock gets appended to. Each now lives in DashboardPageMockData.cs, PipelinePageMockData.cs and LeadsPageMockData.cs, matching the two mocks that already had their own file. Each keeps its three-line ForModel partial, which exists only to reach that one mock's protected model-taking constructor. The old file's 34-line header carried the rules every feed-shaped mock follows, including the one that exists to stop a future edit ("these feeds are inline no-capture lambdas — do not deduplicate them into a helper"). Copying it three times would drift, so it moves onto ContactsPageMockData.cs — the mock it already named as the reference — as a numbered recipe the siblings cite by cref. Only the page-specific paragraphs travelled with their own mock: the activity-list comparison to Dashboard, the plain-arrays LiveCharts constraint to Leads. DealDetailPageMockData now states why it sits outside the recipe (no feeds, so nothing for a SourceContext to do). No behaviour change: the previews bind these by type, the SDK globs the new files, and every code line is preserved apart from normalizing [Uno.Extensions.Reactive.ReactiveBindable] to the unqualified form its siblings already used. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent b467f1a commit f7414db

6 files changed

Lines changed: 282 additions & 236 deletions

File tree

studio/uno-crm/UnoCRM/Presentation/MockData/ContactsPageMockData.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
namespace UnoCRM.Presentation.MockData;
22

3+
// The recipe every mock in this folder follows.
4+
//
5+
// Presentation/MockData holds one design-time DataContext per page, for Hot Design / Studio.
6+
// ContactsPageMockData below is the reference: it is the mock whose populated preview provably
7+
// renders on a design surface, so its siblings are built to the same four rules. They are recorded
8+
// here once, and each sibling file points back at them.
9+
//
10+
// 1. The statics hand out the GENERATED ViewModel, never the record. Every page renders at least one
11+
// FeedView, and a FeedView can only subscribe to a FEED — a plain list would never reach it. So
12+
// each mock is [ReactiveBindable], and the ViewModel the analyzer emits for it creates, in its
13+
// constructor, the SourceContext that makes those feeds pump and materializes them into bindable
14+
// lists. A raw record has no context, so its feeds never emit and the preview comes out empty.
15+
// Handing the FeedView the bare feed instead of the ViewModel was tried, and does not help.
16+
//
17+
// 2. Those statics are expression-bodied — a fresh instance per access, never a cached singleton. A
18+
// generated ViewModel has a view-scoped lifecycle: its SourceContext is created with the instance
19+
// and disposed when the hosting view unloads. A shared singleton can be built before the design
20+
// host's dispatcher is ready, or be disposed after a previous preview render, leaving a dead
21+
// context whose feeds never emit. One instance per access mirrors the runtime per-navigation
22+
// lifecycle, so every preview render gets a live ViewModel.
23+
//
24+
// 3. Every static input is declared ABOVE the statics that construct instances. Static members
25+
// initialize in textual order, and an instance initializer that reads a not-yet-assigned static
26+
// field gets null with no exception at all.
27+
//
28+
// 4. And the load-bearing one: every feed is built by an INLINE lambda that CAPTURES NOTHING — it
29+
// reads static seed data directly. A no-capture lambda's delegate is cached by the compiler, and
30+
// the feed factories cache the feed they build against that delegate instance, so every instance
31+
// of a mock shares ONE feed, created once. Routing these through a shared helper that hoisted the
32+
// payload into a local minted a fresh delegate, and so a fresh feed, per mock instance — and
33+
// those previews rendered their lists empty. Do not "deduplicate" these lambdas into a helper.
34+
//
35+
// A variant needs the generated ViewModel's model-taking constructor, which is protected, so each
36+
// file also carries a small partial on its ViewModel exposing a factory that reaches it.
37+
//
38+
// None of these is ever seeded from a page constructor — see those constructors for why.
39+
340
/// <summary>
441
/// Design-time DataContext for <see cref="ContactsPage"/> in Hot Design / Studio. ContactsModel has
542
/// reactive members the design surface can't pump, so the two-way filters and header counts are

studio/uno-crm/UnoCRM/Presentation/MockData/CrmPageMocks.cs

Lines changed: 0 additions & 236 deletions
This file was deleted.

0 commit comments

Comments
 (0)