在调试器代理类上使用 [DebuggerDisplay("{OneLineAddress}")] 时,它似乎不起作用。有什么我做错了吗?或者在不向原始类添加代码的情况下以某种方式解决这个问题?
[DebuggerTypeProxy(typeof(AddressProxy))]
class Address
{
public int Number { get; set; }
public string Street { get; set; }
public string City { get; set; }
public string State { get; set; }
public int Zip { get; set; }
public Address(int number, string street, string city, string state, int zip)
{
Number = number;
Street = street;
City = city;
State = state;
Zip = zip;
}
[DebuggerDisplay("{OneLineAddress}")] // doesn't seem to work on proxy
private class AddressProxy
{
[DebuggerBrowsableAttribute(DebuggerBrowsableState.Never)]
private Address _internalAddress;
public AddressProxy(Address internalAddress)
{
_internalAddress = internalAddress;
}
public string OneLineAddress
{
get { return _internalAddress.Number + " " + _internalAddress.Street + " " + _internalAddress.City + " " + _internalAddress.State + " " + _internalAddress.Zip; }
}
}
}