From 760185cbdac974d51db4e7282533ff2b260a2c25 Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Thu, 13 Jun 2019 00:33:18 -0500 Subject: [PATCH] Add nullable annotations to System.Collections ref assembly (dotnet/corefx#38128) * Add nullable annotations to System.Collections ref assembly * Run GenAPI again with correct attributes format and output * Enable nullable to project * Apply nullable feedback, include attributes and object constraint to notnull Commit migrated from https://github.com/dotnet/corefx/commit/cc8137ede09cdf16811767a6fb262fb498d85e67 --- .../System.Collections/ref/System.Collections.cs | 175 +++++++++++---------- .../ref/System.Collections.csproj | 1 + 2 files changed, 93 insertions(+), 83 deletions(-) diff --git a/src/libraries/System.Collections/ref/System.Collections.cs b/src/libraries/System.Collections/ref/System.Collections.cs index ab33d35..690e2e3 100644 --- a/src/libraries/System.Collections/ref/System.Collections.cs +++ b/src/libraries/System.Collections/ref/System.Collections.cs @@ -44,29 +44,31 @@ namespace System.Collections.Generic { public static partial class CollectionExtensions { - public static TValue GetValueOrDefault(this System.Collections.Generic.IReadOnlyDictionary dictionary, TKey key) { throw null; } - public static TValue GetValueOrDefault(this System.Collections.Generic.IReadOnlyDictionary dictionary, TKey key, TValue defaultValue) { throw null; } - public static bool Remove(this System.Collections.Generic.IDictionary dictionary, TKey key, out TValue value) { throw null; } - public static bool TryAdd(this System.Collections.Generic.IDictionary dictionary, TKey key, TValue value) { throw null; } + [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] + public static TValue GetValueOrDefault(this System.Collections.Generic.IReadOnlyDictionary dictionary, TKey key) where TKey : notnull { throw null; } + [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] + public static TValue GetValueOrDefault(this System.Collections.Generic.IReadOnlyDictionary dictionary, TKey key, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] TValue defaultValue) where TKey : notnull { throw null; } + public static bool Remove(this System.Collections.Generic.IDictionary dictionary, TKey key, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TValue value) where TKey : notnull { throw null; } + public static bool TryAdd(this System.Collections.Generic.IDictionary dictionary, TKey key, TValue value) where TKey : notnull { throw null; } } public abstract partial class Comparer : System.Collections.Generic.IComparer, System.Collections.IComparer { protected Comparer() { } public static System.Collections.Generic.Comparer Default { get { throw null; } } - public abstract int Compare(T x, T y); + public abstract int Compare([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T x, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] T y); public static System.Collections.Generic.Comparer Create(System.Comparison comparison) { throw null; } - int System.Collections.IComparer.Compare(object x, object y) { throw null; } + int System.Collections.IComparer.Compare(object? x, object? y) { throw null; } } - public partial class Dictionary : 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, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable + public partial class Dictionary : 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, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable where TKey : notnull { public Dictionary() { } public Dictionary(System.Collections.Generic.IDictionary dictionary) { } - public Dictionary(System.Collections.Generic.IDictionary dictionary, System.Collections.Generic.IEqualityComparer comparer) { } + public Dictionary(System.Collections.Generic.IDictionary dictionary, System.Collections.Generic.IEqualityComparer? comparer) { } public Dictionary(System.Collections.Generic.IEnumerable> collection) { } - public Dictionary(System.Collections.Generic.IEnumerable> collection, System.Collections.Generic.IEqualityComparer comparer) { } - public Dictionary(System.Collections.Generic.IEqualityComparer comparer) { } + public Dictionary(System.Collections.Generic.IEnumerable> collection, System.Collections.Generic.IEqualityComparer? comparer) { } + public Dictionary(System.Collections.Generic.IEqualityComparer? comparer) { } public Dictionary(int capacity) { } - public Dictionary(int capacity, System.Collections.Generic.IEqualityComparer comparer) { } + public Dictionary(int capacity, System.Collections.Generic.IEqualityComparer? comparer) { } protected Dictionary(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public System.Collections.Generic.IEqualityComparer Comparer { get { throw null; } } public int Count { get { throw null; } } @@ -81,7 +83,8 @@ namespace System.Collections.Generic 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 { } } + [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] + 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.Dictionary.ValueCollection Values { get { throw null; } } @@ -92,16 +95,16 @@ namespace System.Collections.Generic public int EnsureCapacity(int capacity) { throw null; } public System.Collections.Generic.Dictionary.Enumerator GetEnumerator() { throw null; } public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } - public virtual void OnDeserialization(object sender) { } + public virtual void OnDeserialization(object? sender) { } public bool Remove(TKey key) { throw null; } - public bool Remove(TKey key, out TValue value) { throw null; } + public bool Remove(TKey key, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TValue value) { 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; } System.Collections.Generic.IEnumerator> System.Collections.Generic.IEnumerable>.GetEnumerator() { 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) { } @@ -109,7 +112,7 @@ namespace System.Collections.Generic public void TrimExcess() { } public void TrimExcess(int capacity) { } public bool TryAdd(TKey key, TValue value) { throw null; } - public bool TryGetValue(TKey key, out TValue value) { throw null; } + public bool TryGetValue(TKey key, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TValue value) { throw null; } public partial struct Enumerator : System.Collections.Generic.IEnumerator>, System.Collections.IDictionaryEnumerator, System.Collections.IEnumerator, System.IDisposable { private object _dummy; @@ -117,8 +120,8 @@ namespace System.Collections.Generic public System.Collections.Generic.KeyValuePair Current { get { throw null; } } System.Collections.DictionaryEntry System.Collections.IDictionaryEnumerator.Entry { get { throw null; } } object System.Collections.IDictionaryEnumerator.Key { get { throw null; } } - object System.Collections.IDictionaryEnumerator.Value { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IDictionaryEnumerator.Value { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } @@ -145,7 +148,7 @@ namespace System.Collections.Generic private object _dummy; private int _dummyPrimitive; public TKey Current { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } @@ -173,7 +176,7 @@ namespace System.Collections.Generic private object _dummy; private int _dummyPrimitive; public TValue Current { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } @@ -184,19 +187,21 @@ namespace System.Collections.Generic { protected EqualityComparer() { } public static System.Collections.Generic.EqualityComparer Default { get { throw null; } } - public abstract bool Equals(T x, T y); - public abstract int GetHashCode(T obj); - bool System.Collections.IEqualityComparer.Equals(object x, object y) { throw null; } - int System.Collections.IEqualityComparer.GetHashCode(object obj) { throw null; } + public abstract bool Equals([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T x, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] T y); + public abstract int GetHashCode([System.Diagnostics.CodeAnalysis.DisallowNullAttribute] T obj); + bool System.Collections.IEqualityComparer.Equals(object? x, object? y) { throw null; } +#pragma warning disable CS8617 // TODO-NULLABLE: Covariant parameter types (https://github.com/dotnet/roslyn/issues/30958) + int System.Collections.IEqualityComparer.GetHashCode(object? obj) { throw null; } +#pragma warning restore CS8617 } public partial class HashSet : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.ISet, System.Collections.IEnumerable, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable { public HashSet() { } public HashSet(System.Collections.Generic.IEnumerable collection) { } - public HashSet(System.Collections.Generic.IEnumerable collection, System.Collections.Generic.IEqualityComparer comparer) { } - public HashSet(System.Collections.Generic.IEqualityComparer comparer) { } + public HashSet(System.Collections.Generic.IEnumerable collection, System.Collections.Generic.IEqualityComparer? comparer) { } + public HashSet(System.Collections.Generic.IEqualityComparer? comparer) { } public HashSet(int capacity) { } - public HashSet(int capacity, System.Collections.Generic.IEqualityComparer comparer) { } + public HashSet(int capacity, System.Collections.Generic.IEqualityComparer? comparer) { } protected HashSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public System.Collections.Generic.IEqualityComparer Comparer { get { throw null; } } public int Count { get { throw null; } } @@ -217,7 +222,7 @@ namespace System.Collections.Generic public bool IsProperSupersetOf(System.Collections.Generic.IEnumerable other) { throw null; } public bool IsSubsetOf(System.Collections.Generic.IEnumerable other) { throw null; } public bool IsSupersetOf(System.Collections.Generic.IEnumerable other) { throw null; } - public virtual void OnDeserialization(object sender) { } + public virtual void OnDeserialization(object? sender) { } public bool Overlaps(System.Collections.Generic.IEnumerable other) { throw null; } public bool Remove(T item) { throw null; } public int RemoveWhere(System.Predicate match) { throw null; } @@ -227,7 +232,7 @@ namespace System.Collections.Generic System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public void TrimExcess() { } - public bool TryGetValue(T equalValue, out T actualValue) { throw null; } + public bool TryGetValue(T equalValue, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T actualValue) { throw null; } public void UnionWith(System.Collections.Generic.IEnumerable other) { } public partial struct Enumerator : System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable { @@ -235,7 +240,7 @@ namespace System.Collections.Generic private object _dummy; private int _dummyPrimitive; public T Current { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } @@ -244,9 +249,9 @@ namespace System.Collections.Generic public sealed partial class LinkedListNode { public LinkedListNode(T value) { } - public System.Collections.Generic.LinkedList List { get { throw null; } } - public System.Collections.Generic.LinkedListNode Next { get { throw null; } } - public System.Collections.Generic.LinkedListNode Previous { get { throw null; } } + public System.Collections.Generic.LinkedList? List { get { throw null; } } + public System.Collections.Generic.LinkedListNode? Next { get { throw null; } } + public System.Collections.Generic.LinkedListNode? Previous { get { throw null; } } public T Value { get { throw null; } set { } } } public partial class LinkedList : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.ICollection, System.Collections.IEnumerable, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable @@ -255,8 +260,8 @@ namespace System.Collections.Generic public LinkedList(System.Collections.Generic.IEnumerable collection) { } protected LinkedList(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public int Count { get { throw null; } } - public System.Collections.Generic.LinkedListNode First { get { throw null; } } - public System.Collections.Generic.LinkedListNode Last { get { throw null; } } + public System.Collections.Generic.LinkedListNode? First { get { throw null; } } + public System.Collections.Generic.LinkedListNode? Last { get { throw null; } } bool System.Collections.Generic.ICollection.IsReadOnly { get { throw null; } } bool System.Collections.ICollection.IsSynchronized { get { throw null; } } object System.Collections.ICollection.SyncRoot { get { throw null; } } @@ -271,11 +276,11 @@ namespace System.Collections.Generic public void Clear() { } public bool Contains(T value) { throw null; } public void CopyTo(T[] array, int index) { } - public System.Collections.Generic.LinkedListNode Find(T value) { throw null; } - public System.Collections.Generic.LinkedListNode FindLast(T value) { throw null; } + public System.Collections.Generic.LinkedListNode? Find(T value) { throw null; } + public System.Collections.Generic.LinkedListNode? FindLast(T value) { throw null; } public System.Collections.Generic.LinkedList.Enumerator GetEnumerator() { throw null; } public virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } - public virtual void OnDeserialization(object sender) { } + public virtual void OnDeserialization(object? sender) { } public void Remove(System.Collections.Generic.LinkedListNode node) { } public bool Remove(T value) { throw null; } public void RemoveFirst() { } @@ -290,11 +295,11 @@ namespace System.Collections.Generic private object _dummy; private int _dummyPrimitive; public T Current { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } - void System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(object sender) { } + void System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(object? sender) { } void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } } @@ -311,13 +316,13 @@ namespace System.Collections.Generic object System.Collections.ICollection.SyncRoot { get { throw null; } } bool System.Collections.IList.IsFixedSize { get { throw null; } } bool System.Collections.IList.IsReadOnly { get { throw null; } } - object System.Collections.IList.this[int index] { get { throw null; } set { } } + object? System.Collections.IList.this[int index] { get { throw null; } set { } } public void Add(T item) { } public void AddRange(System.Collections.Generic.IEnumerable collection) { } public System.Collections.ObjectModel.ReadOnlyCollection AsReadOnly() { throw null; } - public int BinarySearch(int index, int count, T item, System.Collections.Generic.IComparer comparer) { throw null; } + public int BinarySearch(int index, int count, T item, System.Collections.Generic.IComparer? comparer) { throw null; } public int BinarySearch(T item) { throw null; } - public int BinarySearch(T item, System.Collections.Generic.IComparer comparer) { throw null; } + public int BinarySearch(T item, System.Collections.Generic.IComparer? comparer) { throw null; } public void Clear() { } public bool Contains(T item) { throw null; } public System.Collections.Generic.List ConvertAll(System.Converter converter) { throw null; } @@ -325,11 +330,13 @@ namespace System.Collections.Generic public void CopyTo(T[] array) { } public void CopyTo(T[] array, int arrayIndex) { } public bool Exists(System.Predicate match) { throw null; } + [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public T Find(System.Predicate match) { throw null; } public System.Collections.Generic.List FindAll(System.Predicate match) { throw null; } public int FindIndex(int startIndex, int count, System.Predicate match) { throw null; } public int FindIndex(int startIndex, System.Predicate match) { throw null; } public int FindIndex(System.Predicate match) { throw null; } + [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public T FindLast(System.Predicate match) { throw null; } public int FindLastIndex(int startIndex, int count, System.Predicate match) { throw null; } public int FindLastIndex(int startIndex, System.Predicate match) { throw null; } @@ -352,17 +359,17 @@ namespace System.Collections.Generic public void Reverse() { } public void Reverse(int index, int count) { } public void Sort() { } - public void Sort(System.Collections.Generic.IComparer comparer) { } + public void Sort(System.Collections.Generic.IComparer? comparer) { } public void Sort(System.Comparison comparison) { } - public void Sort(int index, int count, System.Collections.Generic.IComparer comparer) { } + public void Sort(int index, int count, System.Collections.Generic.IComparer? comparer) { } System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } void System.Collections.ICollection.CopyTo(System.Array array, int arrayIndex) { } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - int System.Collections.IList.Add(object item) { throw null; } - bool System.Collections.IList.Contains(object item) { throw null; } - int System.Collections.IList.IndexOf(object item) { throw null; } - void System.Collections.IList.Insert(int index, object item) { } - void System.Collections.IList.Remove(object item) { } + int System.Collections.IList.Add(object? item) { throw null; } + bool System.Collections.IList.Contains(object? item) { throw null; } + int System.Collections.IList.IndexOf(object? item) { throw null; } + void System.Collections.IList.Insert(int index, object? item) { } + void System.Collections.IList.Remove(object? item) { } public T[] ToArray() { throw null; } public void TrimExcess() { } public bool TrueForAll(System.Predicate match) { throw null; } @@ -372,7 +379,7 @@ namespace System.Collections.Generic private object _dummy; private int _dummyPrimitive; public T Current { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } @@ -398,26 +405,26 @@ namespace System.Collections.Generic System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public T[] ToArray() { throw null; } public void TrimExcess() { } - 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 struct Enumerator : System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable { private T _currentElement; private object _dummy; private int _dummyPrimitive; public T Current { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } } } - public partial class SortedDictionary : 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 SortedDictionary : 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 SortedDictionary() { } - public SortedDictionary(System.Collections.Generic.IComparer comparer) { } + public SortedDictionary(System.Collections.Generic.IComparer? comparer) { } public SortedDictionary(System.Collections.Generic.IDictionary dictionary) { } - public SortedDictionary(System.Collections.Generic.IDictionary dictionary, System.Collections.Generic.IComparer comparer) { } + public SortedDictionary(System.Collections.Generic.IDictionary dictionary, System.Collections.Generic.IComparer? comparer) { } public System.Collections.Generic.IComparer Comparer { get { throw null; } } public int Count { get { throw null; } } public TValue this[TKey key] { get { throw null; } set { } } @@ -431,7 +438,7 @@ namespace System.Collections.Generic 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.SortedDictionary.ValueCollection Values { get { throw null; } } @@ -447,12 +454,12 @@ namespace System.Collections.Generic bool System.Collections.Generic.ICollection>.Remove(System.Collections.Generic.KeyValuePair keyValuePair) { throw null; } System.Collections.Generic.IEnumerator> System.Collections.Generic.IEnumerable>.GetEnumerator() { 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 bool TryGetValue(TKey key, out TValue value) { throw null; } + public bool TryGetValue(TKey key, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TValue value) { throw null; } public partial struct Enumerator : System.Collections.Generic.IEnumerator>, System.Collections.IDictionaryEnumerator, System.Collections.IEnumerator, System.IDisposable { private object _dummy; @@ -460,8 +467,8 @@ namespace System.Collections.Generic public System.Collections.Generic.KeyValuePair Current { get { throw null; } } System.Collections.DictionaryEntry System.Collections.IDictionaryEnumerator.Entry { get { throw null; } } object System.Collections.IDictionaryEnumerator.Key { get { throw null; } } - object System.Collections.IDictionaryEnumerator.Value { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IDictionaryEnumerator.Value { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } @@ -486,7 +493,7 @@ namespace System.Collections.Generic { private object _dummy; public TKey Current { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } @@ -512,21 +519,21 @@ namespace System.Collections.Generic { private object _dummy; public TValue Current { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } } } } - public partial class SortedList : 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 SortedList : 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 SortedList() { } - public SortedList(System.Collections.Generic.IComparer comparer) { } + public SortedList(System.Collections.Generic.IComparer? comparer) { } public SortedList(System.Collections.Generic.IDictionary dictionary) { } - public SortedList(System.Collections.Generic.IDictionary dictionary, System.Collections.Generic.IComparer comparer) { } + public SortedList(System.Collections.Generic.IDictionary dictionary, System.Collections.Generic.IComparer? comparer) { } public SortedList(int capacity) { } - public SortedList(int capacity, System.Collections.Generic.IComparer comparer) { } + public SortedList(int capacity, System.Collections.Generic.IComparer? comparer) { } public int Capacity { get { throw null; } set { } } public System.Collections.Generic.IComparer Comparer { get { throw null; } } public int Count { get { throw null; } } @@ -541,7 +548,7 @@ namespace System.Collections.Generic 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.IList Values { get { throw null; } } @@ -559,25 +566,27 @@ namespace System.Collections.Generic void System.Collections.Generic.ICollection>.CopyTo(System.Collections.Generic.KeyValuePair[] array, int arrayIndex) { } bool System.Collections.Generic.ICollection>.Remove(System.Collections.Generic.KeyValuePair keyValuePair) { throw null; } System.Collections.Generic.IEnumerator> System.Collections.Generic.IEnumerable>.GetEnumerator() { throw null; } - void System.Collections.ICollection.CopyTo(System.Array array, int arrayIndex) { } - void System.Collections.IDictionary.Add(object key, object value) { } + void System.Collections.ICollection.CopyTo(System.Array array, int index) { } + 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 void TrimExcess() { } - public bool TryGetValue(TKey key, out TValue value) { throw null; } + public bool TryGetValue(TKey key, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TValue value) { throw null; } } public partial class SortedSet : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.ISet, System.Collections.ICollection, System.Collections.IEnumerable, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable { public SortedSet() { } - public SortedSet(System.Collections.Generic.IComparer comparer) { } + public SortedSet(System.Collections.Generic.IComparer? comparer) { } public SortedSet(System.Collections.Generic.IEnumerable collection) { } - public SortedSet(System.Collections.Generic.IEnumerable collection, System.Collections.Generic.IComparer comparer) { } + public SortedSet(System.Collections.Generic.IEnumerable collection, System.Collections.Generic.IComparer? comparer) { } protected SortedSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public System.Collections.Generic.IComparer Comparer { get { throw null; } } public int Count { get { throw null; } } + [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public T Max { get { throw null; } } + [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public T Min { get { throw null; } } bool System.Collections.Generic.ICollection.IsReadOnly { get { throw null; } } bool System.Collections.ICollection.IsSynchronized { get { throw null; } } @@ -589,7 +598,7 @@ namespace System.Collections.Generic public void CopyTo(T[] array, int index) { } public void CopyTo(T[] array, int index, int count) { } public static System.Collections.Generic.IEqualityComparer> CreateSetComparer() { throw null; } - public static System.Collections.Generic.IEqualityComparer> CreateSetComparer(System.Collections.Generic.IEqualityComparer memberEqualityComparer) { throw null; } + public static System.Collections.Generic.IEqualityComparer> CreateSetComparer(System.Collections.Generic.IEqualityComparer? memberEqualityComparer) { throw null; } public void ExceptWith(System.Collections.Generic.IEnumerable other) { } public System.Collections.Generic.SortedSet.Enumerator GetEnumerator() { throw null; } protected virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } @@ -599,7 +608,7 @@ namespace System.Collections.Generic public bool IsProperSupersetOf(System.Collections.Generic.IEnumerable other) { throw null; } public bool IsSubsetOf(System.Collections.Generic.IEnumerable other) { throw null; } public bool IsSupersetOf(System.Collections.Generic.IEnumerable other) { throw null; } - protected virtual void OnDeserialization(object sender) { } + protected virtual void OnDeserialization(object? sender) { } public bool Overlaps(System.Collections.Generic.IEnumerable other) { throw null; } public bool Remove(T item) { throw null; } public int RemoveWhere(System.Predicate match) { throw null; } @@ -610,20 +619,20 @@ namespace System.Collections.Generic System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } void System.Collections.ICollection.CopyTo(System.Array array, int index) { } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - void System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(object sender) { } + void System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(object? sender) { } void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } - public bool TryGetValue(T equalValue, out T actualValue) { throw null; } + public bool TryGetValue(T equalValue, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T actualValue) { throw null; } public void UnionWith(System.Collections.Generic.IEnumerable other) { } public partial struct Enumerator : System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable { private object _dummy; private int _dummyPrimitive; public T Current { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } - void System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(object sender) { } + void System.Runtime.Serialization.IDeserializationCallback.OnDeserialization(object? sender) { } void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } } @@ -647,15 +656,15 @@ namespace System.Collections.Generic System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } public T[] ToArray() { throw null; } public void TrimExcess() { } - 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 partial struct Enumerator : System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable { private T _currentElement; private object _dummy; private int _dummyPrimitive; public T Current { get { throw null; } } - object System.Collections.IEnumerator.Current { get { throw null; } } + object? System.Collections.IEnumerator.Current { get { throw null; } } public void Dispose() { } public bool MoveNext() { throw null; } void System.Collections.IEnumerator.Reset() { } diff --git a/src/libraries/System.Collections/ref/System.Collections.csproj b/src/libraries/System.Collections/ref/System.Collections.csproj index 6644040..a82f8a3 100644 --- a/src/libraries/System.Collections/ref/System.Collections.csproj +++ b/src/libraries/System.Collections/ref/System.Collections.csproj @@ -2,6 +2,7 @@ {C746D448-E7C3-4850-9CA7-D3F1FA49742F} netcoreapp-Debug;netcoreapp-Release;uap-Debug;uap-Release + enable -- 2.7.4