From 1e636110a5f6acef9a72a3d1872b5cfde29f8628 Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Thu, 1 Aug 2024 15:28:49 -0500 Subject: [PATCH 1/2] `null == x` to `x == null` --- ...qlColumnEncryptionAzureKeyVaultProvider.cs | 2 +- .../add-ons/AzureKeyVaultProvider/Utils.cs | 7 +- .../Data/ProviderBase/DbConnectionClosed.cs | 2 +- .../Data/ProviderBase/DbConnectionFactory.cs | 8 +- .../Data/ProviderBase/DbConnectionInternal.cs | 6 +- .../Data/Common/DbConnectionOptions.cs | 2 +- .../Data/ProviderBase/DbConnectionFactory.cs | 2 +- .../Data/ProviderBase/DbConnectionInternal.cs | 4 +- .../Data/ProviderBase/DbConnectionPool.cs | 10 +-- ...uthenticationProviderManager.NetCoreApp.cs | 2 +- .../Microsoft/Data/SqlClient/SqlBulkCopy.cs | 4 +- .../SqlColumnEncryptionCngProvider.Windows.cs | 8 +- .../SqlColumnEncryptionCspProvider.Windows.cs | 8 +- .../Microsoft/Data/SqlClient/SqlCommand.cs | 45 +++++----- .../Microsoft/Data/SqlClient/SqlConnection.cs | 8 +- .../Data/SqlClient/SqlConnectionFactory.cs | 5 +- .../Data/SqlClient/SqlConnectionHelper.cs | 2 +- .../Microsoft/Data/SqlClient/SqlDataReader.cs | 22 ++--- .../Data/SqlClient/SqlDelegatedTransaction.cs | 4 +- .../SqlClient/SqlInternalConnectionTds.cs | 23 ++--- .../src/Microsoft/Data/SqlClient/TdsParser.cs | 86 +++++++++--------- .../Data/SqlClient/TdsParserHelperClasses.cs | 2 +- .../Data/Common/NameValuePermission.cs | 14 +-- .../Microsoft/Data/Common/AdapterSwitches.cs | 2 +- .../Data/Common/DBConnectionString.cs | 14 +-- .../Data/Common/DbConnectionOptions.cs | 8 +- .../src/Microsoft/Data/Common/GreenMethods.cs | 2 +- .../Data/Interop/SNINativeMethodWrapper.cs | 2 +- .../Data/ProviderBase/DbConnectionClosed.cs | 2 +- .../Data/ProviderBase/DbConnectionFactory.cs | 10 +-- .../Data/ProviderBase/DbConnectionInternal.cs | 12 +-- .../Data/ProviderBase/DbConnectionPool.cs | 10 +-- .../SqlClient/Server/SmiContextFactory.cs | 10 +-- .../SqlAuthenticationProviderManager.cs | 2 +- .../Microsoft/Data/SqlClient/SqlBulkCopy.cs | 7 +- .../Data/SqlClient/SqlClientPermission.cs | 22 ++--- .../SqlClientWrapperSmiStreamChars.cs | 2 +- .../SqlColumnEncryptionCngProvider.cs | 8 +- .../SqlColumnEncryptionCspProvider.cs | 8 +- .../Microsoft/Data/SqlClient/SqlCommand.cs | 46 +++++----- .../Microsoft/Data/SqlClient/SqlConnection.cs | 26 +++--- .../Data/SqlClient/SqlConnectionFactory.cs | 7 +- .../Data/SqlClient/SqlConnectionHelper.cs | 2 +- .../Microsoft/Data/SqlClient/SqlDataReader.cs | 23 ++--- .../Data/SqlClient/SqlDelegatedTransaction.cs | 4 +- .../SqlClient/SqlInternalConnectionSmi.cs | 6 +- .../SqlClient/SqlInternalConnectionTds.cs | 12 +-- .../src/Microsoft/Data/SqlClient/TdsParser.cs | 89 ++++++++++--------- .../Data/SqlClient/TdsParserHelperClasses.cs | 2 +- .../Data/Common/DbConnectionStringCommon.cs | 6 +- .../Data/Common/MultipartIdentifier.cs | 2 +- .../Microsoft/Data/Common/NameValuePair.cs | 2 +- .../ProviderBase/DbConnectionPoolGroup.cs | 4 +- .../Data/ProviderBase/DbMetaDataFactory.cs | 2 +- .../ActiveDirectoryAuthenticationProvider.cs | 6 +- .../Data/SqlClient/ColumnEncryptionKeyInfo.cs | 12 ++- .../Data/SqlClient/Server/MetadataUtilsSmi.cs | 4 +- .../SqlClient/Server/SmiEventSink_Default.cs | 2 +- .../Server/SmiEventSink_Default.netfx.cs | 34 +++---- .../Data/SqlClient/Server/SmiMetaData.cs | 6 +- .../Data/SqlClient/Server/SqlDataRecord.cs | 2 +- .../Data/SqlClient/Server/SqlMetaData.cs | 18 ++-- .../SqlClient/Server/ValueUtilsSmi.netfx.cs | 2 +- .../SqlClient/SignatureVerificationCache.cs | 4 +- ...ryptionCertificateStoreProvider.Windows.cs | 8 +- .../Data/SqlClient/SqlCommandBuilder.cs | 2 +- .../Microsoft/Data/SqlClient/SqlCommandSet.cs | 4 +- .../SqlConnectionPoolGroupProviderInfo.cs | 4 +- .../Data/SqlClient/SqlConnectionString.cs | 8 +- .../Data/SqlClient/SqlDataAdapter.cs | 6 +- .../Microsoft/Data/SqlClient/SqlDependency.cs | 12 +-- .../Data/SqlClient/SqlDependencyListener.cs | 6 +- .../Data/SqlClient/SqlDependencyUtils.cs | 2 +- .../Data/SqlClient/SqlEnclaveSession.cs | 2 +- .../Data/SqlClient/SqlInternalConnection.cs | 6 +- .../Microsoft/Data/SqlClient/SqlParameter.cs | 16 ++-- .../Data/SqlClient/SqlReferenceCollection.cs | 2 +- .../Data/SqlClient/SqlSecurityUtility.cs | 8 +- .../src/Microsoft/Data/SqlClient/SqlStream.cs | 12 +-- .../Data/SqlClient/TdsParserSessionPool.cs | 4 +- .../Data/SqlClient/TdsParserStateObject.cs | 2 +- .../Data/SqlClient/TdsParserStaticMethods.cs | 2 +- .../Data/SqlClient/TdsValueSetter.cs | 6 +- .../ManualTests/DataCommon/DataTestUtility.cs | 6 +- .../MultipleResultsTest.cs | 4 +- .../SQL/AdapterTest/AdapterTest.cs | 4 +- .../ManualTests/SQL/ParameterTest/TvpTest.cs | 15 ++-- .../SqlBulkCopyTest/InvalidAccessFromEvent.cs | 2 +- 88 files changed, 445 insertions(+), 418 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/SqlColumnEncryptionAzureKeyVaultProvider.cs b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/SqlColumnEncryptionAzureKeyVaultProvider.cs index d06063f8c0..eb8c8d77c4 100644 --- a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/SqlColumnEncryptionAzureKeyVaultProvider.cs +++ b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/SqlColumnEncryptionAzureKeyVaultProvider.cs @@ -241,7 +241,7 @@ byte[] DecryptEncryptionKey() byte[] message = new byte[encryptedColumnEncryptionKey.Length - signatureLength]; Buffer.BlockCopy(encryptedColumnEncryptionKey, 0, message, 0, encryptedColumnEncryptionKey.Length - signatureLength); - if (null == message) + if (message == null) { throw ADP.NullHashFound(); } diff --git a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Utils.cs b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Utils.cs index 2909422c1a..f71080ffab 100644 --- a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Utils.cs +++ b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Utils.cs @@ -45,7 +45,7 @@ internal static void ValidateNotNullOrWhitespaceForEach(string[] parameters, str internal static void ValidateEncryptionAlgorithm(string encryptionAlgorithm, bool isSystemOp) { // This validates that the encryption algorithm is RSA_OAEP - if (null == encryptionAlgorithm) + if (encryptionAlgorithm == null) { throw ADP.NullAlgorithm(isSystemOp); } @@ -124,8 +124,9 @@ internal static ArgumentException InvalidSignatureTemplate(string masterKeyPath) internal static ArgumentException InvalidAKVPath(string masterKeyPath, bool isSystemOp) { - string errorMessage = null == masterKeyPath ? Strings.NullAkvPath - : string.Format(CultureInfo.InvariantCulture, Strings.InvalidAkvPathTemplate, masterKeyPath); + string errorMessage = masterKeyPath == null + ? Strings.NullAkvPath + : string.Format(CultureInfo.InvariantCulture, Strings.InvalidAkvPathTemplate, masterKeyPath); if (isSystemOp) { return new ArgumentNullException(Constants.AeParamMasterKeyPath, errorMessage); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs index a7c98207c7..a8d9dcc13f 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs @@ -102,7 +102,7 @@ internal override bool TryOpenConnection(DbConnection outerConnection, DbConnect // we are completing an asynchronous open Debug.Assert(retry.Task.Status == TaskStatus.RanToCompletion, "retry task must be completed successfully"); DbConnectionInternal openConnection = retry.Task.Result; - if (null == openConnection) + if (openConnection == null) { connectionFactory.SetInnerConnectionTo(outerConnection, this); throw ADP.InternalConnectionError(ADP.ConnectionError.GetConnectionReturnsNull); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs index e5c76701e4..d1b7bf1ca0 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs @@ -214,12 +214,12 @@ internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnectionPoolKey key, D // new pool entry and add it to our collection. DbConnectionOptions connectionOptions = CreateConnectionOptions(key.ConnectionString, userConnectionOptions); - if (null == connectionOptions) + if (connectionOptions == null) { throw ADP.InternalConnectionError(ADP.ConnectionError.ConnectionOptionsMissing); } - if (null == userConnectionOptions) + if (userConnectionOptions == null) { // we only allow one expansion on the connection string userConnectionOptions = connectionOptions; @@ -236,7 +236,7 @@ internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnectionPoolKey key, D } // We don't support connection pooling on Win9x - if (null == poolOptions) + if (poolOptions == null) { if (null != connectionPoolGroup) { @@ -279,7 +279,7 @@ internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnectionPoolKey key, D Debug.Assert(null != connectionPoolGroup, "how did we not create a pool entry?"); Debug.Assert(null != userConnectionOptions, "how did we not have user connection options?"); } - else if (null == userConnectionOptions) + else if (userConnectionOptions == null) { userConnectionOptions = connectionPoolGroup.ConnectionOptions; } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs index bc77341b30..107b5c1850 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs @@ -178,10 +178,10 @@ public ConnectionState State internal void AddWeakReference(object value, int tag) { - if (null == _referenceCollection) + if (_referenceCollection == null) { _referenceCollection = CreateReferenceCollection(); - if (null == _referenceCollection) + if (_referenceCollection == null) { throw ADP.InternalError(ADP.InternalErrorCode.CreateReferenceCollectionReturnedNull); } @@ -349,7 +349,7 @@ protected bool TryOpenConnectionInternal(DbConnection outerConnection, DbConnect connectionFactory.SetInnerConnectionTo(outerConnection, this); throw; } - if (null == openConnection) + if (openConnection == null) { connectionFactory.SetInnerConnectionTo(outerConnection, this); throw ADP.InternalConnectionError(ADP.ConnectionError.GetConnectionReturnsNull); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionOptions.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionOptions.cs index 35440e9e11..693717c7d7 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionOptions.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionOptions.cs @@ -43,7 +43,7 @@ internal static string ExpandDataDirectory(string keyword, string value) // find the replacement path object rootFolderObject = AppDomain.CurrentDomain.GetData("DataDirectory"); var rootFolderPath = (rootFolderObject as string); - if ((null != rootFolderObject) && (null == rootFolderPath)) + if ((null != rootFolderObject) && rootFolderPath == null) { throw ADP.InvalidDataDirectory(); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs index 1a2e809147..bbf59fbb47 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs @@ -43,7 +43,7 @@ internal bool TryGetConnection(DbConnection owningConnection, TaskCompletionSour poolGroup = GetConnectionPoolGroup(owningConnection); // Doing this on the callers thread is important because it looks up the WindowsIdentity from the thread. connectionPool = GetConnectionPool(owningConnection, poolGroup); - if (null == connectionPool) + if (connectionPool == null) { // If GetConnectionPool returns null, we can be certain that // this connection should not be pooled via DbConnectionPool diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs index a3624ccdce..056576f7fa 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs @@ -37,7 +37,7 @@ protected internal Transaction EnlistedTransaction set { Transaction currentEnlistedTransaction = _enlistedTransaction; - if (((null == currentEnlistedTransaction) && (null != value)) + if ((currentEnlistedTransaction == null && (null != value)) || ((null != currentEnlistedTransaction) && !currentEnlistedTransaction.Equals(value))) { // WebData 20000024 @@ -354,7 +354,7 @@ virtual internal void DelegatedTransactionEnded() DbConnectionPool pool = Pool; - if (null == pool) + if (pool == null) { throw ADP.InternalError(ADP.InternalErrorCode.PooledObjectWithoutPool); // pooled connection does not have a pool } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs index 3bf8a9d561..e8c2ccbc97 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs @@ -729,7 +729,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio try { newObj = _connectionFactory.CreatePooledConnection(this, owningObject, _connectionPoolGroup.ConnectionOptions, _connectionPoolGroup.PoolKey, userOptions); - if (null == newObj) + if (newObj == null) { throw ADP.InternalError(ADP.InternalErrorCode.CreateObjectReturnedNull); // CreateObject succeeded, but null object } @@ -1172,7 +1172,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj obj = GetFromTransactedPool(out transaction); } - if (null == obj) + if (obj == null) { Interlocked.Increment(ref _waitCount); @@ -1217,7 +1217,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj } catch { - if (null == obj) + if (obj == null) { Interlocked.Decrement(ref _waitCount); } @@ -1233,7 +1233,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj } } - if (null == obj) + if (obj == null) { // If we were not able to create an object, check to see if // we reached MaxPoolSize. If so, we will no longer wait on @@ -1309,7 +1309,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj DestroyObject(obj); obj = null; } - } while (null == obj); + } while (obj == null); } if (null != obj) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs index dd57c60da8..b92a30905e 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs @@ -21,7 +21,7 @@ static SqlAuthenticationProviderManager() { // New configuration section "SqlClientAuthenticationProviders" for Microsoft.Data.SqlClient accepted to avoid conflicts with older one. configurationSection = FetchConfigurationSection(SqlClientAuthenticationProviderConfigurationSection.Name); - if (null == configurationSection) + if (configurationSection == null) { // If configuration section is not yet found, try with old Configuration Section name for backwards compatibility configurationSection = FetchConfigurationSection(SqlAuthenticationProviderConfigurationSection.Name); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs index 92c6d0075c..68221caf66 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs @@ -540,7 +540,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i isInTransaction = _connection.HasLocalTransaction; // Throw if there is a transaction but no flag is set - if (isInTransaction && null == _externalTransaction && null == _internalTransaction && (_connection.Parser != null && _connection.Parser.CurrentTransaction != null && _connection.Parser.CurrentTransaction.IsLocal)) + if (isInTransaction && _externalTransaction == null && _internalTransaction == null && (_connection.Parser != null && _connection.Parser.CurrentTransaction != null && _connection.Parser.CurrentTransaction.IsLocal)) { throw SQL.BulkLoadExistingTransaction(); } @@ -1281,7 +1281,7 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal) private void CreateOrValidateConnection(string method) { - if (null == _connection) + if (_connection == null) { throw ADP.ConnectionRequired(method); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.Windows.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.Windows.cs index a3c92002d1..cb09f49d91 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.Windows.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.Windows.cs @@ -32,7 +32,7 @@ public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string e // Validate the input parameters ValidateNonEmptyKeyPath(masterKeyPath, isSystemOp: true); - if (null == encryptedColumnEncryptionKey) + if (encryptedColumnEncryptionKey == null) { throw SQL.NullEncryptedColumnEncryptionKey(); } @@ -126,7 +126,7 @@ public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string e // Validate the input parameters ValidateNonEmptyKeyPath(masterKeyPath, isSystemOp: false); - if (null == columnEncryptionKey) + if (columnEncryptionKey == null) { throw SQL.NullColumnEncryptionKey(); } @@ -231,7 +231,7 @@ public override bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool al private void ValidateEncryptionAlgorithm(string encryptionAlgorithm, bool isSystemOp) { // This validates that the encryption algorithm is RSA_OAEP - if (null == encryptionAlgorithm) + if (encryptionAlgorithm == null) { throw SQL.NullKeyEncryptionAlgorithm(isSystemOp); } @@ -251,7 +251,7 @@ private void ValidateNonEmptyKeyPath(string masterKeyPath, bool isSystemOp) { if (string.IsNullOrWhiteSpace(masterKeyPath)) { - if (null == masterKeyPath) + if (masterKeyPath == null) { throw SQL.NullCngKeyPath(isSystemOp); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.Windows.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.Windows.cs index 891c0e1c61..c356e73527 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.Windows.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.Windows.cs @@ -40,7 +40,7 @@ public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string e // Validate the input parameters ValidateNonEmptyCSPKeyPath(masterKeyPath, isSystemOp: true); - if (null == encryptedColumnEncryptionKey) + if (encryptedColumnEncryptionKey == null) { throw SQL.NullEncryptedColumnEncryptionKey(); } @@ -134,7 +134,7 @@ public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string e // Validate the input parameters ValidateNonEmptyCSPKeyPath(masterKeyPath, isSystemOp: false); - if (null == columnEncryptionKey) + if (columnEncryptionKey == null) { throw SQL.NullColumnEncryptionKey(); } @@ -239,7 +239,7 @@ public override bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool al private void ValidateEncryptionAlgorithm(string encryptionAlgorithm, bool isSystemOp) { // This validates that the encryption algorithm is RSA_OAEP - if (null == encryptionAlgorithm) + if (encryptionAlgorithm == null) { throw SQL.NullKeyEncryptionAlgorithm(isSystemOp); } @@ -260,7 +260,7 @@ private void ValidateNonEmptyCSPKeyPath(string masterKeyPath, bool isSystemOp) { if (string.IsNullOrWhiteSpace(masterKeyPath)) { - if (null == masterKeyPath) + if (masterKeyPath == null) { throw SQL.NullCspKeyPath(isSystemOp); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs index dd052bb346..b238cef3cc 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs @@ -615,7 +615,7 @@ internal SqlStatistics Statistics get { // if the transaction object has been zombied, just return null - if ((null != _transaction) && (null == _transaction.Connection)) + if ((null != _transaction) && _transaction.Connection == null) { _transaction = null; } @@ -783,7 +783,7 @@ public override bool DesignTimeVisible { get { - if (null == _parameters) + if (_parameters == null) { // delay the creation of the SqlParameterCollection // until user actually uses the Parameters property @@ -1028,12 +1028,12 @@ public override void Cancel() // if we have pending data, but it is not a result of this command, then we don't cancel either. Note that // this model is implementable because we only allow one active command at any one time. This code // will have to change we allow multiple outstanding batches - if (null == _activeConnection) + if (_activeConnection == null) { return; } SqlInternalConnectionTds connection = (_activeConnection.InnerConnection as SqlInternalConnectionTds); - if (null == connection) + if (connection == null) { // Fail with out locking return; } @@ -1050,12 +1050,11 @@ public override void Cancel() } TdsParser parser = connection.Parser; - if (null == parser) + if (parser == null) { return; } - if (!_pendingCancel) { // Do nothing if already pending. // Before attempting actual cancel, set the _pendingCancel flag to false. @@ -1644,7 +1643,7 @@ private object InternalEndExecuteNonQuery(IAsyncResult asyncResult, bool isInter } } - Debug.Assert(null == _stateObj, "non-null state object in EndExecuteNonQuery"); + Debug.Assert(_stateObj == null, "non-null state object in EndExecuteNonQuery"); return _rowsAffected; } @@ -1716,7 +1715,7 @@ private Task InternalExecuteNonQuery(TaskCompletionSource completion, bo } } - Debug.Assert(isAsync || null == _stateObj, "non-null state object in InternalExecuteNonQuery"); + Debug.Assert(isAsync || _stateObj == null, "non-null state object in InternalExecuteNonQuery"); return task; } @@ -2564,7 +2563,7 @@ private SqlDataReader InternalEndExecuteReader(IAsyncResult asyncResult, bool is CheckThrowSNIException(); SqlDataReader reader = CompleteAsyncExecuteReader(isInternal); - Debug.Assert(null == _stateObj, "non-null state object in InternalEndExecuteReader"); + Debug.Assert(_stateObj == null, "non-null state object in InternalEndExecuteReader"); return reader; } @@ -3297,7 +3296,7 @@ internal void DeriveParameters() // Use common parser for SqlClient and OleDb - parse into 4 parts - Server, Catalog, Schema, ProcedureName string[] parsedSProc = MultipartIdentifier.ParseMultipartIdentifier(CommandText, "[\"", "]\"", Strings.SQL_SqlCommandCommandText, false); - if (null == parsedSProc[3] || string.IsNullOrEmpty(parsedSProc[3])) + if (string.IsNullOrEmpty(parsedSProc[3])) { throw ADP.NoStoredProcedureExists(CommandText); } @@ -3590,7 +3589,7 @@ private void CheckNotificationStateAndAutoEnlist() { if (_sqlDep != null) { - if (null == _sqlDep.Options) + if (_sqlDep.Options == null) { // If null, SqlDependency was not created with options, so we need to obtain default options now. // GetDefaultOptions can and will throw under certain conditions. @@ -3885,10 +3884,10 @@ private void PrepareForTransparentEncryption(CommandBehavior cmdBehavior, bool r // If we didn't have parameters, we can fall back to regular code path, by simply returning. if (!describeParameterEncryptionNeeded) { - Debug.Assert(null == fetchInputParameterEncryptionInfoTask, + Debug.Assert(fetchInputParameterEncryptionInfoTask == null, "fetchInputParameterEncryptionInfoTask should not be set if describe parameter encryption is not needed."); - Debug.Assert(null == describeParameterEncryptionDataReader, + Debug.Assert(describeParameterEncryptionDataReader == null, "SqlDataReader created for describe parameter encryption params when it is not needed."); return; @@ -4013,7 +4012,7 @@ private SqlDataReader GetParameterEncryptionDataReader(out Task returnTask, Task // Complete executereader. describeParameterEncryptionDataReader = command.CompleteAsyncExecuteReader(forDescribeParameterEncryption: true); - Debug.Assert(null == command._stateObj, "non-null state object in PrepareForTransparentEncryption."); + Debug.Assert(command._stateObj == null, "non-null state object in PrepareForTransparentEncryption."); // Read the results of describe parameter encryption. command.ReadDescribeEncryptionParameterResults(describeParameterEncryptionDataReader, describeParameterEncryptionRpcOriginalRpcMap, inRetry); @@ -4087,7 +4086,7 @@ private SqlDataReader GetParameterEncryptionDataReaderAsync(out Task returnTask, // Complete executereader. describeParameterEncryptionDataReader = CompleteAsyncExecuteReader(forDescribeParameterEncryption: true); - Debug.Assert(null == _stateObj, "non-null state object in PrepareForTransparentEncryption."); + Debug.Assert(_stateObj == null, "non-null state object in PrepareForTransparentEncryption."); // Read the results of describe parameter encryption. ReadDescribeEncryptionParameterResults(describeParameterEncryptionDataReader, @@ -5191,7 +5190,7 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi } } - Debug.Assert(isAsync || null == _stateObj, "non-null state object in RunExecuteReader"); + Debug.Assert(isAsync || _stateObj == null, "non-null state object in RunExecuteReader"); return ds; } @@ -5409,7 +5408,7 @@ private Task RegisterForConnectionCloseNotification(Task outerTask) // throws exception for error case, returns false if the commandText is empty private void ValidateCommand(bool isAsync, [CallerMemberName] string method = "") { - if (null == _activeConnection) + if (_activeConnection == null) { throw ADP.ConnectionRequired(method); } @@ -5462,7 +5461,7 @@ private void ValidateCommand(bool isAsync, [CallerMemberName] string method = "" // throw if the connection is in a transaction but there is no // locally assigned transaction object - if (_activeConnection.HasLocalTransactionFromAPI && (null == _transaction)) + if (_activeConnection.HasLocalTransactionFromAPI && _transaction == null) { throw ADP.TransactionRequired(method); } @@ -5499,7 +5498,7 @@ private void ValidateAsyncCommand() private void GetStateObject(TdsParser parser = null) { - Debug.Assert(null == _stateObj, "StateObject not null on GetStateObject"); + Debug.Assert(_stateObj == null, "StateObject not null on GetStateObject"); Debug.Assert(null != _activeConnection, "no active connection?"); if (_pendingCancel) @@ -5850,7 +5849,7 @@ private SqlParameter GetParameterForOutputValueExtraction(SqlParameterCollection SqlParameter thisParam = null; bool foundParam = false; - if (null == paramName) + if (paramName == null) { // rec.parameter should only be null for a return value from a function for (int i = 0; i < paramCount; i++) @@ -5979,12 +5978,12 @@ private void SetUpRPCParameters(_SqlRPC rpc, bool inSchema, SqlParameterCollecti // set default value bit if (parameter.Direction != ParameterDirection.Output) { - // remember that null == Convert.IsEmpty, DBNull.Value is a database null! + // remember that Convert.IsEmpty is null, DBNull.Value is a database null! // Don't assume a default value exists for parameters in the case when // the user is simply requesting schema. // TVPs use DEFAULT and do not allow NULL, even for schema only. - if (null == parameter.Value && (!inSchema || SqlDbType.Structured == parameter.SqlDbType)) + if (parameter.Value == null && (!inSchema || SqlDbType.Structured == parameter.SqlDbType)) { options |= TdsEnums.RPC_PARAM_DEFAULT; } @@ -6440,7 +6439,7 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete if ((null != val) && (DBNull.Value != val)) { s = (val as string); - if (null == s) + if (s == null) { SqlString sval = val is SqlString ? (SqlString)val : SqlString.Null; if (!sval.IsNull) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs index fd4ed4d0de..a9a168f490 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -468,7 +468,7 @@ public bool StatisticsEnabled // start if (ConnectionState.Open == State) { - if (null == _statistics) + if (_statistics == null) { _statistics = new SqlStatistics(); _statistics._openTimestamp = ADP.TimerCurrent(); @@ -1883,7 +1883,7 @@ private void PrepareStatisticsForNewConnection() s_diagnosticListener.IsEnabled(SqlClientCommandAfter.Name) || s_diagnosticListener.IsEnabled(SqlClientConnectionOpenAfter.Name)) { - if (null == _statistics) + if (_statistics == null) { _statistics = new SqlStatistics(); } @@ -2146,7 +2146,7 @@ internal void OnError(SqlException exception, bool breakConnection, Action= cchars) @@ -2252,7 +2254,7 @@ private long GetCharsFromPlpData(int i, long dataIndex, char[] buffer, int buffe } // if no buffer is passed in, return the total number of characters or -1 - if (null == buffer) + if (buffer == null) { cch = (long)_parser.PlpBytesTotalLength(_stateObj); return (isUnicode && (cch > 0)) ? cch >> 1 : cch; @@ -2631,7 +2633,7 @@ virtual public int GetSqlValues(object[] values) { statistics = SqlStatistics.StartTimer(Statistics); CheckDataIsReady(); - if (null == values) + if (values == null) { throw ADP.ArgumentNull(nameof(values)); } @@ -3045,7 +3047,7 @@ override public int GetValues(object[] values) { statistics = SqlStatistics.StartTimer(Statistics); - if (null == values) + if (values == null) { throw ADP.ArgumentNull(nameof(values)); } @@ -5826,7 +5828,7 @@ public ReadOnlyCollection GetColumnSchema() try { statistics = SqlStatistics.StartTimer(Statistics); - if (null == _metaData || null == _metaData.dbColumnSchema) + if (_metaData == null || _metaData.dbColumnSchema == null) { if (null != this.MetaData) { diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs index 2f9e1e8e06..08ba5ec80e 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs @@ -99,7 +99,7 @@ public void Initialize() connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Begin, null, _isolationLevel, _internalTransaction, true); // Handle case where ExecuteTran didn't produce a new transaction, but also didn't throw. - if (null == connection.CurrentTransaction) + if (connection.CurrentTransaction == null) { connection.DoomThisConnection(); throw ADP.InternalError(ADP.InternalErrorCode.UnknownTransactionFailure); @@ -485,7 +485,7 @@ internal void TransactionEnded(Transaction transaction) private SqlInternalConnection GetValidConnection() { SqlInternalConnection connection = _connection; - if (null == connection && Transaction.TransactionInformation.Status != TransactionStatus.Aborted) + if (connection == null && Transaction.TransactionInformation.Status != TransactionStatus.Aborted) { throw ADP.ObjectDisposed(this); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs index 5d6a1d30e0..d1abdb310f 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs @@ -641,7 +641,7 @@ internal protected override bool IsNonPoolableTransactionRoot { get { - return IsTransactionRoot && (!Is2008OrNewer || null == Pool); + return IsTransactionRoot && (!Is2008OrNewer || Pool == null); } } @@ -689,7 +689,7 @@ protected override bool ReadyToPrepareTransaction { get { - bool result = (null == FindLiveReader(null)); // can't prepare with a live data reader... + bool result = FindLiveReader(null) == null; // can't prepare with a live data reader... return result; } } @@ -1004,7 +1004,7 @@ internal override void ExecuteTransaction(TransactionRequest transactionRequest, } } - string transactionName = (null == name) ? string.Empty : name; + string transactionName = name == null ? string.Empty : name; ExecuteTransaction2005(transactionRequest, transactionName, iso, internalTransaction, isDelegateControlRequest); } @@ -1591,12 +1591,13 @@ private void LoginNoFailover(ServerInfo serverInfo, continue; } - if (null == _parser - || TdsParserState.Closed != _parser.State - || IsDoNotRetryConnectError(sqlex) - || timeout.IsExpired) - { // no more time to try again - throw; // Caller will call LoginFailure() + if (_parser == null + || TdsParserState.Closed != _parser.State + || IsDoNotRetryConnectError(sqlex) + || timeout.IsExpired) + { + // no more time to try again + throw; // Caller will call LoginFailure() } // Check sleep interval to make sure we won't exceed the timeout @@ -1710,7 +1711,7 @@ TimeoutTimer timeout ServerInfo failoverServerInfo = new ServerInfo(connectionOptions, failoverHost, connectionOptions.FailoverPartnerSPN); ResolveExtendedServerName(primaryServerInfo, !redirectedUserInstance, connectionOptions); - if (null == ServerProvidedFailOverPartner) + if (ServerProvidedFailOverPartner == null) { ResolveExtendedServerName(failoverServerInfo, !redirectedUserInstance && failoverHost != primaryServerInfo.UserServerName, connectionOptions); } @@ -1844,7 +1845,7 @@ TimeoutTimer timeout _activeDirectoryAuthTimeoutRetryHelper.State = ActiveDirectoryAuthenticationTimeoutRetryState.HasLoggedIn; // if connected to failover host, but said host doesn't have DbMirroring set up, throw an error - if (useFailoverHost && null == ServerProvidedFailOverPartner) + if (useFailoverHost && ServerProvidedFailOverPartner == null) { throw SQL.InvalidPartnerConfiguration(failoverHost, CurrentDatabase); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs index da0d437927..58b253499b 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -231,16 +231,16 @@ internal SqlInternalTransaction CurrentTransaction set { Debug.Assert(value == _currentTransaction - || null == _currentTransaction - || null == value + || _currentTransaction == null + || value == null || (null != _currentTransaction && !_currentTransaction.IsLocal), "attempting to change current transaction?"); // If there is currently a transaction active, we don't want to // change it; this can occur when there is a delegated transaction // and the user attempts to do an API begin transaction; in these // cases, it's safe to ignore the set. - if ((null == _currentTransaction && null != value) - || (null != _currentTransaction && null == value)) + if ((_currentTransaction == null && null != value) + || (null != _currentTransaction && value == null)) { _currentTransaction = value; } @@ -508,7 +508,7 @@ internal void Connect( uint result = _physicalStateObj.SniGetConnectionId(ref _connHandler._clientConnectionId); Debug.Assert(result == TdsEnums.SNI_SUCCESS, "Unexpected failure state upon calling SniGetConnectionId"); - if (null == _connHandler.pendingSQLDNSObject) + if (_connHandler.pendingSQLDNSObject == null) { // for DNS Caching phase 1 _physicalStateObj.AssignPendingDNSInfo(serverInfo.UserProtocol, FQDNforDNSCache, ref _connHandler.pendingSQLDNSObject); @@ -581,7 +581,7 @@ internal void Connect( Debug.Assert(retCode == TdsEnums.SNI_SUCCESS, "Unexpected failure state upon calling SniGetConnectionId"); SqlClientEventSource.Log.TryTraceEvent(" Sending prelogin handshake"); - if (null == _connHandler.pendingSQLDNSObject) + if (_connHandler.pendingSQLDNSObject == null) { // for DNS Caching phase 1 _physicalStateObj.AssignPendingDNSInfo(serverInfo.UserProtocol, FQDNforDNSCache, ref _connHandler.pendingSQLDNSObject); @@ -1183,7 +1183,7 @@ internal void Deactivate(bool connectionIsDoomed) _sessionPool.Deactivate(); } - Debug.Assert(connectionIsDoomed || null == _pendingTransaction, "pending transaction at disconnect?"); + Debug.Assert(connectionIsDoomed || _pendingTransaction == null, "pending transaction at disconnect?"); if (!connectionIsDoomed && null != _physicalStateObj) { @@ -1211,7 +1211,7 @@ internal void Deactivate(bool connectionIsDoomed) if (null != currentTransaction && currentTransaction.HasParentTransaction) { currentTransaction.CloseFromConnection(); - Debug.Assert(null == CurrentTransaction, "rollback didn't clear current transaction?"); + Debug.Assert(CurrentTransaction == null, "rollback didn't clear current transaction?"); } Statistics = null; // must come after CleanWire or we won't count the stuff that happens there... @@ -1316,7 +1316,7 @@ internal void RollbackOrphanedAPITransactions() if (null != currentTransaction && currentTransaction.HasParentTransaction && currentTransaction.IsOrphaned) { currentTransaction.CloseFromConnection(); - Debug.Assert(null == CurrentTransaction, "rollback didn't clear current transaction?"); + Debug.Assert(CurrentTransaction == null, "rollback didn't clear current transaction?"); } } @@ -1680,7 +1680,7 @@ internal void CheckResetConnection(TdsParserStateObject stateObj) // internal byte[] SerializeShort(int v, TdsParserStateObject stateObj) { - if (null == stateObj._bShortBytes) + if (stateObj._bShortBytes == null) { stateObj._bShortBytes = new byte[2]; } @@ -1739,7 +1739,7 @@ internal void WriteUnsignedInt(uint i, TdsParserStateObject stateObj) // internal byte[] SerializeInt(int v, TdsParserStateObject stateObj) { - if (null == stateObj._bIntBytes) + if (stateObj._bIntBytes == null) { stateObj._bIntBytes = new byte[sizeof(int)]; } @@ -1812,7 +1812,7 @@ internal void WriteFloat(float v, TdsParserStateObject stateObj) internal byte[] SerializeLong(long v, TdsParserStateObject stateObj) { int current = 0; - if (null == stateObj._bLongBytes) + if (stateObj._bLongBytes == null) { stateObj._bLongBytes = new byte[8]; } @@ -2256,7 +2256,7 @@ internal TdsOperationStatus TryRun(RunBehavior runBehavior, SqlCommand cmdHandle // the current transaction, then we store the token in it. // if there isn't a pending transaction, then it's either // a TSQL transaction or a distributed transaction. - Debug.Assert(null == _currentTransaction, "non-null current transaction with an ENV Change"); + Debug.Assert(_currentTransaction == null, "non-null current transaction with an ENV Change"); _currentTransaction = _pendingTransaction; _pendingTransaction = null; @@ -6235,12 +6235,12 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt { System.Text.Encoding encoding = md.baseTI.encoding; - if (null == encoding) + if (encoding == null) { encoding = _defaultEncoding; } - if (null == encoding) + if (encoding == null) { ThrowUnsupportedCollationEncountered(stateObj); } @@ -7134,7 +7134,7 @@ internal Task WriteSqlVariantValue(object value, int length, int offset, TdsPars internal Task WriteSqlVariantDataRowValue(object value, TdsParserStateObject stateObj, bool canAccumulate = true) { // handle null values - if ((null == value) || (DBNull.Value == value)) + if (value == null || (DBNull.Value == value)) { WriteInt(TdsEnums.FIXEDNULL, stateObj); return null; @@ -7369,7 +7369,7 @@ private byte[] SerializeCurrency(Decimal value, int length, TdsParserStateObject } Debug.Assert(8 == length, "invalid length in SerializeCurrency"); - if (null == stateObj._bLongBytes) + if (stateObj._bLongBytes == null) { stateObj._bLongBytes = new byte[8]; } @@ -7543,7 +7543,7 @@ private TdsOperationStatus TryReadDecimalBits(int length, TdsParserStateObject s bits = stateObj._decimalBits; // used alloc'd array if we have one already int i; - if (null == bits) + if (bits == null) { bits = new int[4]; stateObj._decimalBits = bits; @@ -7601,7 +7601,7 @@ internal static decimal AdjustDecimalScale(decimal value, int newScale) internal byte[] SerializeSqlDecimal(SqlDecimal d, TdsParserStateObject stateObj) { - if (null == stateObj._bDecimalBytes) + if (stateObj._bDecimalBytes == null) { stateObj._bDecimalBytes = new byte[17]; } @@ -7660,7 +7660,7 @@ internal void WriteSqlDecimal(SqlDecimal d, TdsParserStateObject stateObj) private byte[] SerializeDecimal(decimal value, TdsParserStateObject stateObj) { int[] decimalBits = Decimal.GetBits(value); - if (null == stateObj._bDecimalBytes) + if (stateObj._bDecimalBytes == null) { stateObj._bDecimalBytes = new byte[17]; } @@ -7931,7 +7931,7 @@ internal int GetEncodingCharLength(string value, int numChars, int charOffset, E // 7.0 has no support for multiple code pages in data - single code page support only if (encoding == null) { - if (null == _defaultEncoding) + if (_defaultEncoding == null) { ThrowUnsupportedCollationEncountered(null); } @@ -8586,8 +8586,10 @@ private void WriteLoginData(SqlLogin rec, WriteShort(rec.database.Length, _physicalStateObj); offset += rec.database.Length * 2; - if (null == s_nicAddress) + if (s_nicAddress == null) + { s_nicAddress = TdsParserStaticMethods.GetNetworkPhysicalAddressForTdsLoginOnly(); + } _physicalStateObj.WriteByteArray(s_nicAddress, s_nicAddress.Length, 0); @@ -10772,7 +10774,7 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin case TdsEnums.SQLBIGCHAR: case TdsEnums.SQLBIGVARCHAR: case TdsEnums.SQLTEXT: - if (null == _defaultEncoding) + if (_defaultEncoding == null) { ThrowUnsupportedCollationEncountered(null); // stateObject only when reading } @@ -10910,7 +10912,7 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars case TdsEnums.SQLBIGCHAR: case TdsEnums.SQLBIGVARCHAR: case TdsEnums.SQLTEXT: - if (null == _defaultEncoding) + if (_defaultEncoding == null) { ThrowUnsupportedCollationEncountered(null); // stateObject only when reading } @@ -11076,7 +11078,7 @@ private int GetNotificationHeaderSize(SqlNotificationRequest notificationRequest string service = notificationRequest.Options; int timeout = notificationRequest.Timeout; - if (null == callbackId) + if (callbackId == null) { throw ADP.ArgumentNull(nameof(callbackId)); } @@ -11085,7 +11087,7 @@ private int GetNotificationHeaderSize(SqlNotificationRequest notificationRequest throw ADP.ArgumentOutOfRange(nameof(callbackId)); } - if (null == service) + if (service == null) { throw ADP.ArgumentNull(nameof(service)); } @@ -12376,7 +12378,7 @@ private byte[] SerializeUnencryptedValue(object value, MetaType type, byte scale if (0 > dt.days || dt.days > UInt16.MaxValue) throw SQL.SmallDateTimeOverflow(MetaType.ToDateTime(dt.days, dt.time, 4).ToString(CultureInfo.InvariantCulture)); - if (null == stateObj._bIntBytes) + if (stateObj._bIntBytes == null) { stateObj._bIntBytes = new byte[4]; } @@ -12395,7 +12397,7 @@ private byte[] SerializeUnencryptedValue(object value, MetaType type, byte scale } else { - if (null == stateObj._bLongBytes) + if (stateObj._bLongBytes == null) { stateObj._bLongBytes = new byte[8]; } @@ -12569,7 +12571,7 @@ private byte[] SerializeUnencryptedSqlValue(object value, MetaType type, int act if (0 > dt.DayTicks || dt.DayTicks > UInt16.MaxValue) throw SQL.SmallDateTimeOverflow(dt.ToString()); - if (null == stateObj._bIntBytes) + if (stateObj._bIntBytes == null) { stateObj._bIntBytes = new byte[4]; } @@ -12588,7 +12590,7 @@ private byte[] SerializeUnencryptedSqlValue(object value, MetaType type, int act } else { - if (null == stateObj._bLongBytes) + if (stateObj._bLongBytes == null) { stateObj._bLongBytes = new byte[8]; } @@ -12909,7 +12911,7 @@ internal int ReadPlpAnsiChars(ref char[] buff, int offst, int len, SqlMetaDataPr if (enc == null) { - if (null == _defaultEncoding) + if (_defaultEncoding == null) { ThrowUnsupportedCollationEncountered(stateObj); } @@ -13153,38 +13155,38 @@ internal string TraceString() { return string.Format(/*IFormatProvider*/ null, StateTraceFormatString, - null == _physicalStateObj ? "(null)" : _physicalStateObj.ObjectID.ToString((IFormatProvider)null), - null == _pMarsPhysicalConObj ? "(null)" : _pMarsPhysicalConObj.ObjectID.ToString((IFormatProvider)null), + _physicalStateObj == null ? "(null)" : _physicalStateObj.ObjectID.ToString((IFormatProvider)null), + _pMarsPhysicalConObj == null ? "(null)" : _pMarsPhysicalConObj.ObjectID.ToString((IFormatProvider)null), _state, _server, _fResetConnection ? bool.TrueString : bool.FalseString, - null == _defaultCollation ? "(null)" : _defaultCollation.TraceString(), + _defaultCollation == null ? "(null)" : _defaultCollation.TraceString(), _defaultCodePage, _defaultLCID, TraceObjectClass(_defaultEncoding), _encryptionOption, - null == _currentTransaction ? "(null)" : _currentTransaction.TraceString(), - null == _pendingTransaction ? "(null)" : _pendingTransaction.TraceString(), + _currentTransaction == null ? "(null)" : _currentTransaction.TraceString(), + _pendingTransaction == null ? "(null)" : _pendingTransaction.TraceString(), _retainedTransactionId, _nonTransactedOpenResultCount, - null == _connHandler ? "(null)" : _connHandler.ObjectID.ToString((IFormatProvider)null), + _connHandler == null ? "(null)" : _connHandler.ObjectID.ToString((IFormatProvider)null), _fMARS ? bool.TrueString : bool.FalseString, - null == _sessionPool ? "(null)" : _sessionPool.TraceString(), + _sessionPool == null ? "(null)" : _sessionPool.TraceString(), _is2005 ? bool.TrueString : bool.FalseString, - null == _sniSpnBuffer ? "(null)" : _sniSpnBuffer.Length.ToString((IFormatProvider)null), + _sniSpnBuffer == null ? "(null)" : _sniSpnBuffer.Length.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.ErrorCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.WarningCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionErrorCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionWarningCount.ToString((IFormatProvider)null), - null == _statistics ? bool.TrueString : bool.FalseString, + _statistics == null ? bool.TrueString : bool.FalseString, _statisticsIsInTransaction ? bool.TrueString : bool.FalseString, _fPreserveTransaction ? bool.TrueString : bool.FalseString, - null == _connHandler ? "(null)" : _connHandler.ConnectionOptions.MultiSubnetFailover.ToString((IFormatProvider)null)); + _connHandler == null ? "(null)" : _connHandler.ConnectionOptions.MultiSubnetFailover.ToString((IFormatProvider)null)); } private string TraceObjectClass(object instance) { - if (null == instance) + if (instance == null) { return "(null)"; } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs index d0431e1901..8654aa4c54 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs @@ -361,7 +361,7 @@ internal _SqlMetaData this[int index] } set { - Debug.Assert(null == value, "used only by SqlBulkCopy"); + Debug.Assert(value == null, "used only by SqlBulkCopy"); _metaDataArray[index] = value; } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Common/src/Microsoft/Data/Common/NameValuePermission.cs b/src/Microsoft.Data.SqlClient/netfx/src/Common/src/Microsoft/Data/Common/NameValuePermission.cs index e47c3ab456..4a3055a777 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Common/src/Microsoft/Data/Common/NameValuePermission.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Common/src/Microsoft/Data/Common/NameValuePermission.cs @@ -74,7 +74,7 @@ static internal void AddEntry(NameValuePermission kvtree, ArrayList entries, DBC NameValuePermission kv; kv = kvtree.CheckKeyForValue(keychain.Name); - if (null == kv) + if (kv == null) { kv = new NameValuePermission(keychain.Name); kvtree.Add(kv); // add directly into live tree @@ -82,7 +82,7 @@ static internal void AddEntry(NameValuePermission kvtree, ArrayList entries, DBC kvtree = kv; kv = kvtree.CheckKeyForValue(keychain.Value); - if (null == kv) + if (kv == null) { DBConnectionString insertValue = ((null != keychain.Next) ? null : entry); kv = new NameValuePermission(keychain.Value, insertValue); @@ -92,7 +92,7 @@ static internal void AddEntry(NameValuePermission kvtree, ArrayList entries, DBC entries.Add(insertValue); } } - else if (null == keychain.Next) + else if (keychain.Next == null) { // shorter chain potential if (null != kv._entry) { @@ -128,7 +128,7 @@ static internal void AddEntry(NameValuePermission kvtree, ArrayList entries, DBC internal void Intersect(ArrayList entries, NameValuePermission target) { - if (null == target) + if (target == null) { _tree = null; _entry = null; @@ -199,7 +199,7 @@ private void Add(NameValuePermission permit) internal bool CheckValueForKeyPermit(DBConnectionString parsetable) { - if (null == parsetable) + if (parsetable == null) { return false; } @@ -219,7 +219,7 @@ internal bool CheckValueForKeyPermit(DBConnectionString parsetable) { string keyword = permitKey._value; #if DEBUG - Debug.Assert(null == permitKey._entry, "key member has no restrictions"); + Debug.Assert(permitKey._entry == null, "key member has no restrictions"); #endif if (parsetable.ContainsKey(keyword)) { @@ -252,7 +252,7 @@ internal bool CheckValueForKeyPermit(DBConnectionString parsetable) // else try next keyword } } - // partial chain match, either leaf-node by shorter chain or fail mid-chain if (null == _restrictions) + // partial chain match, either leaf-node by shorter chain or fail mid-chain if ( _restrictions == null) } DBConnectionString entry = _entry; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/AdapterSwitches.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/AdapterSwitches.cs index 0563e8a1ef..fdbdf4f270 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/AdapterSwitches.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/AdapterSwitches.cs @@ -15,7 +15,7 @@ internal static class AdapterSwitches { static internal TraceSwitch DataSchema { get { TraceSwitch dataSchema = _dataSchema; - if (null == dataSchema) { + if (dataSchema == null) { _dataSchema = dataSchema = new TraceSwitch("Data.Schema", "Enable tracing for schema actions."); } return dataSchema; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DBConnectionString.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DBConnectionString.cs index 4a2ea20c4d..8a31b9679c 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DBConnectionString.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DBConnectionString.cs @@ -147,7 +147,7 @@ internal string ConnectionString internal bool IsEmpty { - get { return (null == _keychain); } + get { return _keychain == null; } } internal NameValuePair KeyChain @@ -160,7 +160,7 @@ internal string Restrictions get { string restrictions = _restrictions; - if (null == restrictions) + if (restrictions == null) { string[] restrictionValues = _restrictionValues; if ((null != restrictionValues) && (0 < restrictionValues.Length)) @@ -202,7 +202,7 @@ internal DBConnectionString Intersect(DBConnectionString entry) KeyRestrictionBehavior behavior = _behavior; string[] restrictionValues = null; - if (null == entry) + if (entry == null) { //Debug.WriteLine("0 entry AllowNothing"); behavior = KeyRestrictionBehavior.AllowOnly; @@ -287,7 +287,7 @@ internal DBConnectionString Intersect(DBConnectionString entry) // verify _hasPassword & _parsetable are in sync between Everett/Whidbey Debug.Assert(!_hasPassword || ContainsKey(KEY.Password) || ContainsKey(KEY.Pwd), "OnDeserialized password mismatch this"); - Debug.Assert(null == entry || !entry._hasPassword || entry.ContainsKey(KEY.Password) || entry.ContainsKey(KEY.Pwd), "OnDeserialized password mismatch entry"); + Debug.Assert(entry == null || !entry._hasPassword || entry.ContainsKey(KEY.Password) || entry.ContainsKey(KEY.Pwd), "OnDeserialized password mismatch entry"); DBConnectionString value = new DBConnectionString(this, restrictionValues, behavior); ValidateCombinedSet(this, value); @@ -367,7 +367,7 @@ private void ValidateCombinedSet(DBConnectionString componentSet, DBConnectionSt private bool IsRestrictedKeyword(string key) { // restricted if not found - return ((null == _restrictionValues) || (0 > Array.BinarySearch(_restrictionValues, key, StringComparer.Ordinal))); + return (_restrictionValues == null || (0 > Array.BinarySearch(_restrictionValues, key, StringComparer.Ordinal))); } internal bool IsSupersetOf(DBConnectionString entry) @@ -415,7 +415,7 @@ static private string[] NewRestrictionAllowOnly(string[] allowonly, string[] pre { if (0 > Array.BinarySearch(preventusage, allowonly[i], StringComparer.Ordinal)) { - if (null == newlist) + if (newlist == null) { newlist = new List(); } @@ -438,7 +438,7 @@ static private string[] NewRestrictionIntersect(string[] a, string[] b) { if (0 <= Array.BinarySearch(b, a[i], StringComparer.Ordinal)) { - if (null == newlist) + if (newlist == null) { newlist = new List(); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DbConnectionOptions.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DbConnectionOptions.cs index 364f256fdc..a17621c613 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DbConnectionOptions.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DbConnectionOptions.cs @@ -88,7 +88,7 @@ internal static void AppendKeyValuePairBuilder(StringBuilder builder, string key ADP.CheckArgumentNull(builder, nameof(builder)); ADP.CheckArgumentLength(keyName, nameof(keyName)); - if ((null == keyName) || !s_connectionStringValidKeyRegex.IsMatch(keyName)) + if (keyName == null || !s_connectionStringValidKeyRegex.IsMatch(keyName)) { throw ADP.InvalidKeyname(keyName); } @@ -169,12 +169,12 @@ internal static string ExpandDataDirectory(string keyword, string value, ref str { string rootFolderPath = datadir; - if (null == rootFolderPath) + if (rootFolderPath == null) { // find the replacement path object rootFolderObject = AppDomain.CurrentDomain.GetData("DataDirectory"); rootFolderPath = (rootFolderObject as string); - if ((null != rootFolderObject) && (null == rootFolderPath)) + if ((null != rootFolderObject) && rootFolderPath == null) { throw ADP.InvalidDataDirectory(); } @@ -182,7 +182,7 @@ internal static string ExpandDataDirectory(string keyword, string value, ref str { rootFolderPath = AppDomain.CurrentDomain.BaseDirectory; } - if (null == rootFolderPath) + if (rootFolderPath == null) { rootFolderPath = ""; } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/GreenMethods.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/GreenMethods.cs index 8cbf6e0543..b23728ba29 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/GreenMethods.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/GreenMethods.cs @@ -29,7 +29,7 @@ internal static class GreenMethods internal static object MicrosoftDataSqlClientSqlProviderServices_Instance() { - if (null == MicrosoftDataSqlClientSqlProviderServices_Instance_FieldInfo) + if (MicrosoftDataSqlClientSqlProviderServices_Instance_FieldInfo == null) { Type t = Type.GetType(MicrosoftDataSqlClientSqlProviderServices_TypeName, false); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs index f6dcccacd3..bf28304b91 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs @@ -126,7 +126,7 @@ internal static bool NativeSetData(void* passedData, int passedSize) } Trace.Assert(1 == thelock); // Now that we have the lock, lock should be equal to 1. - if (null == data) + if (data == null) { data = Marshal.AllocHGlobal(passedSize).ToPointer(); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs index 99ad6029de..3ec932cdc0 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs @@ -141,7 +141,7 @@ internal override bool TryOpenConnection(DbConnection outerConnection, DbConnect // we are completing an asynchronous open Debug.Assert(retry.Task.Status == TaskStatus.RanToCompletion, "retry task must be completed successfully"); DbConnectionInternal openConnection = retry.Task.Result; - if (null == openConnection) + if (openConnection == null) { connectionFactory.SetInnerConnectionTo(outerConnection, this); throw ADP.InternalConnectionError(ADP.ConnectionError.GetConnectionReturnsNull); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs index b857323bb1..e83373dae1 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs @@ -220,7 +220,7 @@ internal bool TryGetConnection(DbConnection owningConnection, TaskCompletionSour poolGroup = GetConnectionPoolGroup(owningConnection); // Doing this on the callers thread is important because it looks up the WindowsIdentity from the thread. connectionPool = GetConnectionPool(owningConnection, poolGroup); - if (null == connectionPool) + if (connectionPool == null) { // If GetConnectionPool returns null, we can be certain that // this connection should not be pooled via DbConnectionPool @@ -426,13 +426,13 @@ internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnectionPoolKey key, D // new pool entry and add it to our collection. DbConnectionOptions connectionOptions = CreateConnectionOptions(key.ConnectionString, userConnectionOptions); - if (null == connectionOptions) + if (connectionOptions == null) { throw ADP.InternalConnectionError(ADP.ConnectionError.ConnectionOptionsMissing); } string expandedConnectionString = key.ConnectionString; - if (null == userConnectionOptions) + if (userConnectionOptions == null) { // we only allow one expansion on the connection string userConnectionOptions = connectionOptions; @@ -449,7 +449,7 @@ internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnectionPoolKey key, D } // We don't support connection pooling on Win9x; it lacks too many of the APIs we require. - if ((null == poolOptions) && ADP.s_isWindowsNT) + if (poolOptions == null && ADP.s_isWindowsNT) { if (null != connectionPoolGroup) { @@ -492,7 +492,7 @@ internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnectionPoolKey key, D Debug.Assert(null != connectionPoolGroup, "how did we not create a pool entry?"); Debug.Assert(null != userConnectionOptions, "how did we not have user connection options?"); } - else if (null == userConnectionOptions) + else if (userConnectionOptions == null) { userConnectionOptions = connectionPoolGroup.ConnectionOptions; } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs index ad218453b4..7fa6e88e27 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs @@ -92,7 +92,7 @@ protected internal Transaction EnlistedTransaction set { Transaction currentEnlistedTransaction = _enlistedTransaction; - if (((null == currentEnlistedTransaction) && (null != value)) + if ((currentEnlistedTransaction == null && (null != value)) || ((null != currentEnlistedTransaction) && !currentEnlistedTransaction.Equals(value))) { // WebData 20000024 @@ -404,10 +404,10 @@ internal void ActivateConnection(Transaction transaction) internal void AddWeakReference(object value, int tag) { - if (null == _referenceCollection) + if (_referenceCollection == null) { _referenceCollection = CreateReferenceCollection(); - if (null == _referenceCollection) + if (_referenceCollection == null) { throw ADP.InternalError(ADP.InternalErrorCode.CreateReferenceCollectionReturnedNull); } @@ -615,7 +615,7 @@ virtual internal void DelegatedTransactionEnded() DbConnectionPool pool = Pool; - if (null == pool) + if (pool == null) { throw ADP.InternalError(ADP.InternalErrorCode.PooledObjectWithoutPool); // pooled connection does not have a pool } @@ -768,7 +768,7 @@ protected bool TryOpenConnectionInternal(DbConnection outerConnection, DbConnect connectionFactory.SetInnerConnectionTo(outerConnection, this); throw; } - if (null == openConnection) + if (openConnection == null) { connectionFactory.SetInnerConnectionTo(outerConnection, this); throw ADP.InternalConnectionError(ADP.ConnectionError.GetConnectionReturnsNull); @@ -790,7 +790,7 @@ internal void PrePush(object expectedOwner) //3 // The following tests are retail assertions of things we can't allow to happen. bool isAlive = _owningObject.TryGetTarget(out DbConnection connection); - if (null == expectedOwner) + if (expectedOwner == null) { if (isAlive) { diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs index 62fb98df2a..71f8b3ff2f 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs @@ -850,7 +850,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio try { newObj = _connectionFactory.CreatePooledConnection(this, owningObject, _connectionPoolGroup.ConnectionOptions, _connectionPoolGroup.PoolKey, userOptions); - if (null == newObj) + if (newObj == null) { throw ADP.InternalError(ADP.InternalErrorCode.CreateObjectReturnedNull); // CreateObject succeeded, but null object } @@ -1347,7 +1347,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj obj = GetFromTransactedPool(out transaction); } - if (null == obj) + if (obj == null) { Interlocked.Increment(ref _waitCount); uint waitHandleCount = allowCreate ? 3u : 2u; @@ -1411,7 +1411,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj } catch { - if (null == obj) + if (obj == null) { Interlocked.Decrement(ref _waitCount); } @@ -1427,7 +1427,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj } } - if (null == obj) + if (obj == null) { // If we were not able to create an object, check to see if // we reached MaxPoolSize. If so, we will no longer wait on @@ -1541,7 +1541,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj DestroyObject(obj); obj = null; } - } while (null == obj); + } while (obj == null); } if (null != obj) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiContextFactory.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiContextFactory.cs index d231fe861a..820c9c1bd2 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiContextFactory.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiContextFactory.cs @@ -40,7 +40,7 @@ private SmiContextFactory() { Type smiLinkType = Type.GetType("Microsoft.SqlServer.Server.InProcLink, SqlAccess, PublicKeyToken=89845dcd8080cc91"); - if (null == smiLinkType) + if (smiLinkType == null) { Debug.Assert(false, "could not get InProcLink type"); throw SQL.ContextUnavailableOutOfProc(); // Must not be a valid version of Sql Server. @@ -95,7 +95,7 @@ internal ulong NegotiatedSmiVersion { get { - if (null == _smiLink) + if (_smiLink == null) { throw SQL.ContextUnavailableOutOfProc(); // Must not be a valid version of Sql Server, or not be SqlCLR } @@ -108,7 +108,7 @@ internal string ServerVersion { get { - if (null == _smiLink) + if (_smiLink == null) { throw SQL.ContextUnavailableOutOfProc(); // Must not be a valid version of Sql Server, or not be SqlCLR } @@ -119,7 +119,7 @@ internal string ServerVersion internal SmiContext GetCurrentContext() { - if (null == _smiLink) + if (_smiLink == null) { throw SQL.ContextUnavailableOutOfProc(); // Must not be a valid version of Sql Server, or not be SqlCLR } @@ -127,7 +127,7 @@ internal SmiContext GetCurrentContext() object result = _smiLink.GetCurrentContext(_eventSinkForGetCurrentContext); _eventSinkForGetCurrentContext.ProcessMessagesAndThrow(); - if (null == result) + if (result == null) { throw SQL.ContextUnavailableWhileInProc(); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs index bc654f39f7..b908356739 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs @@ -31,7 +31,7 @@ static SqlAuthenticationProviderManager() { // New configuration section "SqlClientAuthenticationProviders" for Microsoft.Data.SqlClient accepted to avoid conflicts with older one. configurationSection = FetchConfigurationSection(SqlClientAuthenticationProviderConfigurationSection.Name); - if (null == configurationSection) + if (configurationSection == null) { // If configuration section is not yet found, try with old Configuration Section name for backwards compatibility configurationSection = FetchConfigurationSection(SqlAuthenticationProviderConfigurationSection.Name); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs index 54b03683b7..1ba7f9a6a1 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs @@ -572,7 +572,10 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i } // Throw if there is a transaction but no flag is set - if (isInTransaction && null == _externalTransaction && null == _internalTransaction && (_connection.Parser != null && _connection.Parser.CurrentTransaction != null && _connection.Parser.CurrentTransaction.IsLocal)) + if (isInTransaction && + _externalTransaction == null && + _internalTransaction == null && + (_connection.Parser != null && _connection.Parser.CurrentTransaction != null && _connection.Parser.CurrentTransaction.IsLocal)) { throw SQL.BulkLoadExistingTransaction(); } @@ -1319,7 +1322,7 @@ private SourceColumnMetadata GetColumnMetadata(int ordinal) private void CreateOrValidateConnection(string method) { - if (null == _connection) + if (_connection == null) { throw ADP.ConnectionRequired(method); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientPermission.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientPermission.cs index 8c497f90d2..163319dd7d 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientPermission.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientPermission.cs @@ -55,7 +55,7 @@ internal SqlClientPermission(SqlConnectionString constr) : base(PermissionState. AllowBlankPassword = constr.HasBlankPassword; // MDAC 84563 AddPermissionEntry(new DBConnectionString(constr)); } - if ((null == constr) || constr.IsEmpty) + if (constr == null || constr.IsEmpty) { base.Add("", "", KeyRestrictionBehavior.AllowOnly); } @@ -81,11 +81,11 @@ override public IPermission Copy() internal void AddPermissionEntry(DBConnectionString entry) { - if (null == _keyvaluetree) + if (_keyvaluetree == null) { _keyvaluetree = new NameValuePermission(); } - if (null == _keyvalues) + if (_keyvalues == null) { _keyvalues = new ArrayList(); } @@ -129,7 +129,7 @@ private void CopyFrom(SqlClientPermission permission) /// override public IPermission Intersect(IPermission target) { // used during Deny actions - if (null == target) + if (target == null) { return null; } @@ -175,7 +175,7 @@ override public IPermission Intersect(IPermission target) private bool IsEmpty() { // MDAC 84804 ArrayList keyvalues = _keyvalues; - bool flag = (!IsUnrestricted() && !AllowBlankPassword && ((null == keyvalues) || (0 == keyvalues.Count))); + bool flag = !IsUnrestricted() && !AllowBlankPassword && (keyvalues == null || (0 == keyvalues.Count)); return flag; } @@ -198,7 +198,7 @@ override public bool IsSubsetOf(IPermission target) { if (!IsUnrestricted() && (!AllowBlankPassword || superset.AllowBlankPassword) && - ((null == _keyvalues) || (null != superset._keyvaluetree))) + (_keyvalues == null || (null != superset._keyvaluetree))) { subset = true; @@ -221,7 +221,7 @@ override public bool IsSubsetOf(IPermission target) /// override public IPermission Union(IPermission target) { - if (null == target) + if (target == null) { return this.Copy(); } @@ -285,7 +285,7 @@ private string EncodeXmlValue(string value) override public void FromXml(SecurityElement securityElement) { // code derived from CodeAccessPermission.ValidateElement - if (null == securityElement) + if (securityElement == null) { throw ADP.ArgumentNull("securityElement"); } @@ -375,8 +375,10 @@ override public SecurityElement ToXml() } tmp = value.Restrictions; tmp = EncodeXmlValue(tmp); - if (null == tmp) - { tmp = ""; } + if (tmp == null) + { + tmp = ""; + } valueElement.AddAttribute(XmlStr._KeyRestrictions, tmp); tmp = value.Behavior.ToString(); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientWrapperSmiStreamChars.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientWrapperSmiStreamChars.cs index d8fdcd1337..2cbba15d72 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientWrapperSmiStreamChars.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientWrapperSmiStreamChars.cs @@ -29,7 +29,7 @@ public override bool IsNull { get { - return null == _stream; + return _stream == null; } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.cs index ad84233197..9ea5374c9f 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.cs @@ -32,7 +32,7 @@ public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string e // Validate the input parameters ValidateNonEmptyKeyPath(masterKeyPath, isSystemOp: true); - if (null == encryptedColumnEncryptionKey) + if (encryptedColumnEncryptionKey == null) { throw SQL.NullEncryptedColumnEncryptionKey(); } @@ -126,7 +126,7 @@ public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string e // Validate the input parameters ValidateNonEmptyKeyPath(masterKeyPath, isSystemOp: false); - if (null == columnEncryptionKey) + if (columnEncryptionKey == null) { throw SQL.NullColumnEncryptionKey(); } @@ -231,7 +231,7 @@ public override bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool al private void ValidateEncryptionAlgorithm(string encryptionAlgorithm, bool isSystemOp) { // This validates that the encryption algorithm is RSA_OAEP - if (null == encryptionAlgorithm) + if (encryptionAlgorithm == null) { throw SQL.NullKeyEncryptionAlgorithm(isSystemOp); } @@ -251,7 +251,7 @@ private void ValidateNonEmptyKeyPath(string masterKeyPath, bool isSystemOp) { if (string.IsNullOrWhiteSpace(masterKeyPath)) { - if (null == masterKeyPath) + if (masterKeyPath == null) { throw SQL.NullCngKeyPath(isSystemOp); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.cs index 6296d4005d..9489f1b5f4 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.cs @@ -36,7 +36,7 @@ public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string e // Validate the input parameters ValidateNonEmptyCSPKeyPath(masterKeyPath, isSystemOp: true); - if (null == encryptedColumnEncryptionKey) + if (encryptedColumnEncryptionKey == null) { throw SQL.NullEncryptedColumnEncryptionKey(); } @@ -130,7 +130,7 @@ public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string e // Validate the input parameters ValidateNonEmptyCSPKeyPath(masterKeyPath, isSystemOp: false); - if (null == columnEncryptionKey) + if (columnEncryptionKey == null) { throw SQL.NullColumnEncryptionKey(); } @@ -235,7 +235,7 @@ public override bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool al private void ValidateEncryptionAlgorithm(string encryptionAlgorithm, bool isSystemOp) { // This validates that the encryption algorithm is RSA_OAEP - if (null == encryptionAlgorithm) + if (encryptionAlgorithm == null) { throw SQL.NullKeyEncryptionAlgorithm(isSystemOp); } @@ -256,7 +256,7 @@ private void ValidateNonEmptyCSPKeyPath(string masterKeyPath, bool isSystemOp) { if (string.IsNullOrWhiteSpace(masterKeyPath)) { - if (null == masterKeyPath) + if (masterKeyPath == null) { throw SQL.NullCspKeyPath(isSystemOp); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs index fb1b563e67..e2206ee955 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs @@ -411,7 +411,7 @@ private CommandEventSink EventSink { get { - if (null == _smiEventSink) + if (_smiEventSink == null) { _smiEventSink = new CommandEventSink(this); } @@ -425,7 +425,7 @@ private SmiEventSink_DeferedProcessing OutParamEventSink { get { - if (null == _outParamEventSink) + if (_outParamEventSink == null) { _outParamEventSink = new SmiEventSink_DeferedProcessing(EventSink); } @@ -711,7 +711,7 @@ internal SqlStatistics Statistics get { // if the transaction object has been zombied, just return null - if ((null != _transaction) && (null == _transaction.Connection)) + if ((null != _transaction) && _transaction.Connection == null) { _transaction = null; } @@ -895,7 +895,7 @@ public override bool DesignTimeVisible { get { - if (null == _parameters) + if (_parameters == null) { // delay the creation of the SqlParameterCollection // until user actually uses the Parameters property @@ -1230,12 +1230,12 @@ public override void Cancel() // if we have pending data, but it is not a result of this command, then we don't cancel either. Note that // this model is implementable because we only allow one active command at any one time. This code // will have to change we allow multiple outstanding batches - if (null == _activeConnection) + if (_activeConnection == null) { return; } SqlInternalConnectionTds connection = (_activeConnection.InnerConnection as SqlInternalConnectionTds); - if (null == connection) + if (connection == null) { // Fail with out locking return; } @@ -1252,7 +1252,7 @@ public override void Cancel() } TdsParser parser = connection.Parser; - if (null == parser) + if (parser == null) { return; } @@ -2004,7 +2004,7 @@ private object InternalEndExecuteNonQuery(IAsyncResult asyncResult, string endMe } } - Debug.Assert(null == _stateObj, "non-null state object in EndExecuteNonQuery"); + Debug.Assert(_stateObj == null, "non-null state object in EndExecuteNonQuery"); return _rowsAffected; } #if DEBUG @@ -2119,7 +2119,7 @@ private Task InternalExecuteNonQuery(TaskCompletionSource completion, st } } } - Debug.Assert(async || null == _stateObj, "non-null state object in InternalExecuteNonQuery"); + Debug.Assert(async || _stateObj == null, "non-null state object in InternalExecuteNonQuery"); return task; } #if DEBUG @@ -3016,7 +3016,7 @@ private SqlDataReader InternalEndExecuteReader(IAsyncResult asyncResult, string #endif //DEBUG bestEffortCleanupTarget = SqlInternalConnection.GetBestEffortCleanupTarget(_activeConnection); SqlDataReader reader = CompleteAsyncExecuteReader(isInternal); - Debug.Assert(null == _stateObj, "non-null state object in InternalEndExecuteReader"); + Debug.Assert(_stateObj == null, "non-null state object in InternalEndExecuteReader"); return reader; } #if DEBUG @@ -3553,7 +3553,7 @@ internal void DeriveParameters() // Use common parser for SqlClient and OleDb - parse into 4 parts - Server, Catalog, Schema, ProcedureName string[] parsedSProc = MultipartIdentifier.ParseMultipartIdentifier(CommandText, "[\"", "]\"", Strings.SQL_SqlCommandCommandText, false); - if (null == parsedSProc[3] || ADP.IsEmpty(parsedSProc[3])) + if (parsedSProc[3] == null || ADP.IsEmpty(parsedSProc[3])) { throw ADP.NoStoredProcedureExists(CommandText); } @@ -3877,7 +3877,7 @@ private void CheckNotificationStateAndAutoEnlist() { if (_sqlDep != null) { - if (null == _sqlDep.Options) + if (_sqlDep.Options == null) { // If null, SqlDependency was not created with options, so we need to obtain default options now. // GetDefaultOptions can and will throw under certain conditions. @@ -4265,10 +4265,10 @@ private void PrepareForTransparentEncryption(CommandBehavior cmdBehavior, bool r // If we didn't have parameters, we can fall back to regular code path, by simply returning. if (!describeParameterEncryptionNeeded) { - Debug.Assert(null == fetchInputParameterEncryptionInfoTask, + Debug.Assert(fetchInputParameterEncryptionInfoTask == null, "fetchInputParameterEncryptionInfoTask should not be set if describe parameter encryption is not needed."); - Debug.Assert(null == describeParameterEncryptionDataReader, + Debug.Assert(describeParameterEncryptionDataReader == null, "SqlDataReader created for describe parameter encryption params when it is not needed."); return; @@ -4315,7 +4315,7 @@ private void PrepareForTransparentEncryption(CommandBehavior cmdBehavior, bool r // Complete executereader. describeParameterEncryptionDataReader = CompleteAsyncExecuteReader(forDescribeParameterEncryption: true); - Debug.Assert(null == _stateObj, "non-null state object in PrepareForTransparentEncryption."); + Debug.Assert(_stateObj == null, "non-null state object in PrepareForTransparentEncryption."); // Read the results of describe parameter encryption. ReadDescribeEncryptionParameterResults( @@ -4403,7 +4403,7 @@ private void PrepareForTransparentEncryption(CommandBehavior cmdBehavior, bool r // Complete executereader. describeParameterEncryptionDataReader = CompleteAsyncExecuteReader(forDescribeParameterEncryption: true); - Debug.Assert(null == _stateObj, "non-null state object in PrepareForTransparentEncryption."); + Debug.Assert(_stateObj == null, "non-null state object in PrepareForTransparentEncryption."); // Read the results of describe parameter encryption. ReadDescribeEncryptionParameterResults(describeParameterEncryptionDataReader, describeParameterEncryptionRpcOriginalRpcMap, inRetry); @@ -5679,7 +5679,7 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi } } - Debug.Assert(async || null == _stateObj, "non-null state object in RunExecuteReader"); + Debug.Assert(async || _stateObj == null, "non-null state object in RunExecuteReader"); return ds; } @@ -5942,7 +5942,7 @@ private Task RegisterForConnectionCloseNotification(Task outterTask) // throws exception for error case, returns false if the commandText is empty private void ValidateCommand(string method, bool async) { - if (null == _activeConnection) + if (_activeConnection == null) { throw ADP.ConnectionRequired(method); } @@ -6035,7 +6035,7 @@ private void ValidateCommand(string method, bool async) // throw if the connection is in a transaction but there is no // locally assigned transaction object - if (_activeConnection.HasLocalTransactionFromAPI && (null == _transaction)) + if (_activeConnection.HasLocalTransactionFromAPI && _transaction == null) { throw ADP.TransactionRequired(method); } @@ -6085,7 +6085,7 @@ private void ValidateAsyncCommand() private void GetStateObject(TdsParser parser = null) { - Debug.Assert(null == _stateObj, "StateObject not null on GetStateObject"); + Debug.Assert(_stateObj == null, "StateObject not null on GetStateObject"); Debug.Assert(null != _activeConnection, "no active connection?"); if (_pendingCancel) @@ -6533,7 +6533,7 @@ private SqlParameter GetParameterForOutputValueExtraction(SqlParameterCollection SqlParameter thisParam = null; bool foundParam = false; - if (null == paramName) + if (paramName == null) { // rec.parameter should only be null for a return value from a function for (int i = 0; i < paramCount; i++) @@ -6679,7 +6679,7 @@ private void SetUpRPCParameters(_SqlRPC rpc, bool inSchema, SqlParameterCollecti // MDAC 62117, don't assume a default value exists for parameters in the case when // the user is simply requesting schema // SQLBUVSTS 179488 TVPs use DEFAULT and do not allow NULL, even for schema only. - if (null == parameter.Value && (!inSchema || SqlDbType.Structured == parameter.SqlDbType)) + if (parameter.Value == null && (!inSchema || SqlDbType.Structured == parameter.SqlDbType)) { options |= TdsEnums.RPC_PARAM_DEFAULT; } @@ -7146,7 +7146,7 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete if ((null != val) && (DBNull.Value != val)) { s = (val as string); - if (null == s) + if (s == null) { SqlString sval = val is SqlString ? (SqlString)val : SqlString.Null; if (!sval.IsNull) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs index 7492f76dea..f9bfc41275 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -499,7 +499,7 @@ public bool StatisticsEnabled // start if (ConnectionState.Open == State) { - if (null == _statistics) + if (_statistics == null) { _statistics = new SqlStatistics(); _statistics._openTimestamp = ADP.TimerCurrent(); @@ -1124,7 +1124,7 @@ public string WorkstationId // rebooting. Therefore, don't cache this machine name. SqlConnectionString constr = (SqlConnectionString)ConnectionOptions; string result = ((null != constr) ? constr.WorkstationId : null); - if (null == result) + if (result == null) { // getting machine name requires Environment.Permission // user must have that permission in order to retrieve this @@ -1719,7 +1719,7 @@ public void Open(SqlConnectionOverrides overrides) if (StatisticsEnabled) { - if (null == _statistics) + if (_statistics == null) { _statistics = new SqlStatistics(); } @@ -1988,7 +1988,7 @@ private Task InternalOpenAsync(CancellationToken cancellationToken) { if (StatisticsEnabled) { - if (null == _statistics) + if (_statistics == null) { _statistics = new SqlStatistics(); } @@ -2351,7 +2351,7 @@ internal TdsParser Parser get { SqlInternalConnectionTds tdsConnection = (GetOpenConnection() as SqlInternalConnectionTds); - if (null == tdsConnection) + if (tdsConnection == null) { throw SQL.NotAvailableOnContextConnection(); } @@ -2496,7 +2496,7 @@ private void CompleteOpen() internal SqlInternalConnection GetOpenConnection() { SqlInternalConnection innerConnection = (InnerConnection as SqlInternalConnection); - if (null == innerConnection) + if (innerConnection == null) { throw ADP.ClosedConnectionError(); } @@ -2507,7 +2507,7 @@ internal SqlInternalConnection GetOpenConnection(string method) { DbConnectionInternal innerConnection = InnerConnection; SqlInternalConnection innerSqlConnection = (innerConnection as SqlInternalConnection); - if (null == innerSqlConnection) + if (innerSqlConnection == null) { throw ADP.OpenConnectionRequired(method, innerConnection.State); } @@ -2517,7 +2517,7 @@ internal SqlInternalConnection GetOpenConnection(string method) internal SqlInternalConnectionTds GetOpenTdsConnection() { SqlInternalConnectionTds innerConnection = (InnerConnection as SqlInternalConnectionTds); - if (null == innerConnection) + if (innerConnection == null) { throw ADP.ClosedConnectionError(); } @@ -2527,7 +2527,7 @@ internal SqlInternalConnectionTds GetOpenTdsConnection() internal SqlInternalConnectionTds GetOpenTdsConnection(string method) { SqlInternalConnectionTds innerConnection = (InnerConnection as SqlInternalConnectionTds); - if (null == innerConnection) + if (innerConnection == null) { throw ADP.OpenConnectionRequired(method, InnerConnection.State); } @@ -3278,12 +3278,16 @@ bool ISQLDebug.SQLDebug(int dwpidDebugger, int dwpidDebuggee, [MarshalAs(Unmanag IntPtr pDacl = IntPtr.Zero; // validate the structure - if (null == pszMachineName || null == pszSDIDLLName) + if (pszMachineName == null || pszSDIDLLName == null) + { return false; + } if (pszMachineName.Length > TdsEnums.SDCI_MAX_MACHINENAME || - pszSDIDLLName.Length > TdsEnums.SDCI_MAX_DLLNAME) + pszSDIDLLName.Length > TdsEnums.SDCI_MAX_DLLNAME) + { return false; + } // note that these are ansi strings Encoding cp = System.Text.Encoding.GetEncoding(TdsEnums.DEFAULT_ENGLISH_CODE_PAGE_VALUE); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs index aca7bfc151..f0c8f403b2 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs @@ -92,8 +92,7 @@ override protected DbConnectionInternal CreateConnection(DbConnectionOptions opt redirectedUserInstance = true; string instanceName; - if ((null == pool) || - (null != pool && pool.Count <= 0)) + if (pool == null || (null != pool && pool.Count <= 0)) { // Non-pooled or pooled and no connections in the pool. SqlInternalConnectionTds sseConnection = null; @@ -229,7 +228,7 @@ override internal DbConnectionPoolGroupProviderInfo CreateConnectionPoolGroupPro internal static SqlConnectionString FindSqlConnectionOptions(SqlConnectionPoolKey key) { SqlConnectionString connectionOptions = (SqlConnectionString)SingletonInstance.FindConnectionOptions(key); - if (null == connectionOptions) + if (connectionOptions == null) { connectionOptions = new SqlConnectionString(key.ConnectionString); } @@ -247,7 +246,7 @@ private SqlInternalConnectionSmi GetContextConnection(SqlConnectionString option SqlInternalConnectionSmi result = (SqlInternalConnectionSmi)smiContext.GetContextValue((int)SmiContextFactory.ContextKey.Connection); // context connections are automatically re-useable if they exist unless they've been doomed. - if (null == result || result.IsConnectionDoomed) + if (result == null || result.IsConnectionDoomed) { if (null != result) { diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs index dcbd0738cb..72f4a27b6a 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs @@ -343,7 +343,7 @@ internal void PermissionDemand() Microsoft.Data.ProviderBase.DbConnectionPoolGroup poolGroup = PoolGroup; DbConnectionOptions connectionOptions = ((null != poolGroup) ? poolGroup.ConnectionOptions : null); - if ((null == connectionOptions) || connectionOptions.IsEmpty) + if (connectionOptions == null || connectionOptions.IsEmpty) { throw ADP.NoConnectionString(); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs index 18eb99bd04..2c5a144bd7 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs @@ -485,8 +485,7 @@ override public object this[string name] internal void Bind(TdsParserStateObject stateObj) { Debug.Assert(null != stateObj, "null stateobject"); - - Debug.Assert(null == _snapshot, "Should not change during execution of asynchronous command"); + Debug.Assert(_snapshot == null, "Should not change during execution of asynchronous command"); stateObj.Owner = this; _stateObj = stateObj; @@ -1641,7 +1640,7 @@ override public int GetOrdinal(string name) try { statistics = SqlStatistics.StartTimer(Statistics); - if (null == _fieldNameLookup) + if (_fieldNameLookup == null) { CheckMetaDataIsReady(); _fieldNameLookup = new FieldNameLookup(this, _defaultLCID); @@ -1675,7 +1674,7 @@ override public DataTable GetSchemaTable() try { statistics = SqlStatistics.StartTimer(Statistics); - if (null == _metaData || null == _metaData._schemaTable) + if (_metaData == null || _metaData._schemaTable == null) { if (null != this.MetaData) { @@ -1904,7 +1903,7 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf } // if no buffer is passed in, return the number total of bytes, or -1 - if (null == buffer) + if (buffer == null) { if (_metaData[i].metaType.IsPlp) { @@ -2015,7 +2014,7 @@ private TdsOperationStatus TryGetBytesInternal(int i, long dataIndex, byte[] buf cbytes = data.Length; // if no buffer is passed in, return the number of characters we have - if (null == buffer) + if (buffer == null) { remaining = cbytes; return TdsOperationStatus.Done; @@ -2438,12 +2437,16 @@ override public long GetChars(int i, long dataIndex, char[] buffer, int bufferIn int ndataIndex = (int)dataIndex; // if no buffer is passed in, return the number of characters we have - if (null == buffer) + if (buffer == null) + { return cchars; + } // if dataIndex outside of data range, return 0 if (ndataIndex < 0 || ndataIndex >= cchars) + { return 0; + } try { @@ -2558,7 +2561,7 @@ private long GetCharsFromPlpData(int i, long dataIndex, char[] buffer, int buffe // if no buffer is passed in, return the total number of characters or -1 // TODO: for DBCS encoding it returns number of bytes, not number of chars - if (null == buffer) + if (buffer == null) { cch = (long)_parser.PlpBytesTotalLength(_stateObj); return (isUnicode && (cch > 0)) ? cch >> 1 : cch; @@ -2985,7 +2988,7 @@ virtual public int GetSqlValues(object[] values) { statistics = SqlStatistics.StartTimer(Statistics); CheckDataIsReady(); - if (null == values) + if (values == null) { throw ADP.ArgumentNull("values"); } @@ -3391,7 +3394,7 @@ override public int GetValues(object[] values) { statistics = SqlStatistics.StartTimer(Statistics); - if (null == values) + if (values == null) { throw ADP.ArgumentNull("values"); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs index ffe44e328c..3503b38632 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs @@ -115,7 +115,7 @@ public void Initialize() connection.ExecuteTransaction(SqlInternalConnection.TransactionRequest.Begin, null, _isolationLevel, _internalTransaction, true); // Handle case where ExecuteTran didn't produce a new transaction, but also didn't throw. - if (null == connection.CurrentTransaction) + if (connection.CurrentTransaction == null) { connection.DoomThisConnection(); throw ADP.InternalError(ADP.InternalErrorCode.UnknownTransactionFailure); @@ -546,7 +546,7 @@ internal void TransactionEnded(Transaction transaction) private SqlInternalConnection GetValidConnection() { SqlInternalConnection connection = _connection; - if (null == connection && _atomicTransaction.TransactionInformation.Status != TransactionStatus.Aborted) + if (connection == null && _atomicTransaction.TransactionInformation.Status != TransactionStatus.Aborted) { throw ADP.ObjectDisposed(this); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs index 88b9aa2430..77f83a2546 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs @@ -237,7 +237,7 @@ private Transaction InternalEnlistedTransaction // This works for now only because we can't unenlist from the context transaction Transaction tx = EnlistedTransaction; - if (null == tx) + if (tx == null) { tx = ContextTransaction; } @@ -282,7 +282,7 @@ internal void AutomaticEnlistment() _currentTransaction = new SqlInternalTransaction(this, TransactionType.Context, null, contextTransactionId); ContextTransaction = contextTransaction; } - else if (null == currentSystemTransaction) + else if (currentSystemTransaction == null) { _currentTransaction = null; // there really isn't a transaction. SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, no transaction.", ObjectID); @@ -535,7 +535,7 @@ private void TransactionStarted(long transactionId, bool isDistributed) // the current transaction, then we store the token in it. // if there isn't a pending transaction, then it's either // a TSQL transaction or a distributed transaction. - Debug.Assert(null == _currentTransaction, "non-null current transaction with an env change"); + Debug.Assert(_currentTransaction == null, "non-null current transaction with an env change"); _currentTransaction = _pendingTransaction; _pendingTransaction = null; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs index cc80af6767..7b7bc80962 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs @@ -738,7 +738,7 @@ override protected internal bool IsNonPoolableTransactionRoot { get { - return IsTransactionRoot && (!Is2008OrNewer || null == Pool); + return IsTransactionRoot && (!Is2008OrNewer || Pool == null); } } @@ -803,7 +803,7 @@ override protected bool ReadyToPrepareTransaction get { // TODO: probably need to use a different method, but that's a different bug - bool result = (null == FindLiveReader(null)); // can't prepare with a live data reader... + bool result = FindLiveReader(null) == null; // can't prepare with a live data reader... return result; } } @@ -1173,7 +1173,7 @@ override internal void ExecuteTransaction(TransactionRequest transactionRequest, } } - string transactionName = (null == name) ? String.Empty : name; + string transactionName = name == null ? String.Empty : name; if (!_parser.Is2005OrNewer) { @@ -1914,7 +1914,7 @@ private void LoginNoFailover(ServerInfo serverInfo, string newPassword, SecureSt continue; } - if (null == _parser + if (_parser == null || TdsParserState.Closed != _parser.State || IsDoNotRetryConnectError(sqlex) || timeout.IsExpired) @@ -2060,7 +2060,7 @@ TimeoutTimer timeout ServerInfo failoverServerInfo = new ServerInfo(connectionOptions, failoverHost, connectionOptions.FailoverPartnerSPN); ResolveExtendedServerName(primaryServerInfo, !redirectedUserInstance, connectionOptions); - if (null == ServerProvidedFailOverPartner) + if (ServerProvidedFailOverPartner == null) {// No point in resolving the failover partner when we're going to override it below // Don't resolve aliases if failover == primary // UNDONE: WHY? Previous code in TdsParser.Connect did this, but the reason is not clear ResolveExtendedServerName(failoverServerInfo, !redirectedUserInstance && failoverHost != primaryServerInfo.UserServerName, connectionOptions); @@ -2233,7 +2233,7 @@ TimeoutTimer timeout _activeDirectoryAuthTimeoutRetryHelper.State = ActiveDirectoryAuthenticationTimeoutRetryState.HasLoggedIn; // if connected to failover host, but said host doesn't have DbMirroring set up, throw an error - if (useFailoverHost && null == ServerProvidedFailOverPartner) + if (useFailoverHost && ServerProvidedFailOverPartner == null) { throw SQL.InvalidPartnerConfiguration(failoverHost, CurrentDatabase); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs index c6b338d2a0..326a125a15 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -347,16 +347,16 @@ internal SqlInternalTransaction CurrentTransaction set { Debug.Assert(value == _currentTransaction - || null == _currentTransaction - || null == value + || _currentTransaction == null + || value == null || (null != _currentTransaction && !_currentTransaction.IsLocal), "attempting to change current transaction?"); // If there is currently a transaction active, we don't want to // change it; this can occur when there is a delegated transaction // and the user attempts to do an API begin transaction; in these // cases, it's safe to ignore the set. - if ((null == _currentTransaction && null != value) - || (null != _currentTransaction && null == value)) + if ((_currentTransaction == null && null != value) || + (null != _currentTransaction && value == null)) { _currentTransaction = value; } @@ -1621,7 +1621,7 @@ internal void Deactivate(bool connectionIsDoomed) _sessionPool.Deactivate(); } - Debug.Assert(connectionIsDoomed || null == _pendingTransaction, "pending transaction at disconnect?"); + Debug.Assert(connectionIsDoomed || _pendingTransaction == null, "pending transaction at disconnect?"); if (!connectionIsDoomed && null != _physicalStateObj) { @@ -1649,7 +1649,7 @@ internal void Deactivate(bool connectionIsDoomed) if (null != currentTransaction && currentTransaction.HasParentTransaction) { currentTransaction.CloseFromConnection(); - Debug.Assert(null == CurrentTransaction, "rollback didn't clear current transaction?"); + Debug.Assert(CurrentTransaction == null, "rollback didn't clear current transaction?"); } Statistics = null; // must come after CleanWire or we won't count the stuff that happens there... @@ -1749,7 +1749,7 @@ internal void RollbackOrphanedAPITransactions() if (null != currentTransaction && currentTransaction.HasParentTransaction && currentTransaction.IsOrphaned) { currentTransaction.CloseFromConnection(); - Debug.Assert(null == CurrentTransaction, "rollback didn't clear current transaction?"); + Debug.Assert(CurrentTransaction == null, "rollback didn't clear current transaction?"); } } @@ -2087,7 +2087,7 @@ internal void CheckResetConnection(TdsParserStateObject stateObj) // internal byte[] SerializeShort(int v, TdsParserStateObject stateObj) { - if (null == stateObj._bShortBytes) + if (stateObj._bShortBytes == null) { stateObj._bShortBytes = new byte[2]; } @@ -2145,7 +2145,7 @@ internal void WriteUnsignedInt(uint i, TdsParserStateObject stateObj) // internal byte[] SerializeInt(int v, TdsParserStateObject stateObj) { - if (null == stateObj._bIntBytes) + if (stateObj._bIntBytes == null) { stateObj._bIntBytes = new byte[4]; } @@ -2213,7 +2213,7 @@ internal void WriteFloat(float v, TdsParserStateObject stateObj) internal byte[] SerializeLong(long v, TdsParserStateObject stateObj) { int current = 0; - if (null == stateObj._bLongBytes) + if (stateObj._bLongBytes == null) { stateObj._bLongBytes = new byte[8]; } @@ -2702,7 +2702,7 @@ internal TdsOperationStatus TryRun(RunBehavior runBehavior, SqlCommand cmdHandle // the current transaction, then we store the token in it. // if there isn't a pending transaction, then it's either // a TSQL transaction or a distributed transaction. - Debug.Assert(null == _currentTransaction, "non-null current transaction with an ENV Change"); + Debug.Assert(_currentTransaction == null, "non-null current transaction with an ENV Change"); _currentTransaction = _pendingTransaction; _pendingTransaction = null; @@ -7065,12 +7065,12 @@ internal bool DeserializeUnencryptedValue(SqlBuffer value, byte[] unencryptedByt { System.Text.Encoding encoding = md.baseTI.encoding; - if (null == encoding) + if (encoding == null) { encoding = _defaultEncoding; } - if (null == encoding) + if (encoding == null) { ThrowUnsupportedCollationEncountered(stateObj); } @@ -7971,7 +7971,7 @@ internal Task WriteSqlVariantDataRowValue(object value, TdsParserStateObject sta Debug.Assert(_is2000 == true, "Shouldn't be dealing with sql_variant in pre-SQL2000 server!"); // handle null values - if ((null == value) || (DBNull.Value == value)) + if (value == null || (DBNull.Value == value)) { WriteInt(TdsEnums.FIXEDNULL, stateObj); return null; @@ -8206,7 +8206,7 @@ private byte[] SerializeCurrency(Decimal value, int length, TdsParserStateObject } Debug.Assert(8 == length, "invalid length in SerializeCurrency"); - if (null == stateObj._bLongBytes) + if (stateObj._bLongBytes == null) { stateObj._bLongBytes = new byte[8]; } @@ -8381,8 +8381,10 @@ private TdsOperationStatus TryReadDecimalBits(int length, TdsParserStateObject s bits = stateObj._decimalBits; // used alloc'd array if we have one already int i; - if (null == bits) + if (bits == null) + { bits = new int[4]; + } else { for (i = 0; i < bits.Length; i++) @@ -8437,7 +8439,7 @@ static internal decimal AdjustDecimalScale(decimal value, int newScale) internal byte[] SerializeSqlDecimal(SqlDecimal d, TdsParserStateObject stateObj) { - if (null == stateObj._bDecimalBytes) + if (stateObj._bDecimalBytes == null) { stateObj._bDecimalBytes = new byte[17]; } @@ -8487,7 +8489,7 @@ internal void WriteSqlDecimal(SqlDecimal d, TdsParserStateObject stateObj) private byte[] SerializeDecimal(decimal value, TdsParserStateObject stateObj) { int[] decimalBits = Decimal.GetBits(value); - if (null == stateObj._bDecimalBytes) + if (stateObj._bDecimalBytes == null) { stateObj._bDecimalBytes = new byte[17]; } @@ -8747,7 +8749,7 @@ internal int GetEncodingCharLength(string value, int numChars, int charOffset, E // 7.0 has no support for multiple code pages in data - single code page support only if (encoding == null) { - if (null == _defaultEncoding) + if (_defaultEncoding == null) { ThrowUnsupportedCollationEncountered(null); } @@ -9428,8 +9430,10 @@ private void WriteLoginData(SqlLogin rec, // UNDONE: NIC address // previously we declared the array and simply sent it over - byte[] of 0's - if (null == s_nicAddress) + if (s_nicAddress == null) + { s_nicAddress = TdsParserStaticMethods.GetNetworkPhysicalAddressForTdsLoginOnly(); + } _physicalStateObj.WriteByteArray(s_nicAddress, s_nicAddress.Length, 0); @@ -11701,7 +11705,7 @@ internal object EncryptColumnValue(object value, SqlMetaDataPriv metadata, strin case TdsEnums.SQLBIGCHAR: case TdsEnums.SQLBIGVARCHAR: case TdsEnums.SQLTEXT: - if (null == _defaultEncoding) + if (_defaultEncoding == null) { ThrowUnsupportedCollationEncountered(null); // stateObject only when reading } @@ -11839,7 +11843,7 @@ internal Task WriteBulkCopyValue(object value, SqlMetaDataPriv metadata, TdsPars case TdsEnums.SQLBIGCHAR: case TdsEnums.SQLBIGVARCHAR: case TdsEnums.SQLTEXT: - if (null == _defaultEncoding) + if (_defaultEncoding == null) { ThrowUnsupportedCollationEncountered(null); // stateObject only when reading } @@ -12007,7 +12011,7 @@ private int GetNotificationHeaderSize(SqlNotificationRequest notificationRequest string service = notificationRequest.Options; int timeout = notificationRequest.Timeout; - if (null == callbackId) + if (callbackId == null) { throw ADP.ArgumentNull("CallbackId"); } @@ -12016,7 +12020,7 @@ private int GetNotificationHeaderSize(SqlNotificationRequest notificationRequest throw ADP.ArgumentOutOfRange("CallbackId"); } - if (null == service) + if (service == null) { throw ADP.ArgumentNull("Service"); } @@ -13366,9 +13370,11 @@ private byte[] SerializeUnencryptedValue(object value, MetaType type, byte scale if (type.FixedLength == 4) { if (0 > dt.days || dt.days > UInt16.MaxValue) + { throw SQL.SmallDateTimeOverflow(MetaType.ToDateTime(dt.days, dt.time, 4).ToString(CultureInfo.InvariantCulture)); + } - if (null == stateObj._bIntBytes) + if (stateObj._bIntBytes == null) { stateObj._bIntBytes = new byte[4]; } @@ -13387,7 +13393,7 @@ private byte[] SerializeUnencryptedValue(object value, MetaType type, byte scale } else { - if (null == stateObj._bLongBytes) + if (stateObj._bLongBytes == null) { stateObj._bLongBytes = new byte[8]; } @@ -13562,7 +13568,7 @@ private byte[] SerializeUnencryptedSqlValue(object value, MetaType type, int act if (0 > dt.DayTicks || dt.DayTicks > UInt16.MaxValue) throw SQL.SmallDateTimeOverflow(dt.ToString()); - if (null == stateObj._bIntBytes) + if (stateObj._bIntBytes == null) { stateObj._bIntBytes = new byte[4]; } @@ -13581,7 +13587,7 @@ private byte[] SerializeUnencryptedSqlValue(object value, MetaType type, int act } else { - if (null == stateObj._bLongBytes) + if (stateObj._bLongBytes == null) { stateObj._bLongBytes = new byte[8]; } @@ -13874,12 +13880,11 @@ internal int ReadPlpAnsiChars(ref char[] buff, int offst, int len, SqlMetaDataPr { Encoding enc = metadata.encoding; - if (enc == null) + if (null == enc) { - if (null == _defaultEncoding) + if (_defaultEncoding == null) { ThrowUnsupportedCollationEncountered(stateObj); - } enc = _defaultEncoding; @@ -14043,36 +14048,36 @@ internal string TraceString() { return string.Format(/*IFormatProvider*/ null, StateTraceFormatString, - null == _physicalStateObj ? "(null)" : _physicalStateObj.ObjectID.ToString((IFormatProvider)null), - null == _pMarsPhysicalConObj ? "(null)" : _pMarsPhysicalConObj.ObjectID.ToString((IFormatProvider)null), + _physicalStateObj == null ? "(null)" : _physicalStateObj.ObjectID.ToString((IFormatProvider)null), + _pMarsPhysicalConObj == null ? "(null)" : _pMarsPhysicalConObj.ObjectID.ToString((IFormatProvider)null), _state, _server, _fResetConnection ? bool.TrueString : bool.FalseString, - null == _defaultCollation ? "(null)" : _defaultCollation.TraceString(), + _defaultCollation == null ? "(null)" : _defaultCollation.TraceString(), _defaultCodePage, _defaultLCID, TraceObjectClass(_defaultEncoding), _encryptionOption, - null == _currentTransaction ? "(null)" : _currentTransaction.TraceString(), - null == _pendingTransaction ? "(null)" : _pendingTransaction.TraceString(), + _currentTransaction == null ? "(null)" : _currentTransaction.TraceString(), + _pendingTransaction == null ? "(null)" : _pendingTransaction.TraceString(), _retainedTransactionId, _nonTransactedOpenResultCount, - null == _connHandler ? "(null)" : _connHandler.ObjectID.ToString((IFormatProvider)null), + _connHandler == null ? "(null)" : _connHandler.ObjectID.ToString((IFormatProvider)null), _fMARS ? bool.TrueString : bool.FalseString, - null == _sessionPool ? "(null)" : _sessionPool.TraceString(), + _sessionPool == null ? "(null)" : _sessionPool.TraceString(), _is2000 ? bool.TrueString : bool.FalseString, _is2000SP1 ? bool.TrueString : bool.FalseString, _is2005 ? bool.TrueString : bool.FalseString, - null == _sniSpnBuffer ? "(null)" : _sniSpnBuffer.Length.ToString((IFormatProvider)null), + _sniSpnBuffer == null ? "(null)" : _sniSpnBuffer.Length.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.ErrorCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.WarningCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionErrorCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionWarningCount.ToString((IFormatProvider)null), - null == _statistics ? bool.TrueString : bool.FalseString, + _statistics == null ? bool.TrueString : bool.FalseString, _statisticsIsInTransaction ? bool.TrueString : bool.FalseString, _fPreserveTransaction ? bool.TrueString : bool.FalseString, - null == _connHandler ? "(null)" : _connHandler.ConnectionOptions.MultiSubnetFailover.ToString((IFormatProvider)null), - null == _connHandler ? "(null)" : _connHandler.ConnectionOptions.TransparentNetworkIPResolution.ToString((IFormatProvider)null)); + _connHandler == null ? "(null)" : _connHandler.ConnectionOptions.MultiSubnetFailover.ToString((IFormatProvider)null), + _connHandler == null ? "(null)" : _connHandler.ConnectionOptions.TransparentNetworkIPResolution.ToString((IFormatProvider)null)); } private string TraceObjectClass(object instance) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs index 079787506a..8509e51f60 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserHelperClasses.cs @@ -579,7 +579,7 @@ internal _SqlMetaData this[int index] } set { - Debug.Assert(null == value, "used only by SqlBulkCopy"); + Debug.Assert(value == null, "used only by SqlBulkCopy"); _metaDataArray[index] = value; } } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbConnectionStringCommon.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbConnectionStringCommon.cs index 95a54538f9..8bad83989f 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbConnectionStringCommon.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbConnectionStringCommon.cs @@ -570,7 +570,7 @@ internal static string AuthenticationTypeToString(SqlAuthenticationMethod value) internal static SqlAuthenticationMethod ConvertToAuthenticationType(string keyword, object value) { - if (null == value) + if (value == null) { return DbConnectionStringDefaults.Authentication; } @@ -644,7 +644,7 @@ internal static SqlAuthenticationMethod ConvertToAuthenticationType(string keywo /// internal static SqlConnectionColumnEncryptionSetting ConvertToColumnEncryptionSetting(string keyword, object value) { - if (null == value) + if (value == null) { return DbConnectionStringDefaults.ColumnEncryptionSetting; } @@ -765,7 +765,7 @@ internal static string AttestationProtocolToString(SqlConnectionAttestationProto internal static SqlConnectionAttestationProtocol ConvertToAttestationProtocol(string keyword, object value) { - if (null == value) + if (value == null) { return DbConnectionStringDefaults.AttestationProtocol; } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/MultipartIdentifier.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/MultipartIdentifier.cs index a30b462092..b89a080e99 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/MultipartIdentifier.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/MultipartIdentifier.cs @@ -145,7 +145,7 @@ internal static string[] ParseMultipartIdentifier(string name, string leftQuote, if (IsWhitespace(testchar)) { // If it is Whitespace parsedNames[stringCount] = sb.ToString(); // Set the currently parsed string - if (null == whitespaceSB) + if (whitespaceSB == null) { whitespaceSB = new StringBuilder(); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/NameValuePair.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/NameValuePair.cs index f0cfc71d53..a9d1cc4e6b 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/NameValuePair.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/NameValuePair.cs @@ -42,7 +42,7 @@ internal NameValuePair Next get => _next; set { - if ((null != _next) || (null == value)) + if ((null != _next) || value == null) { throw ADP.InternalError(ADP.InternalErrorCode.NameValuePairNext); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs index 7568340594..cd7b3e691d 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs @@ -53,7 +53,7 @@ internal DbConnectionPoolGroup(DbConnectionOptions connectionOptions, DbConnecti { Debug.Assert(null != connectionOptions, "null connection options"); #if NETFRAMEWORK - Debug.Assert(null == poolGroupOptions || ADP.s_isWindowsNT, "should not have pooling options on Win9x"); + Debug.Assert(poolGroupOptions == null || ADP.s_isWindowsNT, "should not have pooling options on Win9x"); #endif _connectionOptions = connectionOptions; @@ -224,7 +224,7 @@ internal DbConnectionPool GetConnectionPool(DbConnectionFactory connectionFactor } } - if (null == pool) + if (pool == null) { lock (this) { diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbMetaDataFactory.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbMetaDataFactory.cs index c3c34c702b..12b572bb47 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbMetaDataFactory.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbMetaDataFactory.cs @@ -237,7 +237,7 @@ internal DataRow FindMetaDataCollectionRow(string collectionName) DataColumn collectionNameColumn = metaDataCollectionsTable.Columns[DbMetaDataColumnNames.CollectionName]; - if ((null == collectionNameColumn) || (typeof(string) != collectionNameColumn.DataType)) + if (collectionNameColumn == null || (typeof(string) != collectionNameColumn.DataType)) { throw ADP.InvalidXmlMissingColumn(DbMetaDataCollectionNames.MetaDataCollections, DbMetaDataColumnNames.CollectionName); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs index 726410f741..6162debf92 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs @@ -218,7 +218,7 @@ public override async Task AcquireTokenAsync(SqlAuthenti { result = await TryAcquireTokenSilent(app, parameters, scopes, cts).ConfigureAwait(false); - if (null == result) + if (result == null) { if (!string.IsNullOrEmpty(parameters.UserId)) { @@ -252,7 +252,7 @@ previousPw is byte[] previousPwBytes && result = await TryAcquireTokenSilent(app, parameters, scopes, cts).ConfigureAwait(false); } - if (null == result) + if (result == null) { result = await app.AcquireTokenByUsernamePassword(scopes, parameters.UserId, parameters.Password) .WithCorrelationId(parameters.ConnectionId) @@ -288,7 +288,7 @@ previousPw is byte[] previousPwBytes && SqlClientEventSource.Log.TryTraceEvent("AcquireTokenAsync | Acquired access token (interactive) for {0} auth mode. Expiry Time: {1}", parameters.AuthenticationMethod, result?.ExpiresOn); } - if (null == result) + if (result == null) { // If no existing 'account' is found, we request user to sign in interactively. result = await AcquireTokenInteractiveDeviceFlowAsync(app, scopes, parameters.ConnectionId, parameters.UserId, parameters.AuthenticationMethod, cts, _customWebUI, _deviceCodeFlowCallback).ConfigureAwait(false); diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ColumnEncryptionKeyInfo.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ColumnEncryptionKeyInfo.cs index 1b1dbceba0..a56dc2ac47 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ColumnEncryptionKeyInfo.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ColumnEncryptionKeyInfo.cs @@ -35,14 +35,22 @@ internal class ColumnEncryptionKeyInfo internal ColumnEncryptionKeyInfo(byte[] decryptedKey, int databaseId, byte[] keyMetadataVersion, int keyid) { - if (null == decryptedKey) + if (decryptedKey == null) + { throw SQL.NullArgumentInConstructorInternal(_decryptedKeyName, _className); + } if (0 == decryptedKey.Length) + { throw SQL.EmptyArgumentInConstructorInternal(_decryptedKeyName, _className); - if (null == keyMetadataVersion) + } + if (keyMetadataVersion == null) + { throw SQL.NullArgumentInConstructorInternal(_keyMetadataVersionName, _className); + } if (0 == keyMetadataVersion.Length) + { throw SQL.EmptyArgumentInConstructorInternal(_keyMetadataVersionName, _className); + } KeyId = keyid; DatabaseId = databaseId; diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MetadataUtilsSmi.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MetadataUtilsSmi.cs index d3c01546ce..a0ce819222 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MetadataUtilsSmi.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/MetadataUtilsSmi.cs @@ -199,7 +199,7 @@ Type udtType ExtendedClrTypeCode extendedCode = ExtendedClrTypeCode.Invalid; // fast-track null, which is valid for all types - if (null == value) + if (value == null) { extendedCode = ExtendedClrTypeCode.Empty; } @@ -343,7 +343,7 @@ Type udtType break; case SqlDbType.Udt: // Validate UDT type if caller gave us a type to validate against - if (null == udtType || value.GetType() == udtType) + if (udtType == null || value.GetType() == udtType) { extendedCode = ExtendedClrTypeCode.Object; } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs index 39f87beaae..ce7c115626 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs @@ -118,7 +118,7 @@ protected SqlException ProcessMessages(bool ignoreWarnings } else { - Debug.Assert(null == _warnings || 0 != _warnings.Count, "empty warning collection?");// must be something in the collection + Debug.Assert(_warnings == null || 0 != _warnings.Count, "empty warning collection?");// must be something in the collection if (!ignoreWarnings) { diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.netfx.cs index 75d61f09ff..b87c7d8e8e 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.netfx.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.netfx.cs @@ -13,7 +13,7 @@ private SqlErrorCollection Errors { get { - if (null == _errors) + if (_errors == null) { _errors = new SqlErrorCollection(); } @@ -32,7 +32,7 @@ private SqlErrorCollection Warnings { get { - if (null == _warnings) + if (_warnings == null) { _warnings = new SqlErrorCollection(); } @@ -98,7 +98,7 @@ internal SmiEventSink_Default(SmiEventSink parent) // internal override void BatchCompleted() { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.BatchCompleted); } @@ -107,7 +107,7 @@ internal override void BatchCompleted() internal override void ParametersAvailable(SmiParameterMetaData[] metaData, ITypedGettersV3 paramValues) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.ParametersAvailable); } @@ -116,7 +116,7 @@ internal override void ParametersAvailable(SmiParameterMetaData[] metaData, ITyp internal override void ParameterAvailable(SmiParameterMetaData metaData, SmiTypedGetterSetter paramValue, int ordinal) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.ParameterAvailable); } @@ -126,7 +126,7 @@ internal override void ParameterAvailable(SmiParameterMetaData metaData, SmiType // Called when the server database context changes (ENVCHANGE token) internal override void DefaultDatabaseChanged(string databaseName) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.DefaultDatabaseChanged); } @@ -136,7 +136,7 @@ internal override void DefaultDatabaseChanged(string databaseName) // Called for messages and errors (ERROR and INFO tokens) internal override void MessagePosted(int number, byte state, byte errorClass, string server, string message, string procedure, int lineNumber) { - if (null == _parent) + if (_parent == null) { SqlClientEventSource.Log.TryAdvancedTraceEvent(" {0}, number={1} state={2} errorClass={3} server='{4}' message='{5}' procedure='{6}' linenumber={7}.", 0, number, state, errorClass, server, message, procedure, lineNumber); SqlError error = new SqlError(number, state, errorClass, server, message, procedure, lineNumber); @@ -159,7 +159,7 @@ internal override void MessagePosted(int number, byte state, byte errorClass, st // Called for new resultset starting (COLMETADATA token) internal override void MetaDataAvailable(SmiQueryMetaData[] metaData, bool nextEventIsRow) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.MetaDataAvailable); } @@ -169,7 +169,7 @@ internal override void MetaDataAvailable(SmiQueryMetaData[] metaData, bool nextE // Called when a new row arrives (ROW token) internal override void RowAvailable(ITypedGetters rowData) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.RowAvailable); } @@ -179,7 +179,7 @@ internal override void RowAvailable(ITypedGetters rowData) // Called when a new row arrives (ROW token) internal override void RowAvailable(ITypedGettersV3 rowData) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.RowAvailable); } @@ -189,7 +189,7 @@ internal override void RowAvailable(ITypedGettersV3 rowData) // Called when any statement completes on server (DONE token) internal override void StatementCompleted(int rowsAffected) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.StatementCompleted); } @@ -199,7 +199,7 @@ internal override void StatementCompleted(int rowsAffected) // Called when a transaction is committed (ENVCHANGE token) internal override void TransactionCommitted(long transactionId) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionCommitted); } @@ -209,7 +209,7 @@ internal override void TransactionCommitted(long transactionId) // Called when a transaction is committed (ENVCHANGE token) internal override void TransactionDefected(long transactionId) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionDefected); } @@ -219,7 +219,7 @@ internal override void TransactionDefected(long transactionId) // Called when a transaction is committed (ENVCHANGE token) internal override void TransactionEnlisted(long transactionId) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionEnlisted); } @@ -230,7 +230,7 @@ internal override void TransactionEnlisted(long transactionId) // by the provider's batch (ENVCHANGE token) internal override void TransactionEnded(long transactionId) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionEnded); } @@ -240,7 +240,7 @@ internal override void TransactionEnded(long transactionId) // Called when a transaction is rolled back (ENVCHANGE token) internal override void TransactionRolledBack(long transactionId) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionRolledBack); } @@ -250,7 +250,7 @@ internal override void TransactionRolledBack(long transactionId) // Called when a transaction is started (ENVCHANGE token) internal override void TransactionStarted(long transactionId) { - if (null == _parent) + if (_parent == null) { throw SQL.UnexpectedSmiEvent(UnexpectedEventType.TransactionStarted); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiMetaData.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiMetaData.cs index d69ab6448c..a3945a42e8 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiMetaData.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SmiMetaData.cs @@ -493,7 +493,7 @@ internal Type Type get { // Fault-in UDT clr types on access if have assembly-qualified name - if (null == _clrType && SqlDbType.Udt == _databaseType && _udtAssemblyQualifiedName != null) + if (_clrType == null && SqlDbType.Udt == _databaseType && _udtAssemblyQualifiedName != null) { _clrType = Type.GetType(_udtAssemblyQualifiedName, true); } @@ -507,7 +507,7 @@ internal Type TypeWithoutThrowing get { // Fault-in UDT clr types on access if have assembly-qualified name - if (null == _clrType && SqlDbType.Udt == _databaseType && _udtAssemblyQualifiedName != null) + if (_clrType == null && SqlDbType.Udt == _databaseType && _udtAssemblyQualifiedName != null) { _clrType = Type.GetType(_udtAssemblyQualifiedName, false); } @@ -872,7 +872,7 @@ string typeSpecificNamePart3 extendedProperties ) { - Debug.Assert(null == name || MaxNameLength >= name.Length, "Name is too long"); + Debug.Assert(name == null || MaxNameLength >= name.Length, "Name is too long"); _name = name; _typeSpecificNamePart1 = typeSpecificNamePart1; diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlDataRecord.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlDataRecord.cs index 0afb0f7b7a..5e150a9ea4 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlDataRecord.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlDataRecord.cs @@ -183,7 +183,7 @@ public virtual SqlMetaData GetSqlMetaData(int ordinal) /// public virtual int GetSqlValues(object[] values) { - if (null == values) + if (values == null) { throw ADP.ArgumentNull(nameof(values)); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlMetaData.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlMetaData.cs index 9cc490f0ce..beaecfb5d8 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlMetaData.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/SqlMetaData.cs @@ -913,7 +913,7 @@ int sortOrdinal throw SQL.InvalidSqlDbTypeForConstructor(dbType); } - if (null == userDefinedType) + if (userDefinedType == null) { throw ADP.ArgumentNull(nameof(userDefinedType)); } @@ -954,7 +954,7 @@ int sortOrdinal if (null != database || null != owningSchema) { - if (null == objectName) + if (objectName == null) { throw ADP.ArgumentNull(nameof(objectName)); } @@ -974,7 +974,7 @@ int sortOrdinal private void AssertNameIsValid(string name) { - if (null == name) + if (name == null) { throw ADP.ArgumentNull(nameof(name)); } @@ -1078,7 +1078,7 @@ public string Adjust(string value) } // Handle null values after type check - if (null == value) + if (value == null) { return null; } @@ -1389,7 +1389,7 @@ public SqlChars Adjust(SqlChars value) } // Handle null values after type check. - if (null == value || value.IsNull) + if (value == null || value.IsNull) { return value; } @@ -1438,7 +1438,7 @@ public SqlBytes Adjust(SqlBytes value) } // Handle null values after type check. - if (null == value || value.IsNull) + if (value == null || value.IsNull) { return value; } @@ -1487,7 +1487,7 @@ public DateTimeOffset Adjust(DateTimeOffset value) public object Adjust(object value) { // Pass null references through - if (null == value) + if (value == null) { return null; } @@ -1961,7 +1961,7 @@ public byte[] Adjust(byte[] value) } // Handle null values after type check - if (null == value) + if (value == null) { return null; } @@ -2032,7 +2032,7 @@ public char[] Adjust(char[] value) } // Handle null values after type check - if (null == value) + if (value == null) { return null; } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.netfx.cs index 53bcedf146..a8d995296c 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.netfx.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Server/ValueUtilsSmi.netfx.cs @@ -120,7 +120,7 @@ internal static TimeSpan GetTimeSpan(SmiEventSink_Default sink, ITypedGettersV3 } ThrowIfITypedGettersIsNull(sink, getters, ordinal); object obj = GetValue(sink, getters, ordinal, metaData); - if (null == obj) + if (obj == null) { throw ADP.InvalidCast(); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SignatureVerificationCache.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SignatureVerificationCache.cs index e54e88f23e..40d4ed9b79 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SignatureVerificationCache.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SignatureVerificationCache.cs @@ -87,7 +87,7 @@ private void ValidateSignatureNotNullOrEmpty(byte[] signature, string methodName { if (signature == null || signature.Length == 0) { - if (null == signature) + if (signature == null) { throw SQL.NullArgumentInternal(_signatureName, _className, methodName); } @@ -102,7 +102,7 @@ private void ValidateStringArgumentNotNullOrEmpty(string stringArgValue, string { if (string.IsNullOrWhiteSpace(stringArgValue)) { - if (null == stringArgValue) + if (stringArgValue == null) { throw SQL.NullArgumentInternal(stringArgName, _className, methodName); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCertificateStoreProvider.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCertificateStoreProvider.Windows.cs index f850259311..b2dad9ed0f 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCertificateStoreProvider.Windows.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCertificateStoreProvider.Windows.cs @@ -57,7 +57,7 @@ public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string e // Validate the input parameters ValidateNonEmptyCertificatePath(masterKeyPath, isSystemOp: true); - if (null == encryptedColumnEncryptionKey) + if (encryptedColumnEncryptionKey == null) { throw SQL.NullEncryptedColumnEncryptionKey(); } @@ -152,7 +152,7 @@ public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string e { // Validate the input parameters ValidateNonEmptyCertificatePath(masterKeyPath, isSystemOp: false); - if (null == columnEncryptionKey) + if (columnEncryptionKey == null) { throw SQL.NullColumnEncryptionKey(); } @@ -295,7 +295,7 @@ private byte[] ComputeMasterKeyMetadataHash(string masterKeyPath, bool allowEncl private void ValidateEncryptionAlgorithm(string encryptionAlgorithm, bool isSystemOp) { // This validates that the encryption algorithm is RSA_OAEP - if (null == encryptionAlgorithm) + if (encryptionAlgorithm == null) { throw SQL.NullKeyEncryptionAlgorithm(isSystemOp); } @@ -334,7 +334,7 @@ private void ValidateNonEmptyCertificatePath(string masterKeyPath, bool isSystem { if (string.IsNullOrWhiteSpace(masterKeyPath)) { - if (null == masterKeyPath) + if (masterKeyPath == null) { throw SQL.NullCertificatePath(GetValidCertificateLocations(), isSystemOp); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandBuilder.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandBuilder.cs index e256dde95c..0f57a0e74f 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandBuilder.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandBuilder.cs @@ -250,7 +250,7 @@ public static void DeriveParameters(SqlCommand command) #if NETFRAMEWORK SqlConnection.ExecutePermission.Demand(); #endif - if (null == command) + if (command == null) { throw ADP.ArgumentNull(nameof(command)); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandSet.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandSet.cs index fd7dd61e59..c9a8d24b52 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandSet.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlCommandSet.cs @@ -35,7 +35,7 @@ private SqlCommand BatchCommand get { SqlCommand command = _batchCommand; - if (null == command) + if (command == null) { throw ADP.ObjectDisposed(this); } @@ -50,7 +50,7 @@ private List CommandList get { List commandList = _commandList; - if (null == commandList) + if (commandList == null) { throw ADP.ObjectDisposed(this); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolGroupProviderInfo.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolGroupProviderInfo.cs index 238885b368..636a1cc6ba 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolGroupProviderInfo.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionPoolGroupProviderInfo.cs @@ -39,7 +39,7 @@ internal void AliasCheck(string server) { lock (this) { - if (null == _alias) + if (_alias == null) { _alias = server; } @@ -105,7 +105,7 @@ private PermissionSet CreateFailoverPermission(SqlConnectionString userConnectio // in the original connection string. if (userConnectionOptions.ContainsKey(SqlConnectionString.KEY.FailoverPartner) && - null == userConnectionOptions[SqlConnectionString.KEY.FailoverPartner]) + userConnectionOptions[SqlConnectionString.KEY.FailoverPartner] == null) { keywordToReplace = SqlConnectionString.KEY.Data_Source; } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs index 243efb3db1..53b8ea4437 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs @@ -782,7 +782,7 @@ internal bool EnforceLocalHost { // so tdsparser.connect can determine if SqlConnection.UserConnectionOptions // needs to enforce local host after datasource alias lookup - return (null != _expandedAttachDBFilename) && (null == _localDBInstance); + return (null != _expandedAttachDBFilename) && _localDBInstance == null; } } @@ -831,7 +831,7 @@ private static bool CompareHostName(ref string host, string name, bool fixup) internal static Dictionary GetParseSynonyms() { Dictionary synonyms = s_sqlClientSynonyms; - if (null == synonyms) + if (synonyms == null) { int count = SqlConnectionStringBuilder.KeywordsCount + SynonymCount; @@ -936,7 +936,7 @@ internal string ObtainWorkstationId() // Note: In Longhorn you'll be able to rename a machine without // rebooting. Therefore, don't cache this machine name. string result = WorkstationId; - if (null == result) + if (result == null) { // permission to obtain Environment.MachineName is Asserted // since permission to open the connection has been granted @@ -1172,7 +1172,7 @@ static internal Hashtable NetlibMapping() const int NetLibCount = 8; Hashtable hash = s_netlibMapping; - if (null == hash) + if (hash == null) { hash = new Hashtable(NetLibCount) { diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs index bf1b67093a..e4825add3b 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs @@ -193,13 +193,13 @@ protected override void InitializeBatching() SqlClientEventSource.Log.TryTraceEvent("SqlDataAdapter.InitializeBatching | API | Object Id {0}", ObjectID); _commandSet = new SqlCommandSet(); SqlCommand command = SelectCommand; - if (null == command) + if (command == null) { command = InsertCommand; - if (null == command) + if (command == null) { command = UpdateCommand; - if (null == command) + if (command == null) { command = DeleteCommand; } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs index 0b882bc02c..2dbad8a514 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs @@ -50,7 +50,7 @@ public override bool Equals(object value) bool result = false; - if (null == temp) + if (temp == null) { // If passed value null - false. result = false; } @@ -115,7 +115,7 @@ public override bool Equals(object value) bool result = false; - if (null == temp) + if (temp == null) { // If passed value null - false. result = false; } @@ -158,7 +158,7 @@ public override bool Equals(object value) bool result = false; - if (null == temp) + if (temp == null) { // If passed value null - false. result = false; } @@ -577,7 +577,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul #endif if (string.IsNullOrEmpty(connectionString)) { - if (null == connectionString) + if (connectionString == null) { throw ADP.ArgumentNull(nameof(connectionString)); } @@ -612,7 +612,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul { try { - if (null == s_processDispatcher) + if (s_processDispatcher == null) { // Ensure _processDispatcher reference is present - inside lock. #if NETFRAMEWORK ObtainProcessDispatcher(); @@ -730,7 +730,7 @@ internal static bool Stop(string connectionString, string queue, bool useDefault #endif if (string.IsNullOrEmpty(connectionString)) { - if (null == connectionString) + if (connectionString == null) { throw ADP.ArgumentNull(nameof(connectionString)); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs index 0dbdb28c42..5850dd9178 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs @@ -426,7 +426,7 @@ private void CreateQueueAndService(bool restart) } } - if (null == trans) + if (trans == null) { // Create a new transaction for next operations. trans = _con.BeginTransaction(); com.Transaction = trans; @@ -1281,7 +1281,7 @@ public override bool Equals(object value) // Ignore SqlConnectionStringBuilder, since it is present largely for debug purposes. - if (null == temp) + if (temp == null) { // If passed value null - false. result = false; } @@ -1363,7 +1363,7 @@ public override int GetHashCode() // Private constructor - only called by public constructor for static initialization. private SqlDependencyProcessDispatcher(object dummyVariable) { - Debug.Assert(null == s_staticInstance, "Real constructor called with static instance already created!"); + Debug.Assert(s_staticInstance == null, "Real constructor called with static instance already created!"); long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}", ObjectID); try { diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs index c3a0bb1492..b5135d25c9 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs @@ -351,7 +351,7 @@ internal SqlDependency LookupDependencyEntry(string id) long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}, Key: '{1}'", ObjectID, id); try { - if (null == id) + if (id == null) { throw ADP.ArgumentNull(nameof(id)); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs index b7b87112af..a4c30621d3 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlEnclaveSession.cs @@ -43,7 +43,7 @@ private byte[] Clone(byte[] arrayToClone) /// internal SqlEnclaveSession(byte[] sessionKey, long sessionId) { - if (null == sessionKey) + if (sessionKey == null) { throw SQL.NullArgumentInConstructorInternal(_sessionKeyName, _className); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs index 401815cf94..afc1a8634f 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs @@ -430,7 +430,7 @@ protected void Enlist(Transaction tx) // Sys.Tx keeps the connection alive until the transaction is completed. Debug.Assert(!IsNonPoolableTransactionRoot, "cannot defect an active delegated transaction!"); // potential race condition, but it's an assert - if (null == tx) + if (tx == null) { if (IsEnlistedInTransaction) { @@ -581,7 +581,7 @@ private void EnlistNonNull(Transaction tx) } else { - if (null == _whereAbouts) + if (_whereAbouts == null) { byte[] dtcAddress = GetDTCAddress(); _whereAbouts = dtcAddress ?? throw SQL.CannotGetDTCAddress(); @@ -644,7 +644,7 @@ internal void EnlistNull() // In either case, when we're working with a 2005 or newer server // we better not have a current transaction at this point. - Debug.Assert(null == CurrentTransaction, "unenlisted transaction with non-null current transaction?"); // verify it! + Debug.Assert(CurrentTransaction == null, "unenlisted transaction with non-null current transaction?"); // verify it! } override public void EnlistTransaction(Transaction transaction) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs index a7c7fa58e1..97200b4055 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs @@ -465,7 +465,7 @@ public override DbType DbType set { MetaType metatype = _metaType; - if ((null == metatype) || (metatype.DbType != value)) + if (metatype == null || (metatype.DbType != value)) { PropertyTypeChanging(); _metaType = MetaType.GetMetaTypeFromDbType(value); @@ -608,7 +608,7 @@ public SqlDbType SqlDbType { throw SQL.InvalidSqlDbType(value); } - if ((null == metatype) || (metatype.SqlDbType != value)) + if (metatype == null || (metatype.SqlDbType != value)) { PropertyTypeChanging(); _metaType = MetaType.GetMetaTypeFromSqlDbType(value, value == SqlDbType.Structured); @@ -741,7 +741,7 @@ public override object Value _coercedValue = null; _valueAsINullable = _value as INullable; SetFlag(SqlParameterFlags.IsSqlParameterSqlType, _valueAsINullable != null); - SetFlag(SqlParameterFlags.IsNull, (null == _value) || (_value == DBNull.Value) || (HasFlag(SqlParameterFlags.IsSqlParameterSqlType) && _valueAsINullable.IsNull)); + SetFlag(SqlParameterFlags.IsNull, _value == null || (_value == DBNull.Value) || (HasFlag(SqlParameterFlags.IsSqlParameterSqlType) && _valueAsINullable.IsNull)); _udtLoadError = null; _actualSize = -1; } @@ -897,7 +897,7 @@ internal bool CoercedValueIsDataFeed { get { - if (null == _coercedValue) + if (_coercedValue == null) { GetCoercedValue(); } @@ -1346,7 +1346,7 @@ private void GetActualFieldsAndProperties(out List fields, if (hasDefault) { // May have already created props list in unique key handling - if (null == props) + if (props == null) { props = new SmiMetaDataPropertyCollection(); } @@ -1375,7 +1375,7 @@ private void GetActualFieldsAndProperties(out List fields, } // May have already created props list - if (null == props) + if (props == null) { props = new SmiMetaDataPropertyCollection(); } @@ -1877,7 +1877,7 @@ internal void AssertPropertiesAreValid(object value, bool? isSqlType = null, boo private SqlDbType GetMetaSqlDbTypeOnly() { MetaType metaType = _metaType; - if (null == metaType) + if (metaType == null) { // infer the type from the value metaType = MetaType.GetDefaultMetaType(); } @@ -1977,7 +1977,7 @@ internal void Validate(int index, bool isCommandProc) !ADP.IsDirection(this, ParameterDirection.ReturnValue) && (!metaType.IsFixed) && !ShouldSerializeSize() && - ((null == _value) || Convert.IsDBNull(_value)) && + (_value == null || Convert.IsDBNull(_value)) && (SqlDbType != SqlDbType.Timestamp) && (SqlDbType != SqlDbType.Udt) && // BUG: (VSTFDevDiv - 479609): Output parameter with size 0 throws for XML, TEXT, NTEXT, IMAGE. diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlReferenceCollection.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlReferenceCollection.cs index f6780b1bf4..4ee4d625f3 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlReferenceCollection.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlReferenceCollection.cs @@ -52,7 +52,7 @@ internal SqlDataReader FindLiveReader(SqlCommand command) { if (command is null) { - // if null == command, will find first live datareader + // if command is null, will find first live datareader return FindItem(DataReaderTag, s_hasOpenReaderFunc); } else diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs index 01d2d1bc61..90fb9a5d32 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs @@ -80,7 +80,7 @@ internal static void GenerateRandomBytes(byte[] randomBytes) /// returns true if both the arrays have the same byte values else returns false internal static bool CompareBytes(byte[] buffer1, byte[] buffer2, int buffer2Index, int lengthToCompare) { - if (null == buffer1 || null == buffer2) + if (buffer1 == null || buffer2 == null) { return false; } @@ -140,7 +140,7 @@ private static string ValidateAndGetEncryptionAlgorithmName(byte cipherAlgorithm { if (TdsEnums.CustomCipherAlgorithmId == cipherAlgorithmId) { - if (null == cipherAlgorithmName) + if (cipherAlgorithmName == null) { throw SQL.NullColumnEncryptionAlgorithm(SqlClientEncryptionAlgorithmFactoryList.GetInstance().GetRegisteredCipherAlgorithmNames()); } @@ -178,7 +178,7 @@ internal static byte[] EncryptWithKey(byte[] plainText, SqlCipherMetadata md, Sq Debug.Assert(md.IsAlgorithmInitialized(), "Encryption Algorithm is not initialized"); byte[] cipherText = md.CipherAlgorithm.EncryptData(plainText); // this call succeeds or throws. - if (null == cipherText || 0 == cipherText.Length) + if (cipherText == null || 0 == cipherText.Length) { throw SQL.NullCipherText(); } @@ -217,7 +217,7 @@ internal static byte[] DecryptWithKey(byte[] cipherText, SqlCipherMetadata md, S try { byte[] plainText = md.CipherAlgorithm.DecryptData(cipherText); // this call succeeds or throws. - if (null == plainText) + if (plainText == null) { throw SQL.NullPlainText(); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlStream.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlStream.cs index 4c78cc4c85..62401a49de 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlStream.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlStream.cs @@ -76,11 +76,11 @@ public override int Read(byte[] buffer, int offset, int count) int intCount = 0; int cBufferedData = 0; - if (null == _reader) + if (_reader == null) { throw ADP.StreamClosed(); } - if (null == buffer) + if (buffer == null) { throw ADP.ArgumentNull(nameof(buffer)); } @@ -305,7 +305,7 @@ public override long Position } set { - if (null == _cachedBytes) + if (_cachedBytes == null) { throw ADP.StreamClosed(ADP.ParameterSetPosition); } @@ -337,12 +337,12 @@ public override int Read(byte[] buffer, int offset, int count) int cb; int intCount = 0; - if (null == _cachedBytes) + if (_cachedBytes == null) { throw ADP.StreamClosed(); } - if (null == buffer) + if (buffer == null) { throw ADP.ArgumentNull(nameof(buffer)); } @@ -394,7 +394,7 @@ public override long Seek(long offset, SeekOrigin origin) { long pos = 0; - if (null == _cachedBytes) + if (_cachedBytes == null) { throw ADP.StreamClosed(); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs index 269b69ca3e..cabb027e9e 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs @@ -43,7 +43,7 @@ private bool IsDisposed { get { - return (null == _freeStateObjects); + return _freeStateObjects == null; } } @@ -212,7 +212,7 @@ internal string TraceString() return string.Format(/*IFormatProvider*/ null, "(ObjID={0}, free={1}, cached={2}, total={3})", _objectID, - null == _freeStateObjects ? "(null)" : _freeStateObjectCount.ToString((IFormatProvider)null), + _freeStateObjects == null ? "(null)" : _freeStateObjectCount.ToString((IFormatProvider)null), _cachedCount, _cache.Count); } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs index c1dc058ff2..7184604963 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs @@ -1654,7 +1654,7 @@ internal TdsOperationStatus TryReadStringWithEncoding(int length, System.Text.En TdsParser.ReliabilitySection.Assert("unreliable call to ReadStringWithEncoding"); // you need to setup for a thread abort somewhere before you call this method Debug.Assert(_syncOverAsync || !_asyncReadWithoutSnapshot, "This method is not safe to call when doing sync over async"); - if (null == encoding) + if (encoding == null) { // Need to skip the current column before throwing the error - this ensures that the state shared between this and the data reader is consistent when calling DrainData if (isPlp) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStaticMethods.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStaticMethods.cs index 93aac3fdea..6ba8be499c 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStaticMethods.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStaticMethods.cs @@ -199,7 +199,7 @@ static internal byte[] GetNetworkPhysicalAddressForTdsLoginOnly() } } - if (null == nicAddress) + if (nicAddress == null) { nicAddress = new byte[TdsEnums.MAX_NIC_SIZE]; Random random = new Random(); diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsValueSetter.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsValueSetter.cs index 6b05698972..a1e019140c 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsValueSetter.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsValueSetter.cs @@ -250,7 +250,7 @@ internal int SetChars(long fieldOffset, char[] buffer, int bufferOffset, int len // ANSI types must convert to byte[] because that's the tool we have. if (MetaDataUtilsSmi.IsAnsiType(_metaData.SqlDbType)) { - if (null == _encoder) + if (_encoder == null) { _encoder = _stateObj.Parser._defaultEncoding.GetEncoder(); } @@ -452,7 +452,7 @@ internal void SetInt64(long value) SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetInt64)); if (SqlDbType.Variant == _metaData.SqlDbType) { - if (null == _variantType) + if (_variantType == null) { _stateObj.Parser.WriteSqlVariantHeader(10, TdsEnums.SQLINT8, 0, _stateObj); _stateObj.Parser.WriteLong(value, _stateObj); @@ -735,7 +735,7 @@ internal void SetDateTimeOffset(DateTimeOffset value) internal void SetVariantType(SmiMetaData value) { - Debug.Assert(null == _variantType, "Variant type can only be set once"); + Debug.Assert(_variantType == null, "Variant type can only be set once"); Debug.Assert(value != null && (value.SqlDbType == SqlDbType.Money || value.SqlDbType == SqlDbType.NVarChar || diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs index 78ac30190a..310fae44be 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs @@ -643,7 +643,7 @@ public static void DropDatabase(SqlConnection sqlConnection, string dbName) public static string GetAccessToken() { - if (null == AADAccessToken && IsAADPasswordConnStrSetup() && IsAADAuthorityURLSetup()) + if (AADAccessToken == null && IsAADPasswordConnStrSetup() && IsAADAuthorityURLSetup()) { string username = RetrieveValueFromConnStr(AADPasswordConnectionString, new string[] { "User ID", "UID" }); string password = RetrieveValueFromConnStr(AADPasswordConnectionString, new string[] { "Password", "PWD" }); @@ -655,7 +655,7 @@ public static string GetAccessToken() public static string GetSystemIdentityAccessToken() { - if (ManagedIdentitySupported && SupportsSystemAssignedManagedIdentity && null == AADSystemIdentityAccessToken && IsAADPasswordConnStrSetup()) + if (ManagedIdentitySupported && SupportsSystemAssignedManagedIdentity && AADSystemIdentityAccessToken == null && IsAADPasswordConnStrSetup()) { AADSystemIdentityAccessToken = AADUtility.GetManagedIdentityToken().GetAwaiter().GetResult(); if (AADSystemIdentityAccessToken == null) @@ -668,7 +668,7 @@ public static string GetSystemIdentityAccessToken() public static string GetUserIdentityAccessToken() { - if (ManagedIdentitySupported && null == AADUserIdentityAccessToken && IsAADPasswordConnStrSetup()) + if (ManagedIdentitySupported && AADUserIdentityAccessToken == null && IsAADPasswordConnStrSetup()) { // Pass User Assigned Managed Identity Client Id here. AADUserIdentityAccessToken = AADUtility.GetManagedIdentityToken(UserManagedIdentityClientId).GetAwaiter().GetResult(); diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/ProviderAgnostic/MultipleResultsTest/MultipleResultsTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/ProviderAgnostic/MultipleResultsTest/MultipleResultsTest.cs index 5b11b46b8c..ef1a48fdea 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/ProviderAgnostic/MultipleResultsTest/MultipleResultsTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/ProviderAgnostic/MultipleResultsTest/MultipleResultsTest.cs @@ -263,7 +263,7 @@ private string FindDiffFromBaseline(string baselinePath, string outputPath) private string AssemblyFilter(StreamWriter writer) { - if (null == _outputBuilder) + if (_outputBuilder == null) { _outputBuilder = new StringBuilder(); } @@ -279,7 +279,7 @@ private string AssemblyFilter(StreamWriter writer) private void AssemblyFilter(StringBuilder builder) { string[] filter = _outputFilter; - if (null == filter) + if (filter == null) { filter = new string[5]; string tmp = typeof(System.Guid).AssemblyQualifiedName; diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs index e3226c5e3c..2240836993 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AdapterTest/AdapterTest.cs @@ -1643,7 +1643,7 @@ private void WriteObject(StringBuilder textBuilder, object value, CultureInfo cu { return; } - if (null == value) + if (value == null) { textBuilder.Append("DEFAULT"); } @@ -1847,7 +1847,7 @@ private void WriteObject(StringBuilder textBuilder, object value, CultureInfo cu if (property.CanRead) { ParameterInfo[] parameters = property.GetIndexParameters(); - if ((null == parameters) || (0 == parameters.Length)) + if (parameters == null || (0 == parameters.Length)) { AppendNewLineIndent(textBuilder, indent + 1); textBuilder.Append(property.Name); diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/TvpTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/TvpTest.cs index b8882b451a..07bb0f33f5 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/TvpTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/TvpTest.cs @@ -1034,7 +1034,7 @@ private DataTable CreateNewTable(object[] row, ref Type[] lastRowTypes) { object value = row[i]; Type t; - if ((null == value || DBNull.Value == value)) + if (value == null || DBNull.Value == value) { if (lastRowTypes[i] == null) { @@ -1310,7 +1310,7 @@ private IList GenerateDataTables(object[][] values) } } - if (null == targetTable) + if (targetTable == null) { targetTable = CreateNewTable(row, ref valueTypes); if (null != targetTable) @@ -1345,10 +1345,9 @@ private string GetTypeName(StePermutation tvpPerm) private bool IsNull(object value) { - return null == value || - DBNull.Value == value || - (value is INullable nullable && - nullable.IsNull); + return value == null || + DBNull.Value == value || + (value is INullable nullable && nullable.IsNull); } private SqlMetaData PermToSqlMetaData(StePermutation perm) @@ -1417,11 +1416,11 @@ private SqlMetaData PermToSqlMetaData(StePermutation perm) private void ReportMismatch(object source, object result, StePermutation perm) { - if (null == source) + if (source == null) { source = "(null)"; } - if (null == result) + if (result == null) { result = "(null)"; } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/InvalidAccessFromEvent.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/InvalidAccessFromEvent.cs index f799796bec..744b8ae66a 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/InvalidAccessFromEvent.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlBulkCopyTest/InvalidAccessFromEvent.cs @@ -104,7 +104,7 @@ internal static void InnerTest(SqlRowsCopiedEventHandler eventHandler) bool hitException = false; try { - if (null == _tx || null == _tx.Connection) + if (_tx == null || _tx.Connection == null) { _tx = _dstConn.BeginTransaction(); _dstcmd.Transaction = _tx; From 2d236c9fc81d434997cc6c58fc783e675f8cbfef Mon Sep 17 00:00:00 2001 From: Benjamin Russell Date: Fri, 2 Aug 2024 13:56:24 -0500 Subject: [PATCH 2/2] Update src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs Co-authored-by: David Engel --- .../netfx/src/Microsoft/Data/SqlClient/TdsParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs index 326a125a15..d855c4ea87 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -13880,7 +13880,7 @@ internal int ReadPlpAnsiChars(ref char[] buff, int offst, int len, SqlMetaDataPr { Encoding enc = metadata.encoding; - if (null == enc) + if (enc == null) { if (_defaultEncoding == null) {