From bc8d26236d4ffd8746d0a7bb42774fae01a3e784 Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Tue, 18 Jun 2019 18:35:07 -0700 Subject: [PATCH] Add nullable annotations to System.Collections.Concurrent ref assembly (dotnet/corefx#38189) * Add nullable annotations to System.Collections.Concurrent ref assembly * Re-run GenAPI after some attribute fixes * Update attributes and object -> notnull constraint Commit migrated from https://github.com/dotnet/corefx/commit/1494abacb0ec55e7065282311966b1c32329a1f5 --- .../ref/System.Collections.Concurrent.cs | 70 +++++++++++----------- .../ref/System.Collections.Concurrent.csproj | 1 + 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs b/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs index 3c73cac..57a21d2 100644 --- a/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs +++ b/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.cs @@ -34,8 +34,8 @@ namespace System.Collections.Concurrent System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public T Take() { throw null; } public T Take(System.Threading.CancellationToken cancellationToken) { throw null; } - public static int TakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, out T item) { throw null; } - public static int TakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, out T item, System.Threading.CancellationToken cancellationToken) { throw null; } + public static int TakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item) { throw null; } + public static int TakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item, System.Threading.CancellationToken cancellationToken) { throw null; } public T[] ToArray() { throw null; } public bool TryAdd(T item) { throw null; } public bool TryAdd(T item, int millisecondsTimeout) { throw null; } @@ -45,14 +45,14 @@ namespace System.Collections.Concurrent public static int TryAddToAny(System.Collections.Concurrent.BlockingCollection[] collections, T item, int millisecondsTimeout) { throw null; } public static int TryAddToAny(System.Collections.Concurrent.BlockingCollection[] collections, T item, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } public static int TryAddToAny(System.Collections.Concurrent.BlockingCollection[] collections, T item, System.TimeSpan timeout) { throw null; } - public bool TryTake(out T item) { throw null; } - public bool TryTake(out T item, int millisecondsTimeout) { throw null; } - public bool TryTake(out T item, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } - public bool TryTake(out T item, System.TimeSpan timeout) { throw null; } - public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, out T item) { throw null; } - public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, out T item, int millisecondsTimeout) { throw null; } - public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, out T item, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } - public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, out T item, System.TimeSpan timeout) { throw null; } + public bool TryTake([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T item) { throw null; } + public bool TryTake([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T item, int millisecondsTimeout) { throw null; } + public bool TryTake([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T item, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } + public bool TryTake([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T item, System.TimeSpan timeout) { throw null; } + public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item) { throw null; } + public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item, int millisecondsTimeout) { throw null; } + public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; } + public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item, System.TimeSpan timeout) { throw null; } } public partial class ConcurrentBag : System.Collections.Concurrent.IProducerConsumerCollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.ICollection, System.Collections.IEnumerable { @@ -70,30 +70,30 @@ namespace System.Collections.Concurrent void System.Collections.ICollection.CopyTo(System.Array array, int index) { } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public T[] ToArray() { throw null; } - public bool TryPeek(out T result) { throw null; } - public bool TryTake(out T result) { throw null; } + public bool TryPeek([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T result) { throw null; } + public bool TryTake([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T result) { throw null; } } - public partial class ConcurrentDictionary : System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.Generic.IReadOnlyDictionary, System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable + public partial class ConcurrentDictionary : System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.Generic.IReadOnlyDictionary, System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable where TKey : notnull { public ConcurrentDictionary() { } public ConcurrentDictionary(System.Collections.Generic.IEnumerable> collection) { } - public ConcurrentDictionary(System.Collections.Generic.IEnumerable> collection, System.Collections.Generic.IEqualityComparer comparer) { } - public ConcurrentDictionary(System.Collections.Generic.IEqualityComparer comparer) { } - public ConcurrentDictionary(int concurrencyLevel, System.Collections.Generic.IEnumerable> collection, System.Collections.Generic.IEqualityComparer comparer) { } + public ConcurrentDictionary(System.Collections.Generic.IEnumerable> collection, System.Collections.Generic.IEqualityComparer? comparer) { } + public ConcurrentDictionary(System.Collections.Generic.IEqualityComparer? comparer) { } + public ConcurrentDictionary(int concurrencyLevel, System.Collections.Generic.IEnumerable> collection, System.Collections.Generic.IEqualityComparer? comparer) { } public ConcurrentDictionary(int concurrencyLevel, int capacity) { } - public ConcurrentDictionary(int concurrencyLevel, int capacity, System.Collections.Generic.IEqualityComparer comparer) { } + public ConcurrentDictionary(int concurrencyLevel, int capacity, System.Collections.Generic.IEqualityComparer? comparer) { } public int Count { get { throw null; } } public bool IsEmpty { get { throw null; } } public TValue this[TKey key] { get { throw null; } set { } } public System.Collections.Generic.ICollection Keys { get { throw null; } } - bool System.Collections.Generic.ICollection>.IsReadOnly { get { throw null; } } - System.Collections.Generic.IEnumerable System.Collections.Generic.IReadOnlyDictionary.Keys { get { throw null; } } - System.Collections.Generic.IEnumerable System.Collections.Generic.IReadOnlyDictionary.Values { get { throw null; } } + bool System.Collections.Generic.ICollection>.IsReadOnly { get { throw null; } } + System.Collections.Generic.IEnumerable System.Collections.Generic.IReadOnlyDictionary.Keys { get { throw null; } } + System.Collections.Generic.IEnumerable System.Collections.Generic.IReadOnlyDictionary.Values { get { throw null; } } bool System.Collections.ICollection.IsSynchronized { get { throw null; } } object System.Collections.ICollection.SyncRoot { get { throw null; } } bool System.Collections.IDictionary.IsFixedSize { get { throw null; } } bool System.Collections.IDictionary.IsReadOnly { get { throw null; } } - object System.Collections.IDictionary.this[object key] { get { throw null; } set { } } + object? System.Collections.IDictionary.this[object key] { get { throw null; } set { } } System.Collections.ICollection System.Collections.IDictionary.Keys { get { throw null; } } System.Collections.ICollection System.Collections.IDictionary.Values { get { throw null; } } public System.Collections.Generic.ICollection Values { get { throw null; } } @@ -106,22 +106,22 @@ namespace System.Collections.Concurrent public TValue GetOrAdd(TKey key, System.Func valueFactory) { throw null; } public TValue GetOrAdd(TKey key, TValue value) { throw null; } public TValue GetOrAdd(TKey key, System.Func valueFactory, TArg factoryArgument) { throw null; } - void System.Collections.Generic.ICollection>.Add(System.Collections.Generic.KeyValuePair keyValuePair) { } - bool System.Collections.Generic.ICollection>.Contains(System.Collections.Generic.KeyValuePair keyValuePair) { throw null; } - void System.Collections.Generic.ICollection>.CopyTo(System.Collections.Generic.KeyValuePair[] array, int index) { } - bool System.Collections.Generic.ICollection>.Remove(System.Collections.Generic.KeyValuePair keyValuePair) { throw null; } - void System.Collections.Generic.IDictionary.Add(TKey key, TValue value) { } - bool System.Collections.Generic.IDictionary.Remove(TKey key) { throw null; } + void System.Collections.Generic.ICollection>.Add(System.Collections.Generic.KeyValuePair keyValuePair) { } + bool System.Collections.Generic.ICollection>.Contains(System.Collections.Generic.KeyValuePair keyValuePair) { throw null; } + void System.Collections.Generic.ICollection>.CopyTo(System.Collections.Generic.KeyValuePair[] array, int index) { } + bool System.Collections.Generic.ICollection>.Remove(System.Collections.Generic.KeyValuePair keyValuePair) { throw null; } + void System.Collections.Generic.IDictionary.Add(TKey key, TValue value) { } + bool System.Collections.Generic.IDictionary.Remove(TKey key) { throw null; } void System.Collections.ICollection.CopyTo(System.Array array, int index) { } - void System.Collections.IDictionary.Add(object key, object value) { } + void System.Collections.IDictionary.Add(object key, object? value) { } bool System.Collections.IDictionary.Contains(object key) { throw null; } System.Collections.IDictionaryEnumerator System.Collections.IDictionary.GetEnumerator() { throw null; } void System.Collections.IDictionary.Remove(object key) { } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public System.Collections.Generic.KeyValuePair[] ToArray() { throw null; } public bool TryAdd(TKey key, TValue value) { throw null; } - public bool TryGetValue(TKey key, out TValue value) { throw null; } - public bool TryRemove(TKey key, out TValue value) { throw null; } + public bool TryGetValue(TKey key, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TValue value) { throw null; } + public bool TryRemove(TKey key, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TValue value) { throw null; } public bool TryUpdate(TKey key, TValue newValue, TValue comparisonValue) { throw null; } } public partial class ConcurrentQueue : System.Collections.Concurrent.IProducerConsumerCollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.ICollection, System.Collections.IEnumerable @@ -141,8 +141,8 @@ namespace System.Collections.Concurrent void System.Collections.ICollection.CopyTo(System.Array array, int index) { } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public T[] ToArray() { throw null; } - public bool TryDequeue(out T result) { throw null; } - public bool TryPeek(out T result) { throw null; } + public bool TryDequeue([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T result) { throw null; } + public bool TryPeek([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T result) { throw null; } } public partial class ConcurrentStack : System.Collections.Concurrent.IProducerConsumerCollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.ICollection, System.Collections.IEnumerable { @@ -163,8 +163,8 @@ namespace System.Collections.Concurrent void System.Collections.ICollection.CopyTo(System.Array array, int index) { } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public T[] ToArray() { throw null; } - public bool TryPeek(out T result) { throw null; } - public bool TryPop(out T result) { throw null; } + public bool TryPeek([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T result) { throw null; } + public bool TryPop([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T result) { throw null; } public int TryPopRange(T[] items) { throw null; } public int TryPopRange(T[] items, int startIndex, int count) { throw null; } } @@ -179,7 +179,7 @@ namespace System.Collections.Concurrent void CopyTo(T[] array, int index); T[] ToArray(); bool TryAdd(T item); - bool TryTake(out T item); + bool TryTake([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T item); } public abstract partial class OrderablePartitioner : System.Collections.Concurrent.Partitioner { diff --git a/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.csproj b/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.csproj index 7fc75d7..9388889 100644 --- a/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.csproj +++ b/src/libraries/System.Collections.Concurrent/ref/System.Collections.Concurrent.csproj @@ -2,6 +2,7 @@ {772CB0A7-3D45-4D3A-B975-671A1937C761} netcoreapp-Debug;netcoreapp-Release;uap-Debug;uap-Release + enable -- 2.7.4