using VarDump.Visitor.Descriptors;
using VarDump.Visitor.Descriptors.Specific;
CardNumber = "4953089013607",
CardNumber = "5201294442453002",
var options = new DumpOptions
new ObjectContentReplacer { Replacement = MaskCardNumber }
var csDumper = new CSharpDumper(options);
var cs = csDumper.Dump(obj);
var vbDumper = new VisualBasicDumper(options);
var vb = vbDumper.Dump(obj);
static ReflectionDescription MaskCardNumber(ReflectionDescription description)
if (!IsCardNumber(description) || string.IsNullOrWhiteSpace((string)description.Value))
var stringValue = (string)description.Value;
var maskedValue = stringValue.Length - 4 > 0
? new string('*', stringValue.Length - 4) + stringValue.Substring(stringValue.Length - 4)
static bool IsCardNumber(ReflectionDescription description)
return description.Type == typeof(string)
&& description.Name?.EndsWith("cardnumber", StringComparison.OrdinalIgnoreCase) == true;