Compono.CompositionBuilder
Compono¶
Compono¶
CompositionBuilder Class¶
Mutable configuration accumulator for a Composer, live only for the duration of the Create(Action<CompositionBuilder>) callback that receives it.
Inheritance System.Object → CompositionBuilder
Remarks¶
Every accumulated setting is validated and frozen into an immutable Compono.CompositionConfiguration once the callback returns - nothing about a later Create<T>()/ CreateMany<T>(int) call can observe a mutation made after that point, since this instance is never reachable again. See docs/adr/0017-immutable-composer-configuration-and-builder-model.md.
| Methods | |
|---|---|
| AddProfile(ICompositionProfile) | Applies profile's Configure(CompositionBuilder) to this builder immediately, synchronously - the instance-based counterpart to AddProfile<TProfile>(), for a profile that needs constructor arguments or is already an instance. |
| AddProfile<TProfile>() | Applies TProfile's Configure(CompositionBuilder) to this builder immediately, synchronously - constructed via an ordinary, reflection-free new(). |
| AddSemanticProvider(ICompositionValueProvider) | Registers provider into pipeline stage 5 (semantic value providers) - the open-ended, pattern-matching extension point an integration package (e.g. a future Compono.Bogus) uses instead of a closed-set For<T>() rule. See docs/adr/0024-public-provider-extensibility-model.md. |
| AddTestDoubleProvider(ICompositionValueProvider) | Registers provider into pipeline stage 6 (test-double providers) - the open-ended, pattern-matching extension point an integration package (e.g. Compono.NSubstitute) uses instead of a closed-set For<T>() rule. See docs/adr/0024-public-provider-extensibility-model.md. |
| For<T>() | Starts a type or member configuration rule for T - calling .Use(...) directly registers a type rule (matches any stage-4 request for exactly T, regardless of which member/position requested it); calling .Member(x => x.Y) first registers a member rule instead (matches only requests for that exact declaring type/member pair). See docs/adr/0020-composition-configuration-rules.md. |
| Register<T>(Func<ICompositionContext,T>) | Registers an exact-type factory for T - pipeline stage 3 (docs/architecture.md) resolves T by invoking factory, called through ICompositionContext exactly like generated code's own resolution, so factory can call Resolve<TValue>() to compose nested dependencies. |
| Register<T>(Func<T>) | Registers an exact-type factory for T with no dependency on the resolving context - the convenience overload for Register<T>(Func<ICompositionContext,T>)'s common no-dependency case (e.g. Register<IClock>(() => new FakeClock())). |
| UseServiceProvider(IServiceProvider) | Configures a native System.IServiceProvider as stage 3's fallback for a type with no exact Register<T>(Func<ICompositionContext,T>) entry - tried only after every exact registration misses, before falling through to stage 4. See docs/adr/0019-registrations-and-service-provider-injection.md for the full ordering and null/exception/wrong-type semantics. |
| WithCollectionSize(int) | Sets this composer's global default collection size - the size a generated collection plan builds when no member-scoped .For<T>().Member(x => x.Y).WithCollectionSize(...) override applies. Falls back to the built-in size of 3 if never called. See docs/adr/0020-composition-configuration-rules.md. |
| WithSeed(int) | Sets this composer's explicit root seed - the same seed produces the same composed output (for a given Compono package version) across every Create<T>()/ CreateMany<T>(int) call this composer ever serves. Without this call, each root composition operation generates its own seed. |