When dealing with various dto's and other classes that contains data, we are often faced with sensitive data like passwords. I would like to be able to put an annotation on those fields which then ensures that they are not included fully in any ToString methods, but instead masked in some way.
Describe the solution you'd like
A possible solution could be:
[ToString]
public partial class CreateProfileRequest {
public string Name{get;set;}
[Masked]
public string Password{get;set;}
}
Which should then generate a ToString method that would output something like:
{Name="MyName", Password="*********"}
Describe alternatives you've considered
Currently for logging to serilog, I'm using destructurama:
https://github.com/destructurama/attributed
This has a method callec [LogMasked] which takes parameters like PreserveLength=true|false, ShowFirst=3, ShowLast=2 which can affect how the masking is added
Besides the mentioned annotations above, it would be good to also have ways to exclude specific properties from the ToString method
I have added a [Masked] attribute. Adding attributes like in destructurama would require some more work, which is why I won't do this right now. If you need this soon, feel free to open a PR or let me know.
When dealing with various dto's and other classes that contains data, we are often faced with sensitive data like passwords. I would like to be able to put an annotation on those fields which then ensures that they are not included fully in any ToString methods, but instead masked in some way.
Describe the solution you'd like A possible solution could be:
Which should then generate a ToString method that would output something like:
Describe alternatives you've considered Currently for logging to serilog, I'm using destructurama: https://github.com/destructurama/attributed This has a method callec
[LogMasked]
which takes parameters likePreserveLength=true|false
,ShowFirst=3
,ShowLast=2
which can affect how the masking is addedBesides the mentioned annotations above, it would be good to also have ways to exclude specific properties from the ToString method