From 9233fd508893bd9b9dfd2e16e2e1bdad3a04319b Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Wed, 5 Feb 2020 11:44:53 -0800 Subject: [PATCH] Nullability: RuntimeHelpers.GetHashCode should accept null obj input --- .../System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs | 2 +- src/libraries/System.Runtime/ref/System.Runtime.cs | 2 +- .../System/Runtime/CompilerServices/RuntimeHelpers.Mono.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs index 3f2c4d0e59028..0f2f96ef38ee8 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs @@ -107,7 +107,7 @@ public static void PrepareMethod(RuntimeMethodHandle method, RuntimeTypeHandle[] public static extern void PrepareDelegate(Delegate d); [MethodImpl(MethodImplOptions.InternalCall)] - public static extern int GetHashCode(object o); + public static extern int GetHashCode(object? o); [MethodImpl(MethodImplOptions.InternalCall)] public static extern new bool Equals(object? o1, object? o2); diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 9e91c7fc1cd90..af0088dc237e6 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -7273,7 +7273,7 @@ public static partial class RuntimeHelpers public static void EnsureSufficientExecutionStack() { } public static new bool Equals(object? o1, object? o2) { throw null; } public static void ExecuteCodeWithGuaranteedCleanup(System.Runtime.CompilerServices.RuntimeHelpers.TryCode code, System.Runtime.CompilerServices.RuntimeHelpers.CleanupCode backoutCode, object? userData) { } - public static int GetHashCode(object o) { throw null; } + public static int GetHashCode(object? o) { throw null; } [return: System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute("obj")] public static object? GetObjectValue(object? obj) { throw null; } public static T[] GetSubArray(T[] array, System.Range range) { throw null; } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.Mono.cs index 43efbaa9de655..79a6a6902593b 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.Mono.cs @@ -20,9 +20,9 @@ public static int OffsetToStringData { } [MethodImplAttribute (MethodImplOptions.InternalCall)] - static extern int InternalGetHashCode (object o); + static extern int InternalGetHashCode (object? o); - public static int GetHashCode (object o) + public static int GetHashCode (object? o) { return InternalGetHashCode (o); }