---
updatedAt: 2025-05-05T20:57:22.000Z
agentTools:
  projectIndex: https://dossier.teststack.net/llms.txt
---

# Sharing anonymous value fixture

Within a particular instance of `AnonymousValueFixture`, which is created for every builder, any generators that return a sequence of values (e.g. unique values) will be maintained. If you want to ensure that the same anonymous value fixture is used across multiple related builders then:

* Using `CreateListOfSize` will automatically propagate the anonymous value fixture across builders
* Call the `GetChildBuilder<TChildObject, TChildBuilder>(Func<TChildBuilder, TChildBuilder> modifier = null)` method from within your custom builder, e.g.:

```csharp
public MyCustomBuilder WithSomeValue(Func<SomeBuilder, SomeBuilder> modifier = null)
{
	return Set(x => x.SomeValue, GetChildBuilder<SomeObject, SomeBuilder>(modifier));
}
```

* If using `Builder<T>` then call the `SetUsingBuilder` method, e.g.:

```csharp
// Uses Builder<T>
Builder<StudentViewModel>.CreateNew()
	.SetUsingBuilder(x => x.Address)
	.Build();
	
// Uses Builder<T>, includes customisation
Builder<StudentViewModel>.CreateNew()
	.SetUsingBuilder(x => x.Address, b => b.Set(y => y.Street, "A street"))
	.Build();
	
// Uses AddressBuilder
Builder<StudentViewModel>.CreateNew()
	.SetUsingBuilder<AddressViewModel, AddressViewModelBuilder>(x => x.Address)
	.Build();
	
// Uses AddressBuilder, includes customisation
Builder<StudentViewModel>.CreateNew()
	.SetUsingBuilder<AddressViewModel, AddressViewModelBuilder>(x => x.Address, b => b.Set(y => y.Street, "A street"))
	.Build();
```

* If you want to use the anonymous value fixture to generate a value for a specific test then you can use the [Set method overload with a lambda expression](https://dossier.teststack.net/docs/basic-builder-methods), e.g.:

```csharp
var student = Builder<StudentViewModel>.CreateNew()
    .Set(x => x.FirstName, any => any.FirstName())
    .Build();
```

There is currently no way to share an anonymous value fixture across unrelated builder instances. If this is something you need please raise an issue so we can discuss your requirement.