Sep 13, 2010 at 7:01 PM

A couple of improvements to help when debugging:

Add Attribute: [System.Diagnostics.DebuggerDisplay("Count = {Count}")]

Add Attribute: [System.Diagnostics.DebuggerTypeProxy(typeof(DebugView<,>))]

Add inner class:
private class DebugView<TKey2, TValue2>
    private ReadOnlyDictionary<TKey2, TValue2> _d;
    public DebugView(ReadOnlyDictionary<TKey2, TValue2> d) { _d = d; }
    public KeyValuePair<TKey2, TValue2>[] Items { get { return _d.ToArray(); } }

It might also be a good idea to implement the non-generic IDictionary interface. Sometimes it is helpful to be able to access a collection without generics.

Sep 14, 2010 at 5:13 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Sep 14, 2010 at 5:13 PM

Thank you for the suggestions, dump247.  I initially considered implementing the debug view types for ReadOnlyDictionary, but had to work on some other things and didn't want to spend too much time on the class.  My mitigating rationale to leaving it as-is, is that ReadOnlyDictionary contains only one field, which will render appropriately in the debugger when expanded.

Nevertheless, this will add completeness to the type and I will surely implement it in the future.