From 575dd659dd7229f8dd72258fcf0ca7c8ff9607e0 Mon Sep 17 00:00:00 2001 From: Vlad Date: Sat, 1 May 2021 19:27:31 +0300 Subject: [PATCH 1/7] add NotNullWhen attribute --- .../ref/System.Reflection.Metadata.cs | 28 +++++++++---------- .../Reflection/Metadata/BlobContentId.cs | 2 +- .../Ecma335/EditAndContinueLogEntry.cs | 2 +- .../Metadata/Ecma335/Encoding/LabelHandle.cs | 2 +- .../Reflection/Metadata/EntityHandle.cs | 2 +- .../src/System/Reflection/Metadata/Handle.cs | 2 +- .../PortablePdb/DocumentNameBlobHandle.cs | 2 +- .../Metadata/PortablePdb/Handles.Debug.cs | 6 ++-- .../Metadata/PortablePdb/SequencePoint.cs | 2 +- .../Metadata/Signatures/SignatureHeader.cs | 2 +- .../Metadata/TypeSystem/Handles.TypeSystem.cs | 6 ++-- .../Constructors/RoDefinitionConstructor.cs | 2 +- .../Constructors/RoSyntheticConstructor.cs | 2 +- .../TypeLoading/Events/Ecma/EcmaEvent.cs | 2 +- .../TypeLoading/Fields/Ecma/EcmaField.cs | 2 +- .../TypeLoading/General/RoAssemblyName.cs | 2 +- .../Methods/RoConstructedGenericMethod.cs | 2 +- .../TypeLoading/Methods/RoDefinitionMethod.cs | 2 +- .../TypeLoading/Methods/RoSyntheticMethod.cs | 2 +- .../Properties/Ecma/EcmaProperty.cs | 2 +- .../TypeLoading/Types/RoArrayType.Key.cs | 2 +- .../Types/RoConstructedGenericType.Key.cs | 2 +- 22 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs index 40647b105f968..29c365e99755f 100644 --- a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs +++ b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs @@ -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 hashCode) { throw null; } @@ -305,7 +305,7 @@ void System.IDisposable.Dispose() { } private readonly int _dummyPrimitive; public bool IsNil { get { throw null; } } public override bool Equals(object? obj) { throw null; } - public bool Equals(System.Reflection.Metadata.BlobHandle other) { throw null; } + public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] 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; } public static explicit operator System.Reflection.Metadata.BlobHandle (System.Reflection.Metadata.Handle handle) { throw null; } @@ -539,7 +539,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 bool Equals(System.Reflection.Metadata.CustomDebugInformationHandle other) { throw null; } + public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] 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; } public static explicit operator System.Reflection.Metadata.CustomDebugInformationHandle (System.Reflection.Metadata.EntityHandle handle) { throw null; } @@ -662,7 +662,7 @@ void System.IDisposable.Dispose() { } private readonly int _dummyPrimitive; public bool IsNil { get { throw null; } } public override bool Equals(object? obj) { throw null; } - public bool Equals(System.Reflection.Metadata.DocumentNameBlobHandle other) { throw null; } + public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] 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; } public static explicit operator System.Reflection.Metadata.DocumentNameBlobHandle (System.Reflection.Metadata.BlobHandle handle) { throw null; } @@ -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; } @@ -933,7 +933,7 @@ void System.IDisposable.Dispose() { } private readonly int _dummyPrimitive; public bool IsNil { get { throw null; } } public override bool Equals(object? obj) { throw null; } - public bool Equals(System.Reflection.Metadata.GuidHandle other) { throw null; } + public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] 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; } public static explicit operator System.Reflection.Metadata.GuidHandle (System.Reflection.Metadata.Handle handle) { throw null; } @@ -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; } @@ -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; } @@ -1401,7 +1401,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 bool Equals(System.Reflection.Metadata.LocalConstantHandle other) { throw null; } + public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] 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; } public static explicit operator System.Reflection.Metadata.LocalConstantHandle (System.Reflection.Metadata.EntityHandle handle) { throw null; } @@ -2007,7 +2007,7 @@ public partial struct NamespaceDefinition private readonly int _dummyPrimitive; public bool IsNil { get { throw null; } } public override bool Equals(object? obj) { throw null; } - public bool Equals(System.Reflection.Metadata.NamespaceDefinitionHandle other) { throw null; } + public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] 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; } public static explicit operator System.Reflection.Metadata.NamespaceDefinitionHandle (System.Reflection.Metadata.Handle handle) { throw null; } @@ -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; } } @@ -2248,7 +2248,7 @@ public partial struct SignatureHeader : System.IEquatable, 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); diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs index ca7928051a3f4..01899b3313cdc 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs @@ -14,7 +14,7 @@ public EditAndContinueLogEntry(EntityHandle handle, EditAndContinueOperation ope Operation = operation; } - public override bool Equals(object? obj) => + public override bool Equals([NotNullWhen(true)] object? obj) => obj is EditAndContinueLogEntry && Equals((EditAndContinueLogEntry)obj); public bool Equals(EditAndContinueLogEntry other) => diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs index 16e43967fe501..95465fcc8da86 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs @@ -21,7 +21,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 && Equals((LabelHandle)obj); public override int GetHashCode() => Id.GetHashCode(); public static bool operator ==(LabelHandle left, LabelHandle right) => left.Equals(right); diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs index cf04510e01603..e3a87abd0494f 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs @@ -94,7 +94,7 @@ internal int Token } } - public override bool Equals(object? obj) + public override bool Equals([NotNullWhen(true)] object? obj) { return obj is EntityHandle && Equals((EntityHandle)obj); } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs index f9c3981ff8d24..4c0fa7c2efa0f 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs @@ -159,7 +159,7 @@ internal int Token } } - public override bool Equals(object? obj) + public override bool Equals([NotNullWhen(true)] object? obj) { return obj is Handle && Equals((Handle)obj); } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs index 9cc5cbb2695e7..2adee3b7bcb23 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs @@ -53,7 +53,7 @@ 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); } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs index 4f1084939e25c..812ff47595fcb 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs @@ -412,7 +412,7 @@ 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; } @@ -495,7 +495,7 @@ 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; } @@ -578,7 +578,7 @@ 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; } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs index 01308356c2f53..228ae44dd5fb5 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs @@ -47,7 +47,7 @@ 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); } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs index 0bc5b04252e2a..97d8c016b7cf6 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs @@ -85,7 +85,7 @@ 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); } diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs index e2667f6018fa6..a833d6eaa973d 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs @@ -2518,7 +2518,7 @@ internal StringHandle GetFullName() return StringHandle.FromOffset(GetHeapOffset()); } - public override bool Equals(object? obj) + public override bool Equals([NotNullWhen(true)] object? obj) { return obj is NamespaceDefinitionHandle && Equals((NamespaceDefinitionHandle)obj); } @@ -2649,7 +2649,7 @@ private ushort VirtualValue get { return unchecked((ushort)(_value >> 8)); } } - public override bool Equals(object? obj) + public override bool Equals([NotNullWhen(true)] object? obj) { return obj is BlobHandle && Equals((BlobHandle)obj); } @@ -2717,7 +2717,7 @@ internal int Index get { return _index; } } - public override bool Equals(object? obj) + public override bool Equals([NotNullWhen(true)] object? obj) { return obj is GuidHandle && Equals((GuidHandle)obj); } diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoDefinitionConstructor.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoDefinitionConstructor.cs index ead5a0d039120..83ba4a48d8293 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoDefinitionConstructor.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoDefinitionConstructor.cs @@ -35,7 +35,7 @@ internal RoDefinitionConstructor(RoInstantiationProviderType declaringType, TMet protected sealed override MethodSig ComputeMethodSigStrings() => _decoder.SpecializeMethodSigStrings(TypeContext); protected sealed override MethodSig ComputeCustomModifiers() => _decoder.SpecializeCustomModifiers(TypeContext); - public sealed override bool Equals(object? obj) + public sealed override bool Equals([NotNullWhen(true)] object? obj) { if (!(obj is RoDefinitionConstructor other)) return false; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoSyntheticConstructor.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoSyntheticConstructor.cs index a109019971f16..2dbdc93fdaa79 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoSyntheticConstructor.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoSyntheticConstructor.cs @@ -64,7 +64,7 @@ protected sealed override MethodSig ComputeMethodSigStrings() protected sealed override MethodSig ComputeCustomModifiers() => new MethodSig(_parameterTypes.Length); - public sealed override bool Equals(object? obj) + public sealed override bool Equals([NotNullWhen(true)] object? obj) { if (!(obj is RoSyntheticConstructor other)) return false; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Events/Ecma/EcmaEvent.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Events/Ecma/EcmaEvent.cs index 41d5a51edb8f9..70bc1df626e3b 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Events/Ecma/EcmaEvent.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Events/Ecma/EcmaEvent.cs @@ -36,7 +36,7 @@ internal EcmaEvent(RoInstantiationProviderType declaringType, EventDefinitionHan public sealed override int MetadataToken => _handle.GetToken(); - public sealed override bool Equals(object? obj) + public sealed override bool Equals([NotNullWhen(true)] object? obj) { if (!(obj is EcmaEvent other)) return false; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Fields/Ecma/EcmaField.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Fields/Ecma/EcmaField.cs index 9d132288730b4..691c962f2cadb 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Fields/Ecma/EcmaField.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Fields/Ecma/EcmaField.cs @@ -39,7 +39,7 @@ internal EcmaField(RoInstantiationProviderType declaringType, FieldDefinitionHan public sealed override int MetadataToken => _handle.GetToken(); - public sealed override bool Equals(object? obj) + public sealed override bool Equals([NotNullWhen(true)] object? obj) { if (!(obj is EcmaField other)) return false; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/RoAssemblyName.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/RoAssemblyName.cs index 46b34719d6f44..4afd7c13ff800 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/RoAssemblyName.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/RoAssemblyName.cs @@ -66,7 +66,7 @@ public bool Equals(RoAssemblyName? other) return true; } - public sealed override bool Equals(object? obj) => obj is RoAssemblyName other && Equals(other); + public sealed override bool Equals([NotNullWhen(true)] object? obj) => obj is RoAssemblyName other && Equals(other); public sealed override int GetHashCode() => Name.GetHashCode(); public sealed override string ToString() => FullName; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoConstructedGenericMethod.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoConstructedGenericMethod.cs index 84814f81da370..13d9c1bc54236 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoConstructedGenericMethod.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoConstructedGenericMethod.cs @@ -50,7 +50,7 @@ internal RoConstructedGenericMethod(RoDefinitionMethod genericMethodDefinition, public sealed override MethodInfo MakeGenericMethod(params Type[] typeArguments) => throw new InvalidOperationException(SR.Format(SR.Arg_NotGenericMethodDefinition, this)); - public sealed override bool Equals(object? obj) + public sealed override bool Equals([NotNullWhen(true)] object? obj) { if (!(obj is RoConstructedGenericMethod other)) return false; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoDefinitionMethod.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoDefinitionMethod.cs index d3b1c5c3c0aeb..1591fab16e9db 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoDefinitionMethod.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoDefinitionMethod.cs @@ -75,7 +75,7 @@ public sealed override IEnumerable CustomAttributes protected sealed override MethodSig ComputeMethodSigStrings() => _decoder.SpecializeMethodSigStrings(TypeContext); protected sealed override MethodSig ComputeCustomModifiers() => _decoder.SpecializeCustomModifiers(TypeContext); - public sealed override bool Equals(object? obj) + public sealed override bool Equals([NotNullWhen(true)] object? obj) { if (!(obj is RoDefinitionMethod other)) return false; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoSyntheticMethod.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoSyntheticMethod.cs index fd6580c784965..d7d8138a379aa 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoSyntheticMethod.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoSyntheticMethod.cs @@ -66,7 +66,7 @@ protected sealed override MethodSig ComputeMethodSigStrings() protected sealed override MethodSig ComputeCustomModifiers() => new MethodSig(_parameterTypes.Length); - public sealed override bool Equals(object? obj) + public sealed override bool Equals([NotNullWhen(true)] object? obj) { if (!(obj is RoSyntheticMethod other)) return false; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Properties/Ecma/EcmaProperty.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Properties/Ecma/EcmaProperty.cs index 2d17a9089654f..9d6da5c814cc5 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Properties/Ecma/EcmaProperty.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Properties/Ecma/EcmaProperty.cs @@ -35,7 +35,7 @@ internal EcmaProperty(RoInstantiationProviderType declaringType, PropertyDefinit public sealed override int MetadataToken => _handle.GetToken(); - public sealed override bool Equals(object? obj) + public sealed override bool Equals([NotNullWhen(true)] object? obj) { if (!(obj is EcmaProperty other)) return false; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.Key.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.Key.cs index ed520fd6320b4..2ef2e828e3e90 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.Key.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.Key.cs @@ -32,7 +32,7 @@ public bool Equals(Key other) return true; } - public override bool Equals(object? obj) => obj is Key other && Equals(other); + public override bool Equals([NotNullWhen(true)] object? obj) => obj is Key other && Equals(other); public override int GetHashCode() => ElementType.GetHashCode() ^ Rank.GetHashCode(); } } diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoConstructedGenericType.Key.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoConstructedGenericType.Key.cs index cd6a430e99189..9048eaa90d388 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoConstructedGenericType.Key.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoConstructedGenericType.Key.cs @@ -35,7 +35,7 @@ public bool Equals(Key other) return true; } - public override bool Equals(object? obj) => obj is Key other && Equals(other); + public override bool Equals([NotNullWhen(true)] object? obj) => obj is Key other && Equals(other); public override int GetHashCode() { From 0d1d9ba756d3b292b47eb2c9682cf134604d906d Mon Sep 17 00:00:00 2001 From: Vlad Date: Sat, 1 May 2021 20:50:31 +0300 Subject: [PATCH 2/7] add usings --- .../src/System/Reflection/Metadata/BlobContentId.cs | 1 + .../Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs | 2 ++ .../System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs | 1 + .../src/System/Reflection/Metadata/EntityHandle.cs | 1 + .../src/System/Reflection/Metadata/Handle.cs | 1 + .../Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs | 1 + .../src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs | 1 + .../src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs | 1 + .../System/Reflection/Metadata/Signatures/SignatureHeader.cs | 1 + .../System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs | 1 + .../TypeLoading/Constructors/RoDefinitionConstructor.cs | 1 + .../TypeLoading/Constructors/RoSyntheticConstructor.cs | 1 + .../src/System/Reflection/TypeLoading/Events/Ecma/EcmaEvent.cs | 1 + .../src/System/Reflection/TypeLoading/Fields/Ecma/EcmaField.cs | 1 + .../TypeLoading/Methods/RoConstructedGenericMethod.cs | 1 + .../System/Reflection/TypeLoading/Methods/RoDefinitionMethod.cs | 1 + .../System/Reflection/TypeLoading/Methods/RoSyntheticMethod.cs | 1 + .../Reflection/TypeLoading/Properties/Ecma/EcmaProperty.cs | 1 + .../src/System/Reflection/TypeLoading/Types/RoArrayType.Key.cs | 1 + .../TypeLoading/Types/RoConstructedGenericType.Key.cs | 1 + 20 files changed, 21 insertions(+) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobContentId.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobContentId.cs index 5cc0c7ab4c0c2..eb7ca38a6a7a1 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobContentId.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/BlobContentId.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Reflection.Internal; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.Metadata { diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs index 01899b3313cdc..a549680d85420 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs @@ -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 diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs index 95465fcc8da86..3503abb0fa7fe 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs @@ -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 { diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs index e3a87abd0494f..8ecf38254d41f 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Reflection.Metadata.Ecma335; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.Metadata { diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs index 4c0fa7c2efa0f..a6d70d479521d 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Reflection.Metadata.Ecma335; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.Metadata { diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs index 2adee3b7bcb23..548f46366d40b 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Reflection.Internal; using System.Reflection.Metadata.Ecma335; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.Metadata { diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs index 812ff47595fcb..80dbcef5ee755 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Reflection.Metadata.Ecma335; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.Metadata { diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs index 228ae44dd5fb5..cab28a5693fd4 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Reflection.Internal; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.Metadata { diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs index 97d8c016b7cf6..961486f7360c2 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs @@ -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 { diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs index a833d6eaa973d..8ef437a46242a 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Reflection.Metadata.Ecma335; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.Metadata { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoDefinitionConstructor.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoDefinitionConstructor.cs index 83ba4a48d8293..ca28b7d3d3694 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoDefinitionConstructor.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoDefinitionConstructor.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.TypeLoading { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoSyntheticConstructor.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoSyntheticConstructor.cs index 2dbdc93fdaa79..c50786533bfff 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoSyntheticConstructor.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Constructors/RoSyntheticConstructor.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Globalization; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.TypeLoading { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Events/Ecma/EcmaEvent.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Events/Ecma/EcmaEvent.cs index 70bc1df626e3b..aa2aa4a7d3477 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Events/Ecma/EcmaEvent.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Events/Ecma/EcmaEvent.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Reflection.Metadata; using System.Text; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.TypeLoading.Ecma { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Fields/Ecma/EcmaField.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Fields/Ecma/EcmaField.cs index 691c962f2cadb..a148fef2cc0e1 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Fields/Ecma/EcmaField.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Fields/Ecma/EcmaField.cs @@ -6,6 +6,7 @@ using System.Reflection.Metadata; using System.Runtime.InteropServices; using System.Text; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.TypeLoading.Ecma { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoConstructedGenericMethod.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoConstructedGenericMethod.cs index 13d9c1bc54236..da6871ecda8b7 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoConstructedGenericMethod.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoConstructedGenericMethod.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.TypeLoading { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoDefinitionMethod.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoDefinitionMethod.cs index 1591fab16e9db..9906ff4ef3c7c 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoDefinitionMethod.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoDefinitionMethod.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.TypeLoading { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoSyntheticMethod.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoSyntheticMethod.cs index d7d8138a379aa..02f35b6f7b249 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoSyntheticMethod.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Methods/RoSyntheticMethod.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.TypeLoading { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Properties/Ecma/EcmaProperty.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Properties/Ecma/EcmaProperty.cs index 9d6da5c814cc5..47731168c63d0 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Properties/Ecma/EcmaProperty.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Properties/Ecma/EcmaProperty.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Reflection.Metadata; using System.Text; +using System.Diagnostics.CodeAnalysis; namespace System.Reflection.TypeLoading.Ecma { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.Key.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.Key.cs index 2ef2e828e3e90..b1d920cc164bf 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.Key.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.Key.cs @@ -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.TypeLoading { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoConstructedGenericType.Key.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoConstructedGenericType.Key.cs index 9048eaa90d388..92121c08dee22 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoConstructedGenericType.Key.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoConstructedGenericType.Key.cs @@ -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.TypeLoading { From 0499c8cc6d310acce292a3fe9ca454b162c93cf5 Mon Sep 17 00:00:00 2001 From: Vlad Date: Sun, 2 May 2021 00:28:12 +0300 Subject: [PATCH 3/7] fix overload --- .../ref/System.Reflection.Metadata.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs index 29c365e99755f..c4c969f398ed4 100644 --- a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs +++ b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs @@ -661,8 +661,8 @@ void System.IDisposable.Dispose() { } { private readonly int _dummyPrimitive; public bool IsNil { get { throw null; } } - public override bool Equals(object? obj) { throw null; } - public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] System.Reflection.Metadata.DocumentNameBlobHandle other) { 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; } public static explicit operator System.Reflection.Metadata.DocumentNameBlobHandle (System.Reflection.Metadata.BlobHandle handle) { throw null; } From 20802b76dccae53e856f2bc3813c7d9dcbbdcdfa Mon Sep 17 00:00:00 2001 From: Vlad Date: Sun, 2 May 2021 00:44:33 +0300 Subject: [PATCH 4/7] fix overloads --- .../ref/System.Reflection.Metadata.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs index c4c969f398ed4..27bf37ab916fd 100644 --- a/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs +++ b/src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs @@ -304,8 +304,8 @@ void System.IDisposable.Dispose() { } { private readonly int _dummyPrimitive; public bool IsNil { get { throw null; } } - public override bool Equals(object? obj) { throw null; } - public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] System.Reflection.Metadata.BlobHandle other) { 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; } public static explicit operator System.Reflection.Metadata.BlobHandle (System.Reflection.Metadata.Handle handle) { throw null; } @@ -538,8 +538,8 @@ public readonly partial struct CustomDebugInformation { private readonly int _dummyPrimitive; public bool IsNil { get { throw null; } } - public override bool Equals(object? obj) { throw null; } - public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] System.Reflection.Metadata.CustomDebugInformationHandle other) { 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; } public static explicit operator System.Reflection.Metadata.CustomDebugInformationHandle (System.Reflection.Metadata.EntityHandle handle) { throw null; } @@ -932,8 +932,8 @@ void System.IDisposable.Dispose() { } { private readonly int _dummyPrimitive; public bool IsNil { get { throw null; } } - public override bool Equals(object? obj) { throw null; } - public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] System.Reflection.Metadata.GuidHandle other) { 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; } public static explicit operator System.Reflection.Metadata.GuidHandle (System.Reflection.Metadata.Handle handle) { throw null; } @@ -1400,8 +1400,8 @@ public readonly partial struct LocalConstant { private readonly int _dummyPrimitive; public bool IsNil { get { throw null; } } - public override bool Equals(object? obj) { throw null; } - public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] System.Reflection.Metadata.LocalConstantHandle other) { 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; } public static explicit operator System.Reflection.Metadata.LocalConstantHandle (System.Reflection.Metadata.EntityHandle handle) { throw null; } @@ -2006,8 +2006,8 @@ public partial struct NamespaceDefinition { private readonly int _dummyPrimitive; public bool IsNil { get { throw null; } } - public override bool Equals(object? obj) { throw null; } - public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] System.Reflection.Metadata.NamespaceDefinitionHandle other) { 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; } public static explicit operator System.Reflection.Metadata.NamespaceDefinitionHandle (System.Reflection.Metadata.Handle handle) { throw null; } From 3ba6ee15d7d212bedbf00e01d2125c44fb31e64b Mon Sep 17 00:00:00 2001 From: hrrrrustic Date: Thu, 20 May 2021 16:16:57 +0300 Subject: [PATCH 5/7] update is pattern --- .../Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs | 2 +- .../System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs | 2 +- .../src/System/Reflection/Metadata/EntityHandle.cs | 2 +- .../src/System/Reflection/Metadata/Handle.cs | 2 +- .../Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs | 2 +- .../src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs | 2 +- .../src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs | 2 +- .../System/Reflection/Metadata/Signatures/SignatureHeader.cs | 2 +- .../System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs index a549680d85420..b3c61fb368c45 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/EditAndContinueLogEntry.cs @@ -17,7 +17,7 @@ public EditAndContinueLogEntry(EntityHandle handle, EditAndContinueOperation ope } public override bool Equals([NotNullWhen(true)] object? obj) => - obj is EditAndContinueLogEntry && Equals((EditAndContinueLogEntry)obj); + obj is EditAndContinueLogEntry editAndContinue && Equals(editAndContinue); public bool Equals(EditAndContinueLogEntry other) => Operation == other.Operation && Handle == other.Handle; diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs index 3503abb0fa7fe..3c5b7d83ec78d 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/LabelHandle.cs @@ -22,7 +22,7 @@ internal LabelHandle(int id) public bool IsNil => Id == 0; public bool Equals(LabelHandle other) => Id == other.Id; - public override bool Equals([NotNullWhen(true)] 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); diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs index 8ecf38254d41f..26757ed7cc535 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/EntityHandle.cs @@ -97,7 +97,7 @@ internal int Token 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) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs index a6d70d479521d..931c7cef6e647 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Handle.cs @@ -162,7 +162,7 @@ internal int Token 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) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs index 548f46366d40b..888467215e20d 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/DocumentNameBlobHandle.cs @@ -56,7 +56,7 @@ public bool IsNil 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) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs index 80dbcef5ee755..00b17bb884bd7 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs @@ -71,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) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs index cab28a5693fd4..6038031fbd59c 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePoint.cs @@ -50,7 +50,7 @@ public override int GetHashCode() 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) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs index 961486f7360c2..f8506bf7634e4 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/Signatures/SignatureHeader.cs @@ -88,7 +88,7 @@ public bool IsGeneric 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) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs index 8ef437a46242a..7b3dbdfcaf8d1 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs @@ -71,7 +71,7 @@ public bool IsNil public override bool Equals(object? obj) { - return obj is ModuleDefinitionHandle && ((ModuleDefinitionHandle)obj)._rowId == _rowId; + return obj is ModuleDefinitionHandle moduleDefinition && moduleDefinition._rowId == _rowId; } public bool Equals(ModuleDefinitionHandle other) From 93e2a55f3b011f506a9f2fa7a28f13b4e5605dba Mon Sep 17 00:00:00 2001 From: hrrrrustic Date: Fri, 21 May 2021 16:45:59 +0300 Subject: [PATCH 6/7] update old is pattern --- .../Reflection/Metadata/PortablePdb/Handles.Debug.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs index 00b17bb884bd7..b6c00c78a2126 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/Handles.Debug.cs @@ -154,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) @@ -249,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) @@ -332,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) @@ -415,7 +415,7 @@ public bool IsNil 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) @@ -498,7 +498,7 @@ public bool IsNil 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) @@ -581,7 +581,7 @@ public bool IsNil 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) From 2a03aa12d293273d500dddfa3fac99173fbf3847 Mon Sep 17 00:00:00 2001 From: hrrrrustic Date: Fri, 21 May 2021 16:53:26 +0300 Subject: [PATCH 7/7] one more update --- .../Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs index 7b3dbdfcaf8d1..0c89482e05c4f 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeSystem/Handles.TypeSystem.cs @@ -2521,7 +2521,7 @@ internal StringHandle GetFullName() public override bool Equals([NotNullWhen(true)] object? obj) { - return obj is NamespaceDefinitionHandle && Equals((NamespaceDefinitionHandle)obj); + return obj is NamespaceDefinitionHandle ndh && Equals(ndh); } public bool Equals(NamespaceDefinitionHandle other) @@ -2652,7 +2652,7 @@ private ushort VirtualValue public override bool Equals([NotNullWhen(true)] object? obj) { - return obj is BlobHandle && Equals((BlobHandle)obj); + return obj is BlobHandle bh && Equals(bh); } public bool Equals(BlobHandle other) @@ -2720,7 +2720,7 @@ internal int Index public override bool Equals([NotNullWhen(true)] object? obj) { - return obj is GuidHandle && Equals((GuidHandle)obj); + return obj is GuidHandle gh && Equals(gh); } public bool Equals(GuidHandle other)