Skip to content

[Feature]: Composed theory data rows: vary profile configuration and expected values per row in one method #163

Closed

Description

@ncipollina

Child of #161 (item 3). Split out during feature intake. The shapes named in this issue (several [Compose<TProfile, TConfig>(...)] attributes, [InlineData]/[MemberData] interop, a static-member config source) are candidates to compare. None is an approved design.

Motivation

Consumer scenario (#161, Compono 1.3.2 migration): a table-driven theory where each row varies composed configuration (option values, a clock instant) together with expected values. A 6-row table became 6 test methods plus a shared assertion helper. DateTimeOffset and other values that aren't attribute-legal need a string stand-in in the config record.

What Compono does today (validated against main):

  • Exactly one Compose-family attribute per test method. AllowMultiple = false makes a second instance of the same closed attribute type a compiler error. Different closed types ([Compose] + [Compose<P>]) compile but are rejected at runtime by BindingPlan.ValidateSignature (Compono.XunitV3), and at compile time by CMP0045 (Compono.XunitV3.Aot).
  • ADR-0022 Decision Outcome rejected both stacking Compose attributes and combining [Compose] with [InlineData]/[MemberData]. ADR-0022 Amendment 7 (2026-08-04) kept that restriction only because no real call site existed yet and left a pointer for future dogfooding evidence. [Feature]: Test-composition gaps: cross-category log capture, metrics testing, multi-attribute theories and runtime values in profiles #161 is the first real call site.
  • [Compose<TProfile, TConfig>(...)] arguments must be attribute constants (ADR-0036). [Compose(42, ...)] inline values exist on the JIT package but not yet on Compono.XunitV3.Aot (deferred phase per PLAN-0066/0067).
  • Compono.XunitV3's ComposeAttribute returns one row with SupportsDiscoveryEnumeration() => false. The AOT path registers RegisteredEngineConfig.RegisterTheoryDataRowFactory(...), whose factory already returns IReadOnlyCollection<ITheoryDataRow>. That makes multi-row emission structurally available on the AOT path without a parallel mechanism.

Workaround in use: one test method per row plus a shared assertion helper, and string stand-ins for non-constant config values.

Classification: a missing capability. The restriction is a documented, intentional limit (ADR-0022 and Amendment 7), not a bug. This is the evidence Amendment 7 said would justify reopening it.

Proposed solution

Consumer requirement (outcome, not API): one theory method can express N cases. Each case can vary (a) the profile configuration applied to composition, (b) any non-composed values the test needs (expected results), and (c) values not expressible as attribute constants. Each case is reported and reproducible as its own row.

Acceptance criteria

  • A single test method can declare multiple rows, each with its own profile configuration and its own non-composed (expected) values. Composed parameters are still composed per row.
  • A row can carry configuration values that are not attribute constants (for example DateTimeOffset) without a string stand-in, or the ADR explicitly scopes this out with a justification.
  • Each row gets its own seed, Compono.Seed trait and failure message. Row identity and display names are deterministic and distinguishable in test explorers and CI output.
  • Supported on Compono.XunitV3 and Compono.XunitV3.Aot with equivalent semantics, or an explicit, documented divergence. The AOT path builds on the existing RegisterTheoryDataRowFactory emission, not a parallel mechanism.
  • Invalid combinations are rejected with clear diagnostics: compile-time CMPxxxx where the generator can see the shape, and clear CompositionExceptions on the JIT path.
  • Existing single-attribute tests are unchanged (source and behavior).
  • A cross-framework position for Compono.TUnit/Compono.NUnit/Compono.MSTest is recorded: in scope, deferred, or not applicable.

Relevant packages: Compono.XunitV3, Compono.XunitV3.Aot, Compono.Generators (AOT emission, diagnostics, possibly JIT-side discovery), and core Compono only if row binding needs a new seam. The other framework packages are affected only through the consistency question.

Research questions (design dive before an ADR)

  1. Which shape? Compare at least:
    (a) several Compose-family attributes per method, one row each (needs AllowMultiple = true, a public attribute-contract change, and reverses the ADR-0022 restriction);
    (b) [Compose...] plus xUnit's own [InlineData]/[MemberData]/[ClassData], with xUnit supplying the leading non-composed values and Compono composing the rest;
    (c) a Compono-owned row source (for example a static member returning rows of config plus expected values), MemberData-style;
    (d) a hybrid.
    Weigh discoverability, IDE experience, AOT feasibility, and fit with xUnit idioms (capability-admission Gate A criterion 2).
  2. How do xUnit v3 (JIT) and xUnit v3 AOT combine rows from multiple data sources on one method? What happens to row identity when a SupportsDiscoveryEnumeration() == false source is involved (one test case versus N in Test Explorer)?
  3. Binding: positional versus named binding of non-composed values; how inline values, profile configuration arguments and composed parameters coexist without ambiguity (ADR-0036 already separates "inline values" from "profile configuration arguments").
  4. Non-constant config: is a static member reference (field, property or method) acceptable under the generator-first, no-reflection posture? On JIT, MemberData uses reflection; on AOT the generator must emit a direct call. Which member shapes get diagnostics?
  5. Composer and profile caching per row: today the composer is cached per attribute instance. What changes when one method has N configurations?
  6. Does the AOT inline-values gap (deferred in PLAN-0066/0067) need to close first, or can rows vary config only?
  7. Cross-framework: do TUnit/NUnit/MSTest need the same capability now, or does each framework's own row model (TUnit data sources, NUnit IParameterDataSource) make it a separate question?

Compatibility / AOT / performance: any AllowMultiple or attribute-shape change is public API, so stay additive only. New CMPxxxx diagnostics. Generated row factories stay low-allocation. JIT-path reflection must not grow beyond the existing ConfigProfileBinder pattern without justification.

Explicit non-goals

Relationship / dependencies: child of #161 (item 3). Reopens the question ADR-0022 Amendment 7 deferred, so the outcome should be recorded as a new ADR or a dated amendment, per the ADR rules. Soft dependency on #162 (runtime fixture values): both are about feeding non-constant values into profile configuration, so research question 4 should be answered with that item's outcome in view and not settled independently. Possible dependency on AOT inline-value support (PLAN-0066/0067 deferred phase).

Suggested process: deep design dive (more than one plausible shape, several packages, public attribute contract), then an ADR. A short research note may be needed for xUnit multi-source row semantics (question 2), which should be verified empirically. Highest architectural risk of the four #161 items.

Activity

  1. added
    💡 idea
    on Nov 4, 2026
  2. ncipollina commented on Nov 4, 2026

    @ncipollina
    ContributorAuthor

    Design constraint from #162: composed rows must stay execution-time (delayed-enumerated).

    RESEARCH-0037 §4–§6 and §12 established this, and it's carried forward as ADR-0069's "Constraint carried forward". (The research doc, ADR-0069 and PLAN-0070 are on the upcoming feat/162-require-fixture branch and aren't merged to main yet, so these links resolve once that lands.)

    Why it matters. #162's supported way for a profile to read an xUnit fixture (TestContext.Current.GetFixture(...) today, TestContext.Current.RequireFixture<TFixture>() per ADR-0069) works only because Compono composes theory rows during test-method execution, after xUnit has created and initialized every class, collection and assembly fixture:

    • Compono.XunitV3: ComposeAttribute.SupportsDiscoveryEnumeration() => false
    • Compono.XunitV3.Aot: the generated RegisterTheoryDataRowFactory(..., disableDiscoveryEnumeration: true, ...)

    We verified it under JIT and a real Native AOT publish (xUnit 4.0.1). Profile construction, Configure, and registration factories all ran at TestPipelineStage.TestMethodExecution with fixtures available. None ran during discovery.

    Constraint for #163's design.

    1. Don't pre-enumerate or cache composed rows at discovery time (e.g. to give each row its own display or ID up front). A row composed during discovery has no running test class and no fixtures, so fixture-backed profiles would break. If [Feature]: Composed theory data rows: vary profile configuration and expected values per row in one method #163 needs discovery-time rows, its ADR must explicitly redesign fixture access and document the consequence.
    2. Don't rely on Configure-time state for per-row values. Compono.XunitV3 (JIT) runs TProfile.Configure once per attribute instance (a Lazy<Composer>), while Compono.XunitV3.Aot runs it per row. Per-row variation has to flow through registration factories or a new explicit mechanism, not through state captured in Configure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    💡 idea

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions