Skip to content

Commit 6fbbb78

Browse files
Code Cleanup | null == x to x == null (#2749)
- With one approval and CI success, I think that's enough to move ahead on this one. * `null == x` to `x == null` * Update src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs Co-authored-by: David Engel <dengel1012@gmail.com> --------- Co-authored-by: David Engel <dengel1012@gmail.com>
1 parent 6f177e3 commit 6fbbb78

File tree

88 files changed

+444
-417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+444
-417
lines changed

src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/SqlColumnEncryptionAzureKeyVaultProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ byte[] DecryptEncryptionKey()
241241
byte[] message = new byte[encryptedColumnEncryptionKey.Length - signatureLength];
242242
Buffer.BlockCopy(encryptedColumnEncryptionKey, 0, message, 0, encryptedColumnEncryptionKey.Length - signatureLength);
243243

244-
if (null == message)
244+
if (message == null)
245245
{
246246
throw ADP.NullHashFound();
247247
}

src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Utils.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal static void ValidateNotNullOrWhitespaceForEach(string[] parameters, str
4545
internal static void ValidateEncryptionAlgorithm(string encryptionAlgorithm, bool isSystemOp)
4646
{
4747
// This validates that the encryption algorithm is RSA_OAEP
48-
if (null == encryptionAlgorithm)
48+
if (encryptionAlgorithm == null)
4949
{
5050
throw ADP.NullAlgorithm(isSystemOp);
5151
}
@@ -124,8 +124,9 @@ internal static ArgumentException InvalidSignatureTemplate(string masterKeyPath)
124124

125125
internal static ArgumentException InvalidAKVPath(string masterKeyPath, bool isSystemOp)
126126
{
127-
string errorMessage = null == masterKeyPath ? Strings.NullAkvPath
128-
: string.Format(CultureInfo.InvariantCulture, Strings.InvalidAkvPathTemplate, masterKeyPath);
127+
string errorMessage = masterKeyPath == null
128+
? Strings.NullAkvPath
129+
: string.Format(CultureInfo.InvariantCulture, Strings.InvalidAkvPathTemplate, masterKeyPath);
129130
if (isSystemOp)
130131
{
131132
return new ArgumentNullException(Constants.AeParamMasterKeyPath, errorMessage);

src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ internal override bool TryOpenConnection(DbConnection outerConnection, DbConnect
102102
// we are completing an asynchronous open
103103
Debug.Assert(retry.Task.Status == TaskStatus.RanToCompletion, "retry task must be completed successfully");
104104
DbConnectionInternal openConnection = retry.Task.Result;
105-
if (null == openConnection)
105+
if (openConnection == null)
106106
{
107107
connectionFactory.SetInnerConnectionTo(outerConnection, this);
108108
throw ADP.InternalConnectionError(ADP.ConnectionError.GetConnectionReturnsNull);

src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,12 @@ internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnectionPoolKey key, D
214214
// new pool entry and add it to our collection.
215215

216216
DbConnectionOptions connectionOptions = CreateConnectionOptions(key.ConnectionString, userConnectionOptions);
217-
if (null == connectionOptions)
217+
if (connectionOptions == null)
218218
{
219219
throw ADP.InternalConnectionError(ADP.ConnectionError.ConnectionOptionsMissing);
220220
}
221221

222-
if (null == userConnectionOptions)
222+
if (userConnectionOptions == null)
223223
{ // we only allow one expansion on the connection string
224224

225225
userConnectionOptions = connectionOptions;
@@ -236,7 +236,7 @@ internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnectionPoolKey key, D
236236
}
237237

238238
// We don't support connection pooling on Win9x
239-
if (null == poolOptions)
239+
if (poolOptions == null)
240240
{
241241
if (null != connectionPoolGroup)
242242
{
@@ -279,7 +279,7 @@ internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnectionPoolKey key, D
279279
Debug.Assert(null != connectionPoolGroup, "how did we not create a pool entry?");
280280
Debug.Assert(null != userConnectionOptions, "how did we not have user connection options?");
281281
}
282-
else if (null == userConnectionOptions)
282+
else if (userConnectionOptions == null)
283283
{
284284
userConnectionOptions = connectionPoolGroup.ConnectionOptions;
285285
}

src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ public ConnectionState State
178178

179179
internal void AddWeakReference(object value, int tag)
180180
{
181-
if (null == _referenceCollection)
181+
if (_referenceCollection == null)
182182
{
183183
_referenceCollection = CreateReferenceCollection();
184-
if (null == _referenceCollection)
184+
if (_referenceCollection == null)
185185
{
186186
throw ADP.InternalError(ADP.InternalErrorCode.CreateReferenceCollectionReturnedNull);
187187
}
@@ -349,7 +349,7 @@ protected bool TryOpenConnectionInternal(DbConnection outerConnection, DbConnect
349349
connectionFactory.SetInnerConnectionTo(outerConnection, this);
350350
throw;
351351
}
352-
if (null == openConnection)
352+
if (openConnection == null)
353353
{
354354
connectionFactory.SetInnerConnectionTo(outerConnection, this);
355355
throw ADP.InternalConnectionError(ADP.ConnectionError.GetConnectionReturnsNull);

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal static string ExpandDataDirectory(string keyword, string value)
4343
// find the replacement path
4444
object rootFolderObject = AppDomain.CurrentDomain.GetData("DataDirectory");
4545
var rootFolderPath = (rootFolderObject as string);
46-
if ((null != rootFolderObject) && (null == rootFolderPath))
46+
if ((null != rootFolderObject) && rootFolderPath == null)
4747
{
4848
throw ADP.InvalidDataDirectory();
4949
}

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal bool TryGetConnection(DbConnection owningConnection, TaskCompletionSour
4343
poolGroup = GetConnectionPoolGroup(owningConnection);
4444
// Doing this on the callers thread is important because it looks up the WindowsIdentity from the thread.
4545
connectionPool = GetConnectionPool(owningConnection, poolGroup);
46-
if (null == connectionPool)
46+
if (connectionPool == null)
4747
{
4848
// If GetConnectionPool returns null, we can be certain that
4949
// this connection should not be pooled via DbConnectionPool

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected internal Transaction EnlistedTransaction
3737
set
3838
{
3939
Transaction currentEnlistedTransaction = _enlistedTransaction;
40-
if (((null == currentEnlistedTransaction) && (null != value))
40+
if ((currentEnlistedTransaction == null && (null != value))
4141
|| ((null != currentEnlistedTransaction) && !currentEnlistedTransaction.Equals(value)))
4242
{ // WebData 20000024
4343

@@ -354,7 +354,7 @@ virtual internal void DelegatedTransactionEnded()
354354

355355
DbConnectionPool pool = Pool;
356356

357-
if (null == pool)
357+
if (pool == null)
358358
{
359359
throw ADP.InternalError(ADP.InternalErrorCode.PooledObjectWithoutPool); // pooled connection does not have a pool
360360
}

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio
729729
try
730730
{
731731
newObj = _connectionFactory.CreatePooledConnection(this, owningObject, _connectionPoolGroup.ConnectionOptions, _connectionPoolGroup.PoolKey, userOptions);
732-
if (null == newObj)
732+
if (newObj == null)
733733
{
734734
throw ADP.InternalError(ADP.InternalErrorCode.CreateObjectReturnedNull); // CreateObject succeeded, but null object
735735
}
@@ -1172,7 +1172,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
11721172
obj = GetFromTransactedPool(out transaction);
11731173
}
11741174

1175-
if (null == obj)
1175+
if (obj == null)
11761176
{
11771177
Interlocked.Increment(ref _waitCount);
11781178

@@ -1217,7 +1217,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
12171217
}
12181218
catch
12191219
{
1220-
if (null == obj)
1220+
if (obj == null)
12211221
{
12221222
Interlocked.Decrement(ref _waitCount);
12231223
}
@@ -1233,7 +1233,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
12331233
}
12341234
}
12351235

1236-
if (null == obj)
1236+
if (obj == null)
12371237
{
12381238
// If we were not able to create an object, check to see if
12391239
// we reached MaxPoolSize. If so, we will no longer wait on
@@ -1309,7 +1309,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
13091309
DestroyObject(obj);
13101310
obj = null;
13111311
}
1312-
} while (null == obj);
1312+
} while (obj == null);
13131313
}
13141314

13151315
if (null != obj)

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static SqlAuthenticationProviderManager()
2121
{
2222
// New configuration section "SqlClientAuthenticationProviders" for Microsoft.Data.SqlClient accepted to avoid conflicts with older one.
2323
configurationSection = FetchConfigurationSection<SqlClientAuthenticationProviderConfigurationSection>(SqlClientAuthenticationProviderConfigurationSection.Name);
24-
if (null == configurationSection)
24+
if (configurationSection == null)
2525
{
2626
// If configuration section is not yet found, try with old Configuration Section name for backwards compatibility
2727
configurationSection = FetchConfigurationSection<SqlAuthenticationProviderConfigurationSection>(SqlAuthenticationProviderConfigurationSection.Name);

0 commit comments

Comments
 (0)