Skip to content

Instantly share code, notes, and snippets.

@KenBonny
Created December 27, 2017 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KenBonny/2112b48214811d0123feb89e44bf307a to your computer and use it in GitHub Desktop.
Save KenBonny/2112b48214811d0123feb89e44bf307a to your computer and use it in GitHub Desktop.
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