Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Win32.SafeHandles;
using System.Diagnostics.CodeAnalysis;

internal static partial class Interop
{
Expand Down Expand Up @@ -411,7 +412,7 @@ internal X509VerifyStatusCode(int code)

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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public readonly partial struct EventId
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; }
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -77,7 +79,7 @@ public bool Equals(EventId other)
}

/// <inheritdoc />
public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
if (obj is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ private void InvokeCallback(object? arg)
_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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;

namespace System.DirectoryServices.ActiveDirectory
{
Expand Down Expand Up @@ -41,7 +42,7 @@ public bool Equals(DistinguishedName dn)
return result;
}

public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
if (obj is DistinguishedName other)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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:
Expand Down Expand Up @@ -387,7 +388,7 @@ public static OperationStatus DecodeFromUtf8(ReadOnlySpan<byte> source, out Rune
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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// 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
{
internal struct ReferenceEqualsWrapper : IEquatable<ReferenceEqualsWrapper>
{
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);
}
Expand Down