From 7a8f4d8393a27c55830d789c45b229ba0feaae37 Mon Sep 17 00:00:00 2001 From: hrrrrustic <35951936+hrrrrustic@users.noreply.github.com> Date: Thu, 6 May 2021 19:08:58 +0300 Subject: [PATCH] System.Data.* missed Equals nullable annotations (#52165) --- .../System/Data/Common/DbConnectionPoolKey.cs | 4 ++- .../ref/System.Data.Common.cs | 30 +++++++++---------- .../src/System/Data/ForeignKeyConstraint.cs | 3 +- .../src/System/Data/RelatedView.cs | 3 +- .../src/System/Data/SQLTypes/SQLBinary.cs | 3 +- .../src/System/Data/SQLTypes/SQLBoolean.cs | 3 +- .../src/System/Data/SQLTypes/SQLByte.cs | 3 +- .../src/System/Data/SQLTypes/SQLDateTime.cs | 3 +- .../src/System/Data/SQLTypes/SQLDecimal.cs | 3 +- .../src/System/Data/SQLTypes/SQLDouble.cs | 3 +- .../src/System/Data/SQLTypes/SQLGuid.cs | 3 +- .../src/System/Data/SQLTypes/SQLInt16.cs | 3 +- .../src/System/Data/SQLTypes/SQLInt32.cs | 3 +- .../src/System/Data/SQLTypes/SQLInt64.cs | 3 +- .../src/System/Data/SQLTypes/SQLMoney.cs | 3 +- .../src/System/Data/SQLTypes/SQLSingle.cs | 3 +- .../src/System/Data/SQLTypes/SQLString.cs | 3 +- .../src/System/Data/Selection.cs | 3 +- .../src/System/Data/UniqueConstraint.cs | 3 +- .../System/Data/Common/DbConnectionPoolKey.cs | 3 +- 20 files changed, 54 insertions(+), 34 deletions(-) diff --git a/src/libraries/Common/src/System/Data/Common/DbConnectionPoolKey.cs b/src/libraries/Common/src/System/Data/Common/DbConnectionPoolKey.cs index 6e3601ae813..9903247eb8f 100644 --- a/src/libraries/Common/src/System/Data/Common/DbConnectionPoolKey.cs +++ b/src/libraries/Common/src/System/Data/Common/DbConnectionPoolKey.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.Data.Common { // DbConnectionPoolKey: Base class implementation of a key to connection pool groups @@ -37,7 +39,7 @@ namespace System.Data.Common } } - public override bool Equals(object? obj) + public override bool Equals([NotNullWhen(true)] object? obj) { if (obj == null || obj.GetType() != typeof(DbConnectionPoolKey)) { diff --git a/src/libraries/System.Data.Common/ref/System.Data.Common.cs b/src/libraries/System.Data.Common/ref/System.Data.Common.cs index 28821d99590..fd49311cae5 100644 --- a/src/libraries/System.Data.Common/ref/System.Data.Common.cs +++ b/src/libraries/System.Data.Common/ref/System.Data.Common.cs @@ -1200,7 +1200,7 @@ namespace System.Data public override System.Data.DataTable? Table { get { throw null; } } [System.ComponentModel.DefaultValueAttribute(System.Data.Rule.Cascade)] public virtual System.Data.Rule UpdateRule { get { throw null; } set { } } - public override bool Equals(object? key) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? key) { throw null; } public override int GetHashCode() { throw null; } } public partial interface IColumnMapping @@ -1609,7 +1609,7 @@ namespace System.Data public bool IsPrimaryKey { get { throw null; } } [System.ComponentModel.ReadOnlyAttribute(true)] public override System.Data.DataTable? Table { get { throw null; } } - public override bool Equals(object? key2) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? key2) { throw null; } public override int GetHashCode() { throw null; } } public enum UpdateRowSource @@ -2588,7 +2588,7 @@ namespace System.Data.SqlTypes public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlBinary Concat(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlBinary x, System.Data.SqlTypes.SqlBinary y) { throw null; } @@ -2632,7 +2632,7 @@ namespace System.Data.SqlTypes public int CompareTo(System.Data.SqlTypes.SqlBoolean value) { throw null; } public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlBoolean x, System.Data.SqlTypes.SqlBoolean y) { throw null; } @@ -2700,7 +2700,7 @@ namespace System.Data.SqlTypes public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlByte Divide(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlByte x, System.Data.SqlTypes.SqlByte y) { throw null; } @@ -2846,7 +2846,7 @@ namespace System.Data.SqlTypes public int CompareTo(System.Data.SqlTypes.SqlDateTime value) { throw null; } public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlDateTime x, System.Data.SqlTypes.SqlDateTime y) { throw null; } @@ -2904,7 +2904,7 @@ namespace System.Data.SqlTypes public static System.Data.SqlTypes.SqlDecimal ConvertToPrecScale(System.Data.SqlTypes.SqlDecimal n, int precision, int scale) { throw null; } public static System.Data.SqlTypes.SqlDecimal Divide(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlDecimal x, System.Data.SqlTypes.SqlDecimal y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public static System.Data.SqlTypes.SqlDecimal Floor(System.Data.SqlTypes.SqlDecimal n) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } @@ -2975,7 +2975,7 @@ namespace System.Data.SqlTypes public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlDouble Divide(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlDouble x, System.Data.SqlTypes.SqlDouble y) { throw null; } @@ -3037,7 +3037,7 @@ namespace System.Data.SqlTypes public int CompareTo(System.Data.SqlTypes.SqlGuid value) { throw null; } public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlGuid x, System.Data.SqlTypes.SqlGuid y) { throw null; } @@ -3082,7 +3082,7 @@ namespace System.Data.SqlTypes public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlInt16 Divide(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlInt16 x, System.Data.SqlTypes.SqlInt16 y) { throw null; } @@ -3156,7 +3156,7 @@ namespace System.Data.SqlTypes public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlInt32 Divide(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlInt32 x, System.Data.SqlTypes.SqlInt32 y) { throw null; } @@ -3230,7 +3230,7 @@ namespace System.Data.SqlTypes public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlInt64 Divide(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlInt64 x, System.Data.SqlTypes.SqlInt64 y) { throw null; } @@ -3305,7 +3305,7 @@ namespace System.Data.SqlTypes public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlMoney Divide(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlMoney x, System.Data.SqlTypes.SqlMoney y) { throw null; } @@ -3387,7 +3387,7 @@ namespace System.Data.SqlTypes public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlSingle Divide(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public static System.Xml.XmlQualifiedName GetXsdType(System.Xml.Schema.XmlSchemaSet schemaSet) { throw null; } public static System.Data.SqlTypes.SqlBoolean GreaterThan(System.Data.SqlTypes.SqlSingle x, System.Data.SqlTypes.SqlSingle y) { throw null; } @@ -3466,7 +3466,7 @@ namespace System.Data.SqlTypes public int CompareTo(object? value) { throw null; } public static System.Data.SqlTypes.SqlString Concat(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; } public static System.Data.SqlTypes.SqlBoolean Equals(System.Data.SqlTypes.SqlString x, System.Data.SqlTypes.SqlString y) { throw null; } - public override bool Equals(object? value) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; } public override int GetHashCode() { throw null; } public byte[]? GetNonUnicodeBytes() { throw null; } public byte[]? GetUnicodeBytes() { throw null; } diff --git a/src/libraries/System.Data.Common/src/System/Data/ForeignKeyConstraint.cs b/src/libraries/System.Data.Common/src/System/Data/ForeignKeyConstraint.cs index a57fd09b1e4..1d7ee94a478 100644 --- a/src/libraries/System.Data.Common/src/System/Data/ForeignKeyConstraint.cs +++ b/src/libraries/System.Data.Common/src/System/Data/ForeignKeyConstraint.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Diagnostics; using System.Data.Common; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -855,7 +856,7 @@ namespace System.Data /// /// Gets a value indicating whether the current is identical to the specified object. /// - public override bool Equals(object? key) + public override bool Equals([NotNullWhen(true)] object? key) { if (!(key is ForeignKeyConstraint)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/RelatedView.cs b/src/libraries/System.Data.Common/src/System/Data/RelatedView.cs index 590a1b8db09..ea986ce943d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/RelatedView.cs +++ b/src/libraries/System.Data.Common/src/System/Data/RelatedView.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.Data { @@ -89,7 +90,7 @@ namespace System.Data Reset(); } - public override bool Equals(DataView? dv) + public override bool Equals([NotNullWhen(true)] DataView? dv) { RelatedView? other = dv as RelatedView; if (other == null) diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBinary.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBinary.cs index ab176703b46..3792151f36d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBinary.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBinary.cs @@ -7,6 +7,7 @@ using System.Globalization; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -362,7 +363,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlBinary)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBoolean.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBoolean.cs index b76f3d16c7d..1efff18021e 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBoolean.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLBoolean.cs @@ -7,6 +7,7 @@ using System.Runtime.InteropServices; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -464,7 +465,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlBoolean)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLByte.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLByte.cs index fd353138851..f7c1cdde432 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLByte.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLByte.cs @@ -6,6 +6,7 @@ using System.Runtime.InteropServices; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -473,7 +474,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlByte)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDateTime.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDateTime.cs index 2e08f0eb4d2..195ca26628e 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDateTime.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDateTime.cs @@ -8,6 +8,7 @@ using System.Globalization; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -620,7 +621,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlDateTime)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs index 0297adacd4f..fd41a8fb191 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs @@ -8,6 +8,7 @@ using System.Runtime.InteropServices; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -3279,7 +3280,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlDecimal)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDouble.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDouble.cs index aa8ea8cb9dd..3f10f943124 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDouble.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDouble.cs @@ -7,6 +7,7 @@ using System.Globalization; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -389,7 +390,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlDouble)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLGuid.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLGuid.cs index 263cf292444..8e3c58dff3d 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLGuid.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLGuid.cs @@ -5,6 +5,7 @@ using System.Data.Common; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -280,7 +281,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlGuid)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt16.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt16.cs index 7da5e90509a..5833a009385 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt16.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt16.cs @@ -6,6 +6,7 @@ using System.Runtime.InteropServices; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -474,7 +475,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlInt16)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt32.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt32.cs index c02908e39f7..271d6509e71 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt32.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt32.cs @@ -6,6 +6,7 @@ using System.Runtime.InteropServices; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -489,7 +490,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlInt32)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt64.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt64.cs index d65fcd73f6c..b7f33674ce0 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt64.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLInt64.cs @@ -7,6 +7,7 @@ using System.Runtime.InteropServices; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -548,7 +549,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlInt64)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs index 83ecd1c8016..5431c8737d4 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLMoney.cs @@ -8,6 +8,7 @@ using System.Globalization; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -538,7 +539,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlMoney)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLSingle.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLSingle.cs index 9e61441618c..59f29dcc89c 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLSingle.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLSingle.cs @@ -7,6 +7,7 @@ using System.Globalization; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -399,7 +400,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlSingle)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLString.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLString.cs index 1482532b98b..9cd3c54c860 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLString.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLString.cs @@ -9,6 +9,7 @@ using System.Text; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; +using System.Diagnostics.CodeAnalysis; namespace System.Data.SqlTypes { @@ -870,7 +871,7 @@ namespace System.Data.SqlTypes } // Compares this instance with a specified object - public override bool Equals(object? value) + public override bool Equals([NotNullWhen(true)] object? value) { if (!(value is SqlString)) { diff --git a/src/libraries/System.Data.Common/src/System/Data/Selection.cs b/src/libraries/System.Data.Common/src/System/Data/Selection.cs index c66dc5b6484..2d3fa4c921c 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Selection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Selection.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.ComponentModel; using System.Collections.Generic; using System.Threading; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -27,7 +28,7 @@ namespace System.Data public static bool operator !=(IndexField if1, IndexField if2) => !(if1 == if2); // must override Equals if == operator is defined - public override bool Equals(object? obj) => obj is IndexField ? + public override bool Equals([NotNullWhen(true)] object? obj) => obj is IndexField ? this == (IndexField)obj : false; diff --git a/src/libraries/System.Data.Common/src/System/Data/UniqueConstraint.cs b/src/libraries/System.Data.Common/src/System/Data/UniqueConstraint.cs index 83c7e705f2a..e2918b7fae5 100644 --- a/src/libraries/System.Data.Common/src/System/Data/UniqueConstraint.cs +++ b/src/libraries/System.Data.Common/src/System/Data/UniqueConstraint.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; namespace System.Data { @@ -388,7 +389,7 @@ namespace System.Data /// /// Compares this constraint to a second to determine if both are identical. /// - public override bool Equals(object? key2) + public override bool Equals([NotNullWhen(true)] object? key2) { if (!(key2 is UniqueConstraint)) return false; diff --git a/src/libraries/System.Data.OleDb/src/System/Data/Common/DbConnectionPoolKey.cs b/src/libraries/System.Data.OleDb/src/System/Data/Common/DbConnectionPoolKey.cs index e790c71d917..b18bbabca7d 100644 --- a/src/libraries/System.Data.OleDb/src/System/Data/Common/DbConnectionPoolKey.cs +++ b/src/libraries/System.Data.OleDb/src/System/Data/Common/DbConnectionPoolKey.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Diagnostics.CodeAnalysis; namespace System.Data.Common { @@ -40,7 +41,7 @@ namespace System.Data.Common } } - public override bool Equals(object? obj) + public override bool Equals([NotNullWhen(true)] object? obj) { if (obj == null || obj.GetType() != typeof(DbConnectionPoolKey)) { -- 2.34.1