using System; namespace DynamicDescriptors; /// /// Provides internal precondition helper methods. /// internal static class Preconditions { /// /// Provides 'is not null' parameter validation. /// /// The type of the parameter to validate. /// The value of the parameter. /// The name of the parameter. /// The value of the parameter (if it was not null). public static T CheckNotNull(T value, string parameterName) where T : class { if (value == null) { throw new ArgumentNullException(parameterName); } return value; } /// /// Provides 'is not null or an empty string' parameter validation. /// /// The value of the parameter. /// The name of the parameter. /// The value of the parameter (if it was not null or empty). public static string CheckNotNullOrEmpty(string value, string parameterName) { if (value == null) { throw new ArgumentNullException(parameterName); } if (value.Length == 0) { throw new ArgumentException($"{parameterName} should be an empty string.", parameterName); } return value; } }