Skip to content

Commit c5e3c40

Browse files
authored
Remove ADP.IsEmpty() (#3277)
1 parent 6695ecd commit c5e3c40

16 files changed

+58
-59
lines changed

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DBConnectionString.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private DBConnectionString(DbConnectionOptions connectionOptions, string restric
114114
_keychain = connectionOptions.ReplacePasswordPwd(out _encryptedUsersConnectionString, true);
115115
}
116116

117-
if (!ADP.IsEmpty(restrictions))
117+
if (!string.IsNullOrEmpty(restrictions))
118118
{
119119
_restrictionValues = ParseRestrictions(restrictions, synonyms);
120120
_restrictions = restrictions;
@@ -169,7 +169,7 @@ internal string Restrictions
169169
StringBuilder builder = new StringBuilder();
170170
for (int i = 0; i < restrictionValues.Length; ++i)
171171
{
172-
if (!ADP.IsEmpty(restrictionValues[i]))
172+
if (!string.IsNullOrEmpty(restrictionValues[i]))
173173
{
174174
builder.Append(restrictionValues[i]);
175175
builder.Append("=;");
@@ -497,13 +497,13 @@ private static string[] ParseRestrictions(string restrictions, Dictionary<string
497497

498498
string keyname; // since parsing restrictions ignores values, it doesn't matter if we use ODBC rules or OLEDB rules
499499
nextStartPosition = DbConnectionOptions.GetKeyValuePair(restrictions, startPosition, buffer, false, out keyname, out _);
500-
if (!ADP.IsEmpty(keyname))
500+
if (!string.IsNullOrEmpty(keyname))
501501
{
502502
#if DEBUG
503503
SqlClientEventSource.Log.TryAdvancedTraceEvent("<comm.DBConnectionString|INFO|ADV> KeyName='{0}'", keyname);
504504
#endif
505505
string realkeyname = synonyms != null ? (string)synonyms[keyname] : keyname; // MDAC 85144
506-
if (ADP.IsEmpty(realkeyname))
506+
if (string.IsNullOrEmpty(realkeyname))
507507
{
508508
throw ADP.KeywordNotSupported(keyname);
509509
}
@@ -560,8 +560,8 @@ private static void Verify(string[] restrictionValues)
560560
{
561561
for (int i = 1; i < restrictionValues.Length; ++i)
562562
{
563-
Debug.Assert(!ADP.IsEmpty(restrictionValues[i - 1]), "empty restriction");
564-
Debug.Assert(!ADP.IsEmpty(restrictionValues[i]), "empty restriction");
563+
Debug.Assert(!string.IsNullOrEmpty(restrictionValues[i - 1]), "empty restriction");
564+
Debug.Assert(!string.IsNullOrEmpty(restrictionValues[i]), "empty restriction");
565565
Debug.Assert(0 >= StringComparer.Ordinal.Compare(restrictionValues[i - 1], restrictionValues[i]));
566566
}
567567
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ internal bool HasBlankPassword
3535
{
3636
if (_parsetable.ContainsKey(KEY.Password))
3737
{
38-
return ADP.IsEmpty(_parsetable[KEY.Password]);
38+
return string.IsNullOrEmpty(_parsetable[KEY.Password]);
3939
}
4040
else
4141
if (_parsetable.ContainsKey(SYNONYM.Pwd))
4242
{
43-
return ADP.IsEmpty(_parsetable[SYNONYM.Pwd]); // MDAC 83097
43+
return string.IsNullOrEmpty(_parsetable[SYNONYM.Pwd]); // MDAC 83097
4444
}
4545
else
4646
{
47-
return (_parsetable.ContainsKey(KEY.User_ID) && !ADP.IsEmpty(_parsetable[KEY.User_ID])) ||
48-
(_parsetable.ContainsKey(SYNONYM.UID) && !ADP.IsEmpty(_parsetable[SYNONYM.UID]));
47+
return (_parsetable.ContainsKey(KEY.User_ID) && !string.IsNullOrEmpty(_parsetable[KEY.User_ID])) ||
48+
(_parsetable.ContainsKey(SYNONYM.UID) && !string.IsNullOrEmpty(_parsetable[SYNONYM.UID]));
4949
}
5050
}
5151
return false;
@@ -179,7 +179,7 @@ internal static string ExpandDataDirectory(string keyword, string value, ref str
179179
{
180180
throw ADP.InvalidDataDirectory();
181181
}
182-
else if (ADP.IsEmpty(rootFolderPath))
182+
else if (string.IsNullOrEmpty(rootFolderPath))
183183
{
184184
rootFolderPath = AppDomain.CurrentDomain.BaseDirectory;
185185
}

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ private string CreateInitialQuery()
420420
{
421421
throw SQL.BulkLoadInvalidDestinationTable(DestinationTableName, e);
422422
}
423-
if (ADP.IsEmpty(parts[MultipartIdentifier.TableIndex]))
423+
if (string.IsNullOrEmpty(parts[MultipartIdentifier.TableIndex]))
424424
{
425425
throw SQL.BulkLoadInvalidDestinationTable(DestinationTableName, null);
426426
}
@@ -442,7 +442,7 @@ private string CreateInitialQuery()
442442

443443
string TableName = parts[MultipartIdentifier.TableIndex];
444444
bool isTempTable = TableName.Length > 0 && '#' == TableName[0];
445-
if (!ADP.IsEmpty(TableName))
445+
if (!string.IsNullOrEmpty(TableName))
446446
{
447447
// Escape table name to be put inside TSQL literal block (within N'').
448448
TableName = SqlServerEscapeHelper.EscapeStringAsLiteral(TableName);
@@ -451,7 +451,7 @@ private string CreateInitialQuery()
451451
}
452452

453453
string SchemaName = parts[MultipartIdentifier.SchemaIndex];
454-
if (!ADP.IsEmpty(SchemaName))
454+
if (!string.IsNullOrEmpty(SchemaName))
455455
{
456456
// Escape schema name to be put inside TSQL literal block (within N'').
457457
SchemaName = SqlServerEscapeHelper.EscapeStringAsLiteral(SchemaName);
@@ -460,7 +460,7 @@ private string CreateInitialQuery()
460460
}
461461

462462
string CatalogName = parts[MultipartIdentifier.CatalogIndex];
463-
if (isTempTable && ADP.IsEmpty(CatalogName))
463+
if (isTempTable && string.IsNullOrEmpty(CatalogName))
464464
{
465465
TDSCommand += string.Format("exec tempdb..{0} N'{1}.{2}'",
466466
TableCollationsStoredProc,
@@ -471,7 +471,7 @@ private string CreateInitialQuery()
471471
else
472472
{
473473
// VSDD 581951 - escape the catalog name
474-
if (!ADP.IsEmpty(CatalogName))
474+
if (!string.IsNullOrEmpty(CatalogName))
475475
{
476476
CatalogName = SqlServerEscapeHelper.EscapeIdentifier(CatalogName);
477477
}
@@ -1437,7 +1437,7 @@ private void AppendColumnNameAndTypeName(StringBuilder query, string columnName,
14371437

14381438
private string UnquotedName(string name)
14391439
{
1440-
if (ADP.IsEmpty(name))
1440+
if (string.IsNullOrEmpty(name))
14411441
return null;
14421442
if (name[0] == '[')
14431443
{

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientPermission.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ override public SecurityElement ToXml()
369369

370370
tmp = value.ConnectionString; // WebData 97375
371371
tmp = EncodeXmlValue(tmp);
372-
if (!ADP.IsEmpty(tmp))
372+
if (!string.IsNullOrEmpty(tmp))
373373
{
374374
valueElement.AddAttribute(XmlStr._ConnectionString, tmp);
375375
}

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,7 +3388,7 @@ internal void DeriveParameters()
33883388

33893389
// Use common parser for SqlClient and OleDb - parse into 4 parts - Server, Catalog, Schema, ProcedureName
33903390
string[] parsedSProc = MultipartIdentifier.ParseMultipartIdentifier(CommandText, "[\"", "]\"", Strings.SQL_SqlCommandCommandText, false);
3391-
if (parsedSProc[3] == null || ADP.IsEmpty(parsedSProc[3]))
3391+
if (parsedSProc[3] == null || string.IsNullOrEmpty(parsedSProc[3]))
33923392
{
33933393
throw ADP.NoStoredProcedureExists(CommandText);
33943394
}
@@ -3402,14 +3402,14 @@ internal void DeriveParameters()
34023402
// [user server, if provided].[user catalog, else current database].[sys if 2005, else blank].[sp_procedure_params_rowset]
34033403

34043404
// Server - pass only if user provided.
3405-
if (!ADP.IsEmpty(parsedSProc[0]))
3405+
if (!string.IsNullOrEmpty(parsedSProc[0]))
34063406
{
34073407
SqlCommandSet.BuildStoredProcedureName(cmdText, parsedSProc[0]);
34083408
cmdText.Append(".");
34093409
}
34103410

34113411
// Catalog - pass user provided, otherwise use current database.
3412-
if (ADP.IsEmpty(parsedSProc[1]))
3412+
if (string.IsNullOrEmpty(parsedSProc[1]))
34133413
{
34143414
parsedSProc[1] = Connection.Database;
34153415
}
@@ -3459,7 +3459,7 @@ internal void DeriveParameters()
34593459
param.Value = groupNumber;
34603460
}
34613461

3462-
if (!ADP.IsEmpty(parsedSProc[2]))
3462+
if (!string.IsNullOrEmpty(parsedSProc[2]))
34633463
{ // SchemaName is 3rd element in parsed array
34643464
SqlParameter param = paramsCmd.Parameters.Add(new SqlParameter("@procedure_schema", SqlDbType.NVarChar, 255));
34653465
param.Value = UnquoteProcedurePart(parsedSProc[2]);
@@ -3672,7 +3672,7 @@ private void CheckNotificationStateAndAutoEnlist()
36723672
if (NotificationAutoEnlist)
36733673
{
36743674
string notifyContext = SqlNotificationContext();
3675-
if (!ADP.IsEmpty(notifyContext))
3675+
if (!string.IsNullOrEmpty(notifyContext))
36763676
{
36773677
// Map to dependency by ID set in context data.
36783678
SqlDependency dependency = SqlDependencyPerAppDomainDispatcher.SingletonInstance.LookupDependencyEntry(notifyContext);
@@ -5777,7 +5777,7 @@ private void ValidateCommand(string method, bool async)
57775777
throw ADP.TransactionConnectionMismatch();
57785778
}
57795779

5780-
if (ADP.IsEmpty(this.CommandText))
5780+
if (string.IsNullOrEmpty(this.CommandText))
57815781
{
57825782
throw ADP.CommandTextRequired(method);
57835783
}
@@ -6772,15 +6772,15 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete
67726772
if (mt.SqlDbType == SqlDbType.Udt)
67736773
{
67746774
string fullTypeName = sqlParam.UdtTypeName;
6775-
if (ADP.IsEmpty(fullTypeName))
6775+
if (string.IsNullOrEmpty(fullTypeName))
67766776
throw SQL.MustSetUdtTypeNameForUdtParams();
67776777

67786778
paramList.Append(ParseAndQuoteIdentifier(fullTypeName, true /* is UdtTypeName */));
67796779
}
67806780
else if (mt.SqlDbType == SqlDbType.Structured)
67816781
{
67826782
string typeName = sqlParam.TypeName;
6783-
if (ADP.IsEmpty(typeName))
6783+
if (string.IsNullOrEmpty(typeName))
67846784
{
67856785
throw SQL.MustSetTypeNameForParam(mt.TypeName, sqlParam.GetPrefixedParameterName());
67866786
}

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ private bool UsesClearUserIdOrPassword(SqlConnectionString opt)
648648
bool result = false;
649649
if (opt != null)
650650
{
651-
result = (!ADP.IsEmpty(opt.UserID) || !ADP.IsEmpty(opt.Password));
651+
result = (!string.IsNullOrEmpty(opt.UserID) || !string.IsNullOrEmpty(opt.Password));
652652
}
653653
return result;
654654
}
@@ -2258,7 +2258,7 @@ internal void ValidateConnectionForExecute(string method, SqlCommand command)
22582258
// as native OleDb and Odbc.
22592259
static internal string FixupDatabaseTransactionName(string name)
22602260
{
2261-
if (!ADP.IsEmpty(name))
2261+
if (!string.IsNullOrEmpty(name))
22622262
{
22632263
return SqlServerEscapeHelper.EscapeIdentifier(name);
22642264
}
@@ -2407,11 +2407,11 @@ public static void ChangePassword(string connectionString, string newPassword)
24072407
{
24082408
SqlClientEventSource.Log.TryCorrelationTraceEvent("<sc.SqlConnection.ChangePassword|API|Correlation> ActivityID {0}", ActivityCorrelator.Current);
24092409

2410-
if (ADP.IsEmpty(connectionString))
2410+
if (string.IsNullOrEmpty(connectionString))
24112411
{
24122412
throw SQL.ChangePasswordArgumentMissing("connectionString");
24132413
}
2414-
if (ADP.IsEmpty(newPassword))
2414+
if (string.IsNullOrEmpty(newPassword))
24152415
{
24162416
throw SQL.ChangePasswordArgumentMissing("newPassword");
24172417
}
@@ -2427,7 +2427,7 @@ public static void ChangePassword(string connectionString, string newPassword)
24272427
{
24282428
throw SQL.ChangePasswordConflictsWithSSPI();
24292429
}
2430-
if (!ADP.IsEmpty(connectionOptions.AttachDBFilename))
2430+
if (!string.IsNullOrEmpty(connectionOptions.AttachDBFilename))
24312431
{
24322432
throw SQL.ChangePasswordUseOfUnallowedKey(SqlConnectionString.KEY.AttachDBFilename);
24332433
}
@@ -2450,7 +2450,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent
24502450
{
24512451
SqlClientEventSource.Log.TryCorrelationTraceEvent("<sc.SqlConnection.ChangePassword|API|Correlation> ActivityID {0}", ActivityCorrelator.Current);
24522452

2453-
if (ADP.IsEmpty(connectionString))
2453+
if (string.IsNullOrEmpty(connectionString))
24542454
{
24552455
throw SQL.ChangePasswordArgumentMissing("connectionString");
24562456
}
@@ -2481,7 +2481,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent
24812481
SqlConnectionString connectionOptions = SqlConnectionFactory.FindSqlConnectionOptions(key);
24822482

24832483
// Check for incompatible connection string value with SqlCredential
2484-
if (!ADP.IsEmpty(connectionOptions.UserID) || !ADP.IsEmpty(connectionOptions.Password))
2484+
if (!string.IsNullOrEmpty(connectionOptions.UserID) || !string.IsNullOrEmpty(connectionOptions.Password))
24852485
{
24862486
throw ADP.InvalidMixedArgumentOfSecureAndClearCredential();
24872487
}
@@ -2491,7 +2491,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent
24912491
throw SQL.ChangePasswordConflictsWithSSPI();
24922492
}
24932493

2494-
if (!ADP.IsEmpty(connectionOptions.AttachDBFilename))
2494+
if (!string.IsNullOrEmpty(connectionOptions.AttachDBFilename))
24952495
{
24962496
throw SQL.ChangePasswordUseOfUnallowedKey(SqlConnectionString.KEY.AttachDBFilename);
24972497
}
@@ -2671,7 +2671,7 @@ internal void CheckGetExtendedUDTInfo(SqlMetaDataPriv metaData, bool fThrow)
26712671
{
26722672
if (metaData.udt?.Type == null)
26732673
{ // If null, we have not obtained extended info.
2674-
Debug.Assert(!ADP.IsEmpty(metaData.udt?.AssemblyQualifiedName), "Unexpected state on GetUDTInfo");
2674+
Debug.Assert(!string.IsNullOrEmpty(metaData.udt?.AssemblyQualifiedName), "Unexpected state on GetUDTInfo");
26752675
// Parameter throwOnError determines whether exception from Assembly.Load is thrown.
26762676
metaData.udt.Type =
26772677
Type.GetType(typeName: metaData.udt.AssemblyQualifiedName, assemblyResolver: asmRef => ResolveTypeAssembly(asmRef, fThrow), typeResolver: null, throwOnError: fThrow);

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ override protected DbConnectionInternal CreateConnection(DbConnectionOptions opt
152152

153153
protected override DbConnectionOptions CreateConnectionOptions(string connectionString, DbConnectionOptions previous)
154154
{
155-
Debug.Assert(!ADP.IsEmpty(connectionString), "empty connectionString");
155+
Debug.Assert(!string.IsNullOrEmpty(connectionString), "empty connectionString");
156156
SqlConnectionString result = new SqlConnectionString(connectionString);
157157
return result;
158158
}

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -736,32 +736,32 @@ public override DataTable GetSchemaTable()
736736
schemaRow[IsRowVersion] = false;
737737
}
738738

739-
if (!ADP.IsEmpty(colMetaData.ColumnName))
739+
if (!string.IsNullOrEmpty(colMetaData.ColumnName))
740740
{
741741
schemaRow[BaseColumnName] = colMetaData.ColumnName;
742742
}
743-
else if (!ADP.IsEmpty(colMetaData.Name))
743+
else if (!string.IsNullOrEmpty(colMetaData.Name))
744744
{
745745
// Use projection name if base column name is not present
746746
schemaRow[BaseColumnName] = colMetaData.Name;
747747
}
748748

749-
if (!ADP.IsEmpty(colMetaData.TableName))
749+
if (!string.IsNullOrEmpty(colMetaData.TableName))
750750
{
751751
schemaRow[BaseTableName] = colMetaData.TableName;
752752
}
753753

754-
if (!ADP.IsEmpty(colMetaData.SchemaName))
754+
if (!string.IsNullOrEmpty(colMetaData.SchemaName))
755755
{
756756
schemaRow[BaseSchemaName] = colMetaData.SchemaName;
757757
}
758758

759-
if (!ADP.IsEmpty(colMetaData.CatalogName))
759+
if (!string.IsNullOrEmpty(colMetaData.CatalogName))
760760
{
761761
schemaRow[BaseCatalogName] = colMetaData.CatalogName;
762762
}
763763

764-
if (!ADP.IsEmpty(colMetaData.ServerName))
764+
if (!string.IsNullOrEmpty(colMetaData.ServerName))
765765
{
766766
schemaRow[BaseServerName] = colMetaData.ServerName;
767767
}

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ private void OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectio
14941494

14951495
_timeoutErrorInternal.SetInternalSourceType(useFailoverPartner ? SqlConnectionInternalSourceType.Failover : SqlConnectionInternalSourceType.Principle);
14961496

1497-
bool hasFailoverPartner = !ADP.IsEmpty(failoverPartner);
1497+
bool hasFailoverPartner = !string.IsNullOrEmpty(failoverPartner);
14981498

14991499
// Open the connection and Login
15001500
try
@@ -3192,7 +3192,7 @@ internal void SetDerivedNames(string protocol, string serverName)
31923192
// when using the Dbnetlib dll. If the protocol is not specified, the netlib will
31933193
// try all protocols in the order listed in the Client Network Utility. Connect will
31943194
// then fail if all protocols fail.
3195-
if (!ADP.IsEmpty(protocol))
3195+
if (!string.IsNullOrEmpty(protocol))
31963196
{
31973197
ExtendedServerName = protocol + ":" + serverName;
31983198
}

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj)
15881588
* !=null | == 0 | replace text left of errorMessage
15891589
*/
15901590

1591-
Debug.Assert(!ADP.IsEmpty(errorMessage), "Empty error message received from SNI");
1591+
Debug.Assert(!string.IsNullOrEmpty(errorMessage), "Empty error message received from SNI");
15921592

15931593
string sqlContextInfo = StringsHelper.GetString(Enum.GetName(typeof(SniContext), stateObj.SniContext));
15941594
string providerRid = string.Format("SNI_PN{0}", (int)details.provider);
@@ -4863,7 +4863,7 @@ internal TdsOperationStatus TryProcessAltMetaData(int cColumns, TdsParserStateOb
48634863
return result;
48644864
}
48654865

4866-
if (ADP.IsEmpty(col.column))
4866+
if (string.IsNullOrEmpty(col.column))
48674867
{
48684868
// create column name from op
48694869
switch (col.op)

0 commit comments

Comments
 (0)