Skip to content

[Generated coverage] Support statically resolvable ConstructUsing factories in strict mode #228

Open

Description

@rodri-oliveira-dev

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 ConstructUsing overload and binding contract on current main (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 DFM011 or a more precise, non-conflicting diagnostic for unsupported captures, dynamic delegates, helper indirection and unresolvable symbols; preserve DFM016 on 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

DoR

  • Current main baseline, existing ConstructUsing runtime tests, DFM011 and DFM016 verified.
  • 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 ConstructUsing public/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-followups branch; 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

  1. changed the title [-][3.6] Generate explicit construction strategies for strict materialization[/-] [+][Generated coverage] Support statically resolvable ConstructUsing factories in strict mode[/+] on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions