2012-03-01 2 views
4

사전 정의에 System.Diagnostics.DebuggerDisplay 특성을 할당 할 수 있습니까?사전의 키/값 쌍에 대한 Debugger 표시?

Dictionary<int, SomeClass> 
[System.Diagnostics.DebuggerDisplay("{Info,nq}")] 
public class SomeClass{ 

    string code {get;set;} 

    public string Info { get { return "info" + code; }} 
} 


// place an attribute here?? 
[System.Diagnostics.DebuggerDisplay("{???,nq}")] 
Dictionary<int, SomeClass> dict = new Dictionary<int, SomeClass>(); 

답변

6

편집 : 또한 this answer 참조하십시오.

나는 그것을 시도하지는 않았지만 문서에서 어셈블리 레벨에서이 속성을 적용 할 수 있습니다.

[assembly: DebuggerDisplay("{Key,nq}: {Value,nq}", Target = typeof(KeyValuePair<int, SomeClass>))] 

나는 당신이 열려있는 제네릭 형식, 예를하는 Target를 지정하여 도망 할 경우 놀랠 것입니다 : 그래서 이론적으로, 당신이 뭔가를 할 수 있습니다 Target = typeof(KeyValuePair<,>) 어떤 유형의 KVP에서도 작동합니다. 그러나 필요한 경우 시도해 볼 가치가 있습니다!