diff --git a/src/libraries/System.Collections/ref/System.Collections.cs b/src/libraries/System.Collections/ref/System.Collections.cs index 85f581fb8ad11c..c10810f6a5c97d 100644 --- a/src/libraries/System.Collections/ref/System.Collections.cs +++ b/src/libraries/System.Collections/ref/System.Collections.cs @@ -45,11 +45,11 @@ namespace System.Collections.Generic public static partial class CollectionExtensions { [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] - public static TValue GetValueOrDefault(this System.Collections.Generic.IReadOnlyDictionary dictionary, TKey key) where TKey : notnull { throw null; } + public static TValue GetValueOrDefault(this System.Collections.Generic.IReadOnlyDictionary dictionary, TKey key) { 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 static TValue GetValueOrDefault(this System.Collections.Generic.IReadOnlyDictionary dictionary, TKey key, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] TValue defaultValue) { throw null; } + public static bool Remove(this System.Collections.Generic.IDictionary dictionary, TKey key, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TValue value) { throw null; } + public static bool TryAdd(this System.Collections.Generic.IDictionary dictionary, TKey key, TValue value) { throw null; } } public abstract partial class Comparer : System.Collections.Generic.IComparer, System.Collections.IComparer { diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/CollectionExtensions.cs b/src/libraries/System.Collections/src/System/Collections/Generic/CollectionExtensions.cs index 24eed76b7e3b2d..a3b0bddcb1f721 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/CollectionExtensions.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/CollectionExtensions.cs @@ -9,13 +9,13 @@ namespace System.Collections.Generic public static class CollectionExtensions { [return: MaybeNull] - public static TValue GetValueOrDefault(this IReadOnlyDictionary dictionary, TKey key) where TKey : notnull + public static TValue GetValueOrDefault(this IReadOnlyDictionary dictionary, TKey key) { return dictionary.GetValueOrDefault(key, default); } [return: MaybeNull] - public static TValue GetValueOrDefault(this IReadOnlyDictionary dictionary, TKey key, [AllowNull] TValue defaultValue) where TKey : notnull + public static TValue GetValueOrDefault(this IReadOnlyDictionary dictionary, TKey key, [AllowNull] TValue defaultValue) { if (dictionary == null) { @@ -26,7 +26,7 @@ public static TValue GetValueOrDefault(this IReadOnlyDictionary(this IDictionary dictionary, TKey key, TValue value) where TKey : notnull + public static bool TryAdd(this IDictionary dictionary, TKey key, TValue value) { if (dictionary == null) { @@ -42,7 +42,7 @@ public static bool TryAdd(this IDictionary dictionar return false; } - public static bool Remove(this IDictionary dictionary, TKey key, [MaybeNullWhen(false)] out TValue value) where TKey : notnull + public static bool Remove(this IDictionary dictionary, TKey key, [MaybeNullWhen(false)] out TValue value) { if (dictionary == null) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/IDictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/IDictionary.cs index a79782c9d204c1..3e3fa3618cd0f1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/IDictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/IDictionary.cs @@ -10,7 +10,7 @@ namespace System.Collections.Generic // Keys can be any non-null object. Values can be any object. // You can look up a value in an IDictionary via the default indexed // property, Items. - public interface IDictionary : ICollection> where TKey : notnull + public interface IDictionary : ICollection> { // Interfaces are not serializable // The Item property provides methods to read and edit entries diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/IReadOnlyDictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/IReadOnlyDictionary.cs index af7ff0871dc1c9..47ec8eae759436 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/IReadOnlyDictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/IReadOnlyDictionary.cs @@ -7,7 +7,7 @@ namespace System.Collections.Generic { // Provides a read-only view of a generic dictionary. - public interface IReadOnlyDictionary : IReadOnlyCollection> where TKey : notnull + public interface IReadOnlyDictionary : IReadOnlyCollection> { bool ContainsKey(TKey key); bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value); diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index c1ce2529f3303f..b39fd8be029ed3 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -3954,7 +3954,7 @@ public partial interface IComparer { int Compare([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T x, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] T y); } - public partial interface IDictionary : System.Collections.Generic.ICollection>, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable where TKey : notnull + public partial interface IDictionary : System.Collections.Generic.ICollection>, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable { TValue this[TKey key] { get; set; } System.Collections.Generic.ICollection Keys { get; } @@ -3988,7 +3988,7 @@ public partial interface IReadOnlyCollection : System.Collections.Generic { int Count { get; } } - public partial interface IReadOnlyDictionary : System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.IEnumerable where TKey : notnull + public partial interface IReadOnlyDictionary : System.Collections.Generic.IEnumerable>, System.Collections.Generic.IReadOnlyCollection>, System.Collections.IEnumerable { TValue this[TKey key] { get; } System.Collections.Generic.IEnumerable Keys { get; }