-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
theory craftingLet's discuss ideasLet's discuss ideas
Description
What about generating additional extension methods for optional properties which can be populated in any order after fluent builder was fully executed?
Example:
[FluentApi]
public class Student
{
[FluentMember(0)]
public string FirstName { get; private set; }
[FluentMember(1)]
public string LastName { get; private set; }
...
public string? FavoriteFood { get; private set; }
public string? Hobby { get; private set; }
}
Usage:
Student alice1 = CreateStudent
.WithFirstName("Alice").
.WithLastName("TestName")
.WithHobby("Reading")
.WithFavoriteFood("Pizza");
Student alice2 = CreateStudent
.WithFirstName("Alice").
.WithLastName("TestName")
.WithFavoriteFood("Pizza")
.WithHobby("Reading");
Generated code (pseudo code):
public static Student WithHobby(this Student student, string hobby)
{
student.Hobby = hobby; // Probably set via reflection
return student;
}
Metadata
Metadata
Assignees
Labels
theory craftingLet's discuss ideasLet's discuss ideas