RecordGenerator
RecordGenerator copied to clipboard
Proposal of Fluent Builder
Right not, here is available only basic builder that publicly allows assign any property in object.
I would like to propose new type of Fluent Builder that would have private constructor and public static method like Define()
which would initiate process of building desired object.
Such builder might have defined required fields that have to be specified before final Create()
would be available.
Here is an example:
[Record]
[RecordFluentBuilder]
partial class Company {
[RequiredField]
string Name { get; }
[RequiredField]
string Address { get; }
double Revenue { get; }
}
interface ICompanyBuilder {
ICompanyWithNameBuilder WithName(string name);
}
interface ICompanyWithNameBuilder {
ICompanyWithAddressBuilder WithAddress(string address);
}
interface ICompanyWithAddressBuilder {
ICompanyWithAddressBuilder WithRevenue(double revenue);
Company Create();
}