< Summary

Information
Class: SwiftCollections.Diagnostics.SwiftThrowHelper
Assembly: SwiftCollections
File(s): /home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Diagnostics/SwiftThrowHelper.cs
Line coverage
73%
Covered lines: 83
Uncovered lines: 30
Coverable lines: 113
Total lines: 523
Line coverage: 73.4%
Branch coverage
67%
Covered branches: 57
Total branches: 84
Branch coverage: 67.8%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/SwiftCollections/SwiftCollections/src/SwiftCollections/Diagnostics/SwiftThrowHelper.cs

#LineLine coverage
 1//=======================================================================
 2// SwiftThrowHelper.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8namespace SwiftCollections.Diagnostics;
 9
 10using System;
 11using System.Collections.Generic;
 12using System.Diagnostics.CodeAnalysis;
 13using System.Runtime.CompilerServices;
 14
 15/// <summary>
 16/// Provides allocation-conscious guard helpers for throwing common exceptions.
 17/// </summary>
 18/// <remarks>
 19/// Validation methods keep the success path small and route exception creation through no-inline throw helpers.
 20/// Interpolated custom messages are condition-gated so formatted expressions are not evaluated unless the guard throws.
 21/// </remarks>
 22public static class SwiftThrowHelper
 23{
 24    #region Null Argument Validation
 25
 26    /// <summary>
 27    /// Throws an <see cref="ArgumentNullException"/> if the provided argument is null.
 28    /// </summary>
 29    /// <param name="argument">The argument to check for null.</param>
 30    /// <param name="paramName">The name of the parameter that caused the exception.</param>
 31    /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
 32    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 33    public static void ThrowIfNull(
 34        [NotNull] object? argument,
 35        [CallerArgumentExpression(nameof(argument))] string? paramName = null)
 36    {
 21451037        if (argument is null)
 3138            ThrowArgumentNullException(paramName);
 21447939    }
 40
 41    /// <summary>
 42    /// Throws an <see cref="ArgumentNullException"/> if the provided generic argument is null.
 43    /// </summary>
 44    /// <typeparam name="T">The type of the argument to check.</typeparam>
 45    /// <param name="argument">The argument to check for null.</param>
 46    /// <param name="paramName">The name of the parameter that caused the exception.</param>
 47    /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
 48    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 49    public static void ThrowIfNullGeneric<T>(
 50        [NotNull] T argument,
 51        [CallerArgumentExpression(nameof(argument))] string? paramName = null)
 52    {
 34100753        if (argument is null)
 454            ThrowArgumentNullException(paramName);
 34100355    }
 56
 57    /// <summary>
 58    /// Throws an <see cref="ArgumentNullException"/> if the specified value is null and nulls are not legal for <typepa
 59    /// </summary>
 60    /// <typeparam name="TValue">The value type used to determine whether null is legal.</typeparam>
 61    /// <param name="value">The value to check.</param>
 62    /// <param name="defaultValue">A default value of type <typeparamref name="TValue"/> used to determine if nulls are 
 63    /// <param name="paramName">The name of the parameter that caused the exception.</param>
 64    /// <exception cref="ArgumentNullException">Thrown when the value is null and nulls are illegal.</exception>
 65    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 66    public static void ThrowIfNullAndNullsAreIllegal<TValue>(
 67        object? value,
 68        TValue? defaultValue,
 69        [CallerArgumentExpression(nameof(value))] string? paramName = null)
 70    {
 1571        if (value is null && defaultValue is not null)
 172            ThrowArgumentNullException(paramName);
 1473    }
 74
 75    [DoesNotReturn]
 76    [MethodImpl(MethodImplOptions.NoInlining)]
 77    private static void ThrowArgumentNullException(string? paramName)
 78    {
 3679        paramName = NormalizeParamName(paramName);
 80
 3681        if (string.IsNullOrEmpty(paramName))
 082            throw new ArgumentNullException(null, "Value cannot be null.");
 83
 3684        throw new ArgumentNullException(paramName);
 85    }
 86
 87    #endregion
 88
 89    #region Out of Range Validation
 90
 91    /// <summary>
 92    /// Throws an <see cref="ArgumentOutOfRangeException"/> if the specified value is negative.
 93    /// </summary>
 94    /// <param name="value">The value to check.</param>
 95    /// <param name="paramName">The name of the parameter that caused the exception.</param>
 96    /// <exception cref="ArgumentOutOfRangeException">Thrown when the value is negative.</exception>
 97    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 98    public static void ThrowIfNegative(
 99        int value,
 100        [CallerArgumentExpression(nameof(value))] string? paramName = null)
 101    {
 356102        if (value < 0)
 103        {
 5104            paramName = NormalizeParamName(paramName);
 5105            ThrowArgumentOutOfRangeException(paramName, value, GetNonNegativeMessage(paramName));
 106        }
 351107    }
 108
 109    /// <summary>
 110    /// Throws an <see cref="ArgumentOutOfRangeException"/> if the specified value is negative or zero.
 111    /// </summary>
 112    /// <param name="value">The value to check.</param>
 113    /// <param name="paramName">The name of the parameter that caused the exception.</param>
 114    /// <exception cref="ArgumentOutOfRangeException">Thrown when the value is negative or zero.</exception>
 115    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 116    public static void ThrowIfNegativeOrZero(
 117        int value,
 118        [CallerArgumentExpression(nameof(value))] string? paramName = null)
 119    {
 102120        if (value <= 0)
 121        {
 2122            paramName = NormalizeParamName(paramName);
 2123            ThrowArgumentOutOfRangeException(paramName, value, GetPositiveMessage(paramName));
 124        }
 100125    }
 126
 127    /// <summary>
 128    /// Throws an <see cref="ArgumentOutOfRangeException"/> if the specified condition is true.
 129    /// </summary>
 130    /// <param name="condition">The condition to evaluate.</param>
 131    /// <param name="actualValue">The value that caused the exception.</param>
 132    /// <param name="paramName">The name of the parameter that caused the exception.</param>
 133    /// <param name="message">An optional message to include in the exception.</param>
 134    /// <exception cref="ArgumentOutOfRangeException">Thrown when the condition is true.</exception>
 135    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 136    public static void ThrowIfArgumentOutOfRange(
 137        [DoesNotReturnIf(true)] bool condition,
 138        int? actualValue,
 139        [CallerArgumentExpression(nameof(actualValue))] string? paramName = null,
 140        string? message = null)
 141    {
 170142        if (condition)
 143        {
 4144            paramName = NormalizeParamName(paramName);
 4145            ThrowArgumentOutOfRangeException(paramName, actualValue, message ?? GetArgumentOutOfRangeMessage(paramName))
 146        }
 166147    }
 148
 149    /// <summary>
 150    /// Throws an <see cref="ArgumentOutOfRangeException"/> with a lazily formatted message if the specified condition i
 151    /// </summary>
 152    /// <param name="condition">The condition to evaluate.</param>
 153    /// <param name="actualValue">The value that caused the exception.</param>
 154    /// <param name="message">The interpolated exception message.</param>
 155    /// <exception cref="ArgumentOutOfRangeException">Thrown when the condition is true.</exception>
 156    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 157    public static void ThrowIfArgumentOutOfRange(
 158        [DoesNotReturnIf(true)] bool condition,
 159        int? actualValue,
 160        [InterpolatedStringHandlerArgument(nameof(condition))] SwiftThrowInterpolatedStringHandler message)
 161    {
 0162        if (condition)
 0163            ThrowArgumentOutOfRangeException(null, actualValue, message.GetFormattedText());
 0164    }
 165
 166    /// <summary>
 167    /// Throws an <see cref="ArgumentOutOfRangeException"/> with a lazily formatted message if the specified condition i
 168    /// </summary>
 169    /// <param name="condition">The condition to evaluate.</param>
 170    /// <param name="actualValue">The value that caused the exception.</param>
 171    /// <param name="paramName">The name of the parameter that caused the exception.</param>
 172    /// <param name="message">The interpolated exception message.</param>
 173    /// <exception cref="ArgumentOutOfRangeException">Thrown when the condition is true.</exception>
 174    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 175    public static void ThrowIfArgumentOutOfRange(
 176        [DoesNotReturnIf(true)] bool condition,
 177        int? actualValue,
 178        string? paramName,
 179        [InterpolatedStringHandlerArgument(nameof(condition))] SwiftThrowInterpolatedStringHandler message)
 180    {
 1181        if (condition)
 182        {
 0183            paramName = NormalizeParamName(paramName);
 0184            ThrowArgumentOutOfRangeException(paramName, actualValue, message.GetFormattedText());
 185        }
 1186    }
 187
 188    /// <summary>
 189    /// Throws an <see cref="ArgumentOutOfRangeException"/> if a copy destination index is outside [0, length].
 190    /// </summary>
 191    /// <param name="index">The destination index to check.</param>
 192    /// <param name="length">The destination length.</param>
 193    /// <param name="paramName">The name of the parameter that caused the exception.</param>
 194    /// <exception cref="ArgumentOutOfRangeException">Thrown when the index is outside [0, length].</exception>
 195    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 196    public static void ThrowIfArrayIndexInvalid(
 197        int index,
 198        int length,
 199        [CallerArgumentExpression(nameof(index))] string? paramName = null)
 200    {
 194201        if ((uint)index > (uint)length)
 202        {
 7203            paramName = NormalizeParamName(paramName);
 7204            ThrowArgumentOutOfRangeException(paramName, index, "Array index is out of range.");
 205        }
 187206    }
 207
 208    [DoesNotReturn]
 209    [MethodImpl(MethodImplOptions.NoInlining)]
 210    private static void ThrowArgumentOutOfRangeException(string? paramName, object? actualValue, string message) =>
 18211        throw new ArgumentOutOfRangeException(paramName, actualValue, message);
 212
 213    #endregion
 214
 215    #region Invalid State Validation
 216
 217    /// <summary>
 218    /// Throws an <see cref="ArgumentException"/> if the specified condition is true.
 219    /// </summary>
 220    /// <param name="condition">The condition to evaluate.</param>
 221    /// <param name="paramName">The name of the parameter that caused the exception.</param>
 222    /// <param name="message">An optional message to include in the exception.</param>
 223    /// <exception cref="ArgumentException">Thrown when the condition is true.</exception>
 224    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 225    public static void ThrowIfArgument(
 226        [DoesNotReturnIf(true)] bool condition,
 227        string? paramName = null,
 228        string? message = null)
 229    {
 219230        if (condition)
 231        {
 31232            paramName = NormalizeParamName(paramName);
 31233            ThrowArgumentException(paramName, message ?? GetArgumentMessage(paramName));
 234        }
 188235    }
 236
 237    /// <summary>
 238    /// Throws an <see cref="ArgumentException"/> with a lazily formatted message if the specified condition is true.
 239    /// </summary>
 240    /// <param name="condition">The condition to evaluate.</param>
 241    /// <param name="message">The interpolated exception message.</param>
 242    /// <exception cref="ArgumentException">Thrown when the condition is true.</exception>
 243    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 244    public static void ThrowIfArgument(
 245        [DoesNotReturnIf(true)] bool condition,
 246        [InterpolatedStringHandlerArgument(nameof(condition))] SwiftThrowInterpolatedStringHandler message)
 247    {
 0248        if (condition)
 0249            ThrowArgumentException(null, message.GetFormattedText());
 0250    }
 251
 252    /// <summary>
 253    /// Throws an <see cref="ArgumentException"/> with a lazily formatted message if the specified condition is true.
 254    /// </summary>
 255    /// <param name="condition">The condition to evaluate.</param>
 256    /// <param name="paramName">The name of the parameter that caused the exception.</param>
 257    /// <param name="message">The interpolated exception message.</param>
 258    /// <exception cref="ArgumentException">Thrown when the condition is true.</exception>
 259    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 260    public static void ThrowIfArgument(
 261        [DoesNotReturnIf(true)] bool condition,
 262        string? paramName,
 263        [InterpolatedStringHandlerArgument(nameof(condition))] SwiftThrowInterpolatedStringHandler message)
 264    {
 2265        if (condition)
 266        {
 1267            paramName = NormalizeParamName(paramName);
 1268            ThrowArgumentException(paramName, message.GetFormattedText());
 269        }
 1270    }
 271
 272    [DoesNotReturn]
 273    [MethodImpl(MethodImplOptions.NoInlining)]
 274    private static void ThrowArgumentException(string? paramName, string message) =>
 32275        throw new ArgumentException(message, paramName);
 276
 277    /// <summary>
 278    /// Throws an <see cref="InvalidOperationException"/> if the specified condition is true.
 279    /// </summary>
 280    /// <param name="condition">The condition to evaluate.</param>
 281    /// <param name="objectName">The name of the object in an invalid state.</param>
 282    /// <param name="message">An optional message to include in the exception.</param>
 283    /// <exception cref="InvalidOperationException">Thrown when the condition is true.</exception>
 284    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 285    public static void ThrowIfTrue(
 286        [DoesNotReturnIf(true)] bool condition,
 287        string? objectName = null,
 288        string? message = null)
 289    {
 1948290        if (condition)
 39291            ThrowInvalidOperationException(message ?? GetInvalidOperationMessage(objectName));
 1909292    }
 293
 294    /// <summary>
 295    /// Throws an <see cref="InvalidOperationException"/> with a lazily formatted message if the specified condition is 
 296    /// </summary>
 297    /// <param name="condition">The condition to evaluate.</param>
 298    /// <param name="message">The interpolated exception message.</param>
 299    /// <exception cref="InvalidOperationException">Thrown when the condition is true.</exception>
 300    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 301    public static void ThrowIfTrue(
 302        [DoesNotReturnIf(true)] bool condition,
 303        [InterpolatedStringHandlerArgument(nameof(condition))] SwiftThrowInterpolatedStringHandler message)
 304    {
 0305        if (condition)
 0306            ThrowInvalidOperationException(message.GetFormattedText());
 0307    }
 308
 309    /// <summary>
 310    /// Throws an <see cref="InvalidOperationException"/> with a lazily formatted message if the specified condition is 
 311    /// </summary>
 312    /// <param name="condition">The condition to evaluate.</param>
 313    /// <param name="objectName">The name of the object in an invalid state.</param>
 314    /// <param name="message">The interpolated exception message.</param>
 315    /// <exception cref="InvalidOperationException">Thrown when the condition is true.</exception>
 316    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 317    public static void ThrowIfTrue(
 318        [DoesNotReturnIf(true)] bool condition,
 319        string? objectName,
 320        [InterpolatedStringHandlerArgument(nameof(condition))] SwiftThrowInterpolatedStringHandler message)
 321    {
 0322        if (condition)
 0323            ThrowInvalidOperationException(message.GetFormattedText());
 0324    }
 325
 326    [DoesNotReturn]
 327    [MethodImpl(MethodImplOptions.NoInlining)]
 328    private static void ThrowInvalidOperationException(string message) =>
 39329        throw new InvalidOperationException(message);
 330
 331    /// <summary>
 332    /// Throws an <see cref="ObjectDisposedException"/> if the specified condition is true.
 333    /// </summary>
 334    /// <param name="condition">The condition to evaluate.</param>
 335    /// <param name="objectName">The name of the object that has been disposed.</param>
 336    /// <param name="message">An optional message to include in the exception.</param>
 337    /// <exception cref="ObjectDisposedException">Thrown when the condition is true.</exception>
 338    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 339    public static void ThrowIfDisposed(
 340        [DoesNotReturnIf(true)] bool condition,
 341        string? objectName = null,
 342        string? message = null)
 343    {
 235344        if (condition)
 20345            ThrowObjectDisposedException(objectName, message ?? GetObjectDisposedMessage(objectName));
 215346    }
 347
 348    /// <summary>
 349    /// Throws an <see cref="ObjectDisposedException"/> with a lazily formatted message if the specified condition is tr
 350    /// </summary>
 351    /// <param name="condition">The condition to evaluate.</param>
 352    /// <param name="message">The interpolated exception message.</param>
 353    /// <exception cref="ObjectDisposedException">Thrown when the condition is true.</exception>
 354    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 355    public static void ThrowIfDisposed(
 356        [DoesNotReturnIf(true)] bool condition,
 357        [InterpolatedStringHandlerArgument(nameof(condition))] SwiftThrowInterpolatedStringHandler message)
 358    {
 0359        if (condition)
 0360            ThrowObjectDisposedException(null, message.GetFormattedText());
 0361    }
 362
 363    /// <summary>
 364    /// Throws an <see cref="ObjectDisposedException"/> with a lazily formatted message if the specified condition is tr
 365    /// </summary>
 366    /// <param name="condition">The condition to evaluate.</param>
 367    /// <param name="objectName">The name of the object that has been disposed.</param>
 368    /// <param name="message">The interpolated exception message.</param>
 369    /// <exception cref="ObjectDisposedException">Thrown when the condition is true.</exception>
 370    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 371    public static void ThrowIfDisposed(
 372        [DoesNotReturnIf(true)] bool condition,
 373        string? objectName,
 374        [InterpolatedStringHandlerArgument(nameof(condition))] SwiftThrowInterpolatedStringHandler message)
 375    {
 0376        if (condition)
 0377            ThrowObjectDisposedException(objectName, message.GetFormattedText());
 0378    }
 379
 380    [DoesNotReturn]
 381    [MethodImpl(MethodImplOptions.NoInlining)]
 382    private static void ThrowObjectDisposedException(string? objectName, string message) =>
 20383        throw new ObjectDisposedException(objectName, message);
 384
 385    /// <summary>
 386    /// Throws a <see cref="KeyNotFoundException"/> if the specified index is negative.
 387    /// </summary>
 388    /// <param name="index">The index to check.</param>
 389    /// <param name="key">The key associated with the index.</param>
 390    /// <exception cref="KeyNotFoundException">Thrown when the index is negative.</exception>
 391    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 392    public static void ThrowIfKeyInvalid(int index, object? key = null)
 393    {
 4341394        if (index < 0)
 3395            ThrowKeyNotFoundException(GetKeyNotFoundMessage(key));
 4338396    }
 397
 398    /// <summary>
 399    /// Throws a <see cref="KeyNotFoundException"/> if the specified condition is true.
 400    /// </summary>
 401    /// <param name="condition">The condition to evaluate.</param>
 402    /// <param name="key">The key associated with the lookup.</param>
 403    /// <param name="message">An optional message to include in the exception.</param>
 404    /// <exception cref="KeyNotFoundException">Thrown when the condition is true.</exception>
 405    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 406    public static void ThrowIfKeyNotFound(
 407        [DoesNotReturnIf(true)] bool condition,
 408        object? key = null,
 409        string? message = null)
 410    {
 42411        if (condition)
 3412            ThrowKeyNotFoundException(message ?? GetKeyNotFoundMessage(key));
 39413    }
 414
 415    /// <summary>
 416    /// Throws a <see cref="KeyNotFoundException"/> with a lazily formatted message if the specified condition is true.
 417    /// </summary>
 418    /// <param name="condition">The condition to evaluate.</param>
 419    /// <param name="message">The interpolated exception message.</param>
 420    /// <exception cref="KeyNotFoundException">Thrown when the condition is true.</exception>
 421    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 422    public static void ThrowIfKeyNotFound(
 423        [DoesNotReturnIf(true)] bool condition,
 424        [InterpolatedStringHandlerArgument(nameof(condition))] SwiftThrowInterpolatedStringHandler message)
 425    {
 0426        if (condition)
 0427            ThrowKeyNotFoundException(message.GetFormattedText());
 0428    }
 429
 430    /// <summary>
 431    /// Throws a <see cref="KeyNotFoundException"/> with a lazily formatted message if the specified condition is true.
 432    /// </summary>
 433    /// <param name="condition">The condition to evaluate.</param>
 434    /// <param name="key">The key associated with the lookup.</param>
 435    /// <param name="message">The interpolated exception message.</param>
 436    /// <exception cref="KeyNotFoundException">Thrown when the condition is true.</exception>
 437    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 438    public static void ThrowIfKeyNotFound(
 439        [DoesNotReturnIf(true)] bool condition,
 440        object? key,
 441        [InterpolatedStringHandlerArgument(nameof(condition))] SwiftThrowInterpolatedStringHandler message)
 442    {
 0443        if (condition)
 0444            ThrowKeyNotFoundException(message.GetFormattedText());
 0445    }
 446
 447    [DoesNotReturn]
 448    [MethodImpl(MethodImplOptions.NoInlining)]
 449    private static void ThrowKeyNotFoundException(string message) =>
 6450        throw new KeyNotFoundException(message);
 451
 452    /// <summary>
 453    /// Throws an <see cref="IndexOutOfRangeException"/> if the specified index is outside the valid range defined by co
 454    /// </summary>
 455    /// <param name="index">The index to check.</param>
 456    /// <param name="count">The total number of elements in the collection.</param>
 457    /// <exception cref="IndexOutOfRangeException">Thrown when the index is outside the valid range.</exception>
 458    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 459    public static void ThrowIfListIndexInvalid(
 460        int index,
 461        int count)
 462    {
 8195463        if ((uint)index >= (uint)count)
 11464            ThrowIndexOutOfRangeException(index);
 8184465    }
 466
 467    [DoesNotReturn]
 468    [MethodImpl(MethodImplOptions.NoInlining)]
 469    private static void ThrowIndexOutOfRangeException(int value) =>
 11470        throw new IndexOutOfRangeException($"Index out of range: {value}");
 471
 472    #endregion
 473
 474    #region Message Helpers
 475
 476    private static string GetNonNegativeMessage(string? paramName) =>
 5477        string.IsNullOrEmpty(paramName)
 5478            ? "Value must be non-negative."
 5479            : $"{paramName} must be non-negative.";
 480
 481    private static string GetPositiveMessage(string? paramName) =>
 2482        string.IsNullOrEmpty(paramName)
 2483            ? "Value must be greater than zero."
 2484            : $"{paramName} must be greater than zero.";
 485
 486    private static string GetArgumentOutOfRangeMessage(string? paramName) =>
 2487        string.IsNullOrEmpty(paramName)
 2488            ? "Specified argument was out of range."
 2489            : $"{paramName} is out of range.";
 490
 491    private static string GetArgumentMessage(string? paramName) =>
 0492        string.IsNullOrEmpty(paramName)
 0493            ? "The argument is invalid."
 0494            : $"{paramName} is invalid.";
 495
 496    private static string GetInvalidOperationMessage(string? objectName) =>
 2497        string.IsNullOrEmpty(objectName)
 2498            ? "Operation is not valid in the current state."
 2499            : $"Object '{objectName}' is in an invalid state.";
 500
 501    private static string GetObjectDisposedMessage(string? objectName) =>
 20502        string.IsNullOrEmpty(objectName)
 20503            ? "Object has been disposed."
 20504            : $"Object '{objectName}' has been disposed.";
 505
 506    private static string GetKeyNotFoundMessage(object? key) =>
 6507        key is null
 6508            ? "Key was not found."
 6509            : $"Key not found: {key}";
 510
 511    private static string? NormalizeParamName(string? paramName)
 512    {
 86513        if (string.IsNullOrEmpty(paramName) || paramName == "null")
 1514            return null;
 515
 85516        char first = paramName[0];
 85517        return char.IsLetter(first) || first == '_' || first == '@'
 85518            ? paramName
 85519            : null;
 520    }
 521
 522    #endregion
 523}

