Skip to content

Commit

Permalink
Use StartsWith(char value) for modern TFM
Browse files Browse the repository at this point in the history
  • Loading branch information
jnyrup committed Apr 8, 2023
1 parent d4c4eb5 commit 2a95ebd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Src/FluentAssertions/CallerIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private static bool StartsWithNewKeyword(string candidate)

private static bool IsStringLiteral(string candidate)
{
return candidate.StartsWith("\"", StringComparison.Ordinal);
return candidate.StartsWith('\"');
}

private static bool IsNumeric(string candidate)
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions/Common/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static string Combine(this string @this, string other, string separator =
return @this;
}

if (other.StartsWith("[", StringComparison.Ordinal))
if (other.StartsWith('['))
{
separator = string.Empty;
}
Expand Down
4 changes: 4 additions & 0 deletions Src/FluentAssertions/SystemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ public static bool Contains(this string str, string value, StringComparison comp

public static bool Contains(this string str, char value, StringComparison comparison) =>
str.IndexOf(value, comparison) != -1;

// https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs,1014
public static bool StartsWith(this string str, char value) =>
str.Length != 0 && str[0] == value;
}

0 comments on commit 2a95ebd

Please sign in to comment.