3 // Copyright (c) Microsoft Corporation. All rights reserved.
6 /*=============================================================================
10 ** Purpose: DebugView class for generic collections
12 ** <OWNER>Microsoft</OWNER>
15 =============================================================================*/
17 namespace System.Collections.Generic {
19 using System.Collections.ObjectModel;
20 using System.Security.Permissions;
21 using System.Diagnostics;
22 using System.Diagnostics.Contracts;
25 // VS IDE can't differentiate between types with the same name from different
26 // assembly. So we need to use different names for collection debug view for
27 // collections in mscorlib.dll and system.dll.
29 internal sealed class Mscorlib_CollectionDebugView<T> {
30 private ICollection<T> collection;
32 public Mscorlib_CollectionDebugView(ICollection<T> collection) {
33 if (collection == null)
34 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
36 this.collection = collection;
39 [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
42 T[] items = new T[collection.Count];
43 collection.CopyTo(items, 0);
49 internal sealed class Mscorlib_DictionaryKeyCollectionDebugView<TKey, TValue> {
50 private ICollection<TKey> collection;
52 public Mscorlib_DictionaryKeyCollectionDebugView(ICollection<TKey> collection) {
53 if (collection == null)
54 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
56 this.collection = collection;
59 [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
62 TKey[] items = new TKey[collection.Count];
63 collection.CopyTo(items, 0);
69 internal sealed class Mscorlib_DictionaryValueCollectionDebugView<TKey, TValue> {
70 private ICollection<TValue> collection;
72 public Mscorlib_DictionaryValueCollectionDebugView(ICollection<TValue> collection) {
73 if (collection == null)
74 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
76 this.collection = collection;
79 [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
80 public TValue[] Items {
82 TValue[] items = new TValue[collection.Count];
83 collection.CopyTo(items, 0);
89 internal sealed class Mscorlib_DictionaryDebugView<K, V> {
90 private IDictionary<K, V> dict;
92 public Mscorlib_DictionaryDebugView(IDictionary<K, V> dictionary) {
93 if (dictionary == null)
94 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.dictionary);
96 this.dict = dictionary;
99 [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
100 public KeyValuePair<K, V>[] Items {
102 KeyValuePair<K, V>[] items = new KeyValuePair<K, V>[dict.Count];
103 dict.CopyTo(items, 0);
109 internal sealed class Mscorlib_KeyedCollectionDebugView<K, T> {
110 private KeyedCollection<K, T> kc;
112 public Mscorlib_KeyedCollectionDebugView(KeyedCollection<K, T> keyedCollection) {
113 if (keyedCollection == null) {
114 throw new ArgumentNullException("keyedCollection");
116 Contract.EndContractBlock();
118 kc = keyedCollection;
121 [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
124 T[] items = new T[kc.Count];