Methods/Properties

ThrowIfNull(System.Object,System.String)
ThrowIfNullGeneric(T,System.String)
ThrowIfNullAndNullsAreIllegal(System.Object,TValue,System.String)
ThrowArgumentNullException(System.String)
ThrowIfNegative(System.Int32,System.String)
ThrowIfNegativeOrZero(System.Int32,System.String)
ThrowIfArgumentOutOfRange(System.Boolean,System.Nullable`1<System.Int32>,System.String,System.String)
ThrowIfArgumentOutOfRange(System.Boolean,System.Nullable`1<System.Int32>,SwiftCollections.Diagnostics.SwiftThrowInterpolatedStringHandler)
ThrowIfArgumentOutOfRange(System.Boolean,System.Nullable`1<System.Int32>,System.String,SwiftCollections.Diagnostics.SwiftThrowInterpolatedStringHandler)
ThrowIfArrayIndexInvalid(System.Int32,System.Int32,System.String)
ThrowArgumentOutOfRangeException(System.String,System.Object,System.String)
ThrowIfArgument(System.Boolean,System.String,System.String)
ThrowIfArgument(System.Boolean,SwiftCollections.Diagnostics.SwiftThrowInterpolatedStringHandler)
ThrowIfArgument(System.Boolean,System.String,SwiftCollections.Diagnostics.SwiftThrowInterpolatedStringHandler)
ThrowArgumentException(System.String,System.String)
ThrowIfTrue(System.Boolean,System.String,System.String)
ThrowIfTrue(System.Boolean,SwiftCollections.Diagnostics.SwiftThrowInterpolatedStringHandler)
ThrowIfTrue(System.Boolean,System.String,SwiftCollections.Diagnostics.SwiftThrowInterpolatedStringHandler)
ThrowInvalidOperationException(System.String)
ThrowIfDisposed(System.Boolean,System.String,System.String)
ThrowIfDisposed(System.Boolean,SwiftCollections.Diagnostics.SwiftThrowInterpolatedStringHandler)
ThrowIfDisposed(System.Boolean,System.String,SwiftCollections.Diagnostics.SwiftThrowInterpolatedStringHandler)
ThrowObjectDisposedException(System.String,System.String)
ThrowIfKeyInvalid(System.Int32,System.Object)
ThrowIfKeyNotFound(System.Boolean,System.Object,System.String)
ThrowIfKeyNotFound(System.Boolean,SwiftCollections.Diagnostics.SwiftThrowInterpolatedStringHandler)
ThrowIfKeyNotFound(System.Boolean,System.Object,SwiftCollections.Diagnostics.SwiftThrowInterpolatedStringHandler)
ThrowKeyNotFoundException(System.String)
ThrowIfListIndexInvalid(System.Int32,System.Int32)
ThrowIndexOutOfRangeException(System.Int32)
GetNonNegativeMessage(System.String)
GetPositiveMessage(System.String)
GetArgumentOutOfRangeMessage(System.String)
GetArgumentMessage(System.String)
GetInvalidOperationMessage(System.String)
GetObjectDisposedMessage(System.String)
GetKeyNotFoundMessage(System.Object)
NormalizeParamName(System.String)