DebuggerDisplay for a word / value pair of a dictionary?

Can I assign a dictionary definition to the System.Diagnostics.DebuggerDisplay attribute?

eg.

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>(); 
+4
source share
1 answer

EDIT : see also this answer .

I have not tried, but from the documentation you can apply this attribute at the assembly level. Therefore, theoretically, you can do something like this:

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

I would be surprised if this allows you to get away indicating Target , which is an open generic type, for example. Target = typeof(KeyValuePair<,>) , which will work for KVP of any type. But if you need it, it's worth a try!

+6
source

Source: https://habr.com/ru/post/1399212/


All Articles