WindowsCommunityToolkit/Microsoft.Toolkit.Diagnostics/Guard.String.cs

408 строки
19 KiB
C#
Исходник Обычный вид История

// Licensed to the .NET Foundation under one or more agreements.
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
using System.Diagnostics.CodeAnalysis;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
using System.Runtime.CompilerServices;
2020-11-22 20:15:26 +03:00
#pragma warning disable CS8777
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
namespace Microsoft.Toolkit.Diagnostics
{
/// <summary>
/// Helper methods to verify conditions when running code.
/// </summary>
public static partial class Guard
{
/// <summary>
/// Asserts that the input <see cref="string"/> instance must be <see langword="null"/> or empty.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor empty.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsNullOrEmpty(string? text, string name)
{
if (string.IsNullOrEmpty(text))
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForIsNullOrEmpty(text, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or empty.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or empty.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
public static void IsNotNullOrEmpty([NotNull] string? text, string name)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
if (!string.IsNullOrEmpty(text))
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForIsNotNullOrEmpty(text, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must be <see langword="null"/> or whitespace.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsNullOrWhiteSpace(string? text, string name)
{
if (string.IsNullOrWhiteSpace(text))
{
return;
}
ThrowHelper.ThrowArgumentExceptionForIsNullOrWhiteSpace(text, name);
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must be <see langword="null"/> or whitespace.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Obsolete("Use " + nameof(IsNullOrWhiteSpace))]
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
public static void IsNullOrWhitespace(string? text, string name)
{
if (string.IsNullOrWhiteSpace(text))
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForIsNullOrWhiteSpace(text, name);
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or whitespace.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsNotNullOrWhiteSpace([NotNull] string? text, string name)
{
if (!string.IsNullOrWhiteSpace(text))
{
return;
}
ThrowHelper.ThrowArgumentExceptionForIsNotNullOrWhiteSpace(text, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or whitespace.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Obsolete("Use " + nameof(IsNotNullOrWhiteSpace))]
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
public static void IsNotNullOrWhitespace([NotNull] string? text, string name)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
if (!string.IsNullOrWhiteSpace(text))
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForIsNotNullOrWhiteSpace(text, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must be empty.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is empty.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsEmpty(string text, string name)
{
if (text.Length == 0)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForIsEmpty(text, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must not be empty.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is empty.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsNotEmpty(string text, string name)
{
if (text.Length != 0)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForIsNotEmpty(text, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must be whitespace.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsWhiteSpace(string text, string name)
{
if (string.IsNullOrWhiteSpace(text))
{
return;
}
ThrowHelper.ThrowArgumentExceptionForIsWhiteSpace(text, name);
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must be whitespace.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is neither <see langword="null"/> nor whitespace.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Obsolete("Use " + nameof(IsWhiteSpace))]
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
public static void IsWhitespace(string text, string name)
{
if (string.IsNullOrWhiteSpace(text))
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForIsWhiteSpace(text, name);
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or whitespace.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsNotWhiteSpace(string text, string name)
{
if (!string.IsNullOrWhiteSpace(text))
{
return;
}
ThrowHelper.ThrowArgumentExceptionForIsNotWhiteSpace(text, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or whitespace.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if <paramref name="text"/> is <see langword="null"/> or whitespace.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Obsolete("Use " + nameof(IsNotWhiteSpace))]
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
public static void IsNotWhitespace(string text, string name)
{
if (!string.IsNullOrWhiteSpace(text))
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForIsNotWhiteSpace(text, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must have a size of a specified value.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to check the size for.</param>
/// <param name="size">The target size to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if the size of <paramref name="text"/> is != <paramref name="size"/>.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void HasSizeEqualTo(string text, int size, string name)
{
if (text.Length == size)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(text, size, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must have a size not equal to a specified value.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to check the size for.</param>
/// <param name="size">The target size to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if the size of <paramref name="text"/> is == <paramref name="size"/>.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void HasSizeNotEqualTo(string text, int size, string name)
{
if (text.Length != size)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo(text, size, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must have a size over a specified value.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to check the size for.</param>
/// <param name="size">The target size to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if the size of <paramref name="text"/> is &lt;= <paramref name="size"/>.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
public static void HasSizeGreaterThan(string text, int size, string name)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
if (text.Length > size)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForHasSizeGreaterThan(text, size, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must have a size of at least specified value.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to check the size for.</param>
/// <param name="size">The target size to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if the size of <paramref name="text"/> is &lt; <paramref name="size"/>.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
public static void HasSizeGreaterThanOrEqualTo(string text, int size, string name)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
if (text.Length >= size)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(text, size, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must have a size of less than a specified value.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to check the size for.</param>
/// <param name="size">The target size to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if the size of <paramref name="text"/> is >= <paramref name="size"/>.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void HasSizeLessThan(string text, int size, string name)
{
if (text.Length < size)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan(text, size, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
/// <summary>
/// Asserts that the input <see cref="string"/> instance must have a size of less than or equal to a specified value.
/// </summary>
/// <param name="text">The input <see cref="string"/> instance to check the size for.</param>
/// <param name="size">The target size to test.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if the size of <paramref name="text"/> is > <paramref name="size"/>.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void HasSizeLessThanOrEqualTo(string text, int size, string name)
{
if (text.Length <= size)
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
{
return;
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(text, size, name);
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
/// <summary>
/// Asserts that the source <see cref="string"/> instance must have the same size of a destination <see cref="string"/> instance.
/// </summary>
/// <param name="source">The source <see cref="string"/> instance to check the size for.</param>
/// <param name="destination">The destination <see cref="string"/> instance to check the size for.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if the size of <paramref name="source"/> is != the one of <paramref name="destination"/>.</exception>
/// <remarks>The <see cref="string"/> type is immutable, but the name of this API is kept for consistency with the other overloads.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void HasSizeEqualTo(string source, string destination, string name)
{
if (source.Length == destination.Length)
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
{
return;
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
}
ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, destination, name);
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
}
/// <summary>
/// Asserts that the source <see cref="string"/> instance must have a size of less than or equal to that of a destination <see cref="string"/> instance.
/// </summary>
/// <param name="source">The source <see cref="string"/> instance to check the size for.</param>
/// <param name="destination">The destination <see cref="string"/> instance to check the size for.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentException">Thrown if the size of <paramref name="source"/> is > the one of <paramref name="destination"/>.</exception>
/// <remarks>The <see cref="string"/> type is immutable, but the name of this API is kept for consistency with the other overloads.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void HasSizeLessThanOrEqualTo(string source, string destination, string name)
{
if (source.Length <= destination.Length)
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
{
return;
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
}
ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(source, destination, name);
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
}
/// <summary>
/// Asserts that the input index is valid for a given <see cref="string"/> instance.
/// </summary>
/// <param name="index">The input index to be used to access <paramref name="text"/>.</param>
/// <param name="text">The input <see cref="string"/> instance to use to validate <paramref name="index"/>.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="index"/> is not valid to access <paramref name="text"/>.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsInRangeFor(int index, string text, string name)
{
if ((uint)index < (uint)text.Length)
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
{
return;
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
}
ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, text, name);
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
}
/// <summary>
/// Asserts that the input index is not valid for a given <see cref="string"/> instance.
/// </summary>
/// <param name="index">The input index to be used to access <paramref name="text"/>.</param>
/// <param name="text">The input <see cref="string"/> instance to use to validate <paramref name="index"/>.</param>
/// <param name="name">The name of the input parameter being tested.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="index"/> is valid to access <paramref name="text"/>.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsNotInRangeFor(int index, string text, string name)
{
if ((uint)index >= (uint)text.Length)
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
{
return;
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
}
ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, text, name);
Guard APIs for .NET Standard 2.1 (#3167) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Added .NET Standard 2.1 target, adjusted imported packages * Added [NotNull] attributes when needed * Added flow attributes to bool Guard APIs * Added missing Guard APIs for the string type * Added shared main unit test project * Removed duplicate files from UWP unit test project * Refactored UWP unit tests project (can't be in same folder as .shproj) * Moved markdown tests back into UWP project * Added UnitTests.NetCore project * Fixed some styling issues in test projects * Added .editorconfig file to UniTests.NetCore project too * Moved .editorconfig file to Shared project folder * Removed NetCore Tests compilation for Native Configuration. * Update Windows Community Toolkit.sln * Updated multiline comments style * Renamed some Guard APIs * Fixed collections tests, moved to shared project * Removed unnecessary [SuppressMessage] attributes * Added internal [NotNull] and [DoesNotReturnIf] attributes * Removed build warnings * Removed leftover compiler directives * Added Guard.IsTrue/False overloads with custom message * Fixed test file location after merge * Fixed Span<T> and Unsafe package references Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> Co-authored-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com> Co-authored-by: Alexandre Zollinger Chohfi <chohfi@outlook.com> Co-authored-by: Michael Hawker MSFT (XAML Llama) <24302614+michael-hawker@users.noreply.github.com>
2020-05-16 00:14:14 +03:00
}
Guard APIs (#3131) * Initial guard APIs added * Added EqualTo and NotEqualTo APIs * Added more Guard APIs * New interval Guard APIs added * Added Guard APIs for IEnumerable<T> values * Renamed APIs * Added Guard APIs for Stream values * Added Guard APIs for ReadOnlySpan<T> values * Added Guard APIs for ReadOnlyMemory<T> values * Code refactoring * Minor code refactoring * Added Guard.IsBitwiseEqualTo<T> API * Added Guard.IsNull API * Code refactoring and optimizations * Code refactoring * Added Guard.HasSizeNotEqualTo<T> API * Added Guard size API overloads for the string type * Added Guard size API overloads for T[] arrays * Code refactoring * Removed unnecessary using directives * Added Guard reference check APIs * Added new Guaard APIs for string values * Improved Guard.IsBitwiseEqualTo<T> API * Improved Guard.IsNull APIs * Added new size APIs for copy operations * Added new type test APIs, minor code tweaks * Minor bug fixes * Added Guard APIs for Task values * Minor code tweak * Added new Guard.IsEmpty APIs * Refactored code to remove unsafe requirement * Added Guard.IsInRange<T> APIs * Added missing type checks in Guard.IsBitwiseEqualTo API * Added ValueTypeExtensions.ToHexString API * Code refactoring * Added ValueTypeExtensions tests * Added general Guard tests * Bug fixes in the Guard class * Minor speed improvements * Code refactoring * Removed unnecessary using directives * More speed improvements and API refactoring * Refactored/fixed some Guard APIs * More bug fixes * Added Guard tests for array APIs * Fixed the Guard.IsNotEmpty<T> array API * Moved exception throwers to separate class * Moved general Guard throwers to separate class * Disabled warning for XML overload resolution * Moved array Guard throwers to separate class * Moved stream Guard throwers to separate class * Fixed some XML docs * Moved enumerable Guard throwers to separate class * Moved task Guard throwers to separate class * Added new Guard APIs for tasks * Moved string Guard throwers to separate class * Moved ReadOnlySpan<T> Guard throwers to separate class * Added Span<T> APIs to the Guard class * Moved ReadOnlyMemory<T> Guard throwers to separate class * Added Memory<T> APIs to the Guard class * Minor code refactoring * Update file headers * Removed unnecessary methods * Added TypeExtensions.ToTypeString extension * Improved error messages for general Guard APIs * Improved error messages for Enumerable Guard APIs * Improved error messages for stream Guard APIs * Improved error messages for array Guard APIs * Improved error messages for string Guard APIs * Improved error messages for task Guard APIs * Improved error messages for span Guard APIs * Improved error messages for memory Guard APIs * Improved type string for nullable types * Improved type string for value tuple types * Minor performance improvement * Added numeric comparison T4 file * Updated .gitignore to skip generated files * Moved comparison Guard APIs to separate file * Renamed template file, fixed incorrect XML doc * Fixed missing blank line * Removed unnecessary type parameters * Moved enumerable Guard APIs to separate file * Code refactoring in the enumerable T4 template * Renamed a file * Added empty template for ThrowHelper.Collection * Code refactoring in the T4 templates * Switched collection throw helpers to T4 generation * Code refactoring * Removed incorrect file header * Added new Guard.IsInRangeFor API * Updated .gitignore, added generated files to source control * Added tests for Guard.IsInRangeFor * Improved formatting of values in error messages * Improved error messages * More improvements to the error messages * Minor code tweaks * Added Guard.IsNotOfType APIs * Added Guard.IsNotAssignableToType APIs * Added Guard.IsDefault<T> APIs * Fixed some XML docs * Added missing [Pure] attribute * Fixed typo in a comment * Removed unnecessary comment after code changes * Added XML comment for the T4 service * Added more comments to ToHexString * Suppressed an incorrect code style warning * Added more tests for Guard.IsInRange * Added Guard.IsNotInRangeFor APIs * Added readme file for the T4 templates * Changed generated files extension to .g.cs to avoid conflicts * Added Guard.IsCloseTo and Guard.IsNotCloseTo APIs * Added tests for IsCloseTo * Updated ".g.cs" extension for generated files Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * Removed extra space (typo) Co-Authored-By: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com> * More tweakes to the Guard.md file * Excluded TypeInfo.g.cs file from .ttinclude from checkout * Added more info about target ranges for some APIs * Added IsCloseTo overloads for long type * Minor code tweaks * Added comment to describe (uint) cast range check trick * Added a nore about the .g.cs files being checked in * Fixed IsCloseTo tests * Fixed IsNull tests Co-authored-by: Michael Hawker MSFT (XAML Llama) <michael.hawker@outlook.com>
2020-03-15 04:13:04 +03:00
}
}