Skip to content

New Rule : detect when passing properties of an anonymous type but forgetting the @ destructuring operator #28

@tsimbalar

Description

@tsimbalar

Following the advice from https://nblumhardt.com/2016/02/serilog-tip-dont-serialize-arbitrary-objects/ , it's quite a common pattern to use anonymous classes as a property to enrich a log event. In those case, it's important to remember to add the @ destructuring operator in the message template, or else, the ToString() behavior will be used.

It would be good to detect cases where the user has passed a property of an anonymous type, but forgot to add the @ operator. The code fix would be to add the missing operator in the template.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions