diff --git a/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/.editorconfig b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/.editorconfig
new file mode 100644
index 0000000000..b3c813b5e0
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/.editorconfig
@@ -0,0 +1,9 @@
+# editorconfig.org
+
+# top-most EditorConfig file
+root = false
+
+[*.cs]
+
+# CA1310: Specify StringComparison for correctness
+dotnet_diagnostic.CA1310.severity = error
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/.editorconfig b/src/Microsoft.Data.SqlClient/netcore/src/.editorconfig
index 6225d05c63..b45670d5f5 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/.editorconfig
+++ b/src/Microsoft.Data.SqlClient/netcore/src/.editorconfig
@@ -13,3 +13,6 @@ csharp_prefer_simple_using_statement = false
# SYSLIB0039: Type or member is obsolete
dotnet_diagnostic.SYSLIB0039.severity = suggestion
+
+# CA1310: Specify StringComparison for correctness
+dotnet_diagnostic.CA1310.severity = error
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs
index ac4d3599dd..0e8f2feeca 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIProxy.cs
@@ -675,7 +675,7 @@ private void ReportSNIError(SNIProviders provider)
private bool InferNamedPipesInformation()
{
// If we have a datasource beginning with a pipe or we have already determined that the protocol is Named Pipe
- if (_dataSourceAfterTrimmingProtocol.StartsWith(PipeBeginning) || _connectionProtocol == Protocol.NP)
+ if (_dataSourceAfterTrimmingProtocol.StartsWith(PipeBeginning, StringComparison.Ordinal) || _connectionProtocol == Protocol.NP)
{
// If the data source is "np:servername"
if (!_dataSourceAfterTrimmingProtocol.Contains(PipeBeginning))
@@ -714,7 +714,7 @@ private bool InferNamedPipesInformation()
return false;
}
- if (tokensByBackSlash[4].StartsWith(NamedPipeInstanceNameHeader))
+ if (tokensByBackSlash[4].StartsWith(NamedPipeInstanceNameHeader, StringComparison.Ordinal))
{
InstanceName = tokensByBackSlash[4].Substring(NamedPipeInstanceNameHeader.Length);
}
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 fc7ec7e764..a3c92002d1 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
@@ -369,7 +369,7 @@ private RSACng CreateRSACngProvider(string keyPath, bool isSystemOp)
/// Key identifier inside the CNG provider
private void GetCngProviderAndKeyId(string keyPath, bool isSystemOp, out string cngProvider, out string keyIdentifier)
{
- int indexOfSlash = keyPath.IndexOf(@"/");
+ int indexOfSlash = keyPath.IndexOf(@"/", StringComparison.Ordinal);
if (indexOfSlash == -1)
{
throw SQL.InvalidCngPath(keyPath, 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 40639c382d..891c0e1c61 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
@@ -395,7 +395,7 @@ private RSACryptoServiceProvider CreateRSACryptoProvider(string keyPath, bool is
/// output containing the key name
private void GetCspProviderAndKeyName(string keyPath, bool isSystemOp, out string cspProviderName, out string keyIdentifier)
{
- int indexOfSlash = keyPath.IndexOf(@"/");
+ int indexOfSlash = keyPath.IndexOf(@"/", StringComparison.Ordinal);
if (indexOfSlash == -1)
{
throw SQL.InvalidCspPath(keyPath, isSystemOp);
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 3bb84cee4d..31e880919d 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
@@ -434,7 +434,7 @@ internal void ProcessPendingAck(TdsParserStateObject stateObj)
FQDNforDNSCache = serverInfo.ResolvedServerName;
- int commaPos = FQDNforDNSCache.IndexOf(",");
+ int commaPos = FQDNforDNSCache.IndexOf(",", StringComparison.Ordinal);
if (commaPos != -1)
{
FQDNforDNSCache = FQDNforDNSCache.Substring(0, commaPos);
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs
index 97cabfe674..cfbd2139eb 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs
@@ -453,7 +453,7 @@ static private string GetFullPathInternal(string path)
}
// make sure path is not DOS device path
- if (!path.StartsWith(@"\\") && !System.IO.PathInternal.IsDevice(path.AsSpan()))
+ if (!path.StartsWith(@"\\", StringComparison.Ordinal) && !System.IO.PathInternal.IsDevice(path.AsSpan()))
{
throw ADP.Argument(StringsHelper.GetString(Strings.SqlFileStream_InvalidPath), "path");
}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/.editorconfig b/src/Microsoft.Data.SqlClient/netfx/src/.editorconfig
index f3238bb87b..f6fe9011f8 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/.editorconfig
+++ b/src/Microsoft.Data.SqlClient/netfx/src/.editorconfig
@@ -7,3 +7,6 @@ root = false
# IDE0090: Use 'new(...)'
csharp_style_implicit_object_creation_when_type_is_apparent = false
+
+# CA1310: Specify StringComparison for correctness
+dotnet_diagnostic.CA1310.severity = error
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 7e21441852..6bef73963b 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbConnectionStringCommon.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/DbConnectionStringCommon.cs
@@ -373,7 +373,7 @@ private static bool IsValidAuthenticationMethodEnum()
{
for (int i = 0; i < l; i++)
{
- if (s_supportedAuthenticationModes[i].CompareTo(names[i]) != 0)
+ if (string.Compare(s_supportedAuthenticationModes[i], names[i], StringComparison.Ordinal) != 0)
{
listValid = false;
}
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 6e57bb6c07..60151f1be1 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs
@@ -122,7 +122,7 @@ public override async Task AcquireTokenAsync(SqlAuthenti
// Use Connection timeout value to cancel token acquire request after certain period of time.
cts.CancelAfter(parameters.ConnectionTimeout * 1000); // Convert to milliseconds
- string scope = parameters.Resource.EndsWith(s_defaultScopeSuffix) ? parameters.Resource : parameters.Resource + s_defaultScopeSuffix;
+ string scope = parameters.Resource.EndsWith(s_defaultScopeSuffix, StringComparison.Ordinal) ? parameters.Resource : parameters.Resource + s_defaultScopeSuffix;
string[] scopes = new string[] { scope };
TokenRequestContext tokenRequestContext = new(scopes);
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 10e5fb6697..273728b8b8 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlConnectionString.cs
@@ -983,7 +983,7 @@ private static string GetComputerNameDnsFullyQualified()
{
var domainName = "." + IPGlobalProperties.GetIPGlobalProperties().DomainName;
var hostName = Dns.GetHostName();
- if (domainName != "." && !hostName.EndsWith(domainName))
+ if (domainName != "." && !hostName.EndsWith(domainName, StringComparison.Ordinal))
hostName += domainName;
return hostName;
}
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 d59fa1f91a..d9fea6b211 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlSecurityUtility.cs
@@ -406,7 +406,7 @@ internal static void VerifyColumnMasterKeySignature(string keyStoreName, string
private static bool ShouldUseInstanceLevelProviderFlow(string keyStoreName, SqlConnection connection, SqlCommand command)
{
return InstanceLevelProvidersAreRegistered(connection, command) &&
- !keyStoreName.StartsWith(ADP.ColumnEncryptionSystemProviderNamePrefix);
+ !keyStoreName.StartsWith(ADP.ColumnEncryptionSystemProviderNamePrefix, StringComparison.Ordinal);
}
private static bool InstanceLevelProvidersAreRegistered(SqlConnection connection, SqlCommand command) =>
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/DataCommon/AssemblyResourceManager.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/DataCommon/AssemblyResourceManager.cs
index 9e963a0a00..de72aeefb9 100644
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/DataCommon/AssemblyResourceManager.cs
+++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/DataCommon/AssemblyResourceManager.cs
@@ -47,7 +47,7 @@ public override bool TryGetMember(GetMemberBinder binder, out object result)
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
{
var resourceName = binder.Name;
- if (resourceName.StartsWith("Get_"))
+ if (resourceName.StartsWith("Get_", StringComparison.Ordinal))
resourceName = resourceName.Remove(0, 4);
return TryGetResourceValue(resourceName, args, out result);
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandBuilderTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandBuilderTest.cs
index a237c1579b..cf651b6d46 100644
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandBuilderTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandBuilderTest.cs
@@ -38,8 +38,8 @@ public void CatalogLocation_Value_Invalid()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("'CatalogLocation'") != -1);
- Assert.True(ex.Message.IndexOf("'Start'") != -1);
+ Assert.True(ex.Message.IndexOf("'CatalogLocation'", StringComparison.Ordinal) != -1);
+ Assert.True(ex.Message.IndexOf("'Start'", StringComparison.Ordinal) != -1);
Assert.Null(ex.ParamName);
}
Assert.Equal(CatalogLocation.Start, cb.CatalogLocation);
@@ -55,8 +55,8 @@ public void CatalogLocation_Value_Invalid()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("'CatalogLocation'") != -1);
- Assert.True(ex.Message.IndexOf("'Start'") != -1);
+ Assert.True(ex.Message.IndexOf("'CatalogLocation'", StringComparison.Ordinal) != -1);
+ Assert.True(ex.Message.IndexOf("'Start'", StringComparison.Ordinal) != -1);
Assert.Null(ex.ParamName);
}
Assert.Equal(CatalogLocation.Start, cb.CatalogLocation);
@@ -92,8 +92,8 @@ public void CatalogSeparator_Value_Invalid(string separator)
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("'CatalogSeparator'") != -1);
- Assert.True(ex.Message.IndexOf("'.'") != -1);
+ Assert.True(ex.Message.IndexOf("'CatalogSeparator'", StringComparison.Ordinal) != -1);
+ Assert.True(ex.Message.IndexOf("'.'", StringComparison.Ordinal) != -1);
Assert.Null(ex.ParamName);
}
}
@@ -122,8 +122,8 @@ public void ConflictOption_Value_Invalid()
Assert.Equal(typeof(ArgumentOutOfRangeException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("ConflictOption") != -1);
- Assert.True(ex.Message.IndexOf("666") != -1);
+ Assert.True(ex.Message.IndexOf("ConflictOption", StringComparison.Ordinal) != -1);
+ Assert.True(ex.Message.IndexOf("666", StringComparison.Ordinal) != -1);
Assert.Equal("ConflictOption", ex.ParamName);
}
Assert.Equal(ConflictOption.CompareRowVersion, cb.ConflictOption);
@@ -190,8 +190,8 @@ public void QuoteIdentifier_PrefixSuffix_NoMatch()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("QuotePrefix") != -1);
- Assert.True(ex.Message.IndexOf("QuoteSuffix") != -1);
+ Assert.True(ex.Message.IndexOf("QuotePrefix", StringComparison.Ordinal) != -1);
+ Assert.True(ex.Message.IndexOf("QuoteSuffix", StringComparison.Ordinal) != -1);
Assert.Null(ex.ParamName);
}
@@ -208,8 +208,8 @@ public void QuoteIdentifier_PrefixSuffix_NoMatch()
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("QuotePrefix") != -1);
- Assert.True(ex.Message.IndexOf("QuoteSuffix") != -1);
+ Assert.True(ex.Message.IndexOf("QuotePrefix", StringComparison.Ordinal) != -1);
+ Assert.True(ex.Message.IndexOf("QuoteSuffix", StringComparison.Ordinal) != -1);
Assert.Null(ex.ParamName);
}
}
@@ -340,8 +340,8 @@ public void SchemaSeparator_Value_Invalid(string separator)
Assert.Equal(typeof(ArgumentException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("'SchemaSeparator'") != -1);
- Assert.True(ex.Message.IndexOf("'.'") != -1);
+ Assert.True(ex.Message.IndexOf("'SchemaSeparator'", StringComparison.Ordinal) != -1);
+ Assert.True(ex.Message.IndexOf("'.'", StringComparison.Ordinal) != -1);
Assert.Null(ex.ParamName);
}
}
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandTest.cs
index 560b2a7a64..0a1a8e9ef5 100644
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandTest.cs
@@ -304,7 +304,7 @@ public void CommandType_Value_Invalid()
// The CommandType enumeration value, 666, is invalid
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("666") != -1);
+ Assert.True(ex.Message.IndexOf("666", StringComparison.Ordinal) != -1);
Assert.Equal("CommandType", ex.ParamName);
}
@@ -334,7 +334,7 @@ public void ExecuteNonQuery_Connection_Closed()
// closed.
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("ExecuteNonQuery") != -1);
+ Assert.True(ex.Message.IndexOf("ExecuteNonQuery", StringComparison.Ordinal) != -1);
}
[Fact]
@@ -364,7 +364,7 @@ public void ExecuteReader_Connection_Closed()
// closed.
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("ExecuteReader") != -1);
+ Assert.True(ex.Message.IndexOf("ExecuteReader", StringComparison.Ordinal) != -1);
}
[Fact]
@@ -395,7 +395,7 @@ public void ExecuteScalar_Connection_Closed()
// closed.
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("ExecuteScalar") != -1);
+ Assert.True(ex.Message.IndexOf("ExecuteScalar", StringComparison.Ordinal) != -1);
}
[Fact] // bug #412584
@@ -449,7 +449,7 @@ public void Prepare_Connection_Closed()
// is Closed
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("Prepare") != -1);
+ Assert.True(ex.Message.IndexOf("Prepare", StringComparison.Ordinal) != -1);
// Text, parameters cleared
cmd = new SqlCommand("select count(*) from whatever", cn);
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.cs
index 13fc5c22de..05aebef822 100644
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionTest.cs
@@ -34,7 +34,7 @@ public void Constructor1()
Assert.Null(cn.Site);
Assert.Equal(ConnectionState.Closed, cn.State);
Assert.False(cn.StatisticsEnabled);
- Assert.True(string.Compare(Environment.MachineName, cn.WorkstationId, true) == 0);
+ Assert.True(string.Compare(Environment.MachineName, cn.WorkstationId, StringComparison.OrdinalIgnoreCase) == 0);
}
[Fact]
@@ -54,7 +54,7 @@ public void Constructor2()
Assert.Null(cn.Site);
Assert.Equal(ConnectionState.Closed, cn.State);
Assert.False(cn.StatisticsEnabled);
- Assert.True(string.Compare(Environment.MachineName, cn.WorkstationId, true) == 0);
+ Assert.True(string.Compare(Environment.MachineName, cn.WorkstationId, StringComparison.OrdinalIgnoreCase) == 0);
cn = new SqlConnection((string)null);
Assert.Equal(string.Empty, cn.ConnectionString);
@@ -68,7 +68,7 @@ public void Constructor2()
Assert.Null(cn.Site);
Assert.Equal(ConnectionState.Closed, cn.State);
Assert.False(cn.StatisticsEnabled);
- Assert.True(string.Compare(Environment.MachineName, cn.WorkstationId, true) == 0);
+ Assert.True(string.Compare(Environment.MachineName, cn.WorkstationId, StringComparison.OrdinalIgnoreCase) == 0);
}
[Fact]
@@ -201,7 +201,7 @@ public void ChangePassword_NewPassword_Empty()
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.NotNull(ex.ParamName);
- Assert.True(ex.ParamName.IndexOf("'newPassword'") != -1);
+ Assert.True(ex.ParamName.IndexOf("'newPassword'", StringComparison.Ordinal) != -1);
}
[Fact]
@@ -212,8 +212,8 @@ public void ChangePassword_NewPassword_ExceedMaxLength()
// its limit of '128'
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("'newPassword'") != -1);
- Assert.True(ex.Message.IndexOf("128") != -1);
+ Assert.True(ex.Message.IndexOf("'newPassword'", StringComparison.Ordinal) != -1);
+ Assert.True(ex.Message.IndexOf("128", StringComparison.Ordinal) != -1);
Assert.Null(ex.ParamName);
}
@@ -224,7 +224,7 @@ public void ChangePassword_NewPassword_Null()
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.NotNull(ex.ParamName);
- Assert.True(ex.ParamName.IndexOf("'newPassword'") != -1);
+ Assert.True(ex.ParamName.IndexOf("'newPassword'", StringComparison.Ordinal) != -1);
}
[Fact]
@@ -305,7 +305,7 @@ public void Dispose()
Assert.Equal(string.Empty, cn.Database);
Assert.Equal(string.Empty, cn.DataSource);
Assert.Equal(8000, cn.PacketSize);
- Assert.True(string.Compare(Environment.MachineName, cn.WorkstationId, true) == 0);
+ Assert.True(string.Compare(Environment.MachineName, cn.WorkstationId, StringComparison.OrdinalIgnoreCase) == 0);
Assert.Equal(ConnectionState.Closed, cn.State);
cn.Dispose();
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlParameterTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlParameterTest.cs
index 7a6abdded6..a5172b04bf 100644
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlParameterTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlParameterTest.cs
@@ -1155,7 +1155,7 @@ public void SqlDbTypeTest_Value_Invalid()
Assert.Equal(typeof(ArgumentOutOfRangeException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
- Assert.True(ex.Message.IndexOf("666") != -1);
+ Assert.True(ex.Message.IndexOf("666", StringComparison.Ordinal) != -1);
Assert.Equal("SqlDbType", ex.ParamName);
}
}
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.cs
index 49071def2e..52f52c72df 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.cs
@@ -46,7 +46,7 @@ public void TestKeysFromCertificatesCreatedWithMultipleCryptoProviders(string co
using (Microsoft.Win32.RegistryKey providerKey = defaultCryptoProvidersRegistryKey.OpenSubKey(subKeyName))
{
// Get Provider Name and its type
- providerName = providerKey.Name.Substring(providerKey.Name.LastIndexOf(@"\") + 1);
+ providerName = providerKey.Name.Substring(providerKey.Name.LastIndexOf(@"\", StringComparison.Ordinal) + 1);
providerType = providerKey.GetValue(@"Type").ToString();
// Create a certificate from that provider
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/BulkCopyTruncationTables.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/BulkCopyTruncationTables.cs
index 6b31b0e82c..af4007843e 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/BulkCopyTruncationTables.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/BulkCopyTruncationTables.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System;
using Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted.Setup;
namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted.TestFixtures.Setup
@@ -18,110 +19,110 @@ public BulkCopyTruncationTables(string tableName, ColumnEncryptionKey columnEncr
public override void Create(SqlConnection sqlConnection)
{
- string encryptionInfo = Name.Contains("Target") ? $@" ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = [{ columnEncryptionKey.Name}], ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = '{ColumnEncryptionAlgorithmName}')" : "";
+ string encryptionInfo = Name.Contains("Target") ? $@" ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = [{columnEncryptionKey.Name}], ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = '{ColumnEncryptionAlgorithmName}')" : "";
string c2ColumnType = string.Empty;
- if (Name.StartsWith("AE-TabIntSource-") || Name.StartsWith("AE-TabIntSourceDirect-") || Name.StartsWith("AE-TabIntTargetDirect-"))
+ if (Name.StartsWith("AE-TabIntSource-", StringComparison.Ordinal) || Name.StartsWith("AE-TabIntSourceDirect-", StringComparison.Ordinal) || Name.StartsWith("AE-TabIntTargetDirect-", StringComparison.Ordinal))
{
c2ColumnType = "int";
- if (Name.StartsWith("AE-TabIntSourceDirect-"))
+ if (Name.StartsWith("AE-TabIntSourceDirect-", StringComparison.Ordinal))
{
- c2ColumnType = $"int ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = [{ columnEncryptionKey.Name}], ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = '{ColumnEncryptionAlgorithmName}')";
+ c2ColumnType = $"int ENCRYPTED WITH (COLUMN_ENCRYPTION_KEY = [{columnEncryptionKey.Name}], ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = '{ColumnEncryptionAlgorithmName}')";
}
}
- if (Name.StartsWith("AE-TabTinyIntTarget-"))
+ if (Name.StartsWith("AE-TabTinyIntTarget-", StringComparison.Ordinal))
{
c2ColumnType = "tinyint";
}
- if (Name.StartsWith("AE-TabDatetime2Source-"))
+ if (Name.StartsWith("AE-TabDatetime2Source-", StringComparison.Ordinal))
{
c2ColumnType = "datetime2(6)";
}
- if (Name.StartsWith("AE-TabDatetime2Target-"))
+ if (Name.StartsWith("AE-TabDatetime2Target-", StringComparison.Ordinal))
{
c2ColumnType = "datetime2(2)";
}
- if (Name.StartsWith("AE-TabDecimalSource-"))
+ if (Name.StartsWith("AE-TabDecimalSource-", StringComparison.Ordinal))
{
c2ColumnType = "decimal(10,4)";
}
- if (Name.StartsWith("AE-TabDecimalTarget-"))
+ if (Name.StartsWith("AE-TabDecimalTarget-", StringComparison.Ordinal))
{
c2ColumnType = "decimal(5,2)";
}
- if (Name.StartsWith("AE-TabVarCharSmallSource-") || Name.StartsWith("AE-TabNVarCharSmallSource-"))
+ if (Name.StartsWith("AE-TabVarCharSmallSource-", StringComparison.Ordinal) || Name.StartsWith("AE-TabNVarCharSmallSource-", StringComparison.Ordinal))
{
c2ColumnType = "varchar(10)";
}
- if (Name.StartsWith("AE-TabVarCharTarget-"))
+ if (Name.StartsWith("AE-TabVarCharTarget-", StringComparison.Ordinal))
{
c2ColumnType = "varchar(2) COLLATE Latin1_General_BIN2";
}
- if (Name.StartsWith("AE-TabVarCharMaxSource-") || Name.StartsWith("AE-TabSmallCharMaxTarget-"))
+ if (Name.StartsWith("AE-TabVarCharMaxSource-", StringComparison.Ordinal) || Name.StartsWith("AE-TabSmallCharMaxTarget-", StringComparison.Ordinal))
{
c2ColumnType = "varchar(max) COLLATE Latin1_General_BIN2";
}
- if (Name.StartsWith("AE-TabVarCharMaxTarget-"))
+ if (Name.StartsWith("AE-TabVarCharMaxTarget-", StringComparison.Ordinal))
{
c2ColumnType = "varchar(7000)";
}
- if (Name.StartsWith("AE-TabNVarCharSmallTarget-"))
+ if (Name.StartsWith("AE-TabNVarCharSmallTarget-", StringComparison.Ordinal))
{
c2ColumnType = "nvarchar(2) COLLATE Latin1_General_BIN2";
}
- if (Name.StartsWith("AE-TabNVarCharMaxSource-"))
+ if (Name.StartsWith("AE-TabNVarCharMaxSource-", StringComparison.Ordinal))
{
c2ColumnType = "nvarchar(max) COLLATE Latin1_General_BIN2";
}
- if (Name.StartsWith("AE-TabNVarCharTarget-"))
+ if (Name.StartsWith("AE-TabNVarCharTarget-", StringComparison.Ordinal))
{
c2ColumnType = "nvarchar(4000) COLLATE Latin1_General_BIN2";
}
- if (Name.StartsWith("AE-TabVarBinaryMaxSource-") || Name.StartsWith("AE-TabSmallBinaryMaxTarget-"))
+ if (Name.StartsWith("AE-TabVarBinaryMaxSource-", StringComparison.Ordinal) || Name.StartsWith("AE-TabSmallBinaryMaxTarget-", StringComparison.Ordinal))
{
c2ColumnType = "varbinary(max)";
}
- if (Name.StartsWith("AE-TabVarBinaryTarget-"))
+ if (Name.StartsWith("AE-TabVarBinaryTarget-", StringComparison.Ordinal))
{
c2ColumnType = "varbinary(3000)";
}
- if (Name.StartsWith("AE-TabBinaryMaxSource-"))
+ if (Name.StartsWith("AE-TabBinaryMaxSource-", StringComparison.Ordinal))
{
c2ColumnType = "binary(7000)";
}
- if (Name.StartsWith("AE-TabBinaryTarget-") || Name.StartsWith("AE-TabSmallBinarySource-"))
+ if (Name.StartsWith("AE-TabBinaryTarget-", StringComparison.Ordinal) || Name.StartsWith("AE-TabSmallBinarySource-", StringComparison.Ordinal))
{
c2ColumnType = "binary(3000)";
}
- if (Name.StartsWith("AE-TabSmallBinaryTarget-"))
+ if (Name.StartsWith("AE-TabSmallBinaryTarget-", StringComparison.Ordinal))
{
c2ColumnType = "binary(8000)";
}
- if (Name.StartsWith("AE-TabSmallCharSource-"))
+ if (Name.StartsWith("AE-TabSmallCharSource-", StringComparison.Ordinal))
{
c2ColumnType = "char(8000) COLLATE Latin1_General_BIN2";
}
- if (Name.StartsWith("AE-TabSmallCharTarget-"))
+ if (Name.StartsWith("AE-TabSmallCharTarget-", StringComparison.Ordinal))
{
c2ColumnType = "char(3000) COLLATE Latin1_General_BIN2";
}
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AADUtility.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AADUtility.cs
index 6abff25d13..6733b49b31 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AADUtility.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AADUtility.cs
@@ -96,7 +96,7 @@ HttpRequestMessage getRequestMessage()
if (response.IsSuccessStatusCode)
{
string jsonResponse = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
- int accessTokenStartIndex = jsonResponse.IndexOf(AccessToken) + AccessToken.Length + 3;
+ int accessTokenStartIndex = jsonResponse.IndexOf(AccessToken, StringComparison.Ordinal) + AccessToken.Length + 3;
return jsonResponse.Substring(accessTokenStartIndex, jsonResponse.IndexOf('"', accessTokenStartIndex) - accessTokenStartIndex);
}
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AssemblyResourceManager.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AssemblyResourceManager.cs
index 6ac9105cf5..3beb06dd68 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AssemblyResourceManager.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AssemblyResourceManager.cs
@@ -47,7 +47,7 @@ public override bool TryGetMember(GetMemberBinder binder, out object result)
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
{
var resourceName = binder.Name;
- if (resourceName.StartsWith("Get_"))
+ if (resourceName.StartsWith("Get_", StringComparison.Ordinal))
resourceName = resourceName.Remove(0, 4);
return TryGetResourceValue(resourceName, args, out result);
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
index 598fd1c8d8..9cb15d312d 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
@@ -803,7 +803,7 @@ public static string FetchKeyInConnStr(string connStr, string[] keys)
{
foreach (var key in keys)
{
- if (cp.Trim().ToLower().StartsWith(key.Trim().ToLower()))
+ if (cp.Trim().ToLower().StartsWith(key.Trim().ToLower(), StringComparison.Ordinal))
{
return cp.Substring(cp.IndexOf('=') + 1);
}
@@ -828,7 +828,7 @@ public static string RemoveKeysInConnStr(string connStr, string[] keysToRemove)
bool removeKey = false;
foreach (var keyToRemove in keysToRemove)
{
- if (key.Trim().ToLower().StartsWith(keyToRemove.Trim().ToLower()))
+ if (key.Trim().ToLower().StartsWith(keyToRemove.Trim().ToLower(), StringComparison.Ordinal))
{
removeKey = true;
break;
@@ -857,7 +857,7 @@ public static string RetrieveValueFromConnStr(string connStr, string[] keywords)
{
if (!string.IsNullOrEmpty(key.Trim()))
{
- if (key.Trim().ToLower().StartsWith(keyword.Trim().ToLower()))
+ if (key.Trim().ToLower().StartsWith(keyword.Trim().ToLower(), StringComparison.Ordinal))
{
res = key.Substring(key.IndexOf('=') + 1).Trim();
break;
@@ -880,22 +880,22 @@ public static bool ParseDataSource(string dataSource, out string hostname, out i
if (dataSource.Contains(":"))
{
- dataSource = dataSource.Substring(dataSource.IndexOf(":") + 1);
+ dataSource = dataSource.Substring(dataSource.IndexOf(":", StringComparison.Ordinal) + 1);
}
if (dataSource.Contains(","))
{
- if (!Int32.TryParse(dataSource.Substring(dataSource.LastIndexOf(",") + 1), out port))
+ if (!Int32.TryParse(dataSource.Substring(dataSource.LastIndexOf(",",StringComparison.Ordinal) + 1), out port))
{
return false;
}
- dataSource = dataSource.Substring(0, dataSource.IndexOf(",") - 1);
+ dataSource = dataSource.Substring(0, dataSource.IndexOf(",", StringComparison.Ordinal) - 1);
}
if (dataSource.Contains("\\"))
{
- instanceName = dataSource.Substring(dataSource.LastIndexOf("\\") + 1);
- dataSource = dataSource.Substring(0, dataSource.LastIndexOf("\\"));
+ instanceName = dataSource.Substring(dataSource.LastIndexOf("\\", StringComparison.Ordinal) + 1);
+ dataSource = dataSource.Substring(0, dataSource.LastIndexOf("\\", StringComparison.Ordinal));
}
hostname = dataSource;
@@ -922,7 +922,7 @@ public class BaseEventListener : EventListener
protected override void OnEventSourceCreated(EventSource eventSource)
{
- if (eventSource.Name.StartsWith(Name))
+ if (eventSource.Name.StartsWith(Name, StringComparison.Ordinal))
{
// Collect all traces for better code coverage
EnableEvents(eventSource, EventLevel.LogAlways, EventKeywords.All);
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/SqlClientCustomTokenCredential.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/SqlClientCustomTokenCredential.cs
index 23ed76f81e..c83883fca1 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/SqlClientCustomTokenCredential.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/SqlClientCustomTokenCredential.cs
@@ -114,7 +114,7 @@ private static string ValidateChallenge(string challenge)
string trimmedChallenge = challenge.Trim();
- if (!trimmedChallenge.StartsWith(Bearer))
+ if (!trimmedChallenge.StartsWith(Bearer, StringComparison.Ordinal))
throw new ArgumentException("Challenge is not Bearer", nameof(challenge));
return trimmedChallenge.Substring(Bearer.Length);
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs
index 52e5705140..06080a9ca6 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs
@@ -28,7 +28,7 @@ internal CustomSqlAuthenticationProvider(string appClientId)
public override async Task AcquireTokenAsync(SqlAuthenticationParameters parameters)
{
string s_defaultScopeSuffix = "/.default";
- string scope = parameters.Resource.EndsWith(s_defaultScopeSuffix) ? parameters.Resource : parameters.Resource + s_defaultScopeSuffix;
+ string scope = parameters.Resource.EndsWith(s_defaultScopeSuffix, StringComparison.Ordinal) ? parameters.Resource : parameters.Resource + s_defaultScopeSuffix;
_ = parameters.ServerName;
_ = parameters.DatabaseName;
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlFileStreamTest/SqlFileStreamTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlFileStreamTest/SqlFileStreamTest.cs
index 09c369e11e..c34b7e9ceb 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlFileStreamTest/SqlFileStreamTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlFileStreamTest/SqlFileStreamTest.cs
@@ -216,7 +216,7 @@ private static string SetupFileStreamDB()
{
if (fileStreamDir != null)
{
- if (!fileStreamDir.EndsWith("\\"))
+ if (!fileStreamDir.EndsWith("\\", StringComparison.Ordinal))
{
fileStreamDir += "\\";
}
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs
index 29b3907ef8..31151857c0 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs
@@ -40,7 +40,7 @@ public static void GetSchemaTableTest()
DataTestUtility.AssertEqualsWithDescription($"{db}.sys.hierarchyid".ToUpper(), dataTypeName.ToUpper(), "Unexpected data type name.");
string udtAssemblyName = (string)schemaTable.Rows[0][schemaTable.Columns["UdtAssemblyQualifiedName"]];
- Assert.True(udtAssemblyName?.StartsWith("Microsoft.SqlServer.Types.SqlHierarchyId"), "Unexpected UDT assembly name: " + udtAssemblyName);
+ Assert.True(udtAssemblyName?.StartsWith("Microsoft.SqlServer.Types.SqlHierarchyId", StringComparison.Ordinal), "Unexpected UDT assembly name: " + udtAssemblyName);
}
}
}
@@ -270,21 +270,21 @@ public static void TestUdtSchemaMetadata()
// Validate Microsoft.SqlServer.Types.SqlHierarchyId, Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
column = columns[0];
Assert.Equal("col0", column.ColumnName);
- Assert.True(column.DataTypeName.EndsWith(".hierarchyid"), $"Unexpected DataTypeName \"{column.DataTypeName}\"");
+ Assert.True(column.DataTypeName.EndsWith(".hierarchyid", StringComparison.Ordinal), $"Unexpected DataTypeName \"{column.DataTypeName}\"");
Assert.NotNull(column.UdtAssemblyQualifiedName);
AssertSqlUdtAssemblyQualifiedName(column.UdtAssemblyQualifiedName, "Microsoft.SqlServer.Types.SqlHierarchyId");
// Validate Microsoft.SqlServer.Types.SqlGeometry, Microsoft.SqlServer.Types, Version = 11.0.0.0, Culture = neutral, PublicKeyToken = 89845dcd8080cc91
column = columns[1];
Assert.Equal("col1", column.ColumnName);
- Assert.True(column.DataTypeName.EndsWith(".geometry"), $"Unexpected DataTypeName \"{column.DataTypeName}\"");
+ Assert.True(column.DataTypeName.EndsWith(".geometry", StringComparison.Ordinal), $"Unexpected DataTypeName \"{column.DataTypeName}\"");
Assert.NotNull(column.UdtAssemblyQualifiedName);
AssertSqlUdtAssemblyQualifiedName(column.UdtAssemblyQualifiedName, "Microsoft.SqlServer.Types.SqlGeometry");
// Validate Microsoft.SqlServer.Types.SqlGeography, Microsoft.SqlServer.Types, Version = 11.0.0.0, Culture = neutral, PublicKeyToken = 89845dcd8080cc91
column = columns[2];
Assert.Equal("col2", column.ColumnName);
- Assert.True(column.DataTypeName.EndsWith(".geography"), $"Unexpected DataTypeName \"{column.DataTypeName}\"");
+ Assert.True(column.DataTypeName.EndsWith(".geography", StringComparison.Ordinal), $"Unexpected DataTypeName \"{column.DataTypeName}\"");
Assert.NotNull(column.UdtAssemblyQualifiedName);
AssertSqlUdtAssemblyQualifiedName(column.UdtAssemblyQualifiedName, "Microsoft.SqlServer.Types.SqlGeography");
}
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.cs
index e026674602..9326e5acce 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.cs
@@ -230,7 +230,7 @@ public int CompareTo(object obj)
if (s.IsNull)
return 1;
- return this.ToString().CompareTo(s.ToString());
+ return string.Compare(this.ToString(), s.ToString(), StringComparison.Ordinal);
}
#endregion
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtTest2.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtTest2.cs
index 1f07242ee3..952c49c291 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtTest2.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/UdtTest2.cs
@@ -214,7 +214,7 @@ public void UDTParams_NullInput()
pName.Value = "john";
string spInsertCustomerNoBrackets = spInsertCustomer;
- if (spInsertCustomer.StartsWith("[") && spInsertCustomer.EndsWith("]"))
+ if (spInsertCustomer.StartsWith("[", StringComparison.Ordinal) && spInsertCustomer.EndsWith("]", StringComparison.Ordinal))
spInsertCustomerNoBrackets = spInsertCustomer.Substring(1, spInsertCustomer.Length - 2);
string errorMsg = "Procedure or function '" + spInsertCustomerNoBrackets + "' expects parameter '@addr', which was not supplied.";
diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/AssertExtensions.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/AssertExtensions.cs
index ed0c0af5cf..3368aec05a 100644
--- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/AssertExtensions.cs
+++ b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/Extensions/AssertExtensions.cs
@@ -12,7 +12,7 @@ namespace System
{
public static class AssertExtensions
{
- private static bool IsFullFramework => RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework");
+ private static bool IsFullFramework => RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.Ordinal);
public static void Throws(Action action, string message)
where T : Exception
@@ -35,7 +35,7 @@ public static void Throws(string netCoreParamName, string netFxParamName, Act
IsFullFramework ?
netFxParamName : netCoreParamName;
- if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native"))
+ if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
Assert.Equal(expectedParamName, exception.ParamName);
}
@@ -54,7 +54,7 @@ public static void Throws(string netCoreParamName, string netFxParamName, Fun
IsFullFramework ?
netFxParamName : netCoreParamName;
- if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native"))
+ if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
Assert.Equal(expectedParamName, exception.ParamName);
}
@@ -63,7 +63,7 @@ public static T Throws(string paramName, Action action)
{
T exception = Assert.Throws(action);
- if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native"))
+ if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
Assert.Equal(paramName, exception.ParamName);
return exception;
@@ -82,7 +82,7 @@ public static T Throws(string paramName, Func