You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
@ -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>
|
||||
|
@ -11,14 +11,17 @@ namespace System.Collections.ObjectModel
|
||||
[Serializable]
|
||||
[DebuggerTypeProxy(typeof(CollectionDebugView<>))]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, PublicKeyToken=b77a5c561934e089")]
|
||||
#endif
|
||||
public abstract class KeyedCollection<TKey, TItem> : Collection<TItem>
|
||||
{
|
||||
private const int defaultThreshold = 0;
|
||||
|
||||
private readonly IEqualityComparer<TKey> _comparer;
|
||||
private Dictionary<TKey, TItem> _dict;
|
||||
private int _keyCount;
|
||||
private readonly int _threshold;
|
||||
private readonly IEqualityComparer<TKey> comparer; // Do not rename (binary serialization)
|
||||
private Dictionary<TKey, TItem> dict; // Do not rename (binary serialization)
|
||||
private int keyCount; // Do not rename (binary serialization)
|
||||
private readonly int threshold; // Do not rename (binary serialization)
|
||||
|
||||
protected KeyedCollection() : this(null, defaultThreshold) { }
|
||||
|
||||
@ -44,8 +47,8 @@ namespace System.Collections.ObjectModel
|
||||
throw new ArgumentOutOfRangeException(nameof(dictionaryCreationThreshold), SR.ArgumentOutOfRange_InvalidThreshold);
|
||||
}
|
||||
|
||||
_comparer = comparer;
|
||||
_threshold = dictionaryCreationThreshold;
|
||||
this.comparer = comparer;
|
||||
threshold = dictionaryCreationThreshold;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -65,7 +68,7 @@ namespace System.Collections.ObjectModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _comparer;
|
||||
return comparer;
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,14 +93,14 @@ namespace System.Collections.ObjectModel
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
if (_dict != null)
|
||||
if (dict != null)
|
||||
{
|
||||
return _dict.ContainsKey(key);
|
||||
return dict.ContainsKey(key);
|
||||
}
|
||||
|
||||
foreach (TItem item in Items)
|
||||
{
|
||||
if (_comparer.Equals(GetKeyForItem(item), key)) return true;
|
||||
if (comparer.Equals(GetKeyForItem(item), key)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -109,15 +112,15 @@ namespace System.Collections.ObjectModel
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
if (_dict != null)
|
||||
if (dict != null)
|
||||
{
|
||||
return _dict.TryGetValue(key, out item);
|
||||
return dict.TryGetValue(key, out item);
|
||||
}
|
||||
|
||||
foreach (TItem itemInItems in Items)
|
||||
{
|
||||
TKey keyInItems = GetKeyForItem(itemInItems);
|
||||
if (keyInItems != null && _comparer.Equals(key, keyInItems))
|
||||
if (keyInItems != null && comparer.Equals(key, keyInItems))
|
||||
{
|
||||
item = itemInItems;
|
||||
return true;
|
||||
@ -131,13 +134,13 @@ namespace System.Collections.ObjectModel
|
||||
private bool ContainsItem(TItem item)
|
||||
{
|
||||
TKey key;
|
||||
if ((_dict == null) || ((key = GetKeyForItem(item)) == null))
|
||||
if ((dict == null) || ((key = GetKeyForItem(item)) == null))
|
||||
{
|
||||
return Items.Contains(item);
|
||||
}
|
||||
|
||||
TItem itemInDict;
|
||||
bool exist = _dict.TryGetValue(key, out itemInDict);
|
||||
bool exist = dict.TryGetValue(key, out itemInDict);
|
||||
if (exist)
|
||||
{
|
||||
return EqualityComparer<TItem>.Default.Equals(itemInDict, item);
|
||||
@ -152,15 +155,15 @@ namespace System.Collections.ObjectModel
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
if (_dict != null)
|
||||
if (dict != null)
|
||||
{
|
||||
TItem item;
|
||||
return _dict.TryGetValue(key, out item) && Remove(item);
|
||||
return dict.TryGetValue(key, out item) && Remove(item);
|
||||
}
|
||||
|
||||
for (int i = 0; i < Items.Count; i++)
|
||||
{
|
||||
if (_comparer.Equals(GetKeyForItem(Items[i]), key))
|
||||
if (comparer.Equals(GetKeyForItem(Items[i]), key))
|
||||
{
|
||||
RemoveItem(i);
|
||||
return true;
|
||||
@ -171,7 +174,7 @@ namespace System.Collections.ObjectModel
|
||||
|
||||
protected IDictionary<TKey, TItem> Dictionary
|
||||
{
|
||||
get { return _dict; }
|
||||
get { return dict; }
|
||||
}
|
||||
|
||||
protected void ChangeItemKey(TItem item, TKey newKey)
|
||||
@ -183,7 +186,7 @@ namespace System.Collections.ObjectModel
|
||||
}
|
||||
|
||||
TKey oldKey = GetKeyForItem(item);
|
||||
if (!_comparer.Equals(oldKey, newKey))
|
||||
if (!comparer.Equals(oldKey, newKey))
|
||||
{
|
||||
if (newKey != null)
|
||||
{
|
||||
@ -200,12 +203,12 @@ namespace System.Collections.ObjectModel
|
||||
protected override void ClearItems()
|
||||
{
|
||||
base.ClearItems();
|
||||
if (_dict != null)
|
||||
if (dict != null)
|
||||
{
|
||||
_dict.Clear();
|
||||
dict.Clear();
|
||||
}
|
||||
|
||||
_keyCount = 0;
|
||||
keyCount = 0;
|
||||
}
|
||||
|
||||
protected abstract TKey GetKeyForItem(TItem item);
|
||||
@ -235,11 +238,11 @@ namespace System.Collections.ObjectModel
|
||||
TKey newKey = GetKeyForItem(item);
|
||||
TKey oldKey = GetKeyForItem(Items[index]);
|
||||
|
||||
if (_comparer.Equals(oldKey, newKey))
|
||||
if (comparer.Equals(oldKey, newKey))
|
||||
{
|
||||
if (newKey != null && _dict != null)
|
||||
if (newKey != null && dict != null)
|
||||
{
|
||||
_dict[newKey] = item;
|
||||
dict[newKey] = item;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -259,14 +262,14 @@ namespace System.Collections.ObjectModel
|
||||
|
||||
private void AddKey(TKey key, TItem item)
|
||||
{
|
||||
if (_dict != null)
|
||||
if (dict != null)
|
||||
{
|
||||
_dict.Add(key, item);
|
||||
dict.Add(key, item);
|
||||
}
|
||||
else if (_keyCount == _threshold)
|
||||
else if (keyCount == threshold)
|
||||
{
|
||||
CreateDictionary();
|
||||
_dict.Add(key, item);
|
||||
dict.Add(key, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -275,19 +278,19 @@ namespace System.Collections.ObjectModel
|
||||
throw new ArgumentException(SR.Format(SR.Argument_AddingDuplicate, key));
|
||||
}
|
||||
|
||||
_keyCount++;
|
||||
keyCount++;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateDictionary()
|
||||
{
|
||||
_dict = new Dictionary<TKey, TItem>(_comparer);
|
||||
dict = new Dictionary<TKey, TItem>(comparer);
|
||||
foreach (TItem item in Items)
|
||||
{
|
||||
TKey key = GetKeyForItem(item);
|
||||
if (key != null)
|
||||
{
|
||||
_dict.Add(key, item);
|
||||
dict.Add(key, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -295,13 +298,13 @@ namespace System.Collections.ObjectModel
|
||||
private void RemoveKey(TKey key)
|
||||
{
|
||||
Debug.Assert(key != null, "key shouldn't be null!");
|
||||
if (_dict != null)
|
||||
if (dict != null)
|
||||
{
|
||||
_dict.Remove(key);
|
||||
dict.Remove(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
_keyCount--;
|
||||
keyCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace System.Collections.ObjectModel
|
||||
{
|
||||
@ -17,6 +18,9 @@ namespace System.Collections.ObjectModel
|
||||
[Serializable]
|
||||
[DebuggerTypeProxy(typeof(CollectionDebugView<>))]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=3.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
#endif
|
||||
public class ObservableCollection<T> : Collection<T>, INotifyCollectionChanged, INotifyPropertyChanged
|
||||
{
|
||||
//------------------------------------------------------
|
||||
@ -238,12 +242,16 @@ namespace System.Collections.ObjectModel
|
||||
NotifyCollectionChangedEventHandler handler = CollectionChanged;
|
||||
if (handler != null)
|
||||
{
|
||||
// Not calling BlockReentrancy() here to avoid the IDisposable box allocation.
|
||||
// Not calling BlockReentrancy() here to avoid the SimpleMonitor allocation.
|
||||
_blockReentrancyCount++;
|
||||
using (new BlockReentrancyDisposable(this))
|
||||
try
|
||||
{
|
||||
handler(this, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_blockReentrancyCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,8 +271,7 @@ namespace System.Collections.ObjectModel
|
||||
protected IDisposable BlockReentrancy()
|
||||
{
|
||||
_blockReentrancyCount++;
|
||||
// Lazily box the struct as IDisposable once and reuse the same boxed instance with subsequent calls.
|
||||
return _boxedBlockReentrancyDisposable ?? (_boxedBlockReentrancyDisposable = new BlockReentrancyDisposable(this));
|
||||
return EnsureMonitorInitialized();
|
||||
}
|
||||
|
||||
/// <summary> Check and assert for reentrant attempts to change this collection. </summary>
|
||||
@ -340,6 +347,25 @@ namespace System.Collections.ObjectModel
|
||||
{
|
||||
OnCollectionChanged(EventArgsCache.ResetCollectionChanged);
|
||||
}
|
||||
|
||||
private SimpleMonitor EnsureMonitorInitialized()
|
||||
{
|
||||
return _monitor ?? (_monitor = new SimpleMonitor(this));
|
||||
}
|
||||
|
||||
[OnSerializing]
|
||||
private void OnSerializing(StreamingContext context)
|
||||
{
|
||||
EnsureMonitorInitialized();
|
||||
_monitor._busyCount = _blockReentrancyCount;
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
_blockReentrancyCount = _monitor._busyCount;
|
||||
_monitor._collection = this;
|
||||
}
|
||||
#endregion Private Methods
|
||||
|
||||
//------------------------------------------------------
|
||||
@ -351,17 +377,26 @@ namespace System.Collections.ObjectModel
|
||||
#region Private Types
|
||||
|
||||
[Serializable]
|
||||
private struct BlockReentrancyDisposable : IDisposable
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=3.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
#endif
|
||||
private sealed class SimpleMonitor : IDisposable
|
||||
{
|
||||
private readonly ObservableCollection<T> _collection;
|
||||
internal int _busyCount; // Only used during (de)serialization to maintain compatibility with desktop.
|
||||
|
||||
public BlockReentrancyDisposable(ObservableCollection<T> collection)
|
||||
[NonSerialized]
|
||||
internal ObservableCollection<T> _collection;
|
||||
|
||||
public SimpleMonitor(ObservableCollection<T> collection)
|
||||
{
|
||||
Debug.Assert(collection != null);
|
||||
_collection = collection;
|
||||
}
|
||||
|
||||
public void Dispose() => _collection._blockReentrancyCount--;
|
||||
public void Dispose()
|
||||
{
|
||||
_collection._blockReentrancyCount--;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Types
|
||||
@ -374,8 +409,10 @@ namespace System.Collections.ObjectModel
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private SimpleMonitor _monitor; // Lazily allocated only when a subclass calls BlockReentrancy() or during serialization.
|
||||
|
||||
[NonSerialized]
|
||||
private int _blockReentrancyCount;
|
||||
private IDisposable _boxedBlockReentrancyDisposable; // Lazily allocated only when a subclass calls BlockReentrancy().
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,12 @@ namespace System.Collections.ObjectModel
|
||||
[Serializable]
|
||||
[DebuggerTypeProxy(typeof(DictionaryDebugView<,>))]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
|
||||
#endif
|
||||
public class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, IReadOnlyDictionary<TKey, TValue>
|
||||
{
|
||||
private readonly IDictionary<TKey, TValue> _dictionary;
|
||||
private readonly IDictionary<TKey, TValue> m_dictionary; // Do not rename (binary serialization)
|
||||
[NonSerialized]
|
||||
private Object _syncRoot;
|
||||
[NonSerialized]
|
||||
@ -30,12 +33,12 @@ namespace System.Collections.ObjectModel
|
||||
throw new ArgumentNullException(nameof(dictionary));
|
||||
}
|
||||
Contract.EndContractBlock();
|
||||
_dictionary = dictionary;
|
||||
m_dictionary = dictionary;
|
||||
}
|
||||
|
||||
protected IDictionary<TKey, TValue> Dictionary
|
||||
{
|
||||
get { return _dictionary; }
|
||||
get { return m_dictionary; }
|
||||
}
|
||||
|
||||
public KeyCollection Keys
|
||||
@ -45,7 +48,7 @@ namespace System.Collections.ObjectModel
|
||||
Contract.Ensures(Contract.Result<KeyCollection>() != null);
|
||||
if (_keys == null)
|
||||
{
|
||||
_keys = new KeyCollection(_dictionary.Keys);
|
||||
_keys = new KeyCollection(m_dictionary.Keys);
|
||||
}
|
||||
return _keys;
|
||||
}
|
||||
@ -58,7 +61,7 @@ namespace System.Collections.ObjectModel
|
||||
Contract.Ensures(Contract.Result<ValueCollection>() != null);
|
||||
if (_values == null)
|
||||
{
|
||||
_values = new ValueCollection(_dictionary.Values);
|
||||
_values = new ValueCollection(m_dictionary.Values);
|
||||
}
|
||||
return _values;
|
||||
}
|
||||
@ -68,7 +71,7 @@ namespace System.Collections.ObjectModel
|
||||
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
return _dictionary.ContainsKey(key);
|
||||
return m_dictionary.ContainsKey(key);
|
||||
}
|
||||
|
||||
ICollection<TKey> IDictionary<TKey, TValue>.Keys
|
||||
@ -81,7 +84,7 @@ namespace System.Collections.ObjectModel
|
||||
|
||||
public bool TryGetValue(TKey key, out TValue value)
|
||||
{
|
||||
return _dictionary.TryGetValue(key, out value);
|
||||
return m_dictionary.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
ICollection<TValue> IDictionary<TKey, TValue>.Values
|
||||
@ -96,7 +99,7 @@ namespace System.Collections.ObjectModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary[key];
|
||||
return m_dictionary[key];
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +117,7 @@ namespace System.Collections.ObjectModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dictionary[key];
|
||||
return m_dictionary[key];
|
||||
}
|
||||
set
|
||||
{
|
||||
@ -128,17 +131,17 @@ namespace System.Collections.ObjectModel
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return _dictionary.Count; }
|
||||
get { return m_dictionary.Count; }
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
return _dictionary.Contains(item);
|
||||
return m_dictionary.Contains(item);
|
||||
}
|
||||
|
||||
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
|
||||
{
|
||||
_dictionary.CopyTo(array, arrayIndex);
|
||||
m_dictionary.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly
|
||||
@ -167,7 +170,7 @@ namespace System.Collections.ObjectModel
|
||||
|
||||
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
|
||||
{
|
||||
return _dictionary.GetEnumerator();
|
||||
return m_dictionary.GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -176,7 +179,7 @@ namespace System.Collections.ObjectModel
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return ((IEnumerable)_dictionary).GetEnumerator();
|
||||
return ((IEnumerable)m_dictionary).GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -209,12 +212,12 @@ namespace System.Collections.ObjectModel
|
||||
|
||||
IDictionaryEnumerator IDictionary.GetEnumerator()
|
||||
{
|
||||
IDictionary d = _dictionary as IDictionary;
|
||||
IDictionary d = m_dictionary as IDictionary;
|
||||
if (d != null)
|
||||
{
|
||||
return d.GetEnumerator();
|
||||
}
|
||||
return new DictionaryEnumerator(_dictionary);
|
||||
return new DictionaryEnumerator(m_dictionary);
|
||||
}
|
||||
|
||||
bool IDictionary.IsFixedSize
|
||||
@ -294,14 +297,14 @@ namespace System.Collections.ObjectModel
|
||||
KeyValuePair<TKey, TValue>[] pairs = array as KeyValuePair<TKey, TValue>[];
|
||||
if (pairs != null)
|
||||
{
|
||||
_dictionary.CopyTo(pairs, index);
|
||||
m_dictionary.CopyTo(pairs, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
DictionaryEntry[] dictEntryArray = array as DictionaryEntry[];
|
||||
if (dictEntryArray != null)
|
||||
{
|
||||
foreach (var item in _dictionary)
|
||||
foreach (var item in m_dictionary)
|
||||
{
|
||||
dictEntryArray[index++] = new DictionaryEntry(item.Key, item.Value);
|
||||
}
|
||||
@ -316,7 +319,7 @@ namespace System.Collections.ObjectModel
|
||||
|
||||
try
|
||||
{
|
||||
foreach (var item in _dictionary)
|
||||
foreach (var item in m_dictionary)
|
||||
{
|
||||
objects[index++] = new KeyValuePair<TKey, TValue>(item.Key, item.Value);
|
||||
}
|
||||
@ -340,7 +343,7 @@ namespace System.Collections.ObjectModel
|
||||
{
|
||||
if (_syncRoot == null)
|
||||
{
|
||||
ICollection c = _dictionary as ICollection;
|
||||
ICollection c = m_dictionary as ICollection;
|
||||
if (c != null)
|
||||
{
|
||||
_syncRoot = c.SyncRoot;
|
||||
|
@ -18,6 +18,9 @@ namespace System.Collections.ObjectModel
|
||||
[Serializable]
|
||||
[DebuggerTypeProxy(typeof(CollectionDebugView<>))]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
#if !MONO
|
||||
[System.Runtime.CompilerServices.TypeForwardedFrom("WindowsBase, Version=3.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")]
|
||||
#endif
|
||||
public class ReadOnlyObservableCollection<T> : ReadOnlyCollection<T>, INotifyCollectionChanged, INotifyPropertyChanged
|
||||
{
|
||||
#region Constructors
|
||||
|
@ -19,6 +19,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(SerializeDeserialize_Roundtrips_MemberData))]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Serialization still WIP in UapAot: https://github.com/dotnet/corefx/issues/18942")]
|
||||
public void SerializeDeserialize_Roundtrips(TestCollection c)
|
||||
{
|
||||
TestCollection clone = BinaryFormatterHelpers.Clone(c);
|
@ -78,7 +78,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
[Fact]
|
||||
public static void IEnumerableConstructorTest_Negative()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("collection", () => new ObservableCollection<string>((IEnumerable<string>)null));
|
||||
AssertExtensions.Throws<ArgumentNullException>("collection", () => new ObservableCollection<string>((IEnumerable<string>)null));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -119,7 +119,8 @@ namespace System.Collections.ObjectModel.Tests
|
||||
|
||||
[Fact]
|
||||
// skip the test on desktop as "new ObservableCollection<int>()" returns 0 length collection
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
|
||||
// skip the test on UapAot as the requires Reflection on internal framework types.
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework | TargetFrameworkMonikers.UapAot)]
|
||||
public static void DebuggerAttributeTests()
|
||||
{
|
||||
DebuggerAttributes.ValidateDebuggerDisplayReferences(new ObservableCollection<int>());
|
||||
@ -132,5 +133,36 @@ namespace System.Collections.ObjectModel.Tests
|
||||
|
||||
public List<T> InnerList => (List<T>)base.Items;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that ArgumentNullException is thrown when given a null IEnumerable.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public static void ListConstructorTest_Negative()
|
||||
{
|
||||
AssertExtensions.Throws<ArgumentNullException>("list", () => new ObservableCollection<string>((List<string>)null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void ListConstructorTest()
|
||||
{
|
||||
List<string> collection = new List<string> { "one", "two", "three" };
|
||||
var actual = new ObservableCollection<string>(collection);
|
||||
Assert.Equal(collection, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void ListConstructorTest_MakesCopy()
|
||||
{
|
||||
List<string> collection = new List<string> { "one", "two", "three" };
|
||||
var oc = new ObservableCollectionSubclass<string>(collection);
|
||||
Assert.NotNull(oc.InnerList);
|
||||
Assert.NotSame(collection, oc.InnerList);
|
||||
}
|
||||
|
||||
private partial class ObservableCollectionSubclass<T> : ObservableCollection<T>
|
||||
{
|
||||
public ObservableCollectionSubclass(List<T> list) : base(list) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace System.Collections.ObjectModel.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests the public properties and constructor in ObservableCollection<T>.
|
||||
/// </summary>
|
||||
public partial class ConstructorAndPropertyTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests that ArgumentNullException is thrown when given a null IEnumerable.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public static void ListConstructorTest_Negative()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>("list", () => new ObservableCollection<string>((List<string>)null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void ListConstructorTest()
|
||||
{
|
||||
List<string> collection = new List<string> { "one", "two", "three" };
|
||||
var actual = new ObservableCollection<string>(collection);
|
||||
Assert.Equal(collection, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void ListConstructorTest_MakesCopy()
|
||||
{
|
||||
List<string> collection = new List<string> { "one", "two", "three" };
|
||||
var oc = new ObservableCollectionSubclass<string>(collection);
|
||||
Assert.NotNull(oc.InnerList);
|
||||
Assert.NotSame(collection, oc.InnerList);
|
||||
}
|
||||
|
||||
private partial class ObservableCollectionSubclass<T> : ObservableCollection<T>
|
||||
{
|
||||
public ObservableCollectionSubclass(List<T> list) : base(list) { }
|
||||
}
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(SerializeDeserialize_Roundtrips_MemberData))]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Serialization still WIP in UapAot: https://github.com/dotnet/corefx/issues/18942")]
|
||||
public void SerializeDeserialize_Roundtrips(ObservableCollection<int> c)
|
||||
{
|
||||
ObservableCollection<int> clone = BinaryFormatterHelpers.Clone(c);
|
@ -211,6 +211,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Cannot do DebuggerAttribute testing on UapAot: requires internal Reflection on framework types.")]
|
||||
public static void DebuggerAttributeTests()
|
||||
{
|
||||
DebuggerAttributes.ValidateDebuggerDisplayReferences(new ReadOnlyDictionary<int, int>(new Dictionary<int, int>()));
|
||||
@ -221,6 +222,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Cannot do DebuggerAttribute testing on UapAot: requires internal Reflection on framework types.")]
|
||||
public static void DebuggerAttribute_NullDictionary_ThrowsArgumentNullException()
|
||||
{
|
||||
TargetInvocationException ex = Assert.Throws<TargetInvocationException>(() => DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(ReadOnlyDictionary<int, int>), null));
|
||||
@ -229,6 +231,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Cannot do DebuggerAttribute testing on UapAot: requires internal Reflection on framework types.")]
|
||||
public static void DebuggerAttribute_NullDictionaryKeys_ThrowsArgumentNullException()
|
||||
{
|
||||
TargetInvocationException ex = Assert.Throws<TargetInvocationException>(() => DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(ReadOnlyDictionary<int, int>.KeyCollection), new Type[] { typeof(int) }, null));
|
||||
|
@ -19,6 +19,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(SerializeDeserialize_Roundtrips_MemberData))]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Serialization still WIP in UapAot: https://github.com/dotnet/corefx/issues/18942")]
|
||||
public void SerializeDeserialize_Roundtrips(ReadOnlyDictionary<string, string> d)
|
||||
{
|
||||
ReadOnlyDictionary<string, string> clone = BinaryFormatterHelpers.Clone(d);
|
@ -198,7 +198,8 @@ namespace System.Collections.ObjectModel.Tests
|
||||
|
||||
[Fact]
|
||||
// skip the test on desktop as "new ObservableCollection<int>()" returns 0 length collection
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
|
||||
// skip the test on UapAot as the requires Reflection on internal framework types.
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework | TargetFrameworkMonikers.UapAot)]
|
||||
public static void DebuggerAttribute_Tests()
|
||||
{
|
||||
DebuggerAttributes.ValidateDebuggerDisplayReferences(new ReadOnlyObservableCollection<int>(new ObservableCollection<int>()));
|
||||
|
@ -20,6 +20,7 @@ namespace System.Collections.ObjectModel.Tests
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(SerializeDeserialize_Roundtrips_MemberData))]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot, "Serialization still WIP in UapAot: https://github.com/dotnet/corefx/issues/18942")]
|
||||
public void SerializeDeserialize_Roundtrips(ReadOnlyObservableCollection<int> c)
|
||||
{
|
||||
ReadOnlyObservableCollection<int> clone = BinaryFormatterHelpers.Clone(c);
|
@ -9,6 +9,9 @@
|
||||
<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>
|
||||
@ -27,6 +30,9 @@
|
||||
<Compile Include="$(CommonTestPath)\System\Collections\IDictionaryTest.cs">
|
||||
<Link>Common\System\CollectionsIDictionaryTest.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
|
||||
<Link>Common\System\PlatformDetection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ComponentModel\INotifyPropertyChangingTests.cs" />
|
||||
<Compile Include="ComponentModel\PropertyChangingEventArgsTests.cs" />
|
||||
<Compile Include="KeyedCollection\TestMethods.cs" />
|
||||
@ -46,14 +52,13 @@
|
||||
<Compile Include="KeyedCollection\TestMethods.netcoreapp.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="KeyedCollection\Serialization.netstandard.cs" />
|
||||
<Compile Include="ObservableCollection\ObservableCollection_ConstructorAndPropertyTests.netstandard.cs" />
|
||||
<Compile Include="ObservableCollection\ObservableCollection_Serialization.netstandard.cs" />
|
||||
<Compile Include="ReadOnlyDictionary\ReadOnlyDictionary_SerializationTests.netstandard.cs" />
|
||||
<Compile Include="ReadOnlyObservableCollection\ReadOnlyObservableCollection_SerializationTests.netstandard.cs" />
|
||||
<Compile Include="KeyedCollection\Serialization.cs" />
|
||||
<Compile Include="ObservableCollection\ObservableCollection_Serialization.cs" />
|
||||
<Compile Include="ReadOnlyDictionary\ReadOnlyDictionary_SerializationTests.cs" />
|
||||
<Compile Include="ReadOnlyObservableCollection\ReadOnlyObservableCollection_SerializationTests.cs" />
|
||||
<Compile Include="$(CommonTestPath)\System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs">
|
||||
<Link>Common\System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user