Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Reflection.* missed Equals nullable annotations #52162

Merged
merged 7 commits into from
May 22, 2021
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 @@ -291,7 +291,7 @@ void System.IDisposable.Dispose() { }
public System.Guid Guid { get { throw null; } }
public bool IsDefault { get { throw null; } }
public uint Stamp { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.BlobContentId other) { throw null; }
public static System.Reflection.Metadata.BlobContentId FromHash(byte[] hashCode) { throw null; }
public static System.Reflection.Metadata.BlobContentId FromHash(System.Collections.Immutable.ImmutableArray<byte> hashCode) { throw null; }
Expand All @@ -304,7 +304,7 @@ void System.IDisposable.Dispose() { }
{
private readonly int _dummyPrimitive;
public bool IsNil { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.BlobHandle other) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.BlobHandle left, System.Reflection.Metadata.BlobHandle right) { throw null; }
Expand Down Expand Up @@ -538,7 +538,7 @@ public readonly partial struct CustomDebugInformation
{
private readonly int _dummyPrimitive;
public bool IsNil { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.CustomDebugInformationHandle other) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.CustomDebugInformationHandle left, System.Reflection.Metadata.CustomDebugInformationHandle right) { throw null; }
Expand Down Expand Up @@ -661,7 +661,7 @@ void System.IDisposable.Dispose() { }
{
private readonly int _dummyPrimitive;
public bool IsNil { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.DocumentNameBlobHandle other) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.DocumentNameBlobHandle left, System.Reflection.Metadata.DocumentNameBlobHandle right) { throw null; }
Expand All @@ -676,7 +676,7 @@ void System.IDisposable.Dispose() { }
public static readonly System.Reflection.Metadata.ModuleDefinitionHandle ModuleDefinition;
public bool IsNil { get { throw null; } }
public System.Reflection.Metadata.HandleKind Kind { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.EntityHandle other) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.EntityHandle left, System.Reflection.Metadata.EntityHandle right) { throw null; }
Expand Down Expand Up @@ -932,7 +932,7 @@ void System.IDisposable.Dispose() { }
{
private readonly int _dummyPrimitive;
public bool IsNil { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.GuidHandle other) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.GuidHandle left, System.Reflection.Metadata.GuidHandle right) { throw null; }
Expand All @@ -947,7 +947,7 @@ void System.IDisposable.Dispose() { }
public static readonly System.Reflection.Metadata.ModuleDefinitionHandle ModuleDefinition;
public bool IsNil { get { throw null; } }
public System.Reflection.Metadata.HandleKind Kind { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.Handle other) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.Handle left, System.Reflection.Metadata.Handle right) { throw null; }
Expand Down Expand Up @@ -1320,7 +1320,7 @@ void System.IDisposable.Dispose() { }
{
private readonly int _dummyPrimitive;
public bool IsNil { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.ImportScopeHandle other) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.ImportScopeHandle left, System.Reflection.Metadata.ImportScopeHandle right) { throw null; }
Expand Down Expand Up @@ -1400,7 +1400,7 @@ public readonly partial struct LocalConstant
{
private readonly int _dummyPrimitive;
public bool IsNil { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.LocalConstantHandle other) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.LocalConstantHandle left, System.Reflection.Metadata.LocalConstantHandle right) { throw null; }
Expand Down Expand Up @@ -2006,7 +2006,7 @@ public partial struct NamespaceDefinition
{
private readonly int _dummyPrimitive;
public bool IsNil { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.NamespaceDefinitionHandle other) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.NamespaceDefinitionHandle left, System.Reflection.Metadata.NamespaceDefinitionHandle right) { throw null; }
Expand Down Expand Up @@ -2176,7 +2176,7 @@ void System.IDisposable.Dispose() { }
public int Offset { get { throw null; } }
public int StartColumn { get { throw null; } }
public int StartLine { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.SequencePoint other) { throw null; }
public override int GetHashCode() { throw null; }
}
Expand Down Expand Up @@ -2248,7 +2248,7 @@ public partial struct SignatureHeader : System.IEquatable<System.Reflection.Meta
public bool IsInstance { get { throw null; } }
public System.Reflection.Metadata.SignatureKind Kind { get { throw null; } }
public byte RawValue { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.SignatureHeader other) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.SignatureHeader left, System.Reflection.Metadata.SignatureHeader right) { throw null; }
Expand Down Expand Up @@ -2588,7 +2588,7 @@ public readonly partial struct CustomModifiersEncoder
public EditAndContinueLogEntry(System.Reflection.Metadata.EntityHandle handle, System.Reflection.Metadata.Ecma335.EditAndContinueOperation operation) { throw null; }
public System.Reflection.Metadata.EntityHandle Handle { get { throw null; } }
public System.Reflection.Metadata.Ecma335.EditAndContinueOperation Operation { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.Ecma335.EditAndContinueLogEntry other) { throw null; }
public override int GetHashCode() { throw null; }
}
Expand Down Expand Up @@ -2684,7 +2684,7 @@ public void Token(System.Reflection.Metadata.EntityHandle handle) { }
private readonly int _dummyPrimitive;
public int Id { get { throw null; } }
public bool IsNil { get { throw null; } }
public override bool Equals(object? obj) { throw null; }
public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
public bool Equals(System.Reflection.Metadata.Ecma335.LabelHandle other) { throw null; }
public override int GetHashCode() { throw null; }
public static bool operator ==(System.Reflection.Metadata.Ecma335.LabelHandle left, System.Reflection.Metadata.Ecma335.LabelHandle right) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Reflection.Internal;
using System.Diagnostics.CodeAnalysis;

