Skip to content

Add an option to remove type tag #252

@rafal-marciniak

Description

@rafal-marciniak

Is your feature request related to a problem? Please describe.
Serilog adds the type tag property $type when destructuring objects. It's kind of redundant in many cases and also makes the logs grow bigger (especially in large collections of small objects, whare an additional $type property repeats a lot).

{
  "Users": [
    {
      "Login": "test1",
      "Id": 12345,
      "$type": "UserViewModel"
    },
    {
      "Login": "test2",
      "Id": 98765,
      "$type": "UserViewModel"
    }
  ]
}

Describe the solution you'd like
Would you kindly add an option to skip passing type name when constructing StructureValue inside AttributedDestructuringPolicy. To my understanding that should to the trick. Example:

.Destructure.UsingAttributes(opt =>
{
    ....
    opt.SkipTypeTag = true;
})

Then check it here probably?

return new StructureValue(structureProperties, type.Name);

Now I do understand that implementing a custom text formatter would allow us to go through all the properties and remove the type tags manually. But it seems inefficient and prone to implementation errors. Supporting this feature inside Destructurama.Attributed package feels more natural.

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