diff --git a/src/Ulid/Ulid.Boundaries.cs b/src/Ulid/Ulid.Boundaries.cs index 86acc4f..d477c06 100644 --- a/src/Ulid/Ulid.Boundaries.cs +++ b/src/Ulid/Ulid.Boundaries.cs @@ -23,7 +23,7 @@ public readonly partial struct Ulid /// Represents the maximum possible value for a ULID. /// /// - /// The field is a ULID where all byte components are set to their highest possible value (0xFF). + /// The field is a ULID where all byte components are set to their highest possible value (0xFF). /// It can be used as a sentinel or boundary value in comparison operations or range validations. /// public static Ulid MaxValue { get; } = New(Enumerable.Repeat((byte)0xFF, _ulidSize).ToArray()); diff --git a/src/Ulid/Ulid.Obsolete.cs b/src/Ulid/Ulid.Obsolete.cs deleted file mode 100644 index a873b64..0000000 --- a/src/Ulid/Ulid.Obsolete.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace ByteAether.Ulid; - -public readonly partial struct Ulid -{ - /// - /// Represents the maximum possible value for a ULID. - /// - /// - /// The field is a ULID where all byte components are set to their highest possible value (0xFF). - /// It can be used as a sentinel or boundary value in comparison operations or range validations. - /// - [Obsolete("Use MaxValue instead.")] - public static Ulid Max => MaxValue; - - /// - /// Whether s should be generated in a monotonic manner by default.
- /// Initial value is set to true.
- /// This setting applies globally without any scoping. - ///
- /// - /// When set to true (default), s generated without explicitly specifying monotonicity - /// will ensure that they are monotonically increasing.
- /// When set to false, s generated without explicitly specifying monotonicity will be - /// generated with random value. - ///
- [Obsolete("Use DefaultGenerationOptions instead.")] - public static bool DefaultIsMonotonic - { - get => ObsoleteHelper.GetByGenerationOptions(DefaultGenerationOptions); - set => DefaultGenerationOptions = ObsoleteHelper.GetByBoolean(value); - } - - /// - /// Creates a new with the current timestamp. - /// - /// - /// If true, ensures the is monotonically increasing.
- /// If false, generates a random part in . - /// - /// A new instance. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [Obsolete("Use method with DefaultGenerationOptions argument instead.")] - public static Ulid New(bool isMonotonic) - => New(ObsoleteHelper.GetByBoolean(isMonotonic)); - - /// - /// Creates a new with the specified timestamp. - /// - /// The timestamp to use for the . - /// - /// If true, ensures the is monotonically increasing.
- /// If false, generates a random part in . - /// - /// A new instance. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [Obsolete("Use method with DefaultGenerationOptions argument instead.")] - public static Ulid New(DateTimeOffset dateTimeOffset, bool isMonotonic) - => New(dateTimeOffset, ObsoleteHelper.GetByBoolean(isMonotonic)); - - /// - /// Creates a new with the specified timestamp in milliseconds. - /// - /// The timestamp in milliseconds to use for the . - /// - /// If true, ensures the is monotonically increasing.
- /// If false, generates a random part in . - /// - /// A new instance. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [Obsolete("Use method with DefaultGenerationOptions argument instead.")] - public static Ulid New(long timestamp, bool isMonotonic) - => New(timestamp, ObsoleteHelper.GetByBoolean(isMonotonic)); -} - -internal static class ObsoleteHelper -{ - private static readonly Ulid.GenerationOptions _monotonicDefaultOptions = new(); - - private static readonly Ulid.GenerationOptions _nonmonotonicDefaultOptions = new() - { - InitialRandomSource = new CryptographicallySecureRandomProvider(), - IncrementRandomSource = new PseudoRandomProvider(), // This has no effect - Monotonicity = Ulid.GenerationOptions.MonotonicityOptions.NonMonotonic - }; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [return: NotNullIfNotNull(nameof(isMonotonic))] - public static Ulid.GenerationOptions? GetByBoolean(bool? isMonotonic) - => isMonotonic switch - { - true => _monotonicDefaultOptions, - false => _nonmonotonicDefaultOptions, - _ => null - }; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool GetByGenerationOptions(Ulid.GenerationOptions options) - => options.Monotonicity != Ulid.GenerationOptions.MonotonicityOptions.NonMonotonic; -} \ No newline at end of file