Modeling and Module Generation
Status: Public design proposal and product vision. This series presents Diem CMF .NET’s intended architecture and capabilities. Proposed features remain subject to implementation and validation; existing components are identified separately.
The generator must consume a validated, versionable model and produce owned outputs while preserving authored behavior. The model designer, CLI and build integration must use the same validation and generation services.
Model requirements
A model revision must identify its type definitions, properties, relationships, constraints and referenced extension contracts. Types and properties require stable identities so that a rename can be distinguished from deletion and recreation.
The canonical model is declarative and versionable. The visual designer edits that model in the selected workspace. A serialization format can evolve with the implementation; its version and migration path must be explicit. The product must not maintain two independently editable “authoritative” models in C# and a database.
Authored C# can define application behavior, policy and generator contributions. Generated C# is a derived result.
Generation request and result
An illustrative contract exposes inputs and ownership without claiming a finished API:
public sealed record GenerationRequest(
string ModelRevisionId,
string WorkspaceId,
IReadOnlyList<string> GeneratorIds,
string ToolchainId);
public sealed record GeneratedOutput(
string RelativePath,
string GeneratorId,
string ContentHash);
public sealed record GenerationResult(
bool Succeeded,
IReadOnlyList<GeneratedOutput> Outputs,
IReadOnlyList<string> Diagnostics);public sealed record GenerationRequest(
string ModelRevisionId,
string WorkspaceId,
IReadOnlyList<string> GeneratorIds,
string ToolchainId);
public sealed record GeneratedOutput(
string RelativePath,
string GeneratorId,
string ContentHash);
public sealed record GenerationResult(
bool Succeeded,
IReadOnlyList<GeneratedOutput> Outputs,
IReadOnlyList<string> Diagnostics);The implementation must record input identity, generator version, configuration and resulting outputs. Paths are constrained to declared output roots. A generator cannot write into another generator's or the user's owned files merely because they share a workspace.
Ownership and regeneration
Generated files are identified in a manifest. Handwritten services, contributed renderers and adopted templates remain user-owned.
Repeated generation with the same normalized inputs and toolchain must produce equivalent outputs. Removing a generated artifact must affect only previously owned output. Generation failure must leave diagnostics and a recoverable workspace, rather than a misleading mixture presented as a successful candidate.
Initial templates may be created explicitly as user-owned starting material. Regeneration must not later reclaim them silently.
Model changes and persistence
A Product field rename should retain its model identity. Changing its type, nullability or relationship can require a different compatibility and migration plan. A destructive change must be visible in that plan.
EF Core 11 mappings and migrations are generated or authored according to the persistence provider's capabilities. The source-generation result alone does not prove that a migration is safe against the target data. Validation must include the actual provider and schema transition.
The optional data-merge toggle governs promotion between instances. It does not switch off schema compatibility checks or required migrations.
Extension failures
Unknown contribution types, unavailable generator versions, invalid relationships and conflicting output ownership must produce targeted diagnostics. A customization that depends on a removed member must remain in place and fail visibly until resolved.
One model may produce multiple frontend implementations only when the selected generator/renderers supply them. A dynamic C# component is not automatically a static Hugo rendering.
Acceptance
GEN-01: changing the Product model updates configured outputs and preserves custom enquiry behavior.
GEN-02: rerunning generation is stable and leaves user-owned file hashes unchanged.
GEN-03: invalid models and output collisions fail with attributable diagnostics before release activation.
Module generation as a product explains the author-facing workflow.
Previous: Site and Domain Contracts · Next: Front: Pages, Areas, Zones and Widgets · Series index · Section index