FinishWith for the whole generate set
- Dominant language
- C#
- Stars
- 9.7k
- Forks
- 538
- PR merge metrics
- No merged PRs in 30d
Description
I am happy to post this somewhere else if you have a uservoice or something. It would be nice if there was a way to do finishwith on a whole set. For instance, I want to generate a collection of objects and always have the first one set to primary.
Currently I have to do the following:
```
public static Faker GetBusinessEntityRules()
{
var rules = new Faker()
.RuleFor(o => o.Code, f => f.Random.AlphaNumeric(5))
.RuleFor(o => o.Dba, f => BogusDataSets.Company.CompanyName())
return rules;
}
// Get x
var z = BogusRules.GetBusinessEntityRules().Generate(5).ToList();
// Set the first to primary
z[0].Primary = true;
```
Instead it would nice to make the rule responsible for this:
```
public static Faker GetBusinessEntityRules()
{
var rules = new Faker()
.RuleFor(o => o.Code, f => f.Random.AlphaNumeric(5))
.RuleFor(o => o.Dba, f => BogusDataSets.Company.CompanyName())
.FinishCollectionWith(list) {
.... list[0].Primary = true... etc.
}
return rules;
}
```
Contributor guide
Research direction
Start by tracing the Faker generation flow and the RuleFor and Generate entry points shown in the issue. Define the collection-level behavior around Generate(5), including when the callback runs and how an empty collection is handled; done means a rule can set the first generated object's Primary property without post-processing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100