Skip to content

Feature Request: Destructure only explicitly marked properties #171

@HaydenReeve

Description

@HaydenReeve

Is your feature request related to a problem? Please describe.

We suffer from the large class syndrome, where we often have many fields per class.

The current implementation only supports Opt-Out attributes, which in some circumstances can lead to excessive and undesirable attribute noise throughout a class.

Describe the solution you'd like

Adding Opt-In functionality would be a good addition.

Rather than only supporting Opt Out, like

public class LoginCommand 
{ 
    public string? Username { get; set; } 
 
    [NotLogged] 
    public string? Password { get; set; } 
} 

It would be nice to write something like

[Log(Destructure.OptIn)]
public class LoginCommand
{
    [LogWithName("UserName")]
    public string? Username { get; set; }

    public string? Password { get; set; }
}

So when it becomes

[Log(Destructure.OptIn)]
public class LoginCommand
{
    [LogWithName("UserName")]
    public string? Username { get; set; }

    public string? Password { get; set; }

    [LogWithName("Email")]
    public string? Email { get; set; }

    public string? And { get; set; }
    public string? Many { get; set; }
    public string? Other { get; set; }
    public string? Increasingly { get; set; }
    public string? Long { get; set; }
    public string? Fields { get; set; } // You get the idea...
}

It's a bit easier to manage.

Some inspiration was taken from similar serialization techniques within Newtonsoft.Json

[JsonObject(MemberSerialization.OptIn)]
public class LoginCommand { } 

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions