You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.22
Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
parent
5f4a27cc8a
commit
7d05485754
@ -12,7 +12,7 @@ namespace System.Collections.ObjectModel
|
||||
[DebuggerTypeProxy(typeof(CollectionDebugView<>))]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, PublicKeyToken=b77a5c561934e089")]
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
|
||||
#endif
|
||||
public abstract class KeyedCollection<TKey, TItem> : Collection<TItem>
|
||||
{
|
||||
|
@ -19,10 +19,24 @@ namespace System.Collections.ObjectModel
|
||||
[DebuggerTypeProxy(typeof(CollectionDebugView<>))]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=3.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
#endif
|
||||
public class ObservableCollection<T> : Collection<T>, INotifyCollectionChanged, INotifyPropertyChanged
|
||||
{
|
||||
//------------------------------------------------------
|
||||
//
|
||||
// Private Fields
|
||||
//
|
||||
//------------------------------------------------------
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private SimpleMonitor _monitor; // Lazily allocated only when a subclass calls BlockReentrancy() or during serialization. Do not rename (binary serialization)
|
||||
|
||||
[NonSerialized]
|
||||
private int _blockReentrancyCount;
|
||||
#endregion Private Fields
|
||||
|
||||
//------------------------------------------------------
|
||||
//
|
||||
// Constructors
|
||||
@ -363,8 +377,11 @@ namespace System.Collections.ObjectModel
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
_blockReentrancyCount = _monitor._busyCount;
|
||||
_monitor._collection = this;
|
||||
if (_monitor != null)
|
||||
{
|
||||
_blockReentrancyCount = _monitor._busyCount;
|
||||
_monitor._collection = this;
|
||||
}
|
||||
}
|
||||
#endregion Private Methods
|
||||
|
||||
@ -378,11 +395,11 @@ namespace System.Collections.ObjectModel
|
||||
|
||||
[Serializable]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=3.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
#endif
|
||||
private sealed class SimpleMonitor : IDisposable
|
||||
{
|
||||
internal int _busyCount; // Only used during (de)serialization to maintain compatibility with desktop.
|
||||
internal int _busyCount; // Only used during (de)serialization to maintain compatibility with desktop. Do not rename (binary serialization)
|
||||
|
||||
[NonSerialized]
|
||||
internal ObservableCollection<T> _collection;
|
||||
@ -400,20 +417,6 @@ namespace System.Collections.ObjectModel
|
||||
}
|
||||
|
||||
#endregion Private Types
|
||||
|
||||
//------------------------------------------------------
|
||||
//
|
||||
// Private Fields
|
||||
//
|
||||
//------------------------------------------------------
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private SimpleMonitor _monitor; // Lazily allocated only when a subclass calls BlockReentrancy() or during serialization.
|
||||
|
||||
[NonSerialized]
|
||||
private int _blockReentrancyCount;
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
internal static class EventArgsCache
|
||||
|
@ -19,7 +19,7 @@ namespace System.Collections.ObjectModel
|
||||
[DebuggerTypeProxy(typeof(CollectionDebugView<>))]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=3.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
#endif
|
||||
public class ReadOnlyObservableCollection<T> : ReadOnlyCollection<T>, INotifyCollectionChanged, INotifyPropertyChanged
|
||||
{
|
||||
@ -139,16 +139,6 @@ namespace System.Collections.ObjectModel
|
||||
OnPropertyChanged(e);
|
||||
}
|
||||
#endregion Private Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
//------------------------------------------------------
|
||||
//
|
||||
// Private Fields
|
||||
//
|
||||
//------------------------------------------------------
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,15 +18,9 @@ namespace System.Collections.ObjectModel.Tests
|
||||
new KeyedItem<string, int>("foo", 0),
|
||||
new KeyedItem<string, int>("bar", 1)
|
||||
};
|
||||
Assert.Throws<ArgumentException>(
|
||||
() =>
|
||||
collection.Add(new KeyedItem<string, int>("Foo", 0)));
|
||||
Assert.Throws<ArgumentException>(
|
||||
() =>
|
||||
collection.Add(new KeyedItem<string, int>("fOo", 0)));
|
||||
Assert.Throws<ArgumentException>(
|
||||
() =>
|
||||
collection.Add(new KeyedItem<string, int>("baR", 0)));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.Add(new KeyedItem<string, int>("Foo", 0)));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.Add(new KeyedItem<string, int>("fOo", 0)));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.Add(new KeyedItem<string, int>("baR", 0)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -368,8 +368,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
|
||||
collection.Add(keyedItem1);
|
||||
|
||||
Assert.Throws<ArgumentException>(
|
||||
() => { collection.Add(tmpKeyedItem); });
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.Add(tmpKeyedItem));
|
||||
|
||||
collection.Verify(keys, items, itemsWithKeys);
|
||||
}
|
||||
@ -486,8 +485,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
|
||||
collection.Add(keyedItem1);
|
||||
|
||||
Assert.Throws<ArgumentException>(
|
||||
() => { nonGenericCollection.Add(tmpKeyedItem); });
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => nonGenericCollection.Add(tmpKeyedItem));
|
||||
collection.Verify(keys, items, itemsWithKeys);
|
||||
}
|
||||
|
||||
@ -612,8 +610,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
.ToArray
|
||||
<IKeyedItem<TKey, TValue>>());
|
||||
|
||||
Assert.Throws<ArgumentException>(
|
||||
() => collection.MyChangeItemKey(keyedItem2, key1));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(keyedItem2, key1));
|
||||
collection.Verify(keys, items, itemsWithKeys);
|
||||
}
|
||||
|
||||
@ -700,13 +697,10 @@ namespace System.Collections.ObjectModel.Tests
|
||||
ki => ki.Key != null)
|
||||
.ToArray
|
||||
<IKeyedItem<TKey, TValue>>());
|
||||
Assert.Throws<ArgumentException>(
|
||||
() => collection.MyChangeItemKey(keyedItem3, key3));
|
||||
Assert.Throws<ArgumentException>(
|
||||
() => collection.MyChangeItemKey(keyedItem3, key2));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(keyedItem3, key3));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(keyedItem3, key2));
|
||||
var tempKeyedItem = new KeyedItem<TKey, TValue>(key1, item2);
|
||||
Assert.Throws<ArgumentException>(
|
||||
() => collection.MyChangeItemKey(tempKeyedItem, key2));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(tempKeyedItem, key2));
|
||||
collection.Verify(keys, items, itemsWithKeys);
|
||||
}
|
||||
|
||||
@ -876,9 +870,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
out items,
|
||||
out itemsWithKeys);
|
||||
collection.Add(item1);
|
||||
Assert.Throws<ArgumentException>(
|
||||
() =>
|
||||
collection.MyChangeItemKey(default(TValue), key2));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(default(TValue), key2));
|
||||
collection.Verify(
|
||||
keys.Push(key1),
|
||||
items.Push(item1),
|
||||
@ -1045,8 +1037,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
keyedItem2.Key = key3;
|
||||
if (collectionSize >= 32)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(
|
||||
() => collection.MyChangeItemKey(keyedItem2, key3));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(keyedItem2, key3));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1093,8 +1084,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
keyedItem2.Key = key3;
|
||||
if (collectionSize >= 32)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(
|
||||
() => collection.MyChangeItemKey(keyedItem2, key2));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(keyedItem2, key2));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1143,8 +1133,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
keyedItem2.Key = key3;
|
||||
if (collectionSize >= 32)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(
|
||||
() => collection.MyChangeItemKey(keyedItem2, key4));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(keyedItem2, key4));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1203,9 +1192,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
tempKeyedItem.Key = key3;
|
||||
if (collectionSize >= 32)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(
|
||||
() =>
|
||||
collection.MyChangeItemKey(tempKeyedItem, key3));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(tempKeyedItem, key3));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1265,11 +1252,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
tempKeyedItem.Key = key3;
|
||||
if (collectionSize >= 32)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(
|
||||
() =>
|
||||
collection.MyChangeItemKey(
|
||||
tempKeyedItem,
|
||||
default(TKey)));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(tempKeyedItem, default(TKey)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1333,9 +1316,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
tempKeyedItem.Key = key3;
|
||||
if (collectionSize >= 32)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(
|
||||
() =>
|
||||
collection.MyChangeItemKey(tempKeyedItem, key4));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(tempKeyedItem, key4));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1432,9 +1413,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
keyedItem2.Key = default(TKey);
|
||||
if (collectionSize >= 32)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(
|
||||
() =>
|
||||
collection.MyChangeItemKey(keyedItem2, key2));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(keyedItem2, key2));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1489,9 +1468,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
keyedItem2.Key = default(TKey);
|
||||
if (collectionSize >= 32 && keyedItem2.Key != null)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(
|
||||
() =>
|
||||
collection.MyChangeItemKey(keyedItem2, key4));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => collection.MyChangeItemKey(keyedItem2, key4));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2010,12 +1987,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
items = items.Push(keyedItem1);
|
||||
itemsWithKeys = itemsWithKeys.Push(keyedItem1);
|
||||
insert(collection, collection.Count, keyedItem1);
|
||||
Assert.Throws<ArgumentException>(
|
||||
() =>
|
||||
insert(
|
||||
collection,
|
||||
collection.Count,
|
||||
tempKeyedItem));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => insert(collection, collection.Count, tempKeyedItem));
|
||||
collection.Verify(keys, items, itemsWithKeys);
|
||||
}
|
||||
|
||||
|
@ -423,16 +423,16 @@ namespace System.Collections.ObjectModel.Tests
|
||||
foreach (var index in iArrLargeValues)
|
||||
{
|
||||
string[] aCopy = new string[collection.Count];
|
||||
Assert.Throws<ArgumentException>(() => collection.CopyTo(aCopy, index));
|
||||
AssertExtensions.Throws<ArgumentException>("destinationArray", null, () => collection.CopyTo(aCopy, index));
|
||||
}
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => collection.CopyTo(null, 1));
|
||||
|
||||
string[] copy = new string[collection.Count - 1];
|
||||
Assert.Throws<ArgumentException>(() => collection.CopyTo(copy, 0));
|
||||
AssertExtensions.Throws<ArgumentException>("destinationArray", "", () => collection.CopyTo(copy, 0));
|
||||
|
||||
copy = new string[0];
|
||||
Assert.Throws<ArgumentException>(() => collection.CopyTo(copy, 0));
|
||||
AssertExtensions.Throws<ArgumentException>("destinationArray", "", () => collection.CopyTo(copy, 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -3,6 +3,7 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization.Formatters.Tests;
|
||||
using Xunit;
|
||||
|
||||
@ -26,5 +27,17 @@ namespace System.Collections.ObjectModel.Tests
|
||||
Assert.NotSame(c, clone);
|
||||
Assert.Equal(c, clone);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
|
||||
public void OnDeserialized_MonitorNotInitialized_ExpectSuccess()
|
||||
{
|
||||
var observableCollection = new ObservableCollection<int>();
|
||||
MethodInfo onDeserializedMethodInfo = observableCollection.GetType().GetMethod("OnDeserialized",
|
||||
BindingFlags.Instance | Reflection.BindingFlags.NonPublic);
|
||||
|
||||
Assert.NotNull(onDeserializedMethodInfo);
|
||||
onDeserializedMethodInfo.Invoke(observableCollection, new object[] { null });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,16 +132,16 @@ namespace System.Collections.ObjectModel.Tests
|
||||
foreach (var index in iArrLargeValues)
|
||||
{
|
||||
string[] aCopy = new string[anArray.Length];
|
||||
Assert.Throws<ArgumentException>(() => readOnlyCol.CopyTo(aCopy, index));
|
||||
AssertExtensions.Throws<ArgumentException>("destinationArray", null, () => readOnlyCol.CopyTo(aCopy, index));
|
||||
}
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => readOnlyCol.CopyTo(null, 1));
|
||||
|
||||
string[] copy = new string[anArray.Length - 1];
|
||||
Assert.Throws<ArgumentException>(() => readOnlyCol.CopyTo(copy, 0));
|
||||
AssertExtensions.Throws<ArgumentException>("destinationArray", "", () => readOnlyCol.CopyTo(copy, 0));
|
||||
|
||||
copy = new string[0];
|
||||
Assert.Throws<ArgumentException>(() => readOnlyCol.CopyTo(copy, 0));
|
||||
AssertExtensions.Throws<ArgumentException>("destinationArray", "", () => readOnlyCol.CopyTo(copy, 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -9,9 +9,6 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="$(CommonTestPath)\System\AssertExtensions.cs">
|
||||
<Link>Common\System\AssertExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonTestPath)\System\Collections\IEnumerableTest.cs">
|
||||
<Link>Common\System\CollectionsIEnumerableTest.cs</Link>
|
||||
</Compile>
|
||||
|
Reference in New Issue
Block a user