diff options
Diffstat (limited to 'src/mscorlib/src/System/Collections/Generic/Comparer.cs')
-rw-r--r-- | src/mscorlib/src/System/Collections/Generic/Comparer.cs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/mscorlib/src/System/Collections/Generic/Comparer.cs b/src/mscorlib/src/System/Collections/Generic/Comparer.cs index 9f1a8bff6f..4f06b0af69 100644 --- a/src/mscorlib/src/System/Collections/Generic/Comparer.cs +++ b/src/mscorlib/src/System/Collections/Generic/Comparer.cs @@ -7,6 +7,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; using System.Diagnostics.Contracts; //using System.Globalization; using System.Runtime.CompilerServices; @@ -33,7 +34,7 @@ namespace System.Collections.Generic Contract.Ensures(Contract.Result<Comparer<T>>() != null); if (comparison == null) - throw new ArgumentNullException("comparison"); + throw new ArgumentNullException(nameof(comparison)); return new ComparisonComparer<T>(comparison); } @@ -42,7 +43,6 @@ namespace System.Collections.Generic // Note that logic in this method is replicated in vm\compile.cpp to ensure that NGen // saves the right instantiations // - [System.Security.SecuritySafeCritical] // auto-generated private static Comparer<T> CreateComparer() { object result = null; @@ -139,7 +139,7 @@ namespace System.Collections.Generic [Serializable] internal sealed class NullableComparer<T> : Comparer<T?> where T : struct, IComparable<T> { - public override int Compare(Nullable<T> x, Nullable<T> y) { + public override int Compare(T? x, T? y) { if (x.HasValue) { if (y.HasValue) return x.value.CompareTo(y.value); return 1; @@ -196,7 +196,7 @@ namespace System.Collections.Generic { public Int32EnumComparer() { - Contract.Assert(typeof(T).IsEnum, "This type is only intended to be used to compare enums!"); + Debug.Assert(typeof(T).IsEnum, "This type is only intended to be used to compare enums!"); } // Used by the serialization engine. @@ -216,7 +216,6 @@ namespace System.Collections.Generic public override int GetHashCode() => GetType().GetHashCode(); - [SecurityCritical] public void GetObjectData(SerializationInfo info, StreamingContext context) { // Previously Comparer<T> was not specialized for enums, @@ -232,7 +231,7 @@ namespace System.Collections.Generic { public UInt32EnumComparer() { - Contract.Assert(typeof(T).IsEnum, "This type is only intended to be used to compare enums!"); + Debug.Assert(typeof(T).IsEnum, "This type is only intended to be used to compare enums!"); } // Used by the serialization engine. @@ -252,7 +251,6 @@ namespace System.Collections.Generic public override int GetHashCode() => GetType().GetHashCode(); - [SecurityCritical] public void GetObjectData(SerializationInfo info, StreamingContext context) { info.SetType(typeof(ObjectComparer<T>)); @@ -264,7 +262,7 @@ namespace System.Collections.Generic { public Int64EnumComparer() { - Contract.Assert(typeof(T).IsEnum, "This type is only intended to be used to compare enums!"); + Debug.Assert(typeof(T).IsEnum, "This type is only intended to be used to compare enums!"); } // Used by the serialization engine. @@ -284,7 +282,6 @@ namespace System.Collections.Generic public override int GetHashCode() => GetType().GetHashCode(); - [SecurityCritical] public void GetObjectData(SerializationInfo info, StreamingContext context) { info.SetType(typeof(ObjectComparer<T>)); @@ -296,7 +293,7 @@ namespace System.Collections.Generic { public UInt64EnumComparer() { - Contract.Assert(typeof(T).IsEnum, "This type is only intended to be used to compare enums!"); + Debug.Assert(typeof(T).IsEnum, "This type is only intended to be used to compare enums!"); } // Used by the serialization engine. @@ -316,7 +313,6 @@ namespace System.Collections.Generic public override int GetHashCode() => GetType().GetHashCode(); - [SecurityCritical] public void GetObjectData(SerializationInfo info, StreamingContext context) { info.SetType(typeof(ObjectComparer<T>)); |