Imported Upstream version 4.3.2.467

Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
Xamarin Public Jenkins
2016-02-22 11:00:01 -05:00
parent f302175246
commit f3e3aab35a
4097 changed files with 122406 additions and 82300 deletions

View File

@@ -1,4 +1,4 @@
// ==++==
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
@@ -57,7 +57,7 @@ namespace System.Collections.Concurrent
[DebuggerTypeProxy(typeof(Mscorlib_DictionaryDebugView<,>))]
[DebuggerDisplay("Count = {Count}")]
[HostProtection(Synchronization = true, ExternalThreading = true)]
public class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary
public class ConcurrentDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, IReadOnlyDictionary<TKey, TValue>
{
/// <summary>
/// Tables that hold the internal state of the ConcurrentDictionary
@@ -95,6 +95,12 @@ namespace System.Collections.Concurrent
// How many times we resized becaused of collisions.
// This is used to make sure we don't resize the dictionary because of multi-threaded Add() calls
// that generate collisions. Whenever a GrowTable() should be the only place that changes this
#if !FEATURE_CORECLR
// The field should be have been marked as NonSerialized but because we shipped it without that attribute in 4.5.1.
// we can't add it back without breaking compat. To maximize compat we are going to keep the OptionalField attribute
// This will prevent cases where the field was not serialized.
[OptionalField]
#endif
private int m_keyRehashCount;
#if !FEATURE_CORECLR
@@ -810,7 +816,9 @@ namespace System.Collections.Concurrent
bool resizeDesired = false;
bool lockTaken = false;
#if FEATURE_RANDOMIZED_STRING_HASHING
#if !FEATURE_CORECLR
bool resizeDueToCollisions = false;
#endif // !FEATURE_CORECLR
#endif
try
@@ -826,7 +834,9 @@ namespace System.Collections.Concurrent
}
#if FEATURE_RANDOMIZED_STRING_HASHING
#if !FEATURE_CORECLR
int collisionCount = 0;
#endif // !FEATURE_CORECLR
#endif
// Try to find this key in the bucket
@@ -868,16 +878,20 @@ namespace System.Collections.Concurrent
prev = node;
#if FEATURE_RANDOMIZED_STRING_HASHING
#if !FEATURE_CORECLR
collisionCount++;
#endif // !FEATURE_CORECLR
#endif
}
#if FEATURE_RANDOMIZED_STRING_HASHING
#if !FEATURE_CORECLR
if(collisionCount > HashHelpers.HashCollisionThreshold && HashHelpers.IsWellKnownEqualityComparer(comparer))
{
resizeDesired = true;
resizeDueToCollisions = true;
}
#endif // !FEATURE_CORECLR
#endif
// The key was not found in the bucket. Insert the key-value pair.
@@ -914,11 +928,13 @@ namespace System.Collections.Concurrent
if (resizeDesired)
{
#if FEATURE_RANDOMIZED_STRING_HASHING
#if !FEATURE_CORECLR
if (resizeDueToCollisions)
{
GrowTable(tables, (IEqualityComparer<TKey>)HashHelpers.GetRandomizedEqualityComparer(comparer), true, m_keyRehashCount);
}
else
#endif // !FEATURE_CORECLR
{
GrowTable(tables, tables.m_comparer, false, m_keyRehashCount);
}
@@ -1236,6 +1252,17 @@ namespace System.Collections.Concurrent
get { return GetKeys(); }
}
/// <summary>
/// Gets an <see cref="T:System.Collections.Generic.IEnumerable{TKey}"/> containing the keys of
/// the <see cref="T:System.Collections.Generic.IReadOnlyDictionary{TKey,TValue}"/>.
/// </summary>
/// <value>An <see cref="T:System.Collections.Generic.IEnumerable{TKey}"/> containing the keys of
/// the <see cref="T:System.Collections.Generic.IReadOnlyDictionary{TKey,TValue}"/>.</value>
IEnumerable<TKey> IReadOnlyDictionary<TKey, TValue>.Keys
{
get { return GetKeys(); }
}
/// <summary>
/// Gets a collection containing the values in the <see
/// cref="T:System.Collections.Generic.Dictionary{TKey,TValue}"/>.
@@ -1247,6 +1274,17 @@ namespace System.Collections.Concurrent
{
get { return GetValues(); }
}
/// <summary>
/// Gets an <see cref="T:System.Collections.Generic.IEnumerable{TValue}"/> containing the values
/// in the <see cref="T:System.Collections.Generic.IReadOnlyDictionary{TKey,TValue}"/>.
/// </summary>
/// <value>An <see cref="T:System.Collections.Generic.IEnumerable{TValue}"/> containing the
/// values in the <see cref="T:System.Collections.Generic.IReadOnlyDictionary{TKey,TValue}"/>.</value>
IEnumerable<TValue> IReadOnlyDictionary<TKey, TValue>.Values
{
get { return GetValues(); }
}
#endregion
#region ICollection<KeyValuePair<TKey,TValue>> Members

