Skip to content

Commit

Permalink
CA1868 prefer char literal
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnmbond committed Jan 3, 2025
1 parent 9bf9ca7 commit 5c1ad6b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions PanoramicData.Blazor/Extensions/IQueryableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ public static IQueryable<T> ApplyFilter<T>(this IQueryable<T> query, Filter filt
// apply query only if property name is known
if (!string.IsNullOrWhiteSpace(filter.PropertyName))
{
string[] separatorArray = ["|"];
object[] parameters = filter.FilterType switch
{
FilterTypes.In => filter.Value.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.RemoveQuotes()).ToArray(),
FilterTypes.NotIn => filter.Value.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.RemoveQuotes()).ToArray(),
FilterTypes.In => filter.Value.Split(separatorArray, StringSplitOptions.RemoveEmptyEntries).Select(x => x.RemoveQuotes()).ToArray(),
FilterTypes.NotIn => filter.Value.Split(separatorArray, StringSplitOptions.RemoveEmptyEntries).Select(x => x.RemoveQuotes()).ToArray(),
FilterTypes.Range => [filter.Value.RemoveQuotes(), filter.Value2.RemoveQuotes()],
FilterTypes.IsEmpty => [string.Empty],
FilterTypes.IsNotEmpty => [string.Empty],
Expand Down
4 changes: 2 additions & 2 deletions PanoramicData.Blazor/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static string QuoteIfContainsWhitespace(this string text)
{
if (text.Length > 0)
{
if (!(text.StartsWith("\"", StringComparison.Ordinal) && text.StartsWith("\"", StringComparison.Ordinal)) && !(text.StartsWith("#", StringComparison.Ordinal) && text.StartsWith("#", StringComparison.Ordinal)))
if (!(text.StartsWith('"') && text.StartsWith('"')) && !(text.StartsWith('#') && text.StartsWith('#')))
{
if (text.Contains(' ') || text.Contains('\t') || text.Contains('\r') || text.Contains('\n'))
{
Expand All @@ -99,7 +99,7 @@ public static string QuoteIfContainsWhitespace(this string text)

public static string RemoveQuotes(this string text)
{
if (text.StartsWith("\"", StringComparison.Ordinal) && text.EndsWith("\"", StringComparison.Ordinal))
if (text.StartsWith('"') && text.EndsWith('"'))
{
return text[1..^1];
}
Expand Down

0 comments on commit 5c1ad6b

Please sign in to comment.