Skip to content

Commit

Permalink
fix compatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Baker committed Oct 4, 2024
1 parent 22343d5 commit 5f31713
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CodeTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CodeTimer : IDisposable

private CodeTimer(string name)
{
_name = string.IsNullOrWhiteSpace(name)
_name = name.IsNullOrWhiteSpace()
? throw new ArgumentException($"'{nameof(name)}' cannot be null or whitespace.", nameof(name))
: name;

Expand Down
23 changes: 17 additions & 6 deletions StringUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@

namespace System
{
public static class StringUtilities
{
public static bool IsNullOrEmpty(this string s) => string.IsNullOrEmpty(s);
public static bool IsNullOrWhiteSpace(this string s) => string.IsNullOrWhiteSpace(s);
public static bool Contains(this string s, string value, StringComparison comparison) => s.IndexOf(value, comparison) >= 0;
}
public static class StringUtilities
{
public static bool IsNullOrEmpty(this string s) => string.IsNullOrEmpty(s);
public static bool IsNullOrWhiteSpace(this string value)
{
if (value == null) return true;

for (int i = 0; i < value.Length; i++)
{
if (!Char.IsWhiteSpace(value[i])) return false;
}

return true;
}

public static bool Contains(this string s, string value, StringComparison comparison) => s.IndexOf(value, comparison) >= 0;
}
}

0 comments on commit 5f31713

Please sign in to comment.