Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 436 Bytes

ComplexObjectInContextDestructuringProblem.md

File metadata and controls

29 lines (21 loc) · 436 Bytes

Complex objects with default ToString() implementation probably need to be destructured

Noncompliant Code Example:

class User
{
    public int Age { get; set; }
}

...

LogContext.PushProperty("User", new User());

Compliant Solution:

class User
{
    public int Age { get; set; }
}

...

LogContext.PushProperty("User", new User(), true);

// or

LogContext.PushProperty("User", new User(), false);