I'm building a user management system, with a domain host to which I am sending commands. The commands are records both because of the init-only properties and because of the generated helper methods. However, I quickly ran into a problem with this approach for e.g. the LoginUserCommand.
command.ToString() returns something like this (formatting added):
LoginUserCommand {
Identity = 10000000-1111-2222-3333-444444444444,
CorrelationId = 20000000-1111-2222-3333-444444444444,
Timestamp = 2013-07-26T16:45:20Z,
IssuingUserId = 30000000-1111-2222-3333-444444444444,
EntityId = a80c081c-cf91-4304-9baa-20fb20c8d9f7,
IPAddress = 127.0.0.1,
Password = ThisIsAPr0blem
}
Obviously I can work around this by e.g. overriding ToString() on the classes where it matters. Naïvely, I might do something like
public override string ToString()
{
return base.ToString()
.Replace(Password, "********");
}
But I'm wondering whether I've overlooked some built-in way to have the generated ToString() method mask the value of the Password property.