diff options
12 files changed, 129 insertions, 138 deletions
diff --git a/src/mscorlib/System.Private.CoreLib.csproj b/src/mscorlib/System.Private.CoreLib.csproj index 53f8b985d8..f418f92de6 100644 --- a/src/mscorlib/System.Private.CoreLib.csproj +++ b/src/mscorlib/System.Private.CoreLib.csproj @@ -582,7 +582,6 @@ <Compile Include="$(BclSourcesRoot)\System\Collections\Generic\ComparerHelpers.cs" /> <Compile Include="$(BclSourcesRoot)\System\Collections\Generic\Dictionary.cs" /> <Compile Include="$(BclSourcesRoot)\System\Collections\Generic\EqualityComparer.cs" /> - <Compile Include="$(BclSourcesRoot)\System\Collections\Generic\DebugView.cs" /> <Compile Include="$(BclSourcesRoot)\System\Collections\Generic\ArraySortHelper.cs" /> <Compile Include="$(BclSourcesRoot)\System\Collections\ObjectModel\ReadOnlyDictionary.cs" /> <Compile Include="$(BclSourcesRoot)\System\Collections\Concurrent\ConcurrentStack.cs" /> diff --git a/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems b/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems index af843b84d6..fccaa2f5ed 100644 --- a/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/mscorlib/shared/System.Private.CoreLib.Shared.projitems @@ -54,8 +54,10 @@ <Compile Include="$(MSBuildThisFileDirectory)System\CLSCompliantAttribute.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Collections\DictionaryEntry.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\ICollection.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\ICollectionDebugView.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IComparer.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IDictionary.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IDictionaryDebugView.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IEnumerable.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IEnumerator.cs" /> <Compile Include="$(MSBuildThisFileDirectory)System\Collections\Generic\IEqualityComparer.cs" /> diff --git a/src/mscorlib/shared/System/Collections/Generic/ICollectionDebugView.cs b/src/mscorlib/shared/System/Collections/Generic/ICollectionDebugView.cs new file mode 100644 index 0000000000..9916e857e2 --- /dev/null +++ b/src/mscorlib/shared/System/Collections/Generic/ICollectionDebugView.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; + +namespace System.Collections.Generic +{ + internal sealed class ICollectionDebugView<T> + { + private readonly ICollection<T> _collection; + + public ICollectionDebugView(ICollection<T> collection) + { + if (collection == null) + { + throw new ArgumentNullException(nameof(collection)); + } + + _collection = collection; + } + + [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] + public T[] Items + { + get + { + T[] items = new T[_collection.Count]; + _collection.CopyTo(items, 0); + return items; + } + } + } +} diff --git a/src/mscorlib/shared/System/Collections/Generic/IDictionaryDebugView.cs b/src/mscorlib/shared/System/Collections/Generic/IDictionaryDebugView.cs new file mode 100644 index 0000000000..4721642fee --- /dev/null +++ b/src/mscorlib/shared/System/Collections/Generic/IDictionaryDebugView.cs @@ -0,0 +1,80 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; + +namespace System.Collections.Generic +{ + internal sealed class IDictionaryDebugView<K, V> + { + private readonly IDictionary<K, V> _dict; + + public IDictionaryDebugView(IDictionary<K, V> dictionary) + { + if (dictionary == null) + throw new ArgumentNullException(nameof(dictionary)); + + _dict = dictionary; + } + + [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] + public KeyValuePair<K, V>[] Items + { + get + { + KeyValuePair<K, V>[] items = new KeyValuePair<K, V>[_dict.Count]; + _dict.CopyTo(items, 0); + return items; + } + } + } + + internal sealed class DictionaryKeyCollectionDebugView<TKey, TValue> + { + private readonly ICollection<TKey> _collection; + + public DictionaryKeyCollectionDebugView(ICollection<TKey> collection) + { + if (collection == null) + throw new ArgumentNullException(nameof(collection)); + + _collection = collection; + } + + [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] + public TKey[] Items + { + get + { + TKey[] items = new TKey[_collection.Count]; + _collection.CopyTo(items, 0); + return items; + } + } + } + + internal sealed class DictionaryValueCollectionDebugView<TKey, TValue> + { + private readonly ICollection<TValue> _collection; + + public DictionaryValueCollectionDebugView(ICollection<TValue> collection) + { + if (collection == null) + throw new ArgumentNullException(nameof(collection)); + + _collection = collection; + } + + [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] + public TValue[] Items + { + get + { + TValue[] items = new TValue[_collection.Count]; + _collection.CopyTo(items, 0); + return items; + } + } + } +} diff --git a/src/mscorlib/shared/System/Collections/Generic/List.cs b/src/mscorlib/shared/System/Collections/Generic/List.cs index 0db89a087d..f548f8d1b1 100644 --- a/src/mscorlib/shared/System/Collections/Generic/List.cs +++ b/src/mscorlib/shared/System/Collections/Generic/List.cs @@ -15,7 +15,7 @@ namespace System.Collections.Generic // of the List is automatically increased as required by reallocating the // internal array. // - [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))] + [DebuggerTypeProxy(typeof(ICollectionDebugView<>))] [DebuggerDisplay("Count = {Count}")] [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] diff --git a/src/mscorlib/shared/System/Collections/ObjectModel/Collection.cs b/src/mscorlib/shared/System/Collections/ObjectModel/Collection.cs index 75e88eccb3..1e1b2c7959 100644 --- a/src/mscorlib/shared/System/Collections/ObjectModel/Collection.cs +++ b/src/mscorlib/shared/System/Collections/ObjectModel/Collection.cs @@ -8,7 +8,7 @@ using System.Diagnostics; namespace System.Collections.ObjectModel { [Serializable] - [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))] + [DebuggerTypeProxy(typeof(ICollectionDebugView<>))] [DebuggerDisplay("Count = {Count}")] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class Collection<T> : IList<T>, IList, IReadOnlyList<T> diff --git a/src/mscorlib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs b/src/mscorlib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs index f1d2a0969b..dbf88d8b8d 100644 --- a/src/mscorlib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs +++ b/src/mscorlib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs @@ -8,7 +8,7 @@ using System.Diagnostics; namespace System.Collections.ObjectModel { [Serializable] - [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))] + [DebuggerTypeProxy(typeof(ICollectionDebugView<>))] [DebuggerDisplay("Count = {Count}")] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class ReadOnlyCollection<T> : IList<T>, IList, IReadOnlyList<T> diff --git a/src/mscorlib/shared/System/Lazy.cs b/src/mscorlib/shared/System/Lazy.cs index 2ef3cd2e5f..e71a37dd9e 100644 --- a/src/mscorlib/shared/System/Lazy.cs +++ b/src/mscorlib/shared/System/Lazy.cs @@ -182,7 +182,7 @@ namespace System /// using parameters to the type's constructors. /// </para> /// </remarks> - [DebuggerTypeProxy(typeof(System_LazyDebugView<>))] + [DebuggerTypeProxy(typeof(LazyDebugView<>))] [DebuggerDisplay("ThreadSafetyMode={Mode}, IsValueCreated={IsValueCreated}, IsValueFaulted={IsValueFaulted}, Value={ValueForDebugDisplay}")] public class Lazy<T> { @@ -520,14 +520,14 @@ namespace System /// <summary>A debugger view of the Lazy<T> to surface additional debugging properties and /// to ensure that the Lazy<T> does not become initialized if it was not already.</summary> - internal sealed class System_LazyDebugView<T> + internal sealed class LazyDebugView<T> { //The Lazy object being viewed. private readonly Lazy<T> _lazy; /// <summary>Constructs a new debugger view object for the provided Lazy object.</summary> /// <param name="lazy">A Lazy object to browse in the debugger.</param> - public System_LazyDebugView(Lazy<T> lazy) + public LazyDebugView(Lazy<T> lazy) { _lazy = lazy; } diff --git a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs index 4111c5964e..e1593e35aa 100644 --- a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs +++ b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs @@ -31,7 +31,7 @@ namespace System.Collections.Concurrent /// All public and protected members of <see cref="ConcurrentDictionary{TKey,TValue}"/> are thread-safe and may be used /// concurrently from multiple threads. /// </remarks> - [DebuggerTypeProxy(typeof(Mscorlib_DictionaryDebugView<,>))] + [DebuggerTypeProxy(typeof(IDictionaryDebugView<,>))] [DebuggerDisplay("Count = {Count}")] internal class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, IReadOnlyDictionary<TKey, TValue> { diff --git a/src/mscorlib/src/System/Collections/Generic/DebugView.cs b/src/mscorlib/src/System/Collections/Generic/DebugView.cs deleted file mode 100644 index dc487c1411..0000000000 --- a/src/mscorlib/src/System/Collections/Generic/DebugView.cs +++ /dev/null @@ -1,124 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** -** -** Purpose: DebugView class for generic collections -** -** -** -** -=============================================================================*/ - -using System; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.Diagnostics.Contracts; - -namespace System.Collections.Generic -{ - // - // VS IDE can't differentiate between types with the same name from different - // assembly. So we need to use different names for collection debug view for - // collections in mscorlib.dll and system.dll. - // - internal sealed class Mscorlib_CollectionDebugView<T> - { - private ICollection<T> collection; - - public Mscorlib_CollectionDebugView(ICollection<T> collection) - { - if (collection == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection); - - this.collection = collection; - } - - [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] - public T[] Items - { - get - { - T[] items = new T[collection.Count]; - collection.CopyTo(items, 0); - return items; - } - } - } - - internal sealed class Mscorlib_DictionaryKeyCollectionDebugView<TKey, TValue> - { - private ICollection<TKey> collection; - - public Mscorlib_DictionaryKeyCollectionDebugView(ICollection<TKey> collection) - { - if (collection == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection); - - this.collection = collection; - } - - [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] - public TKey[] Items - { - get - { - TKey[] items = new TKey[collection.Count]; - collection.CopyTo(items, 0); - return items; - } - } - } - - internal sealed class Mscorlib_DictionaryValueCollectionDebugView<TKey, TValue> - { - private ICollection<TValue> collection; - - public Mscorlib_DictionaryValueCollectionDebugView(ICollection<TValue> collection) - { - if (collection == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection); - - this.collection = collection; - } - - [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] - public TValue[] Items - { - get - { - TValue[] items = new TValue[collection.Count]; - collection.CopyTo(items, 0); - return items; - } - } - } - - internal sealed class Mscorlib_DictionaryDebugView<K, V> - { - private IDictionary<K, V> dict; - - public Mscorlib_DictionaryDebugView(IDictionary<K, V> dictionary) - { - if (dictionary == null) - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.dictionary); - - dict = dictionary; - } - - [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] - public KeyValuePair<K, V>[] Items - { - get - { - KeyValuePair<K, V>[] items = new KeyValuePair<K, V>[dict.Count]; - dict.CopyTo(items, 0); - return items; - } - } - } - -} diff --git a/src/mscorlib/src/System/Collections/Generic/Dictionary.cs b/src/mscorlib/src/System/Collections/Generic/Dictionary.cs index 0a83734eb0..1ba146679e 100644 --- a/src/mscorlib/src/System/Collections/Generic/Dictionary.cs +++ b/src/mscorlib/src/System/Collections/Generic/Dictionary.cs @@ -49,7 +49,7 @@ namespace System.Collections.Generic ThrowOnExisting = 2 } - [DebuggerTypeProxy(typeof(Mscorlib_DictionaryDebugView<,>))] + [DebuggerTypeProxy(typeof(IDictionaryDebugView<,>))] [DebuggerDisplay("Count = {Count}")] [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] @@ -1026,7 +1026,7 @@ namespace System.Collections.Generic } } - [DebuggerTypeProxy(typeof(Mscorlib_DictionaryKeyCollectionDebugView<,>))] + [DebuggerTypeProxy(typeof(DictionaryKeyCollectionDebugView<,>))] [DebuggerDisplay("Count = {Count}")] public sealed class KeyCollection : ICollection<TKey>, ICollection, IReadOnlyCollection<TKey> { @@ -1254,7 +1254,7 @@ namespace System.Collections.Generic } } - [DebuggerTypeProxy(typeof(Mscorlib_DictionaryValueCollectionDebugView<,>))] + [DebuggerTypeProxy(typeof(DictionaryValueCollectionDebugView<,>))] [DebuggerDisplay("Count = {Count}")] public sealed class ValueCollection : ICollection<TValue>, ICollection, IReadOnlyCollection<TValue> { diff --git a/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs b/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs index 3fd0cf8c6c..b3eb006898 100644 --- a/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs +++ b/src/mscorlib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs @@ -19,7 +19,7 @@ using System.Diagnostics.Contracts; namespace System.Collections.ObjectModel { - [DebuggerTypeProxy(typeof(Mscorlib_DictionaryDebugView<,>))] + [DebuggerTypeProxy(typeof(IDictionaryDebugView<,>))] [DebuggerDisplay("Count = {Count}")] internal class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, IReadOnlyDictionary<TKey, TValue> { @@ -428,7 +428,7 @@ namespace System.Collections.ObjectModel #endregion IReadOnlyDictionary members - [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))] + [DebuggerTypeProxy(typeof(ICollectionDebugView<>))] [DebuggerDisplay("Count = {Count}")] public sealed class KeyCollection : ICollection<TKey>, ICollection, IReadOnlyCollection<TKey> { @@ -538,7 +538,7 @@ namespace System.Collections.ObjectModel #endregion } - [DebuggerTypeProxy(typeof(Mscorlib_CollectionDebugView<>))] + [DebuggerTypeProxy(typeof(ICollectionDebugView<>))] [DebuggerDisplay("Count = {Count}")] public sealed class ValueCollection : ICollection<TValue>, ICollection, IReadOnlyCollection<TValue> { |