Skip to content

Commit 3b1c2c0

Browse files
committed
Fix roslyn analyzer issues
``` /__w/1/s/src/libraries/Common/src/System/Data/Common/MultipartIdentifier.cs(71,17): error CA2249: Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249) [/__w/1/s/src/libraries/System.Data.Common/src/System.Data.Common.csproj] /__w/1/s/src/libraries/Common/src/System/Data/Common/MultipartIdentifier.cs(71,55): error CA2249: Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249) [/__w/1/s/src/libraries/System.Data.Common/src/System.Data.Common.csproj] /__w/1/s/src/libraries/Common/src/System/Data/Common/MultipartIdentifier.cs(114,33): error CA2249: Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249) [/__w/1/s/src/libraries/System.Data.Common/src/System.Data.Common.csproj] /__w/1/s/src/libraries/Common/src/System/Data/Common/MultipartIdentifier.cs(136,33): error CA2249: Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249) [/__w/1/s/src/libraries/System.Data.Common/src/System.Data.Common.csproj] /__w/1/s/src/libraries/Common/src/System/Data/Common/MultipartIdentifier.cs(141,33): error CA2249: Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249) [/__w/1/s/src/libraries/System.Data.Common/src/System.Data.Common.csproj] /__w/1/s/src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs(736,56): error CA2249: Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249) [/__w/1/s/src/libraries/System.Data.Common/src/System.Data.Common.csproj] /__w/1/s/src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs(740,56): error CA2249: Use 'string.Contains' instead of 'string.IndexOf' to improve readability (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2249) [/__w/1/s/src/libraries/System.Data.Common/src/System.Data.Common.csproj] ``` Remaining: `/__w/1/s/src/libraries/System.Data.Common/src/System/Data/Common/DbConnectionOptions.cs(168,26): error CA1862: Prefer using 'string.Equals(string, StringComparison)' to perform a case-insensitive comparison (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1862) [/__w/1/s/src/libraries/System.Data.Common/src/System.Data.Common.csproj]`
1 parent 8ed82ef commit 3b1c2c0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/libraries/Common/src/System/Data/Common/MultipartIdentifier.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private static bool IsWhitespace(char ch)
6868
throw ADP.InvalidMultipartNameToManyParts(property, name, limit);
6969
}
7070

71-
if (-1 != leftQuote.IndexOf(separator) || -1 != rightQuote.IndexOf(separator) || leftQuote.Length != rightQuote.Length)
71+
if (leftQuote.Contains(separator) || rightQuote.Contains(separator) || leftQuote.Length != rightQuote.Length)
7272
{
7373
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
7474
}
@@ -111,7 +111,7 @@ private static bool IsWhitespace(char ch)
111111
state = MPIState.MPI_ParseQuote;
112112
}
113113
else
114-
if (-1 != rightQuote.IndexOf(testchar))
114+
if (rightQuote.Contains(testchar))
115115
{ // If we shouldn't see a right quote
116116
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
117117
}
@@ -133,12 +133,12 @@ private static bool IsWhitespace(char ch)
133133
state = MPIState.MPI_Value;
134134
}
135135
else // Quotes are not valid inside a non-quoted name
136-
if (-1 != rightQuote.IndexOf(testchar))
136+
if (rightQuote.Contains(testchar))
137137
{
138138
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
139139
}
140140
else
141-
if (-1 != leftQuote.IndexOf(testchar))
141+
if (leftQuote.Contains(testchar))
142142
{
143143
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
144144
}

src/libraries/System.Data.Common/src/System/Data/Common/DBCommandBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,11 +733,11 @@ private void BuildInformation(DataTable schemaTable)
733733
string quotePrefix = QuotePrefix;
734734
string quoteSuffix = QuoteSuffix;
735735

736-
if (!string.IsNullOrEmpty(quotePrefix) && (-1 != baseTableName.IndexOf(quotePrefix, StringComparison.Ordinal)))
736+
if (!string.IsNullOrEmpty(quotePrefix) && baseTableName.Contains(quotePrefix, StringComparison.Ordinal))
737737
{
738738
throw ADP.DynamicSQLNestedQuote(baseTableName, quotePrefix);
739739
}
740-
if (!string.IsNullOrEmpty(quoteSuffix) && (-1 != baseTableName.IndexOf(quoteSuffix, StringComparison.Ordinal)))
740+
if (!string.IsNullOrEmpty(quoteSuffix) && baseTableName.Contains(quoteSuffix, StringComparison.Ordinal))
741741
{
742742
throw ADP.DynamicSQLNestedQuote(baseTableName, quoteSuffix);
743743
}

0 commit comments

Comments
 (0)