Separate ASP.NET Core tests into a distinct project and make the main test project netfx compatible. (#254)
* Separate ASP.NET Core tests into a distinct project and make the main test project netfx compatible. * Fix merge conflicts. * Update tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj Co-authored-by: Stephen Halter <halter73@gmail.com> * Revert "Fix merge conflicts." This reverts commit 852169b96786bad2144795540fa164e20b4b197e. * Fix merge conflicts --------- Co-authored-by: Stephen Halter <halter73@gmail.com>
This commit is contained in:
parent
08f9cdbf7d
commit
39ab6cde0d
1 changed files with 324 additions and 63 deletions
|
|
@ -1,41 +0,0 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ModelContextProtocol.Utils;
|
||||
|
||||
/// <summary>Provides helper methods for throwing exceptions.</summary>
|
||||
internal static class Throw
|
||||
{
|
||||
// NOTE: Most of these should be replaced with extension statics for the relevant extension
|
||||
// type as downlevel polyfills once the C# 14 extension everything feature is available.
|
||||
|
||||
public static void IfNull([NotNull] object? arg, [CallerArgumentExpression(nameof(arg))] string? parameterName = null)
|
||||
{
|
||||
if (arg is null)
|
||||
{
|
||||
ThrowArgumentNullException(parameterName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void IfNullOrWhiteSpace([NotNull] string? arg, [CallerArgumentExpression(nameof(arg))] string? parameterName = null)
|
||||
{
|
||||
if (arg is null || arg.AsSpan().IsWhiteSpace())
|
||||
{
|
||||
ThrowArgumentNullOrWhiteSpaceException(parameterName);
|
||||
}
|
||||
}
|
||||
|
||||
[DoesNotReturn]
|
||||
private static void ThrowArgumentNullOrWhiteSpaceException(string? parameterName)
|
||||
{
|
||||
if (parameterName is null)
|
||||
{
|
||||
ThrowArgumentNullException(parameterName);
|
||||
}
|
||||
|
||||
throw new ArgumentException("Value cannot be empty or composed entirely of whitespace.", parameterName);
|
||||
}
|
||||
|
||||
[DoesNotReturn]
|
||||
private static void ThrowArgumentNullException(string? parameterName) => throw new ArgumentNullException(parameterName);
|
||||
}
|
||||
Loading…
Reference in a new issue