Instantly share code, notes, and snippets.

Embed
What would you like to do?
DebuggerDisplayAttribute experiment
public class DebuggerAttributeTests
{
[Fact]
public void DebuggerTests()
{
var person = new Person
{
Id = 1,
Name = "Ken Bonny",
Birthday = new DateTime(1987, 1, 1)
};
var order = new Order
{
Id = 1,
Person = person
};
var personToString = new PersonToString
{
Id = 1,
Name = "Ken Bonny",
Birthday = new DateTime(1987, 1, 1)
};
order.Person = personToString;
var personDebugger = new PersonDebuggerAttribute
{
Id = 1,
Name = "Ken Bonny",
Birthday = new DateTime(1987, 1, 1)
};
order.Person = personDebugger;
var orderToString = new OrderToString
{
Id = 1,
Person = person
};
orderToString.Person = personToString;
orderToString.Person = personDebugger;
var orderDebugger = new OrderDebuggerAttribute
{
Id = 1,
Person = person
};
orderDebugger.Person = personToString;
orderDebugger.Person = personDebugger;
}
}
internal class Person
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime Birthday { get; set; }
}
internal class PersonToString : Person
{
public override string ToString()
{
return $"ToString {Name} ({Id}): {Birthday}";
}
}
[DebuggerDisplay("Attribute {Id} - {Name} ({Birthday})")]
internal class PersonDebuggerAttribute : Person
{
}
internal class Order
{
public Order()
{
ProductId = Guid.NewGuid();
}
public int Id { get; set; }
public Guid ProductId { get; set; }
public Person Person { get; set; }
}
internal class OrderToString : Order
{
public override string ToString()
{
return $"ToSTring {Id}: {Person}";
}
}
[DebuggerDisplay("Attribute ({Id}){Person}")]
internal class OrderDebuggerAttribute : Order
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment