Skip to content

Commit

Permalink
Fix roslyn analyzer issues
Browse files Browse the repository at this point in the history
```
/__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]`
  • Loading branch information
radical committed Jul 29, 2023
1 parent 8ed82ef commit 3b1c2c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static bool IsWhitespace(char ch)
throw ADP.InvalidMultipartNameToManyParts(property, name, limit);
}

if (-1 != leftQuote.IndexOf(separator) || -1 != rightQuote.IndexOf(separator) || leftQuote.Length != rightQuote.Length)
if (leftQuote.Contains(separator) || rightQuote.Contains(separator) || leftQuote.Length != rightQuote.Length)
{
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
}
Expand Down Expand Up @@ -111,7 +111,7 @@ private static bool IsWhitespace(char ch)
state = MPIState.MPI_ParseQuote;
}
else
if (-1 != rightQuote.IndexOf(testchar))
if (rightQuote.Contains(testchar))
{ // If we shouldn't see a right quote
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
}
Expand All @@ -133,12 +133,12 @@ private static bool IsWhitespace(char ch)
state = MPIState.MPI_Value;
}
else // Quotes are not valid inside a non-quoted name
if (-1 != rightQuote.IndexOf(testchar))
if (rightQuote.Contains(testchar))
{
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
}
else
if (-1 != leftQuote.IndexOf(testchar))
if (leftQuote.Contains(testchar))
{
throw ADP.InvalidMultipartNameIncorrectUsageOfQuotes(property, name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,11 +733,11 @@ private void BuildInformation(DataTable schemaTable)
string quotePrefix = QuotePrefix;
string quoteSuffix = QuoteSuffix;

if (!string.IsNullOrEmpty(quotePrefix) && (-1 != baseTableName.IndexOf(quotePrefix, StringComparison.Ordinal)))
if (!string.IsNullOrEmpty(quotePrefix) && baseTableName.Contains(quotePrefix, StringComparison.Ordinal))
{
throw ADP.DynamicSQLNestedQuote(baseTableName, quotePrefix);
}
if (!string.IsNullOrEmpty(quoteSuffix) && (-1 != baseTableName.IndexOf(quoteSuffix, StringComparison.Ordinal)))
if (!string.IsNullOrEmpty(quoteSuffix) && baseTableName.Contains(quoteSuffix, StringComparison.Ordinal))
{
throw ADP.DynamicSQLNestedQuote(baseTableName, quoteSuffix);
}
Expand Down

0 comments on commit 3b1c2c0

Please sign in to comment.