namespace System.Reflection.Metadata
{
Expand Down Expand Up @@ -100,7 +101,7 @@ public static Func<IEnumerable<Blob>, BlobContentId> GetTimeBasedProvider()
}

public bool Equals(BlobContentId other) => Guid == other.Guid && Stamp == other.Stamp;
public override bool Equals(object? obj) => obj is BlobContentId bcid && Equals(bcid);
public override bool Equals([NotNullWhen(true)] object? obj) => obj is BlobContentId bcid && Equals(bcid);
public override int GetHashCode() => Hash.Combine(Stamp, Guid.GetHashCode());
public static bool operator ==(BlobContentId left, BlobContentId right) => left.Equals(right);
public static bool operator !=(BlobContentId left, BlobContentId right) => !left.Equals(right);
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 System.Reflection.Metadata.Ecma335
{
public readonly struct EditAndContinueLogEntry : IEquatable<EditAndContinueLogEntry>
Expand All @@ -14,8 +16,8 @@ public EditAndContinueLogEntry(EntityHandle handle, EditAndContinueOperation ope
Operation = operation;
}

public override bool Equals(object? obj) =>
obj is EditAndContinueLogEntry && Equals((EditAndContinueLogEntry)obj);
public override bool Equals([NotNullWhen(true)] object? obj) =>
obj is EditAndContinueLogEntry editAndContinue && Equals(editAndContinue);

public bool Equals(EditAndContinueLogEntry other) =>
Operation == other.Operation && Handle == other.Handle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

namespace System.Reflection.Metadata.Ecma335
{
Expand All @@ -21,7 +22,7 @@ internal LabelHandle(int id)
public bool IsNil => Id == 0;

public bool Equals(LabelHandle other) => Id == other.Id;
public override bool Equals(object? obj) => obj is LabelHandle && Equals((LabelHandle)obj);
public override bool Equals([NotNullWhen(true)] object? obj) => obj is LabelHandle labelHandle && Equals(labelHandle);
public override int GetHashCode() => Id.GetHashCode();

public static bool operator ==(LabelHandle left, LabelHandle right) => left.Equals(right);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics;
using System.Reflection.Metadata.Ecma335;
using System.Diagnostics.CodeAnalysis;

namespace System.Reflection.Metadata
{
Expand Down Expand Up @@ -94,9 +95,9 @@ internal int Token
}
}

public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is EntityHandle && Equals((EntityHandle)obj);
return obj is EntityHandle entityHandle && Equals(entityHandle);
}

public bool Equals(EntityHandle other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics;
using System.Reflection.Metadata.Ecma335;
using System.Diagnostics.CodeAnalysis;

namespace System.Reflection.Metadata
{
Expand Down Expand Up @@ -159,9 +160,9 @@ internal int Token
}
}

public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is Handle && Equals((Handle)obj);
return obj is Handle handle && Equals(handle);
}

