Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Aug 9, 2024
2 parents ea62ecf + 8f18564 commit 3ece6f8
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 62 deletions.
16 changes: 8 additions & 8 deletions api_guard.include.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* `T NotNullOrEmpty<T>(T) where T : Collections.IEnumerable`
* `Memory<Char> NotNullOrEmpty(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrEmpty(Nullable<ReadOnlyMemory<Char>>)`
* `String NotNullOrWhitespace(String)`
* `Memory<Char> NotNullOrWhitespace(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrWhitespace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhitespace(String)`
* `void NotWhitespace(ReadOnlySpan<Char>)`
* `void NotWhitespace(Nullable<Memory<Char>>)`
* `void NotWhitespace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhitespace(Span<Char>)`
* `String NotNullOrWhiteSpace(String)`
* `Memory<Char> NotNullOrWhiteSpace(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrWhiteSpace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhiteSpace(String)`
* `void NotWhiteSpace(ReadOnlySpan<Char>)`
* `void NotWhiteSpace(Nullable<Memory<Char>>)`
* `void NotWhiteSpace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhiteSpace(Span<Char>)`


18 changes: 9 additions & 9 deletions api_list.include.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
* `StringBuilder AppendLine(StringBuilder, IFormatProvider, StringBuilder/AppendInterpolatedStringHandler&)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.appendline#system-text-stringbuilder-appendline(system-iformatprovider-system-text-stringbuilder-appendinterpolatedstringhandler@))
* `void CopyTo(Int32, Span<Char>, Int32)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.copyto#system-text-stringbuilder-copyto(system-int32-system-span((system-char))-system-int32))
* `Boolean Equals(ReadOnlySpan<Char>)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.equals#system-text-stringbuilder-equals(system-readonlyspan((system-char))))
* `Polyfill/ChunkEnumerator GetChunks()` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.getchunks)
* `Polyfills.Polyfill/ChunkEnumerator GetChunks()` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.getchunks)
* `StringBuilder Replace(ReadOnlySpan<Char>, ReadOnlySpan<Char>)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.replace#system-text-stringbuilder-replace(system-readonlyspan((system-char))-system-readonlyspan((system-char))))
* `StringBuilder Replace(ReadOnlySpan<Char>, ReadOnlySpan<Char>, Int32, Int32)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.replace#system-text-stringbuilder-replace(system-char-system-char-system-int32-system-int32))

Expand Down Expand Up @@ -544,14 +544,14 @@
* `T NotNullOrEmpty<T>(T) where T : Collections.IEnumerable`
* `Memory<Char> NotNullOrEmpty(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrEmpty(Nullable<ReadOnlyMemory<Char>>)`
* `String NotNullOrWhitespace(String)`
* `Memory<Char> NotNullOrWhitespace(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrWhitespace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhitespace(String)`
* `void NotWhitespace(ReadOnlySpan<Char>)`
* `void NotWhitespace(Nullable<Memory<Char>>)`
* `void NotWhitespace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhitespace(Span<Char>)`
* `String NotNullOrWhiteSpace(String)`
* `Memory<Char> NotNullOrWhiteSpace(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrWhiteSpace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhiteSpace(String)`
* `void NotWhiteSpace(ReadOnlySpan<Char>)`
* `void NotWhiteSpace(Nullable<Memory<Char>>)`
* `void NotWhiteSpace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhiteSpace(Span<Char>)`


#### TaskCompletionSource
34 changes: 17 additions & 17 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ The class `Polyfill` includes the following extension methods:
* `StringBuilder AppendLine(StringBuilder, IFormatProvider, StringBuilder/AppendInterpolatedStringHandler&)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.appendline#system-text-stringbuilder-appendline(system-iformatprovider-system-text-stringbuilder-appendinterpolatedstringhandler@))
* `void CopyTo(Int32, Span<Char>, Int32)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.copyto#system-text-stringbuilder-copyto(system-int32-system-span((system-char))-system-int32))
* `Boolean Equals(ReadOnlySpan<Char>)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.equals#system-text-stringbuilder-equals(system-readonlyspan((system-char))))
* `Polyfill/ChunkEnumerator GetChunks()` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.getchunks)
* `Polyfills.Polyfill/ChunkEnumerator GetChunks()` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.getchunks)
* `StringBuilder Replace(ReadOnlySpan<Char>, ReadOnlySpan<Char>)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.replace#system-text-stringbuilder-replace(system-readonlyspan((system-char))-system-readonlyspan((system-char))))
* `StringBuilder Replace(ReadOnlySpan<Char>, ReadOnlySpan<Char>, Int32, Int32)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder.replace#system-text-stringbuilder-replace(system-char-system-char-system-int32-system-int32))

Expand Down Expand Up @@ -953,14 +953,14 @@ The class `Polyfill` includes the following extension methods:
* `T NotNullOrEmpty<T>(T) where T : Collections.IEnumerable`
* `Memory<Char> NotNullOrEmpty(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrEmpty(Nullable<ReadOnlyMemory<Char>>)`
* `String NotNullOrWhitespace(String)`
* `Memory<Char> NotNullOrWhitespace(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrWhitespace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhitespace(String)`
* `void NotWhitespace(ReadOnlySpan<Char>)`
* `void NotWhitespace(Nullable<Memory<Char>>)`
* `void NotWhitespace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhitespace(Span<Char>)`
* `String NotNullOrWhiteSpace(String)`
* `Memory<Char> NotNullOrWhiteSpace(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrWhiteSpace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhiteSpace(String)`
* `void NotWhiteSpace(ReadOnlySpan<Char>)`
* `void NotWhiteSpace(Nullable<Memory<Char>>)`
* `void NotWhiteSpace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhiteSpace(Span<Char>)`


#### TaskCompletionSource<!-- endInclude -->
Expand Down Expand Up @@ -1125,14 +1125,14 @@ With the equivalent Guard APIs:
* `T NotNullOrEmpty<T>(T) where T : Collections.IEnumerable`
* `Memory<Char> NotNullOrEmpty(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrEmpty(Nullable<ReadOnlyMemory<Char>>)`
* `String NotNullOrWhitespace(String)`
* `Memory<Char> NotNullOrWhitespace(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrWhitespace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhitespace(String)`
* `void NotWhitespace(ReadOnlySpan<Char>)`
* `void NotWhitespace(Nullable<Memory<Char>>)`
* `void NotWhitespace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhitespace(Span<Char>)`
* `String NotNullOrWhiteSpace(String)`
* `Memory<Char> NotNullOrWhiteSpace(Nullable<Memory<Char>>)`
* `ReadOnlyMemory<Char> NotNullOrWhiteSpace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhiteSpace(String)`
* `void NotWhiteSpace(ReadOnlySpan<Char>)`
* `void NotWhiteSpace(Nullable<Memory<Char>>)`
* `void NotWhiteSpace(Nullable<ReadOnlyMemory<Char>>)`
* `void NotWhiteSpace(Span<Char>)`

<!-- endInclude -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Polyfills;

static partial class Guard
{
public static string NotNullOrWhitespace(
public static string NotNullOrWhiteSpace(
[NotNull] string? value,
[CallerArgumentExpression("value")] string argumentName = "")
{
Expand All @@ -47,7 +47,7 @@ public static string NotNullOrWhitespace(
}

#if FeatureMemory
public static Memory<char> NotNullOrWhitespace(
public static Memory<char> NotNullOrWhiteSpace(
[NotNull] Memory<char>? value,
[CallerArgumentExpression("value")] string argumentName = "")
{
Expand All @@ -72,7 +72,7 @@ public static Memory<char> NotNullOrWhitespace(
throw new ArgumentException("Argument cannot be whitespace.", argumentName);
}

public static ReadOnlyMemory<char> NotNullOrWhitespace(
public static ReadOnlyMemory<char> NotNullOrWhiteSpace(
[NotNull] ReadOnlyMemory<char>? value,
[CallerArgumentExpression("value")] string argumentName = "")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Polyfills;

static partial class Guard
{
public static void NotWhitespace(
public static void NotWhiteSpace(
string? value,
[CallerArgumentExpression("value")] string argumentName = "")
{
Expand All @@ -47,7 +47,7 @@ public static void NotWhitespace(
}
#if FeatureMemory

public static void NotWhitespace(
public static void NotWhiteSpace(
ReadOnlySpan<char> value,
[CallerArgumentExpression("value")] string argumentName = "")
{
Expand All @@ -67,7 +67,7 @@ public static void NotWhitespace(
throw new ArgumentException("Argument cannot be whitespace.", argumentName);
}

public static void NotWhitespace(
public static void NotWhiteSpace(
Memory<char>? value,
[CallerArgumentExpression("value")] string argumentName = "")
{
Expand All @@ -92,7 +92,7 @@ public static void NotWhitespace(
throw new ArgumentException("Argument cannot be whitespace.", argumentName);
}

public static void NotWhitespace(
public static void NotWhiteSpace(
ReadOnlyMemory<char>? value,
[CallerArgumentExpression("value")] string argumentName = "")
{
Expand All @@ -117,7 +117,7 @@ public static void NotWhitespace(
throw new ArgumentException("Argument cannot be whitespace.", argumentName);
}

public static void NotWhitespace(
public static void NotWhiteSpace(
Span<char> value,
[CallerArgumentExpression("value")] string argumentName = "")
{
Expand Down
40 changes: 20 additions & 20 deletions src/Tests/GuardTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,58 +173,58 @@ public void NotEmpty()
}

[Test]
public void NotWhitespace()
public void NotWhiteSpace()
{
Assert.Throws<ArgumentException>(
() => Guard.NotWhitespace(" \t"));
() => Guard.NotWhiteSpace(" \t"));
Assert.Throws<ArgumentException>(
() => Guard.NotWhitespace(string.Empty));
() => Guard.NotWhiteSpace(string.Empty));
#if FeatureMemory
Span<char> buffer = [];
var spanCaught = false;
try
{
Guard.NotWhitespace(buffer);
Guard.NotWhiteSpace(buffer);
}
catch (ArgumentException)
{
spanCaught = true;
}
Assert.True(spanCaught);
Assert.Throws<ArgumentException>(
() => Guard.NotWhitespace(Memory<char>.Empty));
() => Guard.NotWhiteSpace(Memory<char>.Empty));
Assert.Throws<ArgumentException>(
() => Guard.NotWhitespace(Span<char>.Empty));
() => Guard.NotWhiteSpace(Span<char>.Empty));
Assert.Throws<ArgumentException>(
() => Guard.NotWhitespace(ReadOnlyMemory<char>.Empty));
Guard.NotWhitespace((Memory<char>?) null!);
Guard.NotWhitespace((ReadOnlyMemory<char>?) null!);
() => Guard.NotWhiteSpace(ReadOnlyMemory<char>.Empty));
Guard.NotWhiteSpace((Memory<char>?) null!);
Guard.NotWhiteSpace((ReadOnlyMemory<char>?) null!);
#endif
// ReSharper disable once RedundantCast
Guard.NotWhitespace((string)null!);
Guard.NotWhitespace("value");
Guard.NotWhiteSpace((string)null!);
Guard.NotWhiteSpace("value");
}

[Test]
public void NotNullOrWhitespace()
public void NotNullOrWhiteSpace()
{
#if FeatureMemory
Assert.Throws<ArgumentException>(
() => Guard.NotNullOrWhitespace(Memory<char>.Empty));
() => Guard.NotNullOrWhiteSpace(Memory<char>.Empty));
Assert.Throws<ArgumentNullException>(
() => Guard.NotNullOrWhitespace((Memory<char>?)null));
() => Guard.NotNullOrWhiteSpace((Memory<char>?)null));
Assert.Throws<ArgumentNullException>(
() => Guard.NotNullOrWhitespace((ReadOnlyMemory<char>?)null));
() => Guard.NotNullOrWhiteSpace((ReadOnlyMemory<char>?)null));
Assert.Throws<ArgumentException>(
() => Guard.NotNullOrWhitespace(ReadOnlyMemory<char>.Empty));
() => Guard.NotNullOrWhiteSpace(ReadOnlyMemory<char>.Empty));
#endif
Assert.Throws<ArgumentException>(
() => Guard.NotNullOrWhitespace(" \t"));
() => Guard.NotNullOrWhiteSpace(" \t"));
Assert.Throws<ArgumentNullException>(
// ReSharper disable once RedundantCast
() => Guard.NotNullOrWhitespace((string)null!));
() => Guard.NotNullOrWhiteSpace((string)null!));
Assert.Throws<ArgumentException>(
() => Guard.NotNullOrWhitespace(string.Empty));
Guard.NotNullOrWhitespace("value");
() => Guard.NotNullOrWhiteSpace(string.Empty));
Guard.NotNullOrWhiteSpace("value");
}
}

0 comments on commit 3ece6f8

Please sign in to comment.