View File

@@ -1,4 +1,4 @@
#pragma warning disable 0420
#pragma warning disable 0420
// ==++==
//
@@ -43,7 +43,7 @@ namespace System.Collections.Concurrent
[DebuggerTypeProxy(typeof(SystemCollectionsConcurrent_ProducerConsumerCollectionDebugView<>))]
[HostProtection(Synchronization = true, ExternalThreading = true)]
[Serializable]
public class ConcurrentQueue<T> : IProducerConsumerCollection<T>
public class ConcurrentQueue<T> : IProducerConsumerCollection<T>, IReadOnlyCollection<T>
{
//fields of ConcurrentQueue
[NonSerialized]

View File

@@ -52,7 +52,7 @@ namespace System.Collections.Concurrent
#if !FEATURE_CORECLR
[Serializable]
#endif //!FEATURE_CORECLR
public class ConcurrentStack<T> : IProducerConsumerCollection<T>
public class ConcurrentStack<T> : IProducerConsumerCollection<T>, IReadOnlyCollection<T>
{
/// <summary>
/// A simple (internal) node type used to store elements of concurrent stacks and queues.

View File

@@ -1 +1 @@
bf7ec8f88e3e31969c5db3673e784dcfb80c8aa0
0e7b25c8eec5ef2270f833d3acd6e2faa65156b0

View File

@@ -139,6 +139,13 @@ namespace System.Collections.Generic
comparer = Comparer<T>.Default;
}
#if FEATURE_CORECLR
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
IntrospectiveSort(keys, index, length, comparer);
#else
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
{
IntrospectiveSort(keys, index, length, comparer);
@@ -147,6 +154,7 @@ namespace System.Collections.Generic
{
DepthLimitedQuickSort(keys, index, length + index - 1, comparer, IntrospectiveSortUtilities.QuickSortDepthThreshold);
}
#endif
}
catch (IndexOutOfRangeException)
{
@@ -473,6 +481,14 @@ namespace System.Collections.Generic
#else
if (comparer == null || comparer == Comparer<T>.Default) {
#endif
#if FEATURE_CORECLR
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
IntrospectiveSort(keys, index, length);
#else
// call the faster version of our sort algorithm if the user doesn't provide a comparer
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
{
@@ -482,9 +498,17 @@ namespace System.Collections.Generic
{
DepthLimitedQuickSort(keys, index, length + index - 1, IntrospectiveSortUtilities.QuickSortDepthThreshold);
}
#endif
}
else
{
#if FEATURE_CORECLR
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
ArraySortHelper<T>.IntrospectiveSort(keys, index, length, comparer);
#else
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
{
ArraySortHelper<T>.IntrospectiveSort(keys, index, length, comparer);
@@ -493,6 +517,7 @@ namespace System.Collections.Generic
{
ArraySortHelper<T>.DepthLimitedQuickSort(keys, index, length + index - 1, comparer, IntrospectiveSortUtilities.QuickSortDepthThreshold);
}
#endif
}
}
catch (IndexOutOfRangeException)
@@ -890,6 +915,13 @@ namespace System.Collections.Generic
comparer = Comparer<TKey>.Default;
}
#if FEATURE_CORECLR
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
IntrospectiveSort(keys, values, index, length, comparer);
#else
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
{
IntrospectiveSort(keys, values, index, length, comparer);
@@ -898,6 +930,7 @@ namespace System.Collections.Generic
{
DepthLimitedQuickSort(keys, values, index, length + index - 1, comparer, IntrospectiveSortUtilities.QuickSortDepthThreshold);
}
#endif
}
catch (IndexOutOfRangeException)
{
@@ -1211,6 +1244,13 @@ namespace System.Collections.Generic
{
if (comparer == null || comparer == Comparer<TKey>.Default)
{
#if FEATURE_CORECLR
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
IntrospectiveSort(keys, values, index, length);
#else
// call the faster version of our sort algorithm if the user doesn't provide a comparer
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
{
@@ -1220,9 +1260,17 @@ namespace System.Collections.Generic
{
DepthLimitedQuickSort(keys, values, index, length + index - 1, IntrospectiveSortUtilities.QuickSortDepthThreshold);
}
#endif
}
else
{
#if FEATURE_CORECLR
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
ArraySortHelper<TKey, TValue>.IntrospectiveSort(keys, values, index, length, comparer);
#else
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
{
ArraySortHelper<TKey, TValue>.IntrospectiveSort(keys, values, index, length, comparer);
@@ -1231,6 +1279,7 @@ namespace System.Collections.Generic
{
ArraySortHelper<TKey, TValue>.DepthLimitedQuickSort(keys, values, index, length + index - 1, comparer, IntrospectiveSortUtilities.QuickSortDepthThreshold);
}
#endif
}
}

View File

@@ -92,6 +92,13 @@ namespace System.Collections.Generic {
if (capacity < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity);
if (capacity > 0) Initialize(capacity);
this.comparer = comparer ?? EqualityComparer<TKey>.Default;
#if FEATURE_CORECLR
if (HashHelpers.s_UseRandomizedStringHashing && comparer == EqualityComparer<string>.Default)
{
this.comparer = (IEqualityComparer<TKey>) NonRandomizedStringEqualityComparer.Default;
}
#endif // FEATURE_CORECLR
}
public Dictionary(IDictionary<TKey,TValue> dictionary): this(dictionary, null) {}
@@ -361,11 +368,26 @@ namespace System.Collections.Generic {
version++;
#if FEATURE_RANDOMIZED_STRING_HASHING
#if FEATURE_CORECLR
// In case we hit the collision threshold we'll need to switch to the comparer which is using randomized string hashing
// in this case will be EqualityComparer<string>.Default.
// Note, randomized string hashing is turned on by default on coreclr so EqualityComparer<string>.Default will
// be using randomized string hashing
if (collisionCount > HashHelpers.HashCollisionThreshold && comparer == NonRandomizedStringEqualityComparer.Default)
{
comparer = (IEqualityComparer<TKey>) EqualityComparer<string>.Default;
Resize(entries.Length, true);
}
#else
if(collisionCount > HashHelpers.HashCollisionThreshold && HashHelpers.IsWellKnownEqualityComparer(comparer))
{
comparer = (IEqualityComparer<TKey>) HashHelpers.GetRandomizedEqualityComparer(comparer);
Resize(entries.Length, true);
}
#endif // FEATURE_CORECLR
#endif
}
@@ -776,7 +798,7 @@ namespace System.Collections.Generic {
[DebuggerTypeProxy(typeof(Mscorlib_DictionaryKeyCollectionDebugView<,>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable]
public sealed class KeyCollection: ICollection<TKey>, ICollection
public sealed class KeyCollection: ICollection<TKey>, ICollection, IReadOnlyCollection<TKey>
{
private Dictionary<TKey,TValue> dictionary;
@@ -963,7 +985,7 @@ namespace System.Collections.Generic {
[DebuggerTypeProxy(typeof(Mscorlib_DictionaryValueCollectionDebugView<,>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable]
public sealed class ValueCollection: ICollection<TValue>, ICollection
public sealed class ValueCollection: ICollection<TValue>, ICollection, IReadOnlyCollection<TValue>
{
private Dictionary<TKey,TValue> dictionary;

View File

@@ -10,6 +10,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Security;
using System.Runtime.Serialization;
namespace System.Collections.Generic
{
@@ -25,9 +26,6 @@ namespace System.Collections.Generic
static volatile EqualityComparer<T> defaultComparer;
public static EqualityComparer<T> Default {
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
get {
Contract.Ensures(Contract.Result<EqualityComparer<T>>() != null);
@@ -79,15 +77,44 @@ namespace System.Collections.Generic
#endif
}
}
// If T is an int-based Enum, return an EnumEqualityComparer<T>
// See the METHOD__JIT_HELPERS__UNSAFE_ENUM_CAST and METHOD__JIT_HELPERS__UNSAFE_ENUM_CAST_LONG cases in getILIntrinsicImplementation
if (t.IsEnum && Enum.GetUnderlyingType(t) == typeof(int))
{
if (t.IsEnum) {
TypeCode underlyingTypeCode = Type.GetTypeCode(Enum.GetUnderlyingType(t));
// Depending on the enum type, we need to special case the comparers so that we avoid boxing
// Note: We have different comparers for Short and SByte because for those types we need to make sure we call GetHashCode on the actual underlying type as the
// implementation of GetHashCode is more complex than for the other types.
switch (underlyingTypeCode) {
case TypeCode.Int16: // short
#if MONO
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(EnumEqualityComparer<>), t);
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(ShortEnumEqualityComparer<>), t);
#else
return (EqualityComparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(EnumEqualityComparer<int>), t);
return (EqualityComparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(ShortEnumEqualityComparer<short>), t);
#endif
case TypeCode.SByte:
#if MONO
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(SByteEnumEqualityComparer<>), t);
#else
return (EqualityComparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(SByteEnumEqualityComparer<sbyte>), t);
#endif
case TypeCode.Int32:
case TypeCode.UInt32:
case TypeCode.Byte:
case TypeCode.UInt16: //ushort
#if MONO
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(EnumEqualityComparer<>), t);
#else
return (EqualityComparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(EnumEqualityComparer<int>), t);
#endif
case TypeCode.Int64:
case TypeCode.UInt64:
#if MONO
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(LongEnumEqualityComparer<>), t);
#else
return (EqualityComparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(LongEnumEqualityComparer<long>), t);
#endif
}
}
// Otherwise return an ObjectEqualityComparer<T>
return new ObjectEqualityComparer<T>();
@@ -146,9 +173,6 @@ namespace System.Collections.Generic
}
[Pure]
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public override int GetHashCode(T obj) {
if (obj == null) return 0;
return obj.GetHashCode();
@@ -268,9 +292,6 @@ namespace System.Collections.Generic
}
[Pure]
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public override int GetHashCode(T obj) {
if (obj == null) return 0;
return obj.GetHashCode();
@@ -317,6 +338,34 @@ namespace System.Collections.Generic
}
}
#if FEATURE_CORECLR
// NonRandomizedStringEqualityComparer is the comparer used by default with the Dictionary<string,...>
// As the randomized string hashing is turned on by default on coreclr, we need to keep the performance not affected
// as much as possible in the main stream scenarios like Dictionary<string,…>
// We use NonRandomizedStringEqualityComparer as default comparer as it doesnt use the randomized string hashing which
// keep the perofrmance not affected till we hit collision threshold and then we switch to the comparer which is using
// randomized string hashing GenericEqualityComparer<string>
internal class NonRandomizedStringEqualityComparer : GenericEqualityComparer<string> {
static IEqualityComparer<string> s_nonRandomizedComparer;
internal static IEqualityComparer<string> Default {
get {
if (s_nonRandomizedComparer == null) {
s_nonRandomizedComparer = new NonRandomizedStringEqualityComparer();
}
return s_nonRandomizedComparer;
}
}
[Pure]
public override int GetHashCode(string obj) {
if (obj == null) return 0;
return obj.GetLegacyNonRandomizedHashCode();
}
}
#endif // FEATURE_CORECLR
// Performance of IndexOf on byte array is very important for some scenarios.
// We will call the C runtime function memchr, which is optimized.
[Serializable]
@@ -366,11 +415,10 @@ namespace System.Collections.Generic
public override int GetHashCode() {
return this.GetType().Name.GetHashCode();
}
}
[Serializable]
internal sealed class EnumEqualityComparer<T>: EqualityComparer<T> where T : struct
internal class EnumEqualityComparer<T> : EqualityComparer<T>, ISerializable where T : struct
{
[Pure]
public override bool Equals(T x, T y) {
@@ -385,6 +433,19 @@ namespace System.Collections.Generic
return x_final.GetHashCode();
}
public EnumEqualityComparer() { }
// This is used by the serialization engine.
protected EnumEqualityComparer(SerializationInfo information, StreamingContext context) { }
[SecurityCritical]
public void GetObjectData(SerializationInfo info, StreamingContext context) {
// For back-compat we need to serialize the comparers for enums with underlying types other than int as ObjectEqualityComparer
if (Type.GetTypeCode(Enum.GetUnderlyingType(typeof(T))) != TypeCode.Int32) {
info.SetType(typeof(ObjectEqualityComparer<T>));
}
}
// Equals method for the comparer itself.
public override bool Equals(Object obj){
EnumEqualityComparer<T> comparer = obj as EnumEqualityComparer<T>;
@@ -397,7 +458,37 @@ namespace System.Collections.Generic
}
[Serializable]
internal sealed class LongEnumEqualityComparer<T>: EqualityComparer<T> where T : struct
internal sealed class SByteEnumEqualityComparer<T> : EnumEqualityComparer<T>, ISerializable where T : struct
{
public SByteEnumEqualityComparer() { }
// This is used by the serialization engine.
public SByteEnumEqualityComparer(SerializationInfo information, StreamingContext context) { }
[Pure]
public override int GetHashCode(T obj) {
int x_final = System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCast(obj);
return ((sbyte)x_final).GetHashCode();
}
}
[Serializable]
internal sealed class ShortEnumEqualityComparer<T> : EnumEqualityComparer<T>, ISerializable where T : struct
{
public ShortEnumEqualityComparer() { }
// This is used by the serialization engine.
public ShortEnumEqualityComparer(SerializationInfo information, StreamingContext context) { }
[Pure]
public override int GetHashCode(T obj) {
int x_final = System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCast(obj);
return ((short)x_final).GetHashCode();
}
}
[Serializable]
internal sealed class LongEnumEqualityComparer<T> : EqualityComparer<T>, ISerializable where T : struct
{
[Pure]
public override bool Equals(T x, T y) {
@@ -421,6 +512,19 @@ namespace System.Collections.Generic
public override int GetHashCode() {
return this.GetType().Name.GetHashCode();
}
public LongEnumEqualityComparer() { }
// This is used by the serialization engine.
public LongEnumEqualityComparer(SerializationInfo information, StreamingContext context) { }
[SecurityCritical]
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
// The LongEnumEqualityComparer does not exist on 4.0 so we need to serialize this comparer as ObjectEqualityComparer
// to allow for roundtrip between 4.0 and 4.5.
info.SetType(typeof(ObjectEqualityComparer<T>));
}
}
[Serializable]

View File

@@ -7,7 +7,7 @@
**
** Interface: ICollection
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Base interface for all generic collections.

View File

@@ -7,7 +7,7 @@
**
** Interface: IComparer
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Interface for comparing two generic Objects.

View File

@@ -7,7 +7,7 @@
**
** Interface: IDictionary
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Base interface for all generic dictionaries.

View File

@@ -7,7 +7,7 @@
**
** Interface: IEnumerable
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Interface for providing generic IEnumerators

View File

@@ -7,7 +7,7 @@
**
** Interface: IEnumerator
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Base interface for all generic enumerators.

View File

@@ -3,7 +3,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
// <OWNER>[....]</OWNER>
// <OWNER>kimhamil</OWNER>
//
namespace System.Collections.Generic {

View File

@@ -7,7 +7,7 @@
**
** Interface: IList
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Base interface for all generic lists.

View File

@@ -7,7 +7,7 @@
**
** Interface: IReadOnlyCollection<T>
**
** <OWNER>[....]</OWNER>
** <OWNER>matell</OWNER>
**
** Purpose: Base interface for read-only generic lists.
**

View File

@@ -7,7 +7,7 @@
**
** Interface: IReadOnlyDictionary<TKey, TValue>
**
** <OWNER>[....]</OWNER>
** <OWNER>matell</OWNER>
**
** Purpose: Base interface for read-only generic dictionaries.
**

View File

@@ -7,7 +7,7 @@
**
** Interface: IReadOnlyList<T>
**
** <OWNER>[....]</OWNER>
** <OWNER>matell</OWNER>
**
** Purpose: Base interface for read-only generic lists.
**

View File

@@ -49,9 +49,6 @@ namespace System.Collections.Generic {
// Constructs a List. The list is initially empty and has a capacity
// of zero. Upon adding the first element to the list the capacity is
// increased to 16, and then increased in multiples of two as required.
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public List() {
_items = _emptyArray;
}
@@ -60,9 +57,6 @@ namespace System.Collections.Generic {
// initially empty, but will have room for the given number of elements
// before any reallocations are required.
//
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public List(int capacity) {
if (capacity < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
Contract.EndContractBlock();
@@ -114,9 +108,6 @@ namespace System.Collections.Generic {
// array of the list is reallocated to the given capacity.
//
public int Capacity {
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
get {
Contract.Ensures(Contract.Result<int>() >= 0);
return _items.Length;
@@ -157,16 +148,10 @@ namespace System.Collections.Generic {
// Is this List read-only?
bool ICollection<T>.IsReadOnly {
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
get { return false; }
}
bool System.Collections.IList.IsReadOnly {
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
get { return false; }
}
@@ -187,9 +172,6 @@ namespace System.Collections.Generic {
// Sets or Gets the element at the given index.
//
public T this[int index] {
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
#if MONO
[System.Runtime.CompilerServices.MethodImpl (System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#endif
@@ -206,9 +188,6 @@ namespace System.Collections.Generic {
#endif
}
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
set {
if ((uint) index >= (uint)_size) {
ThrowHelper.ThrowArgumentOutOfRangeException();
@@ -385,9 +364,6 @@ namespace System.Collections.Generic {
// Copies this List into array, which must be of a
// compatible array type.
//
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public void CopyTo(T[] array) {
CopyTo(array, 0);
}
@@ -395,9 +371,6 @@ namespace System.Collections.Generic {
// Copies this List into array, which must be of a
// compatible array type.
//
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
void System.Collections.ICollection.CopyTo(Array array, int arrayIndex) {
if ((array != null) && (array.Rank != 1)) {
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported);
@@ -447,7 +420,6 @@ namespace System.Collections.Generic {
}
}
#if FEATURE_LIST_PREDICATES || FEATURE_NETCORE
public bool Exists(Predicate<T> match) {
return FindIndex(match) != -1;
}
@@ -576,7 +548,6 @@ namespace System.Collections.Generic {
}
return -1;
}
#endif // FEATURE_LIST_PREDICATES || FEATURE_NETCORE
public void ForEach(Action<T> action) {
if( action == null) {
@@ -602,24 +573,15 @@ namespace System.Collections.Generic {
// while an enumeration is in progress, the MoveNext and
// GetObject methods of the enumerator will throw an exception.
//
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public Enumerator GetEnumerator() {
return new Enumerator(this);
}
/// <internalonly/>
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
IEnumerator<T> IEnumerable<T>.GetEnumerator() {
return new Enumerator(this);
}
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
return new Enumerator(this);
}
@@ -654,18 +616,12 @@ namespace System.Collections.Generic {
// This method uses the Array.IndexOf method to perform the
// search.
//
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public int IndexOf(T item) {
Contract.Ensures(Contract.Result<int>() >= -1);
Contract.Ensures(Contract.Result<int>() < Count);
return Array.IndexOf(_items, item, 0, _size);
}
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
int System.Collections.IList.IndexOf(Object item)
{
if(IsCompatibleObject(item)) {
@@ -871,9 +827,6 @@ namespace System.Collections.Generic {
// Removes the element at the given index. The size of the list is
// decreased by one.
//
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public bool Remove(T item) {
int index = IndexOf(item);
if (index >= 0) {
@@ -1074,7 +1027,6 @@ namespace System.Collections.Generic {
}
}
#if FEATURE_LIST_PREDICATES || FEATURE_NETCORE
public bool TrueForAll(Predicate<T> match) {
if( match == null) {
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
@@ -1088,7 +1040,6 @@ namespace System.Collections.Generic {
}
return true;
}
#endif // FEATURE_LIST_PREDICATES || FEATURE_NETCORE
internal static IList<T> Synchronized(List<T> list) {
return new SynchronizedList(list);
@@ -1207,9 +1158,6 @@ namespace System.Collections.Generic {
current = default(T);
}
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public void Dispose() {
}

View File

@@ -437,9 +437,6 @@ namespace System.Collections {
// ArgumentException is thrown if the key is null or if the key is already
// present in the hashtable.
//
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public virtual void Add(Object key, Object value) {
Insert(key, value, true);
}
@@ -495,9 +492,6 @@ namespace System.Collections {
}
// Checks if this hashtable contains the given key.
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public virtual bool Contains(Object key) {
return ContainsKey(key);
}
@@ -709,9 +703,6 @@ namespace System.Collections {
return null;
}
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
set {
Insert(key, value, false);
}
@@ -786,9 +777,6 @@ namespace System.Collections {
// in progress, the MoveNext and Current methods of the
// enumerator will throw an exception.
//
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
IEnumerator IEnumerable.GetEnumerator() {
return new HashtableEnumerator(this, HashtableEnumerator.DictEntry);
}
@@ -798,9 +786,6 @@ namespace System.Collections {
// in progress, the MoveNext and Current methods of the
// enumerator will throw an exception.
//
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public virtual IDictionaryEnumerator GetEnumerator() {
return new HashtableEnumerator(this, HashtableEnumerator.DictEntry);
}
@@ -808,9 +793,6 @@ namespace System.Collections {
// Internal method to get the hash code for an Object. This will call
// GetHashCode() on each object if you haven't provided an IHashCodeProvider
// instance. Otherwise, it calls hcp.GetHashCode(obj).
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
protected virtual int GetHash(Object key)
{
if (_keycomparer != null)
@@ -861,9 +843,6 @@ namespace System.Collections {
// a static copy of all the keys in the hash table.
//
public virtual ICollection Keys {
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
get {
if (keys == null) keys = new KeyCollection(this);
return keys;
@@ -881,9 +860,6 @@ namespace System.Collections {
// a static copy of all the keys in the hash table.
//
public virtual ICollection Values {
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
get {
if (values == null) values = new ValueCollection(this);
return values;
@@ -955,6 +931,9 @@ namespace System.Collections {
#endif
#if FEATURE_RANDOMIZED_STRING_HASHING
#if !FEATURE_CORECLR
// coreclr has the randomized string hashing on by default so we don't need to resize at this point
if(ntry > HashHelpers.HashCollisionThreshold && HashHelpers.IsWellKnownEqualityComparer(_keycomparer))
{
// PERF: We don't want to rehash if _keycomparer is already a RandomizedObjectEqualityComparer since in some
@@ -965,7 +944,8 @@ namespace System.Collections {
rehash(buckets.Length, true);
}
}
#endif
#endif // !FEATURE_CORECLR
#endif // FEATURE_RANDOMIZED_STRING_HASHING
return;
}
@@ -990,6 +970,7 @@ namespace System.Collections {
#endif
#if FEATURE_RANDOMIZED_STRING_HASHING
#if !FEATURE_CORECLR
if(ntry > HashHelpers.HashCollisionThreshold && HashHelpers.IsWellKnownEqualityComparer(_keycomparer))
{
// PERF: We don't want to rehash if _keycomparer is already a RandomizedObjectEqualityComparer since in some
@@ -1000,6 +981,7 @@ namespace System.Collections {
rehash(buckets.Length, true);
}
}
#endif // !FEATURE_CORECLR
#endif
return;
}
@@ -1037,6 +1019,7 @@ namespace System.Collections {
#endif
#if FEATURE_RANDOMIZED_STRING_HASHING
#if !FEATURE_CORECLR
if(buckets.Length > HashHelpers.HashCollisionThreshold && HashHelpers.IsWellKnownEqualityComparer(_keycomparer))
{
// PERF: We don't want to rehash if _keycomparer is already a RandomizedObjectEqualityComparer since in some
@@ -1047,6 +1030,7 @@ namespace System.Collections {
rehash(buckets.Length, true);
}
}
#endif // !FEATURE_CORECLR
#endif
return;
}
@@ -1333,9 +1317,6 @@ namespace System.Collections {
_hashtable.CopyKeys(array, arrayIndex);
}
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public virtual IEnumerator GetEnumerator() {
return new HashtableEnumerator(_hashtable, HashtableEnumerator.Keys);
}
@@ -1377,9 +1358,6 @@ namespace System.Collections {
_hashtable.CopyValues(array, arrayIndex);
}
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public virtual IEnumerator GetEnumerator() {
return new HashtableEnumerator(_hashtable, HashtableEnumerator.Values);
}
@@ -1455,9 +1433,6 @@ namespace System.Collections {
}
public override Object this[Object key] {
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
get {
return _table[key];
}
@@ -1484,16 +1459,10 @@ namespace System.Collections {
}
}
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public override bool Contains(Object key) {
return _table.Contains(key);
}
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
public override bool ContainsKey(Object key) {
if (key == null) {
throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key"));
@@ -1600,9 +1569,6 @@ namespace System.Collections {
}
public virtual Object Key {
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
get {
if (current == false) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted));
return currentKey;
@@ -1647,9 +1613,6 @@ namespace System.Collections {
}
public virtual Object Value {
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
get {
if (current == false) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumOpCantHappen));
return currentValue;

View File

@@ -7,7 +7,7 @@
**
** Interface: ICollection
**
** <OWNER>[....]</OWNER>
** <OWNER>kimhamil</OWNER>
**
**
** Purpose: Base interface for all collections.

Some files were not shown because too many files have changed in this diff Show More