public bool Equals(Handle other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Diagnostics;
using System.Reflection.Internal;
using System.Reflection.Metadata.Ecma335;
using System.Diagnostics.CodeAnalysis;

namespace System.Reflection.Metadata
{
Expand Down Expand Up @@ -53,9 +54,9 @@ public bool IsNil
get { return _heapOffset == 0; }
}

public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is DocumentNameBlobHandle && Equals((DocumentNameBlobHandle)obj);
return obj is DocumentNameBlobHandle documentHandle && Equals(documentHandle);
}

public bool Equals(DocumentNameBlobHandle other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics;
using System.Reflection.Metadata.Ecma335;
using System.Diagnostics.CodeAnalysis;

namespace System.Reflection.Metadata
{
Expand Down Expand Up @@ -70,7 +71,7 @@ public bool IsNil

public override bool Equals(object? obj)
{
return obj is DocumentHandle && ((DocumentHandle)obj)._rowId == _rowId;
return obj is DocumentHandle documentHandle && documentHandle._rowId == _rowId;
}

public bool Equals(DocumentHandle other)
Expand Down Expand Up @@ -153,7 +154,7 @@ public bool IsNil

public override bool Equals(object? obj)
{
return obj is MethodDebugInformationHandle && ((MethodDebugInformationHandle)obj)._rowId == _rowId;
return obj is MethodDebugInformationHandle mdih && mdih._rowId == _rowId;
}

public bool Equals(MethodDebugInformationHandle other)
Expand Down Expand Up @@ -248,7 +249,7 @@ public bool IsNil

public override bool Equals(object? obj)
{
return obj is LocalScopeHandle && ((LocalScopeHandle)obj)._rowId == _rowId;
return obj is LocalScopeHandle lsh && lsh._rowId == _rowId;
}

public bool Equals(LocalScopeHandle other)
Expand Down Expand Up @@ -331,7 +332,7 @@ public bool IsNil

public override bool Equals(object? obj)
{
return obj is LocalVariableHandle && ((LocalVariableHandle)obj)._rowId == _rowId;
return obj is LocalVariableHandle lvh && lvh._rowId == _rowId;
}

public bool Equals(LocalVariableHandle other)
Expand Down Expand Up @@ -412,9 +413,9 @@ public bool IsNil
return left._rowId == right._rowId;
}

public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is LocalConstantHandle && ((LocalConstantHandle)obj)._rowId == _rowId;
return obj is LocalConstantHandle lch && lch._rowId == _rowId;
}

public bool Equals(LocalConstantHandle other)
Expand Down Expand Up @@ -495,9 +496,9 @@ public bool IsNil
return left._rowId == right._rowId;
}

public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is ImportScopeHandle && ((ImportScopeHandle)obj)._rowId == _rowId;
return obj is ImportScopeHandle ish && ish._rowId == _rowId;
}

public bool Equals(ImportScopeHandle other)
Expand Down Expand Up @@ -578,9 +579,9 @@ public bool IsNil
return left._rowId == right._rowId;
}

public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is CustomDebugInformationHandle && ((CustomDebugInformationHandle)obj)._rowId == _rowId;
return obj is CustomDebugInformationHandle cdih && cdih._rowId == _rowId;
}

public bool Equals(CustomDebugInformationHandle other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics;
using System.Reflection.Internal;
using System.Diagnostics.CodeAnalysis;

namespace System.Reflection.Metadata
{
Expand Down Expand Up @@ -47,9 +48,9 @@ public override int GetHashCode()
Hash.Combine(EndLine, EndColumn)))));
}

public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is SequencePoint && Equals((SequencePoint)obj);
return obj is SequencePoint sequencePoint && Equals(sequencePoint);
}

public bool Equals(SequencePoint other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Text;
using System.Diagnostics.CodeAnalysis;

namespace System.Reflection.Metadata
{
Expand Down Expand Up @@ -85,9 +86,9 @@ public bool IsGeneric
get { return (_rawValue & (byte)SignatureAttributes.Generic) != 0; }
}

public override bool Equals(object? obj)
public override bool Equals([NotNullWhen(true)] object? obj)
{
return obj is SignatureHeader && Equals((SignatureHeader)obj);
return obj is SignatureHeader signatureHeader && Equals(signatureHeader);
}

public bool Equals(SignatureHeader other)
Expand Down
Loading