diff --git a/api_guard.include.md b/api_guard.include.md index 0bcd4002..44f3e20c 100644 --- a/api_guard.include.md +++ b/api_guard.include.md @@ -16,13 +16,13 @@ * `T NotNullOrEmpty(T) where T : Collections.IEnumerable` * `Memory NotNullOrEmpty(Nullable>)` * `ReadOnlyMemory NotNullOrEmpty(Nullable>)` - * `String NotNullOrWhitespace(String)` - * `Memory NotNullOrWhitespace(Nullable>)` - * `ReadOnlyMemory NotNullOrWhitespace(Nullable>)` - * `void NotWhitespace(String)` - * `void NotWhitespace(ReadOnlySpan)` - * `void NotWhitespace(Nullable>)` - * `void NotWhitespace(Nullable>)` - * `void NotWhitespace(Span)` + * `String NotNullOrWhiteSpace(String)` + * `Memory NotNullOrWhiteSpace(Nullable>)` + * `ReadOnlyMemory NotNullOrWhiteSpace(Nullable>)` + * `void NotWhiteSpace(String)` + * `void NotWhiteSpace(ReadOnlySpan)` + * `void NotWhiteSpace(Nullable>)` + * `void NotWhiteSpace(Nullable>)` + * `void NotWhiteSpace(Span)` diff --git a/api_list.include.md b/api_list.include.md index 700a0c9d..9b986ef1 100644 --- a/api_list.include.md +++ b/api_list.include.md @@ -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, 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)` [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, ReadOnlySpan)` [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, ReadOnlySpan, 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)) @@ -544,14 +544,14 @@ * `T NotNullOrEmpty(T) where T : Collections.IEnumerable` * `Memory NotNullOrEmpty(Nullable>)` * `ReadOnlyMemory NotNullOrEmpty(Nullable>)` - * `String NotNullOrWhitespace(String)` - * `Memory NotNullOrWhitespace(Nullable>)` - * `ReadOnlyMemory NotNullOrWhitespace(Nullable>)` - * `void NotWhitespace(String)` - * `void NotWhitespace(ReadOnlySpan)` - * `void NotWhitespace(Nullable>)` - * `void NotWhitespace(Nullable>)` - * `void NotWhitespace(Span)` + * `String NotNullOrWhiteSpace(String)` + * `Memory NotNullOrWhiteSpace(Nullable>)` + * `ReadOnlyMemory NotNullOrWhiteSpace(Nullable>)` + * `void NotWhiteSpace(String)` + * `void NotWhiteSpace(ReadOnlySpan)` + * `void NotWhiteSpace(Nullable>)` + * `void NotWhiteSpace(Nullable>)` + * `void NotWhiteSpace(Span)` #### TaskCompletionSource diff --git a/readme.md b/readme.md index 256b3249..0770fca0 100644 --- a/readme.md +++ b/readme.md @@ -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, 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)` [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, ReadOnlySpan)` [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, ReadOnlySpan, 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)) @@ -953,14 +953,14 @@ The class `Polyfill` includes the following extension methods: * `T NotNullOrEmpty(T) where T : Collections.IEnumerable` * `Memory NotNullOrEmpty(Nullable>)` * `ReadOnlyMemory NotNullOrEmpty(Nullable>)` - * `String NotNullOrWhitespace(String)` - * `Memory NotNullOrWhitespace(Nullable>)` - * `ReadOnlyMemory NotNullOrWhitespace(Nullable>)` - * `void NotWhitespace(String)` - * `void NotWhitespace(ReadOnlySpan)` - * `void NotWhitespace(Nullable>)` - * `void NotWhitespace(Nullable>)` - * `void NotWhitespace(Span)` + * `String NotNullOrWhiteSpace(String)` + * `Memory NotNullOrWhiteSpace(Nullable>)` + * `ReadOnlyMemory NotNullOrWhiteSpace(Nullable>)` + * `void NotWhiteSpace(String)` + * `void NotWhiteSpace(ReadOnlySpan)` + * `void NotWhiteSpace(Nullable>)` + * `void NotWhiteSpace(Nullable>)` + * `void NotWhiteSpace(Span)` #### TaskCompletionSource @@ -1125,14 +1125,14 @@ With the equivalent Guard APIs: * `T NotNullOrEmpty(T) where T : Collections.IEnumerable` * `Memory NotNullOrEmpty(Nullable>)` * `ReadOnlyMemory NotNullOrEmpty(Nullable>)` - * `String NotNullOrWhitespace(String)` - * `Memory NotNullOrWhitespace(Nullable>)` - * `ReadOnlyMemory NotNullOrWhitespace(Nullable>)` - * `void NotWhitespace(String)` - * `void NotWhitespace(ReadOnlySpan)` - * `void NotWhitespace(Nullable>)` - * `void NotWhitespace(Nullable>)` - * `void NotWhitespace(Span)` + * `String NotNullOrWhiteSpace(String)` + * `Memory NotNullOrWhiteSpace(Nullable>)` + * `ReadOnlyMemory NotNullOrWhiteSpace(Nullable>)` + * `void NotWhiteSpace(String)` + * `void NotWhiteSpace(ReadOnlySpan)` + * `void NotWhiteSpace(Nullable>)` + * `void NotWhiteSpace(Nullable>)` + * `void NotWhiteSpace(Span)` diff --git a/src/Polyfill/Guard_NotNullOrWhitespace.cs b/src/Polyfill/Guard_NotNullOrWhiteSpace2.cs similarity index 93% rename from src/Polyfill/Guard_NotNullOrWhitespace.cs rename to src/Polyfill/Guard_NotNullOrWhiteSpace2.cs index 901fae1f..a98dd67f 100644 --- a/src/Polyfill/Guard_NotNullOrWhitespace.cs +++ b/src/Polyfill/Guard_NotNullOrWhiteSpace2.cs @@ -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 = "") { @@ -47,7 +47,7 @@ public static string NotNullOrWhitespace( } #if FeatureMemory - public static Memory NotNullOrWhitespace( + public static Memory NotNullOrWhiteSpace( [NotNull] Memory? value, [CallerArgumentExpression("value")] string argumentName = "") { @@ -72,7 +72,7 @@ public static Memory NotNullOrWhitespace( throw new ArgumentException("Argument cannot be whitespace.", argumentName); } - public static ReadOnlyMemory NotNullOrWhitespace( + public static ReadOnlyMemory NotNullOrWhiteSpace( [NotNull] ReadOnlyMemory? value, [CallerArgumentExpression("value")] string argumentName = "") { diff --git a/src/Polyfill/Guard_NotWhitespace.cs b/src/Polyfill/Guard_NotWhiteSpace2.cs similarity index 94% rename from src/Polyfill/Guard_NotWhitespace.cs rename to src/Polyfill/Guard_NotWhiteSpace2.cs index cfc037c3..69d1c545 100644 --- a/src/Polyfill/Guard_NotWhitespace.cs +++ b/src/Polyfill/Guard_NotWhiteSpace2.cs @@ -21,7 +21,7 @@ namespace Polyfills; static partial class Guard { - public static void NotWhitespace( + public static void NotWhiteSpace( string? value, [CallerArgumentExpression("value")] string argumentName = "") { @@ -47,7 +47,7 @@ public static void NotWhitespace( } #if FeatureMemory - public static void NotWhitespace( + public static void NotWhiteSpace( ReadOnlySpan value, [CallerArgumentExpression("value")] string argumentName = "") { @@ -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? value, [CallerArgumentExpression("value")] string argumentName = "") { @@ -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? value, [CallerArgumentExpression("value")] string argumentName = "") { @@ -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 value, [CallerArgumentExpression("value")] string argumentName = "") { diff --git a/src/Tests/GuardTests.cs b/src/Tests/GuardTests.cs index 853fd7ae..7af5601c 100644 --- a/src/Tests/GuardTests.cs +++ b/src/Tests/GuardTests.cs @@ -173,18 +173,18 @@ public void NotEmpty() } [Test] - public void NotWhitespace() + public void NotWhiteSpace() { Assert.Throws( - () => Guard.NotWhitespace(" \t")); + () => Guard.NotWhiteSpace(" \t")); Assert.Throws( - () => Guard.NotWhitespace(string.Empty)); + () => Guard.NotWhiteSpace(string.Empty)); #if FeatureMemory Span buffer = []; var spanCaught = false; try { - Guard.NotWhitespace(buffer); + Guard.NotWhiteSpace(buffer); } catch (ArgumentException) { @@ -192,39 +192,39 @@ public void NotWhitespace() } Assert.True(spanCaught); Assert.Throws( - () => Guard.NotWhitespace(Memory.Empty)); + () => Guard.NotWhiteSpace(Memory.Empty)); Assert.Throws( - () => Guard.NotWhitespace(Span.Empty)); + () => Guard.NotWhiteSpace(Span.Empty)); Assert.Throws( - () => Guard.NotWhitespace(ReadOnlyMemory.Empty)); - Guard.NotWhitespace((Memory?) null!); - Guard.NotWhitespace((ReadOnlyMemory?) null!); + () => Guard.NotWhiteSpace(ReadOnlyMemory.Empty)); + Guard.NotWhiteSpace((Memory?) null!); + Guard.NotWhiteSpace((ReadOnlyMemory?) 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( - () => Guard.NotNullOrWhitespace(Memory.Empty)); + () => Guard.NotNullOrWhiteSpace(Memory.Empty)); Assert.Throws( - () => Guard.NotNullOrWhitespace((Memory?)null)); + () => Guard.NotNullOrWhiteSpace((Memory?)null)); Assert.Throws( - () => Guard.NotNullOrWhitespace((ReadOnlyMemory?)null)); + () => Guard.NotNullOrWhiteSpace((ReadOnlyMemory?)null)); Assert.Throws( - () => Guard.NotNullOrWhitespace(ReadOnlyMemory.Empty)); + () => Guard.NotNullOrWhiteSpace(ReadOnlyMemory.Empty)); #endif Assert.Throws( - () => Guard.NotNullOrWhitespace(" \t")); + () => Guard.NotNullOrWhiteSpace(" \t")); Assert.Throws( // ReSharper disable once RedundantCast - () => Guard.NotNullOrWhitespace((string)null!)); + () => Guard.NotNullOrWhiteSpace((string)null!)); Assert.Throws( - () => Guard.NotNullOrWhitespace(string.Empty)); - Guard.NotNullOrWhitespace("value"); + () => Guard.NotNullOrWhiteSpace(string.Empty)); + Guard.NotNullOrWhiteSpace("value"); } } \ No newline at end of file