Repository navigation
Description
Parent and baseline
Part of #227. The current main supports explicit ConstructUsing(...) factories with 1–4 mapped root values through runtime materialization. The source generator currently skips such map constructors and emits DFM011 rather than producing a strict-generated materializer. This is a concrete gap; do not change the existing runtime factory contract.
Release: future compatible version, decided through .agents/skills/semantic-versioning/SKILL.md after validating the current 3.6.1 prepared/released state. Not a retroactive 3.6.0 or 3.6.1 feature.
Goal
Generate deterministic construction for a bounded set of statically resolvable explicit factories, preserving exact runtime semantics and rejecting arbitrary closures/delegates rather than reflecting or silently falling back in strict mode.
Scope
Static factory eligibility
- Inventory each supported
ConstructUsingoverload and binding contract on currentmain(including root-property inputs, arity, construction strategy and converter/null precedence). - Determine symbol-based eligibility for accessible static factory methods or other statically provable non-capturing forms; do not infer arbitrary expression meaning from text.
- Require deterministic callable, argument order, types, mapping paths and null behavior. Document accessibility/generic/method-group constraints.
- Retain
DFM011or a more precise, non-conflicting diagnostic for unsupported captures, dynamic delegates, helper indirection and unresolvable symbols; preserveDFM016on conflicting construction strategies.
Generated execution
- Emit compile-time-safe direct factory invocation for eligible forms, with no
MethodInfo.Invoke,DynamicInvoke, compiled-expression runtime fallback or hidden global dependencies. - Reuse the existing generated converter/read helpers when valid; preserve the current error contract, nullable handling, profile identity and strict reader-shape rules.
- Ensure non-strict runtime factory behavior remains unchanged.
Tests, evidence, documentation
- Positive: static factory, multi-argument construction (within supported arities), nullable and converted values, immutable value-object, mapping profile where supported.
- Negative: closures/captures, inaccessible factories, ambiguous/unsupported forms, duplicate/invalid construction, missing/duplicate columns and conversion failure.
- Compare generated and runtime results/errors for equivalent supported shapes; test strict refusal to fall back.
- Document exact eligible factory forms and unsupported alternatives in generator/usage/compatibility docs; add bounded Native AOT smoke only for a shape actually certified.
Out of scope
- Parsing arbitrary lambda bodies or searching for unrelated factory names.
- Extending
ConstructUsingpublic arity beyond 1–4. - Runtime code generation, graph persistence, SQL generation or broad 4.0 API redesign.
- General nested construction beyond the specific factory composition needed here ([Generated coverage] Audit and close strict nested/value-object materialization gaps #229).
DoR
- Current
mainbaseline, existingConstructUsingruntime tests,DFM011andDFM016verified. - Eligible and ineligible factory syntax/symbol shapes recorded before implementation.
- Current release preparation and SemVer policy checked; shared branch created from up-to-date
main.
Acceptance
- An eligible explicit factory successfully materializes a strict-generated result without runtime reflection.
- Generated/runtime values, null rules and contextual exceptions are equivalent for supported shapes.
- Ineligible factories have deterministic generator/strict diagnostics, without false positive support claims.
- Existing
ConstructUsingpublic/runtime compatibility remains intact.
DoD and delivery
- Generator + analyzer + strict/runtime regression tests added, with positive/negative cases.
- XML/PublicAPI baselines updated only for justified public additions; no breaking change introduced implicitly.
- Performance/Native AOT evidence recorded for newly claimed behavior.
- Relevant EN/PT-BR documentation and compatibility limits updated.
- Commit/push to shared
roadmap/generated-coverage-followupsbranch; do not open an intermediate PR. [Generated coverage] Certify strict support matrix, compatibility and cumulative delivery #232 opens the cumulative PR.
Dependencies: parent #227; #229 follows where nested factories need this capability. #230 is closed and not a blocker.
Activity
[-][3.6] Generate explicit construction strategies for strict materialization[/-][+][Generated coverage] Support statically resolvable ConstructUsing factories in strict mode[/+]