Some mixed missed Equals nullable annotations (#52166)
authorhrrrrustic <35951936+hrrrrustic@users.noreply.github.com>
Wed, 2 Jun 2021 05:05:20 +0000 (08:05 +0300)
committerGitHub <noreply@github.com>
Wed, 2 Jun 2021 05:05:20 +0000 (22:05 -0700)
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs
src/libraries/Microsoft.Extensions.Logging.Abstractions/ref/Microsoft.Extensions.Logging.Abstractions.cs
src/libraries/Microsoft.Extensions.Logging.Abstractions/src/EventId.cs
src/libraries/Microsoft.Win32.SystemEvents/src/Microsoft/Win32/SystemEvents.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryEntryManager.cs
src/libraries/System.Text.Encodings.Web/src/Polyfills/System.Text.Rune.netstandard20.cs
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/ReferenceEqualsWrapper.cs

index 0e5806d..a8a272c 100644 (file)
@@ -6,6 +6,7 @@ using System.Runtime.InteropServices;
 using System.Security.Cryptography;
 using System.Security.Cryptography.X509Certificates;
 using Microsoft.Win32.SafeHandles;
+using System.Diagnostics.CodeAnalysis;
 
 internal static partial class Interop
 {
@@ -411,7 +412,7 @@ internal static partial class Interop
 
             public bool Equals(X509VerifyStatusCode other) => Code == other.Code;
 
-            public override bool Equals(object? obj) => obj is X509VerifyStatusCode other && Equals(other);
+            public override bool Equals([NotNullWhen(true)] object? obj) => obj is X509VerifyStatusCode other && Equals(other);
 
             public override int GetHashCode() => Code.GetHashCode();
 
index 60c0cd2..57deb72 100644 (file)
@@ -14,7 +14,7 @@ namespace Microsoft.Extensions.Logging
         public int Id { get { throw null; } }
         public string? Name { get { throw null; } }
         public bool Equals(Microsoft.Extensions.Logging.EventId other) { throw null; }
-        public override bool Equals(object? obj) { throw null; }
+        public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
         public override int GetHashCode() { throw null; }
         public static bool operator ==(Microsoft.Extensions.Logging.EventId left, Microsoft.Extensions.Logging.EventId right) { throw null; }
         public static implicit operator Microsoft.Extensions.Logging.EventId (int i) { throw null; }
index 7e031c5..972fb1e 100644 (file)
@@ -1,6 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
+using System.Diagnostics.CodeAnalysis;
+
 namespace Microsoft.Extensions.Logging
 {
     /// <summary>
@@ -77,7 +79,7 @@ namespace Microsoft.Extensions.Logging
         }
 
         /// <inheritdoc />
-        public override bool Equals(object? obj)
+        public override bool Equals([NotNullWhen(true)] object? obj)
         {
             if (obj is null)
             {
index 077e5fa..2322c2f 100644 (file)
@@ -1343,7 +1343,7 @@ namespace Microsoft.Win32
                 _delegate.DynamicInvoke((object[]?)arg);
             }
 
-            public override bool Equals(object? other)
+            public override bool Equals([NotNullWhen(true)] object? other)
             {
                 return other is SystemEventInvokeInfo otherInvoke && otherInvoke._delegate.Equals(_delegate);
             }
index d30f70c..89c1c6b 100644 (file)
@@ -3,6 +3,7 @@
 
 using System.Collections;
 using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
 
 namespace System.DirectoryServices.ActiveDirectory
 {
@@ -41,7 +42,7 @@ namespace System.DirectoryServices.ActiveDirectory
             return result;
         }
 
-        public override bool Equals(object? obj)
+        public override bool Equals([NotNullWhen(true)] object? obj)
         {
             if (obj is DistinguishedName other)
             {
index f99e39b..66c637e 100644 (file)
@@ -6,6 +6,7 @@ using System.Diagnostics;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Text.Encodings.Web;
+using System.Diagnostics.CodeAnalysis;
 
 // Contains a polyfill implementation of System.Text.Rune that works on netstandard2.0.
 // Implementation copied from:
@@ -387,7 +388,7 @@ namespace System.Text
             return OperationStatus.NeedMoreData;
         }
 
-        public override bool Equals(object? obj) => (obj is Rune other) && Equals(other);
+        public override bool Equals([NotNullWhen(true)] object? obj) => (obj is Rune other) && Equals(other);
 
         public bool Equals(Rune other) => this == other;
 
index dc292e2..d905ff9 100644 (file)
@@ -1,7 +1,8 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System.Runtime.CompilerServices;
+using System.Diagnostics.CodeAnalysis;
 
 namespace System.Text.Json.Serialization
 {
@@ -9,7 +10,7 @@ namespace System.Text.Json.Serialization
     {
         private object _object;
         public ReferenceEqualsWrapper(object obj) => _object = obj;
-        public override bool Equals(object? obj) => obj is ReferenceEqualsWrapper otherObj && Equals(otherObj);
+        public override bool Equals([NotNullWhen(true)] object? obj) => obj is ReferenceEqualsWrapper otherObj && Equals(otherObj);
         public bool Equals(ReferenceEqualsWrapper obj) => ReferenceEquals(_object, obj._object);
         public override int GetHashCode() => RuntimeHelpers.GetHashCode(_object);
     }