Skip to content

Validation that all properties were assigned #47

@POnakS

Description

@POnakS

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions