From ad0b284f192d1e510ccefcafd6c877243881a7bf Mon Sep 17 00:00:00 2001 From: Erik Ejlskov Jensen Date: Tue, 15 Apr 2025 08:39:11 +0200 Subject: [PATCH] Remove ADP.IsEmpty() --- .../Data/Common/DBConnectionString.cs | 12 ++++++------ .../Data/Common/DbConnectionOptions.cs | 10 +++++----- .../Microsoft/Data/SqlClient/SqlBulkCopy.cs | 12 ++++++------ .../Data/SqlClient/SqlClientPermission.cs | 2 +- .../src/Microsoft/Data/SqlClient/SqlCommand.cs | 16 ++++++++-------- .../Microsoft/Data/SqlClient/SqlConnection.cs | 18 +++++++++--------- .../Data/SqlClient/SqlConnectionFactory.cs | 2 +- .../Data/SqlClient/SqlDataReaderSmi.cs | 12 ++++++------ .../Data/SqlClient/SqlInternalConnectionTds.cs | 4 ++-- .../src/Microsoft/Data/SqlClient/TdsParser.cs | 4 ++-- .../src/Microsoft/Data/Common/AdapterUtil.cs | 1 - .../Sql/SqlDataSourceEnumeratorNativeHelper.cs | 2 +- .../DbConnectionPoolCounters.netfx.cs | 8 ++++---- .../Data/SqlClient/SSPI/SSPIContextProvider.cs | 4 ++-- .../src/Microsoft/Data/SqlClient/SqlUtil.cs | 6 +++--- .../Data/SqlClient/TdsParserStaticMethods.cs | 4 ++-- 16 files changed, 58 insertions(+), 59 deletions(-) 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 66c46602c5..4874179760 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 @@ -113,7 +113,7 @@ private DBConnectionString(DbConnectionOptions connectionOptions, string restric _keychain = connectionOptions.ReplacePasswordPwd(out _encryptedUsersConnectionString, true); } - if (!ADP.IsEmpty(restrictions)) + if (!string.IsNullOrEmpty(restrictions)) { _restrictionValues = ParseRestrictions(restrictions, synonyms); _restrictions = restrictions; @@ -168,7 +168,7 @@ internal string Restrictions StringBuilder builder = new StringBuilder(); for (int i = 0; i < restrictionValues.Length; ++i) { - if (!ADP.IsEmpty(restrictionValues[i])) + if (!string.IsNullOrEmpty(restrictionValues[i])) { builder.Append(restrictionValues[i]); builder.Append("=;"); @@ -496,13 +496,13 @@ private static string[] ParseRestrictions(string restrictions, Dictionary KeyName='{0}'", keyname); #endif string realkeyname = synonyms != null ? (string)synonyms[keyname] : keyname; // MDAC 85144 - if (ADP.IsEmpty(realkeyname)) + if (string.IsNullOrEmpty(realkeyname)) { throw ADP.KeywordNotSupported(keyname); } @@ -559,8 +559,8 @@ private static void Verify(string[] restrictionValues) { for (int i = 1; i < restrictionValues.Length; ++i) { - Debug.Assert(!ADP.IsEmpty(restrictionValues[i - 1]), "empty restriction"); - Debug.Assert(!ADP.IsEmpty(restrictionValues[i]), "empty restriction"); + Debug.Assert(!string.IsNullOrEmpty(restrictionValues[i - 1]), "empty restriction"); + Debug.Assert(!string.IsNullOrEmpty(restrictionValues[i]), "empty restriction"); Debug.Assert(0 >= StringComparer.Ordinal.Compare(restrictionValues[i - 1], restrictionValues[i])); } } 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 e240c3d822..8aee4c800e 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 @@ -34,17 +34,17 @@ internal bool HasBlankPassword { if (_parsetable.ContainsKey(KEY.Password)) { - return ADP.IsEmpty(_parsetable[KEY.Password]); + return string.IsNullOrEmpty(_parsetable[KEY.Password]); } else if (_parsetable.ContainsKey(SYNONYM.Pwd)) { - return ADP.IsEmpty(_parsetable[SYNONYM.Pwd]); // MDAC 83097 + return string.IsNullOrEmpty(_parsetable[SYNONYM.Pwd]); // MDAC 83097 } else { - return (_parsetable.ContainsKey(KEY.User_ID) && !ADP.IsEmpty(_parsetable[KEY.User_ID])) || - (_parsetable.ContainsKey(SYNONYM.UID) && !ADP.IsEmpty(_parsetable[SYNONYM.UID])); + return (_parsetable.ContainsKey(KEY.User_ID) && !string.IsNullOrEmpty(_parsetable[KEY.User_ID])) || + (_parsetable.ContainsKey(SYNONYM.UID) && !string.IsNullOrEmpty(_parsetable[SYNONYM.UID])); } } return false; @@ -178,7 +178,7 @@ internal static string ExpandDataDirectory(string keyword, string value, ref str { throw ADP.InvalidDataDirectory(); } - else if (ADP.IsEmpty(rootFolderPath)) + else if (string.IsNullOrEmpty(rootFolderPath)) { rootFolderPath = AppDomain.CurrentDomain.BaseDirectory; } 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 6dbb50aaa7..e689a5b8e3 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 @@ -420,7 +420,7 @@ private string CreateInitialQuery() { throw SQL.BulkLoadInvalidDestinationTable(DestinationTableName, e); } - if (ADP.IsEmpty(parts[MultipartIdentifier.TableIndex])) + if (string.IsNullOrEmpty(parts[MultipartIdentifier.TableIndex])) { throw SQL.BulkLoadInvalidDestinationTable(DestinationTableName, null); } @@ -442,7 +442,7 @@ private string CreateInitialQuery() string TableName = parts[MultipartIdentifier.TableIndex]; bool isTempTable = TableName.Length > 0 && '#' == TableName[0]; - if (!ADP.IsEmpty(TableName)) + if (!string.IsNullOrEmpty(TableName)) { // Escape table name to be put inside TSQL literal block (within N''). TableName = SqlServerEscapeHelper.EscapeStringAsLiteral(TableName); @@ -451,7 +451,7 @@ private string CreateInitialQuery() } string SchemaName = parts[MultipartIdentifier.SchemaIndex]; - if (!ADP.IsEmpty(SchemaName)) + if (!string.IsNullOrEmpty(SchemaName)) { // Escape schema name to be put inside TSQL literal block (within N''). SchemaName = SqlServerEscapeHelper.EscapeStringAsLiteral(SchemaName); @@ -460,7 +460,7 @@ private string CreateInitialQuery() } string CatalogName = parts[MultipartIdentifier.CatalogIndex]; - if (isTempTable && ADP.IsEmpty(CatalogName)) + if (isTempTable && string.IsNullOrEmpty(CatalogName)) { TDSCommand += string.Format("exec tempdb..{0} N'{1}.{2}'", TableCollationsStoredProc, @@ -471,7 +471,7 @@ private string CreateInitialQuery() else { // VSDD 581951 - escape the catalog name - if (!ADP.IsEmpty(CatalogName)) + if (!string.IsNullOrEmpty(CatalogName)) { CatalogName = SqlServerEscapeHelper.EscapeIdentifier(CatalogName); } @@ -1437,7 +1437,7 @@ private void AppendColumnNameAndTypeName(StringBuilder query, string columnName, private string UnquotedName(string name) { - if (ADP.IsEmpty(name)) + if (string.IsNullOrEmpty(name)) return null; if (name[0] == '[') { 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 7672804655..69cc432e3e 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 @@ -369,7 +369,7 @@ override public SecurityElement ToXml() tmp = value.ConnectionString; // WebData 97375 tmp = EncodeXmlValue(tmp); - if (!ADP.IsEmpty(tmp)) + if (!string.IsNullOrEmpty(tmp)) { valueElement.AddAttribute(XmlStr._ConnectionString, tmp); } 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 9f9c882067..c4c49a9cf2 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 @@ -3388,7 +3388,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 (parsedSProc[3] == null || ADP.IsEmpty(parsedSProc[3])) + if (parsedSProc[3] == null || string.IsNullOrEmpty(parsedSProc[3])) { throw ADP.NoStoredProcedureExists(CommandText); } @@ -3402,14 +3402,14 @@ internal void DeriveParameters() // [user server, if provided].[user catalog, else current database].[sys if 2005, else blank].[sp_procedure_params_rowset] // Server - pass only if user provided. - if (!ADP.IsEmpty(parsedSProc[0])) + if (!string.IsNullOrEmpty(parsedSProc[0])) { SqlCommandSet.BuildStoredProcedureName(cmdText, parsedSProc[0]); cmdText.Append("."); } // Catalog - pass user provided, otherwise use current database. - if (ADP.IsEmpty(parsedSProc[1])) + if (string.IsNullOrEmpty(parsedSProc[1])) { parsedSProc[1] = Connection.Database; } @@ -3459,7 +3459,7 @@ internal void DeriveParameters() param.Value = groupNumber; } - if (!ADP.IsEmpty(parsedSProc[2])) + if (!string.IsNullOrEmpty(parsedSProc[2])) { // SchemaName is 3rd element in parsed array SqlParameter param = paramsCmd.Parameters.Add(new SqlParameter("@procedure_schema", SqlDbType.NVarChar, 255)); param.Value = UnquoteProcedurePart(parsedSProc[2]); @@ -3672,7 +3672,7 @@ private void CheckNotificationStateAndAutoEnlist() if (NotificationAutoEnlist) { string notifyContext = SqlNotificationContext(); - if (!ADP.IsEmpty(notifyContext)) + if (!string.IsNullOrEmpty(notifyContext)) { // Map to dependency by ID set in context data. SqlDependency dependency = SqlDependencyPerAppDomainDispatcher.SingletonInstance.LookupDependencyEntry(notifyContext); @@ -5777,7 +5777,7 @@ private void ValidateCommand(string method, bool async) throw ADP.TransactionConnectionMismatch(); } - if (ADP.IsEmpty(this.CommandText)) + if (string.IsNullOrEmpty(this.CommandText)) { throw ADP.CommandTextRequired(method); } @@ -6772,7 +6772,7 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete if (mt.SqlDbType == SqlDbType.Udt) { string fullTypeName = sqlParam.UdtTypeName; - if (ADP.IsEmpty(fullTypeName)) + if (string.IsNullOrEmpty(fullTypeName)) throw SQL.MustSetUdtTypeNameForUdtParams(); paramList.Append(ParseAndQuoteIdentifier(fullTypeName, true /* is UdtTypeName */)); @@ -6780,7 +6780,7 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete else if (mt.SqlDbType == SqlDbType.Structured) { string typeName = sqlParam.TypeName; - if (ADP.IsEmpty(typeName)) + if (string.IsNullOrEmpty(typeName)) { throw SQL.MustSetTypeNameForParam(mt.TypeName, sqlParam.GetPrefixedParameterName()); } 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 c141793e1b..2258dc23b7 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 @@ -648,7 +648,7 @@ private bool UsesClearUserIdOrPassword(SqlConnectionString opt) bool result = false; if (opt != null) { - result = (!ADP.IsEmpty(opt.UserID) || !ADP.IsEmpty(opt.Password)); + result = (!string.IsNullOrEmpty(opt.UserID) || !string.IsNullOrEmpty(opt.Password)); } return result; } @@ -2258,7 +2258,7 @@ internal void ValidateConnectionForExecute(string method, SqlCommand command) // as native OleDb and Odbc. static internal string FixupDatabaseTransactionName(string name) { - if (!ADP.IsEmpty(name)) + if (!string.IsNullOrEmpty(name)) { return SqlServerEscapeHelper.EscapeIdentifier(name); } @@ -2407,11 +2407,11 @@ public static void ChangePassword(string connectionString, string newPassword) { SqlClientEventSource.Log.TryCorrelationTraceEvent(" ActivityID {0}", ActivityCorrelator.Current); - if (ADP.IsEmpty(connectionString)) + if (string.IsNullOrEmpty(connectionString)) { throw SQL.ChangePasswordArgumentMissing("connectionString"); } - if (ADP.IsEmpty(newPassword)) + if (string.IsNullOrEmpty(newPassword)) { throw SQL.ChangePasswordArgumentMissing("newPassword"); } @@ -2427,7 +2427,7 @@ public static void ChangePassword(string connectionString, string newPassword) { throw SQL.ChangePasswordConflictsWithSSPI(); } - if (!ADP.IsEmpty(connectionOptions.AttachDBFilename)) + if (!string.IsNullOrEmpty(connectionOptions.AttachDBFilename)) { throw SQL.ChangePasswordUseOfUnallowedKey(SqlConnectionString.KEY.AttachDBFilename); } @@ -2450,7 +2450,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent { SqlClientEventSource.Log.TryCorrelationTraceEvent(" ActivityID {0}", ActivityCorrelator.Current); - if (ADP.IsEmpty(connectionString)) + if (string.IsNullOrEmpty(connectionString)) { throw SQL.ChangePasswordArgumentMissing("connectionString"); } @@ -2481,7 +2481,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent SqlConnectionString connectionOptions = SqlConnectionFactory.FindSqlConnectionOptions(key); // Check for incompatible connection string value with SqlCredential - if (!ADP.IsEmpty(connectionOptions.UserID) || !ADP.IsEmpty(connectionOptions.Password)) + if (!string.IsNullOrEmpty(connectionOptions.UserID) || !string.IsNullOrEmpty(connectionOptions.Password)) { throw ADP.InvalidMixedArgumentOfSecureAndClearCredential(); } @@ -2491,7 +2491,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent throw SQL.ChangePasswordConflictsWithSSPI(); } - if (!ADP.IsEmpty(connectionOptions.AttachDBFilename)) + if (!string.IsNullOrEmpty(connectionOptions.AttachDBFilename)) { throw SQL.ChangePasswordUseOfUnallowedKey(SqlConnectionString.KEY.AttachDBFilename); } @@ -2671,7 +2671,7 @@ internal void CheckGetExtendedUDTInfo(SqlMetaDataPriv metaData, bool fThrow) { if (metaData.udt?.Type == null) { // If null, we have not obtained extended info. - Debug.Assert(!ADP.IsEmpty(metaData.udt?.AssemblyQualifiedName), "Unexpected state on GetUDTInfo"); + Debug.Assert(!string.IsNullOrEmpty(metaData.udt?.AssemblyQualifiedName), "Unexpected state on GetUDTInfo"); // Parameter throwOnError determines whether exception from Assembly.Load is thrown. metaData.udt.Type = Type.GetType(typeName: metaData.udt.AssemblyQualifiedName, assemblyResolver: asmRef => ResolveTypeAssembly(asmRef, fThrow), typeResolver: null, throwOnError: fThrow); 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 d9bf71b663..34b496ab02 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 @@ -152,7 +152,7 @@ override protected DbConnectionInternal CreateConnection(DbConnectionOptions opt protected override DbConnectionOptions CreateConnectionOptions(string connectionString, DbConnectionOptions previous) { - Debug.Assert(!ADP.IsEmpty(connectionString), "empty connectionString"); + Debug.Assert(!string.IsNullOrEmpty(connectionString), "empty connectionString"); SqlConnectionString result = new SqlConnectionString(connectionString); return result; } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs index e72c240f23..95a45c428d 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs @@ -736,32 +736,32 @@ public override DataTable GetSchemaTable() schemaRow[IsRowVersion] = false; } - if (!ADP.IsEmpty(colMetaData.ColumnName)) + if (!string.IsNullOrEmpty(colMetaData.ColumnName)) { schemaRow[BaseColumnName] = colMetaData.ColumnName; } - else if (!ADP.IsEmpty(colMetaData.Name)) + else if (!string.IsNullOrEmpty(colMetaData.Name)) { // Use projection name if base column name is not present schemaRow[BaseColumnName] = colMetaData.Name; } - if (!ADP.IsEmpty(colMetaData.TableName)) + if (!string.IsNullOrEmpty(colMetaData.TableName)) { schemaRow[BaseTableName] = colMetaData.TableName; } - if (!ADP.IsEmpty(colMetaData.SchemaName)) + if (!string.IsNullOrEmpty(colMetaData.SchemaName)) { schemaRow[BaseSchemaName] = colMetaData.SchemaName; } - if (!ADP.IsEmpty(colMetaData.CatalogName)) + if (!string.IsNullOrEmpty(colMetaData.CatalogName)) { schemaRow[BaseCatalogName] = colMetaData.CatalogName; } - if (!ADP.IsEmpty(colMetaData.ServerName)) + if (!string.IsNullOrEmpty(colMetaData.ServerName)) { schemaRow[BaseServerName] = colMetaData.ServerName; } 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 75a0f574f0..8079231f61 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 @@ -1494,7 +1494,7 @@ private void OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectio _timeoutErrorInternal.SetInternalSourceType(useFailoverPartner ? SqlConnectionInternalSourceType.Failover : SqlConnectionInternalSourceType.Principle); - bool hasFailoverPartner = !ADP.IsEmpty(failoverPartner); + bool hasFailoverPartner = !string.IsNullOrEmpty(failoverPartner); // Open the connection and Login try @@ -3192,7 +3192,7 @@ internal void SetDerivedNames(string protocol, string serverName) // when using the Dbnetlib dll. If the protocol is not specified, the netlib will // try all protocols in the order listed in the Client Network Utility. Connect will // then fail if all protocols fail. - if (!ADP.IsEmpty(protocol)) + if (!string.IsNullOrEmpty(protocol)) { ExtendedServerName = protocol + ":" + serverName; } 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 77ad3b793b..f1e4a220dc 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 @@ -1588,7 +1588,7 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj) * !=null | == 0 | replace text left of errorMessage */ - Debug.Assert(!ADP.IsEmpty(errorMessage), "Empty error message received from SNI"); + Debug.Assert(!string.IsNullOrEmpty(errorMessage), "Empty error message received from SNI"); string sqlContextInfo = StringsHelper.GetString(Enum.GetName(typeof(SniContext), stateObj.SniContext)); string providerRid = string.Format("SNI_PN{0}", (int)details.provider); @@ -4863,7 +4863,7 @@ internal TdsOperationStatus TryProcessAltMetaData(int cColumns, TdsParserStateOb return result; } - if (ADP.IsEmpty(col.column)) + if (string.IsNullOrEmpty(col.column)) { // create column name from op switch (col.op) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs index f51723ace2..00a4112059 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs @@ -1338,7 +1338,6 @@ internal static Exception InvalidMixedUsageOfAccessTokenCallbackAndIntegratedSec => InvalidOperation(StringsHelper.GetString(Strings.ADP_InvalidMixedUsageOfAccessTokenCallbackAndIntegratedSecurity)); #endregion - internal static bool IsEmpty(string str) => string.IsNullOrEmpty(str); internal static readonly IntPtr s_ptrZero = IntPtr.Zero; #if NETFRAMEWORK #region netfx project only diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorNativeHelper.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorNativeHelper.cs index 138e671dc9..f53732940c 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorNativeHelper.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorNativeHelper.cs @@ -158,7 +158,7 @@ private static DataTable ParseServerEnumString(string serverInstances) string query = "ServerName='" + serverName + "'"; - if (!ADP.IsEmpty(instanceName)) + if (!string.IsNullOrEmpty(instanceName)) { // SQL BU DT 20006584: only append instanceName if present. query += " AND InstanceName='" + instanceName + "'"; } diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolCounters.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolCounters.netfx.cs index 0eadb7f42c..1ca4fe3aa6 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolCounters.netfx.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolCounters.netfx.cs @@ -103,7 +103,7 @@ internal Counter(string categoryName, string instanceName, string counterName, P { try { - if (!ADP.IsEmpty(categoryName) && !ADP.IsEmpty(instanceName)) + if (!string.IsNullOrEmpty(categoryName) && !string.IsNullOrEmpty(instanceName)) { PerformanceCounter instance = new PerformanceCounter(); instance.CategoryName = categoryName; @@ -186,7 +186,7 @@ protected DbConnectionPoolCounters(string categoryName, string categoryHelp) string instanceName = null; - if (!ADP.IsEmpty(categoryName)) + if (!string.IsNullOrEmpty(categoryName)) { if (ADP.s_isPlatformNT5) { @@ -209,7 +209,7 @@ protected DbConnectionPoolCounters(string categoryName, string categoryHelp) // level 4: expensive stuff string verboseCategoryName = null; - if (!ADP.IsEmpty(categoryName)) + if (!string.IsNullOrEmpty(categoryName)) { // don't load TraceSwitch if no categoryName so that Odbc/OleDb have a chance of not loading TraceSwitch // which are also used by System.Diagnostics.PerformanceCounter.ctor & System.Transactions.get_Current @@ -254,7 +254,7 @@ private string GetInstanceName() string instanceName = GetAssemblyName(); // instance perfcounter name - if (ADP.IsEmpty(instanceName)) + if (string.IsNullOrEmpty(instanceName)) { AppDomain appDomain = AppDomain.CurrentDomain; if (appDomain != null) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SSPIContextProvider.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SSPIContextProvider.cs index 6aef7bfbff..69de086a93 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SSPIContextProvider.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SSPIContextProvider.cs @@ -48,8 +48,8 @@ internal void SSPIData(ReadOnlySpan receivedBuff, IBufferWriter outg protected void SSPIError(string error, string procedure) { - Debug.Assert(!ADP.IsEmpty(procedure), "TdsParser.SSPIError called with an empty or null procedure string"); - Debug.Assert(!ADP.IsEmpty(error), "TdsParser.SSPIError called with an empty or null error string"); + Debug.Assert(!string.IsNullOrEmpty(procedure), "TdsParser.SSPIError called with an empty or null procedure string"); + Debug.Assert(!string.IsNullOrEmpty(error), "TdsParser.SSPIError called with an empty or null error string"); _physicalStateObj.AddError(new SqlError(0, (byte)0x00, (byte)TdsEnums.MIN_ERROR_CLASS, _serverInfo.ResolvedServerName, error, procedure, 0)); _parser.ThrowExceptionAndWarning(_physicalStateObj); diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs index c398110849..6efc08c6da 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs @@ -2663,7 +2663,7 @@ internal static class SqlServerEscapeHelper /// escapes the name with [], also escapes the last close bracket with double-bracket internal static string EscapeIdentifier(string name) { - Debug.Assert(!ADP.IsEmpty(name), "null or empty identifiers are not allowed"); + Debug.Assert(!string.IsNullOrEmpty(name), "null or empty identifiers are not allowed"); return "[" + name.Replace("]", "]]") + "]"; } @@ -2673,7 +2673,7 @@ internal static string EscapeIdentifier(string name) internal static void EscapeIdentifier(StringBuilder builder, string name) { Debug.Assert(builder != null, "builder cannot be null"); - Debug.Assert(!ADP.IsEmpty(name), "null or empty identifiers are not allowed"); + Debug.Assert(!string.IsNullOrEmpty(name), "null or empty identifiers are not allowed"); builder.Append("["); builder.Append(name.Replace("]", "]]")); @@ -2698,7 +2698,7 @@ internal static string EscapeStringAsLiteral(string input) /// escaped and quoted literal string internal static string MakeStringLiteral(string input) { - if (ADP.IsEmpty(input)) + if (string.IsNullOrEmpty(input)) { return "''"; } 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 0551bd79c6..e21bfc7826 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStaticMethods.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStaticMethods.cs @@ -23,12 +23,12 @@ private TdsParserStaticMethods() { /* prevent utility class from being insantiat [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)] static internal void AliasRegistryLookup(ref string host, ref string protocol) { - if (!ADP.IsEmpty(host)) + if (!string.IsNullOrEmpty(host)) { const String folder = "SOFTWARE\\Microsoft\\MSSQLServer\\Client\\ConnectTo"; // Put a try...catch... around this so we don't abort ANY connection if we can't read the registry. string aliasLookup = (string)ADP.LocalMachineRegistryValue(folder, host); - if (!ADP.IsEmpty(aliasLookup)) + if (!string.IsNullOrEmpty(aliasLookup)) { /* Result will be in the form of: "DBNMPNTW,\\server\pipe\sql\query". or Result will be in the form of: "DBNETLIB, via:\\server\pipe\sql\query".