Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@@ -2,7 +2,8 @@
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.1.1.0</AssemblyVersion>
<AssemblyKey>MSFT</AssemblyKey>
<IsNETCoreApp>true</IsNETCoreApp>
<IsUAP>true</IsUAP>
</PropertyGroup>

View File

@@ -15,6 +15,9 @@ namespace System.Collections.Specialized
/// </para>
/// </devdoc>
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public class HybridDictionary : IDictionary
{
// These numbers have been carefully tested to be optimal. Please don't change them

View File

@@ -12,12 +12,15 @@ namespace System.Collections.Specialized
/// </para>
/// </devdoc>
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public class ListDictionary : IDictionary
{
private DictionaryNode _head;
private int _version;
private int _count;
private readonly IComparer _comparer;
private DictionaryNode head; // Do not rename (binary serialization)
private int version; // Do not rename (binary serialization)
private int count; // Do not rename (binary serialization)
private readonly IComparer comparer; // Do not rename (binary serialization)
[NonSerialized]
private Object _syncRoot;
@@ -27,7 +30,7 @@ namespace System.Collections.Specialized
public ListDictionary(IComparer comparer)
{
_comparer = comparer;
this.comparer = comparer;
}
public object this[object key]
@@ -38,8 +41,8 @@ namespace System.Collections.Specialized
{
throw new ArgumentNullException(nameof(key));
}
DictionaryNode node = _head;
if (_comparer == null)
DictionaryNode node = head;
if (comparer == null)
{
while (node != null)
{
@@ -56,7 +59,7 @@ namespace System.Collections.Specialized
while (node != null)
{
object oldKey = node.key;
if (_comparer.Compare(oldKey, key) == 0)
if (comparer.Compare(oldKey, key) == 0)
{
return node.value;
}
@@ -71,13 +74,13 @@ namespace System.Collections.Specialized
{
throw new ArgumentNullException(nameof(key));
}
_version++;
version++;
DictionaryNode last = null;
DictionaryNode node;
for (node = _head; node != null; node = node.next)
for (node = head; node != null; node = node.next)
{
object oldKey = node.key;
if ((_comparer == null) ? oldKey.Equals(key) : _comparer.Compare(oldKey, key) == 0)
if ((comparer == null) ? oldKey.Equals(key) : comparer.Compare(oldKey, key) == 0)
{
break;
}
@@ -99,9 +102,9 @@ namespace System.Collections.Specialized
}
else
{
_head = newNode;
head = newNode;
}
_count++;
count++;
}
}
@@ -109,7 +112,7 @@ namespace System.Collections.Specialized
{
get
{
return _count;
return count;
}
}
@@ -171,13 +174,13 @@ namespace System.Collections.Specialized
{
throw new ArgumentNullException(nameof(key));
}
_version++;
version++;
DictionaryNode last = null;
DictionaryNode node;
for (node = _head; node != null; node = node.next)
for (node = head; node != null; node = node.next)
{
object oldKey = node.key;
if ((_comparer == null) ? oldKey.Equals(key) : _comparer.Compare(oldKey, key) == 0)
if ((comparer == null) ? oldKey.Equals(key) : comparer.Compare(oldKey, key) == 0)
{
throw new ArgumentException(SR.Format(SR.Argument_AddingDuplicate, key));
}
@@ -193,16 +196,16 @@ namespace System.Collections.Specialized
}
else
{
_head = newNode;
head = newNode;
}
_count++;
count++;
}
public void Clear()
{
_count = 0;
_head = null;
_version++;
count = 0;
head = null;
version++;
}
public bool Contains(object key)
@@ -211,10 +214,10 @@ namespace System.Collections.Specialized
{
throw new ArgumentNullException(nameof(key));
}
for (DictionaryNode node = _head; node != null; node = node.next)
for (DictionaryNode node = head; node != null; node = node.next)
{
object oldKey = node.key;
if ((_comparer == null) ? oldKey.Equals(key) : _comparer.Compare(oldKey, key) == 0)
if ((comparer == null) ? oldKey.Equals(key) : comparer.Compare(oldKey, key) == 0)
{
return true;
}
@@ -229,10 +232,10 @@ namespace System.Collections.Specialized
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index), index, SR.ArgumentOutOfRange_NeedNonNegNum);
if (array.Length - index < _count)
if (array.Length - index < count)
throw new ArgumentException(SR.Arg_InsufficientSpace);
for (DictionaryNode node = _head; node != null; node = node.next)
for (DictionaryNode node = head; node != null; node = node.next)
{
array.SetValue(new DictionaryEntry(node.key, node.value), index);
index++;
@@ -255,13 +258,13 @@ namespace System.Collections.Specialized
{
throw new ArgumentNullException(nameof(key));
}
_version++;
version++;
DictionaryNode last = null;
DictionaryNode node;
for (node = _head; node != null; node = node.next)
for (node = head; node != null; node = node.next)
{
object oldKey = node.key;
if ((_comparer == null) ? oldKey.Equals(key) : _comparer.Compare(oldKey, key) == 0)
if ((comparer == null) ? oldKey.Equals(key) : comparer.Compare(oldKey, key) == 0)
{
break;
}
@@ -271,15 +274,15 @@ namespace System.Collections.Specialized
{
return;
}
if (node == _head)
if (node == head)
{
_head = node.next;
head = node.next;
}
else
{
last.next = node.next;
}
_count--;
count--;
}
private class NodeEnumerator : IDictionaryEnumerator
@@ -293,7 +296,7 @@ namespace System.Collections.Specialized
public NodeEnumerator(ListDictionary list)
{
_list = list;
_version = list._version;
_version = list.version;
_start = true;
_current = null;
}
@@ -344,13 +347,13 @@ namespace System.Collections.Specialized
public bool MoveNext()
{
if (_version != _list._version)
if (_version != _list.version)
{
throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
}
if (_start)
{
_current = _list._head;
_current = _list.head;
_start = false;
}
else if (_current != null)
@@ -362,7 +365,7 @@ namespace System.Collections.Specialized
public void Reset()
{
if (_version != _list._version)
if (_version != _list.version)
{
throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
}
@@ -390,7 +393,7 @@ namespace System.Collections.Specialized
if (index < 0)
throw new ArgumentOutOfRangeException(nameof(index), index, SR.ArgumentOutOfRange_NeedNonNegNum);
for (DictionaryNode node = _list._head; node != null; node = node.next)
for (DictionaryNode node = _list.head; node != null; node = node.next)
{
array.SetValue(_isKeys ? node.key : node.value, index);
index++;
@@ -402,7 +405,7 @@ namespace System.Collections.Specialized
get
{
int count = 0;
for (DictionaryNode node = _list._head; node != null; node = node.next)
for (DictionaryNode node = _list.head; node != null; node = node.next)
{
count++;
}
@@ -444,7 +447,7 @@ namespace System.Collections.Specialized
{
_list = list;
_isKeys = isKeys;
_version = list._version;
_version = list.version;
_start = true;
_current = null;
}
@@ -463,13 +466,13 @@ namespace System.Collections.Specialized
public bool MoveNext()
{
if (_version != _list._version)
if (_version != _list.version)
{
throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
}
if (_start)
{
_current = _list._head;
_current = _list.head;
_start = false;
}
else if (_current != null)
@@ -481,7 +484,7 @@ namespace System.Collections.Specialized
public void Reset()
{
if (_version != _list._version)
if (_version != _list.version)
{
throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion);
}

View File

@@ -22,6 +22,9 @@ namespace System.Collections.Specialized
/// the key or with the index.</para>
/// </devdoc>
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public abstract class NameObjectCollectionBase : ICollection, ISerializable, IDeserializationCallback
{
// const names used for serialization

View File

@@ -18,6 +18,9 @@ namespace System.Collections.Specialized
/// can be accessed either with the hash code of the key or with the index.</para>
/// </devdoc>
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public class NameValueCollection : NameObjectCollectionBase
{
private String[] _all;

View File

@@ -21,6 +21,9 @@ namespace System.Collections.Specialized
/// </para>
/// </devdoc>
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public class OrderedDictionary : IOrderedDictionary, ISerializable, IDeserializationCallback
{
private ArrayList _objectsArray;

View File

@@ -9,9 +9,12 @@ namespace System.Collections.Specialized
/// <para>Represents a collection of strings.</para>
/// </devdoc>
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public class StringCollection : IList
{
private readonly ArrayList _data = new ArrayList();
private readonly ArrayList data = new ArrayList(); // Do not rename (binary serialization)
/// <devdoc>
/// <para>Represents the entry at the specified index of the <see cref='System.Collections.Specialized.StringCollection'/>.</para>
@@ -20,11 +23,11 @@ namespace System.Collections.Specialized
{
get
{
return ((string)_data[index]);
return ((string)data[index]);
}
set
{
_data[index] = value;
data[index] = value;
}
}
@@ -36,7 +39,7 @@ namespace System.Collections.Specialized
{
get
{
return _data.Count;
return data.Count;
}
}
@@ -63,7 +66,7 @@ namespace System.Collections.Specialized
/// </devdoc>
public int Add(string value)
{
return _data.Add(value);
return data.Add(value);
}
/// <devdoc>
@@ -75,7 +78,7 @@ namespace System.Collections.Specialized
{
throw new ArgumentNullException(nameof(value));
}
_data.AddRange(value);
data.AddRange(value);
}
/// <devdoc>
@@ -84,7 +87,7 @@ namespace System.Collections.Specialized
/// </devdoc>
public void Clear()
{
_data.Clear();
data.Clear();
}
/// <devdoc>
@@ -94,7 +97,7 @@ namespace System.Collections.Specialized
/// </devdoc>
public bool Contains(string value)
{
return _data.Contains(value);
return data.Contains(value);
}
/// <devdoc>
@@ -103,7 +106,7 @@ namespace System.Collections.Specialized
/// </devdoc>
public void CopyTo(string[] array, int index)
{
_data.CopyTo(array, index);
data.CopyTo(array, index);
}
/// <devdoc>
@@ -121,7 +124,7 @@ namespace System.Collections.Specialized
/// </devdoc>
public int IndexOf(string value)
{
return _data.IndexOf(value);
return data.IndexOf(value);
}
/// <devdoc>
@@ -130,7 +133,7 @@ namespace System.Collections.Specialized
/// </devdoc>
public void Insert(int index, string value)
{
_data.Insert(index, value);
data.Insert(index, value);
}
/// <devdoc>
@@ -163,7 +166,7 @@ namespace System.Collections.Specialized
/// </devdoc>
public void Remove(string value)
{
_data.Remove(value);
data.Remove(value);
}
/// <devdoc>
@@ -171,7 +174,7 @@ namespace System.Collections.Specialized
/// </devdoc>
public void RemoveAt(int index)
{
_data.RemoveAt(index);
data.RemoveAt(index);
}
/// <devdoc>
@@ -181,7 +184,7 @@ namespace System.Collections.Specialized
{
get
{
return _data.SyncRoot;
return data.SyncRoot;
}
}
@@ -225,12 +228,12 @@ namespace System.Collections.Specialized
void ICollection.CopyTo(Array array, int index)
{
_data.CopyTo(array, index);
data.CopyTo(array, index);
}
IEnumerator IEnumerable.GetEnumerator()
{
return _data.GetEnumerator();
return data.GetEnumerator();
}
}

View File

@@ -12,6 +12,9 @@ namespace System.Collections.Specialized
/// with a proper StringComparer instance.</para>
/// </devdoc>
[Serializable]
#if !MONO
[System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
#endif
public class StringDictionary : IEnumerable
{
// For compatibility, we want the Keys property to return values in lower-case.

View File

@@ -430,9 +430,9 @@ namespace System.Collections.Specialized.Tests
[InlineData(0)]
public static void CreateSection_InvalidMaximumTest(short maxvalue)
{
Assert.Throws<ArgumentException>("maxValue", () => BitVector32.CreateSection(maxvalue));
AssertExtensions.Throws<ArgumentException>("maxValue", () => BitVector32.CreateSection(maxvalue));
BitVector32.Section valid = BitVector32.CreateSection(1);
Assert.Throws<ArgumentException>("maxValue", () => BitVector32.CreateSection(maxvalue, valid));
AssertExtensions.Throws<ArgumentException>("maxValue", () => BitVector32.CreateSection(maxvalue, valid));
}
[Theory]

View File

@@ -85,7 +85,7 @@ namespace System.Collections.Specialized.Tests
public void Add_Invalid(int count, bool caseInsensitive)
{
HybridDictionary hybridDictionary = Helpers.CreateHybridDictionary(count, caseInsensitive);
Assert.Throws<ArgumentNullException>("key", () => hybridDictionary.Add(null, "value"));
AssertExtensions.Throws<ArgumentNullException>("key", () => hybridDictionary.Add(null, "value"));
hybridDictionary.Add("key", "value");
Assert.Throws<ArgumentException>(null, () => hybridDictionary.Add("key", "value"));

View File

@@ -48,6 +48,9 @@ namespace System.Collections.Specialized.Tests
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
if (!PlatformDetection.IsNonZeroLowerBoundArraySupported)
return;
ICollection collection = NonGenericICollectionFactory(count);
Array arr = Array.CreateInstance(typeof(object), new int[] { count }, new int[] { 2 });
Assert.Equal(1, arr.Rank);

View File

@@ -48,6 +48,9 @@ namespace System.Collections.Specialized.Tests
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
if (!PlatformDetection.IsNonZeroLowerBoundArraySupported)
return;
ICollection collection = NonGenericICollectionFactory(count);
Array arr = Array.CreateInstance(typeof(object), new int[] { count }, new int[] { 2 });
Assert.Equal(1, arr.Rank);

View File

@@ -40,6 +40,9 @@ namespace System.Collections.Specialized.Tests
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
if (!PlatformDetection.IsNonZeroLowerBoundArraySupported)
return;
ICollection collection = NonGenericICollectionFactory(count);
Array arr = Array.CreateInstance(typeof(object), new int[] { count }, new int[] { 2 });
Assert.Equal(1, arr.Rank);

View File

@@ -49,6 +49,9 @@ namespace System.Collections.Specialized.Tests
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
if (!PlatformDetection.IsNonZeroLowerBoundArraySupported)
return;
ICollection collection = NonGenericICollectionFactory(count);
Array arr = Array.CreateInstance(typeof(object), new int[1] { count }, new int[1] { 2 });

View File

@@ -90,6 +90,9 @@ namespace System.Collections.Specialized.Tests
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
if (!PlatformDetection.IsNonZeroLowerBoundArraySupported)
return;
ICollection collection = NonGenericICollectionFactory(count);
Array arr = Array.CreateInstance(typeof(object), new int[1] { count }, new int[1] { 2 });

View File

@@ -90,6 +90,9 @@ namespace System.Collections.Specialized.Tests
[MemberData(nameof(ValidCollectionSizes))]
public override void ICollection_NonGeneric_CopyTo_NonZeroLowerBound(int count)
{
if (!PlatformDetection.IsNonZeroLowerBoundArraySupported)
return;
ICollection collection = NonGenericICollectionFactory(count);
Array arr = Array.CreateInstance(typeof(object), new int[1] { count }, new int[1] { 2 });

View File

@@ -10,6 +10,10 @@ namespace System.Collections.Specialized.Tests
public MyNameObjectCollection(int capacity) : base(capacity) { }
public MyNameObjectCollection(IEqualityComparer comparer) : base(comparer) { }
public MyNameObjectCollection(int capacity, IEqualityComparer comparer) : base(capacity, comparer) { }
#pragma warning disable CS0618 // Type or member is obsolete
public MyNameObjectCollection(IHashCodeProvider hashProvider, IComparer comparer) : base(hashProvider, comparer) { }
public MyNameObjectCollection(int capacity, IHashCodeProvider hashProvider, IComparer comparer) : base(capacity, hashProvider, comparer) { }
#pragma warning restore CS0618 // Type or member is obsolete
public new bool IsReadOnly
{

View File

@@ -1,14 +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.
namespace System.Collections.Specialized.Tests
{
public partial class MyNameObjectCollection : NameObjectCollectionBase
{
#pragma warning disable CS0618 // Type or member is obsolete
public MyNameObjectCollection(IHashCodeProvider hashProvider, IComparer comparer) : base(hashProvider, comparer) { }
public MyNameObjectCollection(int capacity, IHashCodeProvider hashProvider, IComparer comparer) : base(capacity, hashProvider, comparer) { }
#pragma warning restore CS0618 // Type or member is obsolete
}
}

View File

@@ -48,7 +48,7 @@ namespace System.Collections.Specialized.Tests
MyNameObjectCollection nameObjectCollection = Helpers.CreateNameObjectCollection(count);
ICollection collection = nameObjectCollection;
Assert.Throws<ArgumentNullException>("array", () => collection.CopyTo(null, 0));
AssertExtensions.Throws<ArgumentNullException>("array", () => collection.CopyTo(null, 0));
Assert.Throws<ArgumentException>(() => collection.CopyTo(new string[count, count], 0));
if (count > 0)
@@ -59,7 +59,7 @@ namespace System.Collections.Specialized.Tests
Assert.Throws<InvalidCastException>(() => collection.CopyTo(new Foo[count], 0));
}
Assert.Throws<ArgumentOutOfRangeException>("index", () => collection.CopyTo(new string[count], -1));
AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => collection.CopyTo(new string[count], -1));
Assert.Throws<ArgumentException>(null, () => collection.CopyTo(new string[count], 1));
Assert.Throws<ArgumentException>(null, () => collection.CopyTo(new string[count], count + 1));
}

View File

@@ -38,7 +38,7 @@ namespace System.Collections.Specialized.Tests
public static void GetAllValues_Invalid()
{
MyNameObjectCollection nameObjectCollection = new MyNameObjectCollection();
Assert.Throws<ArgumentNullException>("type", () => nameObjectCollection.GetAllValues(null));
AssertExtensions.Throws<ArgumentNullException>("type", () => nameObjectCollection.GetAllValues(null));
nameObjectCollection.Add("name", new Foo("value"));
Assert.Throws<ArrayTypeMismatchException>(() => nameObjectCollection.GetAllValues(typeof(string)));

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