Skip to content

Compono.CompositionRow

Compono

Compono

CompositionRow Class

One composition scope for several sibling top-level parameter requests - e.g. one xUnit theory row's own method parameters - sharing one seed, one shared-value scope, and one pre-rooted path.

public sealed class CompositionRow : Compono.ICompositionContext

Inheritance System.Object → CompositionRow

Implements ICompositionContext

Remarks

Obtained via CreateRow(Type), never constructed directly. Implements ICompositionContext by forwarding to the internal Compono.CompositionContext it wraps, so a value that itself needs further nested composition (a generated plan's own context.Resolve<T>(descriptor) calls) is unaffected - generated code never sees this type, only the interface. ResolveShared<TValue>(CompositionRequestDescriptor)/ShareExplicit<TValue>(CompositionRequestDescriptor, TValue) are new members with no equivalent on ICompositionContext - they exist only here, for a test-framework integration that holds this concrete type directly. See docs/adr/0021-row-composition-entry-point-for-test-framework-integrations.md.

Properties
Seed This row's root deterministic seed - matches WithSeed(int)'s int contract exactly, so a value read here is always pasteable directly into a seed-configuration API that reports it (e.g. a test-framework integration's own attribute).
Methods
DeriveSeed() Derives a deterministic System.Int32 seed from this context's root seed and the request currently being resolved - usable to seed a caller-owned PRNG (e.g. a Bogus.Randomizer) without exposing the engine's own internal random source or path representation. The same root seed and the same request path always derive the same value; a different path (a different member, a different constructor parameter, a different element of a collection) always derives independently. Calling this method repeatedly for the same active request returns the same value every time - it does not advance any stream, and does not perturb any other value's own derivation. Valid in the same scope as Resolve<TValue>(): from inside a registration or configuration-rule factory, or a public TryProvide(CompositionProviderRequest, ICompositionContext) invocation. See docs/adr/0026-deterministic-seed-derivation-for-providers.md.
Resolve<TValue>() Resolves a value of type TValue from inside a registration or configuration-rule factory, or a public TryProvide(CompositionProviderRequest, ICompositionContext) invocation - the hand-written counterpart to Resolve<TValue>(CompositionRequestDescriptor), which only generated code calls. Only valid while one of those three is actively being invoked.
Resolve<TValue>(CompositionRequestDescriptor) Resolves a value of type TValue for one constructor parameter or required member.
ResolveCollectionSize() Resolves the collection size a generated collection plan should build - the size a member-scoped WithCollectionSize override configures for the collection member currently being resolved, falling back to the global default, then the built-in size of 3. Parameterless: the context already knows the current request's declaring type/member name (the same identity .For<T>().Member(...) rule matching uses), since a collection plan's Compose(ICompositionContext) has no descriptor to pass. See docs/adr/0020-composition-configuration-rules.md.
ResolveShared<TValue>(CompositionRequestDescriptor) Composes TValue through the same pipeline Resolve<TValue>(CompositionRequestDescriptor) uses, and additionally stores the successful result into this row's shared scope - a later request for the same type in this row, including one made by a nested generated plan, reuses it instead of composing its own independent value.
ShareExplicit<TValue>(CompositionRequestDescriptor, TValue) Stores value - already known, not composed - as this row's shared value for TValue, after the same authoritative validation a successful ResolveShared<TValue>(CompositionRequestDescriptor) pipeline result gets. No pipeline dispatch, no random fork consumed - there is nothing left to compose.