Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation that all properties were assigned #47

Open
POnakS opened this issue Dec 4, 2024 · 0 comments
Open

Validation that all properties were assigned #47

POnakS opened this issue Dec 4, 2024 · 0 comments

Comments

@POnakS
Copy link

POnakS commented Dec 4, 2024

Hello, I think this library is good candidate for creating complex objects, i.e.

public ClassA
{  
    public required int Prop1 {get; init;}
    ...
    public required int PropN {get; init;}
}

However using this removes my compile-time safety, i.e. after adding PropN+1 existing builders will just assign default (0 or null) to it, rather than failing at compile time that PropN is not set.

I understand that doing such check at compile time may be not possible, however it would be nice to at least have possibility to do runtime check.

Proposed api:

    [BuilderFor(typeof(ClassA), Strict = true)]
    public partial class ClassABuilder
    {
    }

Then calling .Build() throws if WithPopX was called for each property, if no then it fails with exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant