// Licensed to the .NET Foundation under one or more agreements. // 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; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using Microsoft.Toolkit.Extensions; #nullable enable namespace Microsoft.Toolkit.Diagnostics { /// /// Helper methods to throw exceptions /// [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1618", Justification = "Internal helper methods")] internal static partial class ThrowHelper { /// /// Throws an when fails. /// /// This method is needed because can't be used as a generic type parameter. [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentExceptionForIsNotEmptyWithSpan(string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(Span).ToTypeString()}) must not be empty"); } /// /// Throws an when fails. /// /// This method is needed because can't be used as a generic type parameter. [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentExceptionForIsNotEmptyWithReadOnlySpan(string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(ReadOnlySpan).ToTypeString()}) must not be empty"); } /// /// Throws an when (or an overload) fails. /// [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowArgumentExceptionForIsNotEmpty(string name) { ThrowArgumentException(name, $"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must not be empty"); } } }