diff --git a/OnixLabs.Core.UnitTests/EnumerationTests.cs b/OnixLabs.Core.UnitTests/EnumerationTests.cs index 54e7313d..9ea30863 100644 --- a/OnixLabs.Core.UnitTests/EnumerationTests.cs +++ b/OnixLabs.Core.UnitTests/EnumerationTests.cs @@ -45,16 +45,30 @@ public void EnumerationsShouldNotBeEqual() Assert.False(a == b); } - [Fact(DisplayName = "Enumeration should return all enumeration instances")] - public void EnumerationsShouldReturnAllEnumerationInstances() + [Fact(DisplayName = "Enumeration.Deconstruct should return a value/name tuple")] + public void EnumerationDeconstructShouldReturnValueNameTuple() { // Given - IEnumerable colors = Color.GetAll(); + Color color = Color.Red; + + // When + (int value, string name) = color; // Then - Assert.Contains(colors, item => item == Color.Red); - Assert.Contains(colors, item => item == Color.Green); - Assert.Contains(colors, item => item == Color.Blue); + Assert.Equal(1, value); + Assert.Equal("Red", name); + } + + [Fact(DisplayName = "Enumeration.GetAll should return all enumeration entries")] + public void EnumerationGetAllShouldReturnAllEnumerationEntries() + { + // Given + IEnumerable entries = Color.GetAll(); + + // Then + Assert.Contains(Color.Blue, entries); + Assert.Contains(Color.Green, entries); + Assert.Contains(Color.Red, entries); } [Fact(DisplayName = "Enumeration.FromName should return the expected enumeration entry")] @@ -77,18 +91,6 @@ public void EnumerationFromValueShouldReturnTheExpectedEnumerationEntry() Assert.Equal(Color.Green, color); } - [Fact(DisplayName = "Enumeration.GetAll should return all enumeration entries")] - public void EnumerationGetAllShouldReturnAllEnumerationEntries() - { - // Given - IEnumerable entries = Color.GetAll(); - - // Then - Assert.Contains(Color.Blue, entries); - Assert.Contains(Color.Green, entries); - Assert.Contains(Color.Red, entries); - } - [Fact(DisplayName = "Enumeration.GetEntries should return all enumeration entries")] public void EnumerationGetEntriesShouldReturnAllEnumerationEntries() { diff --git a/OnixLabs.Core/Enumeration.Comparable.cs b/OnixLabs.Core/Enumeration.Comparable.cs index 45847baf..46b0fe7e 100644 --- a/OnixLabs.Core/Enumeration.Comparable.cs +++ b/OnixLabs.Core/Enumeration.Comparable.cs @@ -16,21 +16,9 @@ namespace OnixLabs.Core; public abstract partial class Enumeration { - /// - /// Compares the current instance with another object of the same type and returns an integer that indicates - /// whether the current instance precedes, follows, or occurs in the same position in the sort order as the - /// other object. - /// - /// An object to compare with the current instance. - /// Returns a value that indicates the relative order of the objects being compared. + /// public int CompareTo(T? other) => Value.CompareToNullable(other?.Value); - /// - /// Compares the current instance with another object of the same type and returns an integer that indicates - /// whether the current instance precedes, follows, or occurs in the same position in the sort order as the - /// other object. - /// - /// An object to compare with the current instance. - /// Returns a value that indicates the relative order of the objects being compared. + /// public int CompareTo(object? obj) => this.CompareToObject(obj); } diff --git a/OnixLabs.Core/Enumeration.Deconstruct.cs b/OnixLabs.Core/Enumeration.Deconstruct.cs new file mode 100644 index 00000000..11573faa --- /dev/null +++ b/OnixLabs.Core/Enumeration.Deconstruct.cs @@ -0,0 +1,25 @@ +// Copyright 2020 ONIXLabs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace OnixLabs.Core; + +public abstract partial class Enumeration +{ + /// + /// Deconstructs the current into a value and name tuple. + /// + /// The value of the current instance. + /// The name of the current instance. + public void Deconstruct(out int value, out string name) => (value, name) = (Value, Name); +} diff --git a/OnixLabs.Core/Enumeration.Equatable.cs b/OnixLabs.Core/Enumeration.Equatable.cs index b88006f7..5c29881c 100644 --- a/OnixLabs.Core/Enumeration.Equatable.cs +++ b/OnixLabs.Core/Enumeration.Equatable.cs @@ -18,11 +18,7 @@ namespace OnixLabs.Core; public abstract partial class Enumeration { - /// - /// Checks whether the current object is equal to another object of the same type. - /// - /// An object to compare with the current object. - /// Returns if the current object is equal to the other parameter; otherwise, . + /// public bool Equals(T? other) => ReferenceEquals(this, other) || other is not null @@ -30,32 +26,33 @@ public bool Equals(T? other) => && other.Value == Value && other.Name == Name; - /// - /// Checks for equality between the current instance and another object. - /// - /// The object to check for equality. - /// Returns if the object is equal to the current instance; otherwise, . + /// public override bool Equals(object? obj) => Equals(obj as T); - /// - /// Serves as a hash code function for the current instance. - /// - /// Returns a hash code for the current instance. + /// public override int GetHashCode() => HashCode.Combine(GetType(), Name, Value); /// - /// Performs an equality comparison between two object instances. + /// Determines whether the specified + /// value is equal to the specified value. /// - /// The left-hand instance to compare. - /// The right-hand instance to compare. - /// Returns if the left-hand instance is equal to the right-hand instance; otherwise, . + /// The left-hand value to compare. + /// The right-hand value to compare. + /// + /// Returns if the specified value is equal to + /// the specified value; otherwise, . + /// public static bool operator ==(Enumeration left, Enumeration right) => Equals(left, right); /// - /// Performs an inequality comparison between two object instances. + /// Determines whether the specified + /// value is not equal to the specified value. /// - /// The left-hand instance to compare. - /// The right-hand instance to compare. - /// Returns if the left-hand instance is not equal to the right-hand instance; otherwise, . + /// The left-hand value to compare. + /// The right-hand value to compare. + /// + /// Returns if the specified value is not equal to + /// the specified value; otherwise, . + /// public static bool operator !=(Enumeration left, Enumeration right) => !Equals(left, right); } diff --git a/OnixLabs.Core/Optional.cs b/OnixLabs.Core/Optional.cs index 8c0868e5..716470eb 100644 --- a/OnixLabs.Core/Optional.cs +++ b/OnixLabs.Core/Optional.cs @@ -136,24 +136,13 @@ public static Optional Of(TStruct? value) where TStruct : stru /// Returns if the left-hand instance is not equal to the right-hand instance; otherwise, . public static bool operator !=(Optional? left, Optional? right) => !Equals(left, right); - /// - /// Checks whether the current object is equal to another object of the same type. - /// - /// An object to compare with the current object. - /// Returns if the current object is equal to the other parameter; otherwise, . + /// public bool Equals(Optional? other) => OptionalEqualityComparer.Default.Equals(this, other); - /// - /// Checks for equality between the current instance and another object. - /// - /// The object to check for equality. - /// Returns if the object is equal to the current instance; otherwise, . + /// public sealed override bool Equals(object? obj) => Equals(obj as Optional); - /// - /// Serves as a hash code function for the current instance. - /// - /// Returns a hash code for the current instance. + /// // ReSharper disable once HeapView.PossibleBoxingAllocation public sealed override int GetHashCode() => this is Some some ? some.Value.GetHashCode() : 0; @@ -258,10 +247,7 @@ public void Match(Action? some = null, Action? none = null) /// Returns a new, successful instance containing the current instance. public Result> ToResult() => Result>.Success(this); - /// - /// Returns a that represents the current object. - /// - /// Returns a that represents the current object. + /// // ReSharper disable once HeapView.PossibleBoxingAllocation public sealed override string ToString() => this is Some some ? some.Value.ToString() ?? string.Empty : nameof(None); } diff --git a/OnixLabs.Core/Result.Generic.cs b/OnixLabs.Core/Result.Generic.cs index 57d35727..56b377a0 100644 --- a/OnixLabs.Core/Result.Generic.cs +++ b/OnixLabs.Core/Result.Generic.cs @@ -174,9 +174,7 @@ public static async Task> OfAsync(Func> fun /// Returns if the left-hand instance is not equal to the right-hand instance; otherwise, . public static bool operator !=(Result? left, Result? right) => !Equals(left, right); - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// + /// public void Dispose() { // ReSharper disable once HeapView.PossibleBoxingAllocation @@ -186,12 +184,7 @@ public void Dispose() GC.SuppressFinalize(this); } - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously. - /// - /// - /// Returns a task that represents the asynchronous dispose operation. - /// + /// public async ValueTask DisposeAsync() { // ReSharper disable once HeapView.PossibleBoxingAllocation @@ -201,24 +194,13 @@ public async ValueTask DisposeAsync() GC.SuppressFinalize(this); } - /// - /// Checks whether the current object is equal to another object of the same type. - /// - /// An object to compare with the current object. - /// Returns if the current object is equal to the other parameter; otherwise, . + /// public bool Equals(Result? other) => ResultEqualityComparer.Default.Equals(this, other); - /// - /// Checks for equality between the current instance and another object. - /// - /// The object to check for equality. - /// Returns if the object is equal to the current instance; otherwise, . + /// public sealed override bool Equals(object? obj) => Equals(obj as Result); - /// - /// Serves as a hash code function for the current instance. - /// - /// Returns a hash code for the current instance. + /// public sealed override int GetHashCode() => this switch { // ReSharper disable once HeapView.PossibleBoxingAllocation @@ -855,10 +837,7 @@ public void Throw() throw failure.Exception; } - /// - /// Returns a that represents the current object. - /// - /// Returns a that represents the current object. + /// public sealed override string ToString() => this switch { // ReSharper disable once HeapView.PossibleBoxingAllocation diff --git a/OnixLabs.Core/Result.cs b/OnixLabs.Core/Result.cs index bcab075d..956149fd 100644 --- a/OnixLabs.Core/Result.cs +++ b/OnixLabs.Core/Result.cs @@ -152,11 +152,7 @@ public static async Task OfAsync(Func func, Can /// Returns if the left-hand instance is not equal to the right-hand instance; otherwise, . public static bool operator !=(Result? left, Result? right) => !Equals(left, right); - /// - /// Checks whether the current object is equal to another object of the same type. - /// - /// An object to compare with the current object. - /// Returns if the current object is equal to the other parameter; otherwise, . + /// public bool Equals(Result? other) { if (ReferenceEquals(this, other)) return true; @@ -167,17 +163,10 @@ public bool Equals(Result? other) return this is Success && other is Success; } - /// - /// Checks for equality between the current instance and another object. - /// - /// The object to check for equality. - /// Returns if the object is equal to the current instance; otherwise, . + /// public sealed override bool Equals(object? obj) => Equals(obj as Result); - /// - /// Serves as a hash code function for the current instance. - /// - /// Returns a hash code for the current instance. + /// public sealed override int GetHashCode() => this is Failure failure ? failure.Exception.GetHashCode() : 0; /// @@ -738,10 +727,7 @@ public void Throw() throw failure.Exception; } - /// - /// Returns a that represents the current object. - /// - /// Returns a that represents the current object. + /// public sealed override string ToString() => this is Failure failure ? failure.Exception.Message : string.Empty; } diff --git a/OnixLabs.Core/Specification.cs b/OnixLabs.Core/Specification.cs index ef421657..77d74608 100644 --- a/OnixLabs.Core/Specification.cs +++ b/OnixLabs.Core/Specification.cs @@ -96,6 +96,40 @@ public static Specification Or(params IEnumerable> specifica /// The subject to evaluate. /// Returns if the subject satisfies the specification; otherwise, . public bool IsSatisfiedBy(T subject) => Criteria.Compile().Invoke(subject); + + /// + /// Combines the specified specification and the + /// specified specification using a logical AND operation. + /// + /// The left-hand specification to combine. + /// The right-hand specification to combine. + /// + /// Returns a combined specification that evaluates to if both specifications are satisfied; + /// otherwise, the specification evaluates to . + /// + public static Specification operator &(Specification left, Specification right) => left.And(right); + + /// + /// Combines the specified specification and the + /// specified specification using a logical OR operation. + /// + /// The left-hand specification to combine. + /// The right-hand specification to combine. + /// + /// Returns a combined specification that evaluates to if both specifications are satisfied; + /// otherwise, the specification evaluates to . + /// + public static Specification operator |(Specification left, Specification right) => left.Or(right); + + /// + /// Negates the specified specification. + /// + /// The specification to negate. + /// + /// Returns a specification that evaluates to if the current specification is not satisfied; + /// otherwise, the specification evaluates to . + /// + public static Specification operator !(Specification specification) => specification.Not(); } /// diff --git a/OnixLabs.Core/Text/Base16.Convertible.cs b/OnixLabs.Core/Text/Base16.Convertible.cs index e6b84ecc..ccc5e47c 100644 --- a/OnixLabs.Core/Text/Base16.Convertible.cs +++ b/OnixLabs.Core/Text/Base16.Convertible.cs @@ -20,57 +20,35 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base16 { - /// - /// Gets the underlying array representation of the current instance as a new instance. - /// - /// Return the underlying array representation of the current instance as a new instance. + /// public ReadOnlyMemory AsReadOnlyMemory() => value; - /// - /// Gets the underlying array representation of the current instance as a new instance. - /// - /// Return the underlying array representation of the current instance as a new instance. + /// public ReadOnlySpan AsReadOnlySpan() => value; /// - /// Create a new instance from the specified array. - /// - /// The value from which to create a new instance. - /// Returns a new instance from the specified array. - public static implicit operator Base16(byte[] value) => new(value); - - /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. /// Returns a new instance from the specified value. public static implicit operator Base16(ReadOnlySpan value) => new(value); /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. /// Returns a new instance from the specified value. public static implicit operator Base16(ReadOnlySequence value) => new(value); /// - /// Create a new instance from the specified value. - /// The value will be encoded using the encoding. - /// - /// The value from which to create a new instance. - /// Returns a new instance from the specified value. - public static implicit operator Base16(string value) => new(value); - - /// - /// Create a new instance from the specified array. - /// The array will be encoded using the encoding. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. - /// Returns a new instance from the specified array. - public static implicit operator Base16(char[] value) => new(value); + /// Returns a new instance from the specified value. + public static implicit operator Base16(ReadOnlySpan value) => new(value); /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// The value will be encoded using the encoding. /// /// The value from which to create a new instance. diff --git a/OnixLabs.Core/Text/Base16.Equatable.cs b/OnixLabs.Core/Text/Base16.Equatable.cs index e8af4aa0..61158916 100644 --- a/OnixLabs.Core/Text/Base16.Equatable.cs +++ b/OnixLabs.Core/Text/Base16.Equatable.cs @@ -12,46 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.Collections.Generic; using OnixLabs.Core.Linq; namespace OnixLabs.Core.Text; public readonly partial struct Base16 { - /// - /// Checks whether the current object is equal to another object of the same type. - /// - /// An object to compare with the current object. - /// Returns if the current object is equal to the other parameter; otherwise, . - public bool Equals(Base16 other) => other.value.SequenceEqualOrNull(value); + /// + public static bool Equals(Base16 left, Base16 right) => left.value.SequenceEqualOrNull(right.value); - /// - /// Checks for equality between the current instance and another object. - /// - /// The object to check for equality. - /// Returns if the object is equal to the current instance; otherwise, . + /// + public bool Equals(Base16 other) => Equals(this, other); + + /// public override bool Equals(object? obj) => obj is Base16 other && Equals(other); - /// - /// Serves as a hash code function for the current instance. - /// - /// Returns a hash code for the current instance. + /// public override int GetHashCode() => value.GetContentHashCode(); - - /// - /// Performs an equality comparison between two object instances. - /// - /// The left-hand instance to compare. - /// The right-hand instance to compare. - /// Returns if the left-hand instance is equal to the right-hand instance; otherwise, . - public static bool operator ==(Base16 left, Base16 right) => EqualityComparer.Default.Equals(left, right); - - /// - /// Performs an inequality comparison between two object instances. - /// - /// The left-hand instance to compare. - /// The right-hand instance to compare. - /// Returns if the left-hand instance is not equal to the right-hand instance; otherwise, . - public static bool operator !=(Base16 left, Base16 right) => !EqualityComparer.Default.Equals(left, right); } diff --git a/OnixLabs.Core/Text/Base16.Format.cs b/OnixLabs.Core/Text/Base16.Format.cs index ff7eb9f0..447b0896 100644 --- a/OnixLabs.Core/Text/Base16.Format.cs +++ b/OnixLabs.Core/Text/Base16.Format.cs @@ -18,16 +18,11 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base16 { - /// - /// Tries to format the value of the current instance into the provided span of characters. - /// - /// The span in which to write this instance's value formatted as a span of characters. - /// When this method returns, contains the number of characters that were written in . - /// A span containing the characters that represent a standard or custom format string that defines the acceptable format for . - /// An optional object that supplies culture-specific formatting information for . - /// Returns if the formatting was successful; otherwise, . - bool ISpanFormattable.TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - return ToString(format, provider).TryCopyTo(destination, out charsWritten); - } + /// + bool ISpanFormattable.TryFormat( + Span destination, + out int charsWritten, + ReadOnlySpan format, + IFormatProvider? provider + ) => ToString(format, provider).TryCopyTo(destination, out charsWritten); } diff --git a/OnixLabs.Core/Text/Base16.Parse.cs b/OnixLabs.Core/Text/Base16.Parse.cs index 0cd44e07..b3ef3d4a 100644 --- a/OnixLabs.Core/Text/Base16.Parse.cs +++ b/OnixLabs.Core/Text/Base16.Parse.cs @@ -18,44 +18,16 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base16 { - /// - /// Parses the specified Base-16 encoded value into a value. - /// - /// The Base-16 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// Returns a new instance, parsed from the specified Base-16 encoded value. + /// public static Base16 Parse(string value, IFormatProvider? provider = null) => Parse(value.AsSpan(), provider); - /// - /// Parses the specified Base-16 encoded value into a value. - /// - /// The Base-16 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// Returns a new instance, parsed from the specified Base-16 encoded value. + /// public static Base16 Parse(ReadOnlySpan value, IFormatProvider? provider = null) => new(IBaseCodec.Base16.Decode(value, provider)); - /// - /// Tries to parse the specified Base-16 encoded value into a value. - /// - /// The Base-16 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// - /// A new instance, parsed from the specified Base-16 encoded value, - /// or the default value if the specified Base-16 encoded could not be parsed. - /// - /// Returns if the specified Base-16 value was decoded successfully; otherwise, . + /// public static bool TryParse(string? value, IFormatProvider? provider, out Base16 result) => TryParse(value.AsSpan(), provider, out result); - /// - /// Tries to parse the specified Base-16 encoded value into a value. - /// - /// The Base-16 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// - /// A new instance, parsed from the specified Base-16 encoded value, - /// or the default value if the specified Base-16 encoded could not be parsed. - /// - /// Returns if the specified Base-16 value was decoded successfully; otherwise, . + /// public static bool TryParse(ReadOnlySpan value, IFormatProvider? provider, out Base16 result) { if (IBaseCodec.Base16.TryDecode(value, provider, out byte[] bytes)) diff --git a/OnixLabs.Core/Text/Base16.To.cs b/OnixLabs.Core/Text/Base16.To.cs index 1a148596..f9f7bb27 100644 --- a/OnixLabs.Core/Text/Base16.To.cs +++ b/OnixLabs.Core/Text/Base16.To.cs @@ -18,32 +18,15 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base16 { - /// - /// Returns a that represents the current object. - /// - /// Returns a that represents the current object. + /// public override string ToString() => ToString(Base16FormatProvider.Invariant); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(IFormatProvider? formatProvider) => ToString(null, formatProvider); + /// + public string ToString(IFormatProvider? formatProvider = null) => ToString(null, formatProvider); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The format to use. - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(string? format, IFormatProvider? formatProvider) => ToString(format.AsSpan(), formatProvider); + /// + public string ToString(string? format, IFormatProvider? formatProvider = null) => ToString(format.AsSpan(), formatProvider); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The format to use. - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(ReadOnlySpan format, IFormatProvider? formatProvider) => IBaseCodec.Base16.Encode(value, formatProvider); + /// + public string ToString(ReadOnlySpan format, IFormatProvider? formatProvider = null) => IBaseCodec.Base16.Encode(value, formatProvider); } diff --git a/OnixLabs.Core/Text/Base16.cs b/OnixLabs.Core/Text/Base16.cs index f746e988..dbf8c977 100644 --- a/OnixLabs.Core/Text/Base16.cs +++ b/OnixLabs.Core/Text/Base16.cs @@ -21,44 +21,50 @@ namespace OnixLabs.Core.Text; /// /// Represents a Base-16 value. /// -/// The with which to initialize the instance. -public readonly partial struct Base16(ReadOnlySpan value) : IBaseValue +// ReSharper disable MemberCanBePrivate.Global +public readonly partial struct Base16 : IBaseValue { - private readonly byte[] value = value.ToArray(); + private readonly byte[] value; /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. - // ReSharper disable once MemberCanBePrivate.Global - public Base16(ReadOnlySequence value) : this(ReadOnlySpan.Empty) => value.CopyTo(out this.value); + /// + /// This constructor exists only to assign the array without allocating a new copy. + /// + /// The value with which to initialize the new instance. + private Base16(byte[] value) => this.value = value; /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. - /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global - public Base16(string value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) + /// The value with which to initialize the new instance. + public Base16(ReadOnlySpan value) : this(value.ToArray()) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The value with which to initialize the new instance. + public Base16(ReadOnlySequence value) : this(value.ToArray()) { } /// /// Initializes a new instance of the struct. /// - /// The array with which to initialize the instance. + /// The value with which to initialize the new instance. /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global - public Base16(char[] value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) + public Base16(ReadOnlySpan value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) { } /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. + /// The value with which to initialize the new instance. /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global public Base16(ReadOnlySequence value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) { } diff --git a/OnixLabs.Core/Text/Base16Codec.cs b/OnixLabs.Core/Text/Base16Codec.cs index c7515009..412bd1b8 100644 --- a/OnixLabs.Core/Text/Base16Codec.cs +++ b/OnixLabs.Core/Text/Base16Codec.cs @@ -32,11 +32,9 @@ public sealed class Base16Codec : IBaseCodec /// The value to encode into a Base-16 representation. /// The format provider that will be used to encode the specified value. /// Returns a new Base-16 representation encoded from the specified value. - public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) - { - if (TryEncode(value, provider, out string result)) return result; - throw new FormatException(IBaseCodec.EncodingFormatException); - } + public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) => TryEncode(value, provider, out string result) + ? result + : throw new FormatException(IBaseCodec.EncodingFormatException); /// /// Decodes the specified Base-16 representation into a array. @@ -44,11 +42,9 @@ public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) /// The Base-16 value to decode into a array. /// The format provider that will be used to decode the specified value. /// Returns a new array decoded from the specified value. - public byte[] Decode(ReadOnlySpan value, IFormatProvider? provider = null) - { - if (TryDecode(value, provider, out byte[] result)) return result; - throw new FormatException(IBaseCodec.DecodingFormatException); - } + public byte[] Decode(ReadOnlySpan value, IFormatProvider? provider = null) => TryDecode(value, provider, out byte[] result) + ? result + : throw new FormatException(IBaseCodec.DecodingFormatException); /// /// Tries to encode the specified value into a Base-16 representation. @@ -109,6 +105,7 @@ public bool TryDecode(ReadOnlySpan value, IFormatProvider? provider, out b return true; } + // ReSharper disable DuplicatedSequentialIfBodies if (!IBaseCodec.TryGetFormatProvider(provider, Base16FormatProvider.Invariant, out Base16FormatProvider formatProvider)) { result = []; diff --git a/OnixLabs.Core/Text/Base16FormatProvider.cs b/OnixLabs.Core/Text/Base16FormatProvider.cs index cb0f3e12..387455b4 100644 --- a/OnixLabs.Core/Text/Base16FormatProvider.cs +++ b/OnixLabs.Core/Text/Base16FormatProvider.cs @@ -24,9 +24,11 @@ public sealed class Base16FormatProvider : Enumeration, IF { /// /// Gets the invariant Base-16 format provider. + /// + /// /// The invariant format provider favors lowercase for Base-16 encoding. /// The alphabet provided by this format provider is not a strict Base-16 alphabet as it contains all uppercase and lowercase values. - /// + /// public static readonly Base16FormatProvider Invariant = new(0, nameof(Invariant), "0123456789ABCDEFabcdef"); /// @@ -52,11 +54,6 @@ public sealed class Base16FormatProvider : Enumeration, IF /// public string Alphabet { get; } - /// Gets an object that provides formatting services for the specified type. - /// An object that specifies the type of format object to return. - /// - /// Returns an instance of the object specified by , - /// if the implementation can supply that type of object; otherwise, . - /// + /// public object? GetFormat(Type? formatType) => formatType == typeof(Base16FormatProvider) ? this : null; } diff --git a/OnixLabs.Core/Text/Base32.Convertible.cs b/OnixLabs.Core/Text/Base32.Convertible.cs index 5aa829ba..54ef74cf 100644 --- a/OnixLabs.Core/Text/Base32.Convertible.cs +++ b/OnixLabs.Core/Text/Base32.Convertible.cs @@ -20,57 +20,35 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base32 { - /// - /// Gets the underlying array representation of the current instance as a new instance. - /// - /// Return the underlying array representation of the current instance as a new instance. + /// public ReadOnlyMemory AsReadOnlyMemory() => value; - /// - /// Gets the underlying array representation of the current instance as a new instance. - /// - /// Return the underlying array representation of the current instance as a new instance. + /// public ReadOnlySpan AsReadOnlySpan() => value; /// - /// Create a new instance from the specified array. - /// - /// The value from which to create a new instance. - /// Returns a new instance from the specified array. - public static implicit operator Base32(byte[] value) => new(value); - - /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. /// Returns a new instance from the specified value. public static implicit operator Base32(ReadOnlySpan value) => new(value); /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. /// Returns a new instance from the specified value. public static implicit operator Base32(ReadOnlySequence value) => new(value); /// - /// Create a new instance from the specified value. - /// The value will be encoded using the encoding. - /// - /// The value from which to create a new instance. - /// Returns a new instance from the specified value. - public static implicit operator Base32(string value) => new(value); - - /// - /// Create a new instance from the specified array. - /// The array will be encoded using the encoding. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. - /// Returns a new instance from the specified array. - public static implicit operator Base32(char[] value) => new(value); + /// Returns a new instance from the specified value. + public static implicit operator Base32(ReadOnlySpan value) => new(value); /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// The value will be encoded using the encoding. /// /// The value from which to create a new instance. diff --git a/OnixLabs.Core/Text/Base32.Equatable.cs b/OnixLabs.Core/Text/Base32.Equatable.cs index f99aebc3..fe5e440a 100644 --- a/OnixLabs.Core/Text/Base32.Equatable.cs +++ b/OnixLabs.Core/Text/Base32.Equatable.cs @@ -12,46 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.Collections.Generic; using OnixLabs.Core.Linq; namespace OnixLabs.Core.Text; public readonly partial struct Base32 { - /// - /// Checks whether the current object is equal to another object of the same type. - /// - /// An object to compare with the current object. - /// Returns if the current object is equal to the other parameter; otherwise, . - public bool Equals(Base32 other) => other.value.SequenceEqualOrNull(value); + /// + public static bool Equals(Base32 left, Base32 right) => left.value.SequenceEqualOrNull(right.value); - /// - /// Checks for equality between the current instance and another object. - /// - /// The object to check for equality. - /// Returns if the object is equal to the current instance; otherwise, . + /// + public bool Equals(Base32 other) => Equals(this, other); + + /// public override bool Equals(object? obj) => obj is Base32 other && Equals(other); - /// - /// Serves as a hash code function for the current instance. - /// - /// Returns a hash code for the current instance. + /// public override int GetHashCode() => value.GetContentHashCode(); - - /// - /// Performs an equality comparison between two object instances. - /// - /// The left-hand instance to compare. - /// The right-hand instance to compare. - /// Returns if the left-hand instance is equal to the right-hand instance; otherwise, . - public static bool operator ==(Base32 left, Base32 right) => EqualityComparer.Default.Equals(left, right); - - /// - /// Performs an inequality comparison between two object instances. - /// - /// The left-hand instance to compare. - /// The right-hand instance to compare. - /// Returns if the left-hand instance is not equal to the right-hand instance; otherwise, . - public static bool operator !=(Base32 left, Base32 right) => !EqualityComparer.Default.Equals(left, right); } diff --git a/OnixLabs.Core/Text/Base32.Format.cs b/OnixLabs.Core/Text/Base32.Format.cs index 447bd832..45af9bea 100644 --- a/OnixLabs.Core/Text/Base32.Format.cs +++ b/OnixLabs.Core/Text/Base32.Format.cs @@ -18,16 +18,11 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base32 { - /// - /// Tries to format the value of the current instance into the provided span of characters. - /// - /// The span in which to write this instance's value formatted as a span of characters. - /// When this method returns, contains the number of characters that were written in . - /// A span containing the characters that represent a standard or custom format string that defines the acceptable format for . - /// An optional object that supplies culture-specific formatting information for . - /// Returns if the formatting was successful; otherwise, . - bool ISpanFormattable.TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - return ToString(format, provider).TryCopyTo(destination, out charsWritten); - } + /// + bool ISpanFormattable.TryFormat( + Span destination, + out int charsWritten, + ReadOnlySpan format, + IFormatProvider? provider + ) => ToString(format, provider).TryCopyTo(destination, out charsWritten); } diff --git a/OnixLabs.Core/Text/Base32.Parse.cs b/OnixLabs.Core/Text/Base32.Parse.cs index 59f7d6be..8dac40eb 100644 --- a/OnixLabs.Core/Text/Base32.Parse.cs +++ b/OnixLabs.Core/Text/Base32.Parse.cs @@ -18,44 +18,16 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base32 { - /// - /// Parses the specified Base-32 encoded value into a value. - /// - /// The Base-32 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// Returns a new instance, parsed from the specified Base-32 encoded value. + /// public static Base32 Parse(string value, IFormatProvider? provider = null) => Parse(value.AsSpan(), provider); - /// - /// Parses the specified Base-32 encoded value into a value. - /// - /// The Base-32 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// Returns a new instance, parsed from the specified Base-32 encoded value. + /// public static Base32 Parse(ReadOnlySpan value, IFormatProvider? provider = null) => new(IBaseCodec.Base32.Decode(value, provider)); - /// - /// Tries to parse the specified Base-32 encoded value into a value. - /// - /// The Base-32 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// - /// A new instance, parsed from the specified Base-32 encoded value, - /// or the default value if the specified Base-32 encoded could not be parsed. - /// - /// Returns if the specified Base-32 value was decoded successfully; otherwise, . + /// public static bool TryParse(string? value, IFormatProvider? provider, out Base32 result) => TryParse(value.AsSpan(), provider, out result); - /// - /// Tries to parse the specified Base-32 encoded value into a value. - /// - /// The Base-32 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// - /// A new instance, parsed from the specified Base-32 encoded value, - /// or the default value if the specified Base-32 encoded could not be parsed. - /// - /// Returns if the specified Base-32 value was decoded successfully; otherwise, . + /// public static bool TryParse(ReadOnlySpan value, IFormatProvider? provider, out Base32 result) { if (IBaseCodec.Base32.TryDecode(value, provider, out byte[] bytes)) diff --git a/OnixLabs.Core/Text/Base32.To.cs b/OnixLabs.Core/Text/Base32.To.cs index 87bb96cf..a043491c 100644 --- a/OnixLabs.Core/Text/Base32.To.cs +++ b/OnixLabs.Core/Text/Base32.To.cs @@ -18,32 +18,15 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base32 { - /// - /// Returns a that represents the current object. - /// - /// Returns a that represents the current object. + /// public override string ToString() => ToString(Base32FormatProvider.Rfc4648); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(IFormatProvider? formatProvider) => ToString(null, formatProvider); + /// + public string ToString(IFormatProvider? formatProvider = null) => ToString(null, formatProvider); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The format to use. - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(string? format, IFormatProvider? formatProvider) => ToString(format.AsSpan(), formatProvider); + /// + public string ToString(string? format, IFormatProvider? formatProvider = null) => ToString(format.AsSpan(), formatProvider); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The format to use. - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(ReadOnlySpan format, IFormatProvider? formatProvider) => IBaseCodec.Base32.Encode(value, formatProvider); + /// + public string ToString(ReadOnlySpan format, IFormatProvider? formatProvider = null) => IBaseCodec.Base32.Encode(value, formatProvider); } diff --git a/OnixLabs.Core/Text/Base32.cs b/OnixLabs.Core/Text/Base32.cs index db77b7d1..e9e9b883 100644 --- a/OnixLabs.Core/Text/Base32.cs +++ b/OnixLabs.Core/Text/Base32.cs @@ -21,44 +21,50 @@ namespace OnixLabs.Core.Text; /// /// Represents a Base-32 value. /// -/// The with which to initialize the instance. -public readonly partial struct Base32(ReadOnlySpan value) : IBaseValue +// ReSharper disable MemberCanBePrivate.Global +public readonly partial struct Base32 : IBaseValue { - private readonly byte[] value = value.ToArray(); + private readonly byte[] value; /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. - // ReSharper disable once MemberCanBePrivate.Global - public Base32(ReadOnlySequence value) : this(ReadOnlySpan.Empty) => value.CopyTo(out this.value); + /// + /// This constructor exists only to assign the array without allocating a new copy. + /// + /// The value with which to initialize the new instance. + private Base32(byte[] value) => this.value = value; /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. - /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global - public Base32(string value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) + /// The value with which to initialize the new instance. + public Base32(ReadOnlySpan value) : this(value.ToArray()) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The value with which to initialize the new instance. + public Base32(ReadOnlySequence value) : this(value.ToArray()) { } /// /// Initializes a new instance of the struct. /// - /// The array with which to initialize the instance. + /// The value with which to initialize the new instance. /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global - public Base32(char[] value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) + public Base32(ReadOnlySpan value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) { } /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. + /// The value with which to initialize the new instance. /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global public Base32(ReadOnlySequence value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) { } diff --git a/OnixLabs.Core/Text/Base32Codec.cs b/OnixLabs.Core/Text/Base32Codec.cs index 624539fd..5be8ae29 100644 --- a/OnixLabs.Core/Text/Base32Codec.cs +++ b/OnixLabs.Core/Text/Base32Codec.cs @@ -38,11 +38,9 @@ public sealed class Base32Codec : IBaseCodec /// The value to encode into a Base-32 representation. /// The format provider that will be used to encode the specified value. /// Returns a new Base-32 representation encoded from the specified value. - public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) - { - if (TryEncode(value, provider, out string result)) return result; - throw new FormatException(IBaseCodec.EncodingFormatException); - } + public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) => TryEncode(value, provider, out string result) + ? result + : throw new FormatException(IBaseCodec.EncodingFormatException); /// /// Decodes the specified Base-32 representation into a array. @@ -50,11 +48,9 @@ public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) /// The Base-32 value to decode into a array. /// The format provider that will be used to decode the specified value. /// Returns a new array decoded from the specified value. - public byte[] Decode(ReadOnlySpan value, IFormatProvider? provider = null) - { - if (TryDecode(value, provider, out byte[] result)) return result; - throw new FormatException(IBaseCodec.DecodingFormatException); - } + public byte[] Decode(ReadOnlySpan value, IFormatProvider? provider = null) => TryDecode(value, provider, out byte[] result) + ? result + : throw new FormatException(IBaseCodec.DecodingFormatException); /// /// Tries to encode the specified value into a Base-32 representation. @@ -155,6 +151,7 @@ public bool TryDecode(ReadOnlySpan value, IFormatProvider? provider, out b return true; } + // ReSharper disable once DuplicatedSequentialIfBodies if (!IBaseCodec.TryGetFormatProvider(provider, Base32FormatProvider.Rfc4648, out Base32FormatProvider formatProvider)) { result = []; diff --git a/OnixLabs.Core/Text/Base32FormatProvider.cs b/OnixLabs.Core/Text/Base32FormatProvider.cs index 70052e6d..17dbcf58 100644 --- a/OnixLabs.Core/Text/Base32FormatProvider.cs +++ b/OnixLabs.Core/Text/Base32FormatProvider.cs @@ -91,11 +91,6 @@ public sealed class Base32FormatProvider : Enumeration, IF /// public bool IsPadded { get; } - /// Gets an object that provides formatting services for the specified type. - /// An object that specifies the type of format object to return. - /// - /// Returns an instance of the object specified by , - /// if the implementation can supply that type of object; otherwise, . - /// + /// public object? GetFormat(Type? formatType) => formatType == typeof(Base32FormatProvider) ? this : null; } diff --git a/OnixLabs.Core/Text/Base58.Convertible.cs b/OnixLabs.Core/Text/Base58.Convertible.cs index 79eacaed..10b9c2fc 100644 --- a/OnixLabs.Core/Text/Base58.Convertible.cs +++ b/OnixLabs.Core/Text/Base58.Convertible.cs @@ -20,57 +20,35 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base58 { - /// - /// Gets the underlying array representation of the current instance as a new instance. - /// - /// Return the underlying array representation of the current instance as a new instance. + /// public ReadOnlyMemory AsReadOnlyMemory() => value; - /// - /// Gets the underlying array representation of the current instance as a new instance. - /// - /// Return the underlying array representation of the current instance as a new instance. + /// public ReadOnlySpan AsReadOnlySpan() => value; /// - /// Create a new instance from the specified array. - /// - /// The value from which to create a new instance. - /// Returns a new instance from the specified array. - public static implicit operator Base58(byte[] value) => new(value); - - /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. /// Returns a new instance from the specified value. public static implicit operator Base58(ReadOnlySpan value) => new(value); /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. /// Returns a new instance from the specified value. public static implicit operator Base58(ReadOnlySequence value) => new(value); /// - /// Create a new instance from the specified value. - /// The value will be encoded using the encoding. - /// - /// The value from which to create a new instance. - /// Returns a new instance from the specified value. - public static implicit operator Base58(string value) => new(value); - - /// - /// Create a new instance from the specified array. - /// The array will be encoded using the encoding. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. - /// Returns a new instance from the specified array. - public static implicit operator Base58(char[] value) => new(value); + /// Returns a new instance from the specified value. + public static implicit operator Base58(ReadOnlySpan value) => new(value); /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// The value will be encoded using the encoding. /// /// The value from which to create a new instance. diff --git a/OnixLabs.Core/Text/Base58.Equatable.cs b/OnixLabs.Core/Text/Base58.Equatable.cs index 40898546..bebd6782 100644 --- a/OnixLabs.Core/Text/Base58.Equatable.cs +++ b/OnixLabs.Core/Text/Base58.Equatable.cs @@ -12,46 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.Collections.Generic; using OnixLabs.Core.Linq; namespace OnixLabs.Core.Text; public readonly partial struct Base58 { - /// - /// Checks whether the current object is equal to another object of the same type. - /// - /// An object to compare with the current object. - /// Returns if the current object is equal to the other parameter; otherwise, . - public bool Equals(Base58 other) => other.value.SequenceEqualOrNull(value); + /// + public static bool Equals(Base58 left, Base58 right) => left.value.SequenceEqualOrNull(right.value); - /// - /// Checks for equality between the current instance and another object. - /// - /// The object to check for equality. - /// Returns if the object is equal to the current instance; otherwise, . + /// + public bool Equals(Base58 other) => Equals(this, other); + + /// public override bool Equals(object? obj) => obj is Base58 other && Equals(other); - /// - /// Serves as a hash code function for the current instance. - /// - /// Returns a hash code for the current instance. + /// public override int GetHashCode() => value.GetContentHashCode(); - - /// - /// Performs an equality comparison between two object instances. - /// - /// The left-hand instance to compare. - /// The right-hand instance to compare. - /// Returns if the left-hand instance is equal to the right-hand instance; otherwise, . - public static bool operator ==(Base58 left, Base58 right) => EqualityComparer.Default.Equals(left, right); - - /// - /// Performs an inequality comparison between two object instances. - /// - /// The left-hand instance to compare. - /// The right-hand instance to compare. - /// Returns if the left-hand instance is not equal to the right-hand instance; otherwise, . - public static bool operator !=(Base58 left, Base58 right) => !EqualityComparer.Default.Equals(left, right); } diff --git a/OnixLabs.Core/Text/Base58.Format.cs b/OnixLabs.Core/Text/Base58.Format.cs index 7f63a648..5c5b53ce 100644 --- a/OnixLabs.Core/Text/Base58.Format.cs +++ b/OnixLabs.Core/Text/Base58.Format.cs @@ -18,16 +18,11 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base58 { - /// - /// Tries to format the value of the current instance into the provided span of characters. - /// - /// The span in which to write this instance's value formatted as a span of characters. - /// When this method returns, contains the number of characters that were written in . - /// A span containing the characters that represent a standard or custom format string that defines the acceptable format for . - /// An optional object that supplies culture-specific formatting information for . - /// Returns if the formatting was successful; otherwise, . - bool ISpanFormattable.TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - return ToString(format, provider).TryCopyTo(destination, out charsWritten); - } + /// + bool ISpanFormattable.TryFormat( + Span destination, + out int charsWritten, + ReadOnlySpan format, + IFormatProvider? provider + ) => ToString(format, provider).TryCopyTo(destination, out charsWritten); } diff --git a/OnixLabs.Core/Text/Base58.Parse.cs b/OnixLabs.Core/Text/Base58.Parse.cs index 584ed7e6..bc2fba39 100644 --- a/OnixLabs.Core/Text/Base58.Parse.cs +++ b/OnixLabs.Core/Text/Base58.Parse.cs @@ -18,44 +18,16 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base58 { - /// - /// Parses the specified Base-58 encoded value into a value. - /// - /// The Base-58 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// Returns a new instance, parsed from the specified Base-58 encoded value. + /// public static Base58 Parse(string value, IFormatProvider? provider = null) => Parse(value.AsSpan(), provider); - /// - /// Parses the specified Base-58 encoded value into a value. - /// - /// The Base-58 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// Returns a new instance, parsed from the specified Base-58 encoded value. + /// public static Base58 Parse(ReadOnlySpan value, IFormatProvider? provider = null) => new(IBaseCodec.Base58.Decode(value, provider)); - /// - /// Tries to parse the specified Base-58 encoded value into a value. - /// - /// The Base-58 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// - /// A new instance, parsed from the specified Base-58 encoded value, - /// or the default value if the specified Base-58 encoded could not be parsed. - /// - /// Returns if the specified Base-58 value was decoded successfully; otherwise, . + /// public static bool TryParse(string? value, IFormatProvider? provider, out Base58 result) => TryParse(value.AsSpan(), provider, out result); - /// - /// Tries to parse the specified Base-58 encoded value into a value. - /// - /// The Base-58 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// - /// A new instance, parsed from the specified Base-58 encoded value, - /// or the default value if the specified Base-58 encoded could not be parsed. - /// - /// Returns if the specified Base-58 value was decoded successfully; otherwise, . + /// public static bool TryParse(ReadOnlySpan value, IFormatProvider? provider, out Base58 result) { if (IBaseCodec.Base58.TryDecode(value, provider, out byte[] bytes)) diff --git a/OnixLabs.Core/Text/Base58.To.cs b/OnixLabs.Core/Text/Base58.To.cs index 23b562f1..8b98d1ed 100644 --- a/OnixLabs.Core/Text/Base58.To.cs +++ b/OnixLabs.Core/Text/Base58.To.cs @@ -18,32 +18,15 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base58 { - /// - /// Returns a that represents the current object. - /// - /// Returns a that represents the current object. + /// public override string ToString() => ToString(Base58FormatProvider.Bitcoin); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(IFormatProvider? formatProvider) => ToString(null, formatProvider); + /// + public string ToString(IFormatProvider? formatProvider = null) => ToString(null, formatProvider); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The format to use. - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(string? format, IFormatProvider? formatProvider) => ToString(format.AsSpan(), formatProvider); + /// + public string ToString(string? format, IFormatProvider? formatProvider = null) => ToString(format.AsSpan(), formatProvider); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The format to use. - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(ReadOnlySpan format, IFormatProvider? formatProvider) => IBaseCodec.Base58.Encode(value, formatProvider); + /// + public string ToString(ReadOnlySpan format, IFormatProvider? formatProvider = null) => IBaseCodec.Base58.Encode(value, formatProvider); } diff --git a/OnixLabs.Core/Text/Base58.cs b/OnixLabs.Core/Text/Base58.cs index 142a251b..aa0ef23e 100644 --- a/OnixLabs.Core/Text/Base58.cs +++ b/OnixLabs.Core/Text/Base58.cs @@ -21,44 +21,50 @@ namespace OnixLabs.Core.Text; /// /// Represents a Base-58 value. /// -/// The with which to initialize the instance. -public readonly partial struct Base58(ReadOnlySpan value) : IBaseValue +// ReSharper disable MemberCanBePrivate.Global +public readonly partial struct Base58 : IBaseValue { - private readonly byte[] value = value.ToArray(); + private readonly byte[] value; /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. - // ReSharper disable once MemberCanBePrivate.Global - public Base58(ReadOnlySequence value) : this(ReadOnlySpan.Empty) => value.CopyTo(out this.value); + /// + /// This constructor exists only to assign the array without allocating a new copy. + /// + /// The value with which to initialize the new instance. + private Base58(byte[] value) => this.value = value; /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. - /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global - public Base58(string value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) + /// The value with which to initialize the new instance. + public Base58(ReadOnlySpan value) : this(value.ToArray()) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The value with which to initialize the new instance. + public Base58(ReadOnlySequence value) : this(value.ToArray()) { } /// /// Initializes a new instance of the struct. /// - /// The array with which to initialize the instance. + /// The value with which to initialize the new instance. /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global - public Base58(char[] value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) + public Base58(ReadOnlySpan value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) { } /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. + /// The value with which to initialize the new instance. /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global public Base58(ReadOnlySequence value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) { } diff --git a/OnixLabs.Core/Text/Base58Codec.cs b/OnixLabs.Core/Text/Base58Codec.cs index c8ea8f01..52e44d3a 100644 --- a/OnixLabs.Core/Text/Base58Codec.cs +++ b/OnixLabs.Core/Text/Base58Codec.cs @@ -31,11 +31,9 @@ public sealed class Base58Codec : IBaseCodec /// The value to encode into a Base-58 representation. /// The format provider that will be used to encode the specified value. /// Returns a new Base-58 representation encoded from the specified value. - public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) - { - if (TryEncode(value, provider, out string result)) return result; - throw new FormatException(IBaseCodec.EncodingFormatException); - } + public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) => TryEncode(value, provider, out string result) + ? result + : throw new FormatException(IBaseCodec.EncodingFormatException); /// /// Decodes the specified Base-58 representation into a array. @@ -43,11 +41,9 @@ public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) /// The Base-58 value to decode into a array. /// The format provider that will be used to decode the specified value. /// Returns a new array decoded from the specified value. - public byte[] Decode(ReadOnlySpan value, IFormatProvider? provider = null) - { - if (TryDecode(value, provider, out byte[] result)) return result; - throw new FormatException(IBaseCodec.DecodingFormatException); - } + public byte[] Decode(ReadOnlySpan value, IFormatProvider? provider = null) => TryDecode(value, provider, out byte[] result) + ? result + : throw new FormatException(IBaseCodec.DecodingFormatException); /// /// Tries to encode the specified value into a Base-58 representation. diff --git a/OnixLabs.Core/Text/Base58FormatProvider.cs b/OnixLabs.Core/Text/Base58FormatProvider.cs index be496e00..7456b735 100644 --- a/OnixLabs.Core/Text/Base58FormatProvider.cs +++ b/OnixLabs.Core/Text/Base58FormatProvider.cs @@ -51,11 +51,6 @@ public sealed class Base58FormatProvider : Enumeration, IF /// public string Alphabet { get; } - /// Gets an object that provides formatting services for the specified type. - /// An object that specifies the type of format object to return. - /// - /// Returns an instance of the object specified by , - /// if the implementation can supply that type of object; otherwise, . - /// + /// public object? GetFormat(Type? formatType) => formatType == typeof(Base58FormatProvider) ? this : null; } diff --git a/OnixLabs.Core/Text/Base64.Convertible.cs b/OnixLabs.Core/Text/Base64.Convertible.cs index 6b3e0884..ad8475b5 100644 --- a/OnixLabs.Core/Text/Base64.Convertible.cs +++ b/OnixLabs.Core/Text/Base64.Convertible.cs @@ -20,57 +20,35 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base64 { - /// - /// Gets the underlying array representation of the current instance as a new instance. - /// - /// Return the underlying array representation of the current instance as a new instance. + /// public ReadOnlyMemory AsReadOnlyMemory() => value; - /// - /// Gets the underlying array representation of the current instance as a new instance. - /// - /// Return the underlying array representation of the current instance as a new instance. + /// public ReadOnlySpan AsReadOnlySpan() => value; /// - /// Create a new instance from the specified value. - /// - /// The value from which to create a new instance. - /// Returns a new instance from the specified value. - public static implicit operator Base64(byte[] value) => new(value); - - /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. /// Returns a new instance from the specified value. public static implicit operator Base64(ReadOnlySpan value) => new(value); /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. /// Returns a new instance from the specified value. public static implicit operator Base64(ReadOnlySequence value) => new(value); /// - /// Create a new instance from the specified value. - /// The value will be encoded using the encoding. - /// - /// The value from which to create a new instance. - /// Returns a new instance from the specified value. - public static implicit operator Base64(string value) => new(value); - - /// - /// Create a new instance from the specified array. - /// The array will be encoded using the encoding. + /// Creates a new instance from the specified value. /// /// The value from which to create a new instance. - /// Returns a new instance from the specified array. - public static implicit operator Base64(char[] value) => new(value); + /// Returns a new instance from the specified value. + public static implicit operator Base64(ReadOnlySpan value) => new(value); /// - /// Create a new instance from the specified value. + /// Creates a new instance from the specified value. /// The value will be encoded using the encoding. /// /// The value from which to create a new instance. diff --git a/OnixLabs.Core/Text/Base64.Equatable.cs b/OnixLabs.Core/Text/Base64.Equatable.cs index b102b13f..c66f2fb1 100644 --- a/OnixLabs.Core/Text/Base64.Equatable.cs +++ b/OnixLabs.Core/Text/Base64.Equatable.cs @@ -12,46 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.Collections.Generic; using OnixLabs.Core.Linq; namespace OnixLabs.Core.Text; public readonly partial struct Base64 { - /// - /// Checks whether the current object is equal to another object of the same type. - /// - /// An object to compare with the current object. - /// Returns if the current object is equal to the other parameter; otherwise, . - public bool Equals(Base64 other) => other.value.SequenceEqualOrNull(value); + /// + public static bool Equals(Base64 left, Base64 right) => left.value.SequenceEqualOrNull(right.value); - /// - /// Checks for equality between the current instance and another object. - /// - /// The object to check for equality. - /// Returns if the object is equal to the current instance; otherwise, . + /// + public bool Equals(Base64 other) => Equals(this, other); + + /// public override bool Equals(object? obj) => obj is Base64 other && Equals(other); - /// - /// Serves as a hash code function for the current instance. - /// - /// Returns a hash code for the current instance. + /// public override int GetHashCode() => value.GetContentHashCode(); - - /// - /// Performs an equality comparison between two object instances. - /// - /// The left-hand instance to compare. - /// The right-hand instance to compare. - /// Returns if the left-hand instance is equal to the right-hand instance; otherwise, . - public static bool operator ==(Base64 left, Base64 right) => EqualityComparer.Default.Equals(left, right); - - /// - /// Performs an inequality comparison between two object instances. - /// - /// The left-hand instance to compare. - /// The right-hand instance to compare. - /// Returns if the left-hand instance is not equal to the right-hand instance; otherwise, . - public static bool operator !=(Base64 left, Base64 right) => !EqualityComparer.Default.Equals(left, right); } diff --git a/OnixLabs.Core/Text/Base64.Format.cs b/OnixLabs.Core/Text/Base64.Format.cs index 3f3345a8..e84bfa35 100644 --- a/OnixLabs.Core/Text/Base64.Format.cs +++ b/OnixLabs.Core/Text/Base64.Format.cs @@ -18,16 +18,11 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base64 { - /// - /// Tries to format the value of the current instance into the provided span of characters. - /// - /// The span in which to write this instance's value formatted as a span of characters. - /// When this method returns, contains the number of characters that were written in . - /// A span containing the characters that represent a standard or custom format string that defines the acceptable format for . - /// An optional object that supplies culture-specific formatting information for . - /// Returns if the formatting was successful; otherwise, . - bool ISpanFormattable.TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - return ToString(format, provider).TryCopyTo(destination, out charsWritten); - } + /// + bool ISpanFormattable.TryFormat( + Span destination, + out int charsWritten, + ReadOnlySpan format, + IFormatProvider? provider + ) => ToString(format, provider).TryCopyTo(destination, out charsWritten); } diff --git a/OnixLabs.Core/Text/Base64.Parse.cs b/OnixLabs.Core/Text/Base64.Parse.cs index 83fd5ea4..22c9c234 100644 --- a/OnixLabs.Core/Text/Base64.Parse.cs +++ b/OnixLabs.Core/Text/Base64.Parse.cs @@ -18,44 +18,16 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base64 { - /// - /// Parses the specified Base-64 encoded value into a value. - /// - /// The Base-64 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// Returns a new instance, parsed from the specified Base-64 encoded value. + /// public static Base64 Parse(string value, IFormatProvider? provider = null) => Parse(value.AsSpan(), provider); - /// - /// Parses the specified Base-64 encoded value into a value. - /// - /// The Base-64 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// Returns a new instance, parsed from the specified Base-64 encoded value. + /// public static Base64 Parse(ReadOnlySpan value, IFormatProvider? provider = null) => new(IBaseCodec.Base64.Decode(value, provider)); - /// - /// Tries to parse the specified Base-64 encoded value into a value. - /// - /// The Base-64 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// - /// A new instance, parsed from the specified Base-64 encoded value, - /// or the default value if the specified Base-64 encoded could not be parsed. - /// - /// Returns if the specified Base-64 value was decoded successfully; otherwise, . + /// public static bool TryParse(string? value, IFormatProvider? provider, out Base64 result) => TryParse(value.AsSpan(), provider, out result); - /// - /// Tries to parse the specified Base-64 encoded value into a value. - /// - /// The Base-64 encoded value to parse. - /// The format provider that will be used to decode the specified value. - /// - /// A new instance, parsed from the specified Base-64 encoded value, - /// or the default value if the specified Base-64 encoded could not be parsed. - /// - /// Returns if the specified Base-64 value was decoded successfully; otherwise, . + /// public static bool TryParse(ReadOnlySpan value, IFormatProvider? provider, out Base64 result) { if (IBaseCodec.Base64.TryDecode(value, provider, out byte[] bytes)) diff --git a/OnixLabs.Core/Text/Base64.To.cs b/OnixLabs.Core/Text/Base64.To.cs index 7e1722ac..d1ce3a92 100644 --- a/OnixLabs.Core/Text/Base64.To.cs +++ b/OnixLabs.Core/Text/Base64.To.cs @@ -18,32 +18,15 @@ namespace OnixLabs.Core.Text; public readonly partial struct Base64 { - /// - /// Returns a that represents the current object. - /// - /// Returns a that represents the current object. - public override string ToString() => ToString(null); + /// + public override string ToString() => ToString(Base64FormatProvider.Rfc4648); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(IFormatProvider? formatProvider) => ToString(null, formatProvider); + /// + public string ToString(IFormatProvider? formatProvider = null) => ToString(null, formatProvider); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The format to use. - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(string? format, IFormatProvider? formatProvider) => ToString(format.AsSpan(), formatProvider); + /// + public string ToString(string? format, IFormatProvider? formatProvider = null) => ToString(format.AsSpan(), formatProvider); - /// - /// Formats the value of the current instance using the specified format. - /// - /// The format to use. - /// The provider to use to format the value. - /// The value of the current instance in the specified format. - public string ToString(ReadOnlySpan format, IFormatProvider? formatProvider) => IBaseCodec.Base64.Encode(value, formatProvider); + /// + public string ToString(ReadOnlySpan format, IFormatProvider? formatProvider = null) => IBaseCodec.Base64.Encode(value, formatProvider); } diff --git a/OnixLabs.Core/Text/Base64.cs b/OnixLabs.Core/Text/Base64.cs index 99a04f03..e49aeaf8 100644 --- a/OnixLabs.Core/Text/Base64.cs +++ b/OnixLabs.Core/Text/Base64.cs @@ -21,44 +21,50 @@ namespace OnixLabs.Core.Text; /// /// Represents a Base-64 value. /// -/// The with which to initialize the instance. -public readonly partial struct Base64(ReadOnlySpan value) : IBaseValue +// ReSharper disable MemberCanBePrivate.Global +public readonly partial struct Base64 : IBaseValue { - private readonly byte[] value = value.ToArray(); + private readonly byte[] value; /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. - // ReSharper disable once MemberCanBePrivate.Global - public Base64(ReadOnlySequence value) : this(ReadOnlySpan.Empty) => value.CopyTo(out this.value); + /// + /// This constructor exists only to assign the array without allocating a new copy. + /// + /// The value with which to initialize the new instance. + private Base64(byte[] value) => this.value = value; /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. - /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global - public Base64(string value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) + /// The value with which to initialize the new instance. + public Base64(ReadOnlySpan value) : this(value.ToArray()) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The value with which to initialize the new instance. + public Base64(ReadOnlySequence value) : this(value.ToArray()) { } /// /// Initializes a new instance of the struct. /// - /// The array with which to initialize the instance. + /// The value with which to initialize the new instance. /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global - public Base64(char[] value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) + public Base64(ReadOnlySpan value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) { } /// /// Initializes a new instance of the struct. /// - /// The with which to initialize the instance. + /// The value with which to initialize the new instance. /// The which will be used to obtain the underlying value. - // ReSharper disable once MemberCanBePrivate.Global public Base64(ReadOnlySequence value, Encoding? encoding = null) : this(encoding.GetOrDefault().GetBytes(value)) { } diff --git a/OnixLabs.Core/Text/Base64Codec.cs b/OnixLabs.Core/Text/Base64Codec.cs index 73190935..eee9592a 100644 --- a/OnixLabs.Core/Text/Base64Codec.cs +++ b/OnixLabs.Core/Text/Base64Codec.cs @@ -27,11 +27,9 @@ public sealed class Base64Codec : IBaseCodec /// The value to encode into a Base-64 representation. /// The format provider that will be used to encode the specified value. /// Returns a new Base-64 representation encoded from the specified value. - public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) - { - if (TryEncode(value, provider, out string result)) return result; - throw new FormatException(IBaseCodec.EncodingFormatException); - } + public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) => TryEncode(value, provider, out string result) + ? result + : throw new FormatException(IBaseCodec.EncodingFormatException); /// /// Decodes the specified Base-64 representation into a array. @@ -39,11 +37,9 @@ public string Encode(ReadOnlySpan value, IFormatProvider? provider = null) /// The Base-64 value to decode into a array. /// The format provider that will be used to decode the specified value. /// Returns a new array decoded from the specified value. - public byte[] Decode(ReadOnlySpan value, IFormatProvider? provider = null) - { - if (TryDecode(value, provider, out byte[] result)) return result; - throw new FormatException(IBaseCodec.DecodingFormatException); - } + public byte[] Decode(ReadOnlySpan value, IFormatProvider? provider = null) => TryDecode(value, provider, out byte[] result) + ? result + : throw new FormatException(IBaseCodec.DecodingFormatException); /// /// Tries to encode the specified value into a Base-64 representation. diff --git a/OnixLabs.Core/Text/Base64FormatProvider.cs b/OnixLabs.Core/Text/Base64FormatProvider.cs index 473ff8bf..5ec77497 100644 --- a/OnixLabs.Core/Text/Base64FormatProvider.cs +++ b/OnixLabs.Core/Text/Base64FormatProvider.cs @@ -40,11 +40,6 @@ public sealed class Base64FormatProvider : Enumeration, IF /// public string Alphabet { get; } - /// Gets an object that provides formatting services for the specified type. - /// An object that specifies the type of format object to return. - /// - /// Returns an instance of the object specified by , - /// if the implementation can supply that type of object; otherwise, . - /// + /// public object? GetFormat(Type? formatType) => formatType == typeof(Base64FormatProvider) ? this : null; } diff --git a/OnixLabs.Core/Text/Extensions.Encoding.cs b/OnixLabs.Core/Text/Extensions.Encoding.cs index d8d18a1d..ee72db74 100644 --- a/OnixLabs.Core/Text/Extensions.Encoding.cs +++ b/OnixLabs.Core/Text/Extensions.Encoding.cs @@ -12,22 +12,45 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; using System.ComponentModel; using System.Text; namespace OnixLabs.Core.Text; /// -/// Provides extension methods for text encodings. +/// Provides extension methods for instances. /// [EditorBrowsable(EditorBrowsableState.Never)] internal static class EncodingExtensions { /// - /// Gets the current , or the default encoding if the current is . + /// Provides extension methods for instances. /// - /// The default encoding is . - /// The current . - /// Returns the current , or the default encoding if the current is . - public static Encoding GetOrDefault(this Encoding? encoding) => encoding ?? Encoding.UTF8; + /// The current instance. + extension(Encoding? receiver) + { + /// + /// Gets the current , or the default encoding if the current is . + /// + /// The default encoding is . + /// Returns the current , or the default encoding if the current is . + public Encoding GetOrDefault() => receiver ?? Encoding.UTF8; + + /// + /// Gets a array from the specified value. + /// + /// The of to convert into a array. + /// Returns a array from the specified value. + public byte[] GetBytes(ReadOnlySpan value) + { + Encoding encodingOrDefault = receiver.GetOrDefault(); + int count = encodingOrDefault.GetByteCount(value); + byte[] result = new byte[count]; + + encodingOrDefault.GetBytes(value, result); + + return result; + } + } } diff --git a/OnixLabs.Core/Text/Extensions.IBaseValue.cs b/OnixLabs.Core/Text/Extensions.IBaseValue.cs new file mode 100644 index 00000000..7d9abc55 --- /dev/null +++ b/OnixLabs.Core/Text/Extensions.IBaseValue.cs @@ -0,0 +1,55 @@ +// Copyright 2020-2025 ONIXLabs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.ComponentModel; + +namespace OnixLabs.Core.Text; + +/// +/// Provides extension methods for instances. +/// +[EditorBrowsable(EditorBrowsableState.Never)] +public static class IBaseValueExtensions +{ + /// + /// Provides extension methods for instances. + /// + /// The underlying type. + extension(T) where T : struct, IBaseValue + { + /// + /// Determines whether the specified + /// value is equal to the specified value. + /// + /// The left-hand value to compare. + /// The right-hand value to compare. + /// + /// Returns if the specified value is equal to + /// the specified value; otherwise, . + /// + public static bool operator ==(T left, T right) => T.Equals(left, right); + + /// + /// Determines whether the specified + /// value is not equal to the specified value. + /// + /// The left-hand value to compare. + /// The right-hand value to compare. + /// + /// Returns if the specified value is not equal to + /// the specified value; otherwise, . + /// + public static bool operator !=(T left, T right) => !T.Equals(left, right); + } +} diff --git a/OnixLabs.Core/Text/Extensions.cs b/OnixLabs.Core/Text/Extensions.ReadOnlySpan.cs similarity index 98% rename from OnixLabs.Core/Text/Extensions.cs rename to OnixLabs.Core/Text/Extensions.ReadOnlySpan.cs index 7d32c9b2..2623e592 100644 --- a/OnixLabs.Core/Text/Extensions.cs +++ b/OnixLabs.Core/Text/Extensions.ReadOnlySpan.cs @@ -22,7 +22,7 @@ namespace OnixLabs.Core.Text; /// // ReSharper disable UnusedMethodReturnValue.Global [EditorBrowsable(EditorBrowsableState.Never)] -public static class Extensions +public static class ReadOnlySpanExtensions { /// /// Provides extension methods instances. diff --git a/OnixLabs.Core/Text/Extensions.StringBuilder.cs b/OnixLabs.Core/Text/Extensions.StringBuilder.cs index c140920e..ee549a54 100644 --- a/OnixLabs.Core/Text/Extensions.StringBuilder.cs +++ b/OnixLabs.Core/Text/Extensions.StringBuilder.cs @@ -27,153 +27,145 @@ public static class StringBuilderExtensions private const char EscapeSequence = '\\'; /// - /// Appends the specified values to the current . + /// Provides extension methods for instances. /// - /// The values to append. /// The current instance. - /// Returns the current with the specified values appended. - public static StringBuilder Append(this StringBuilder receiver, params object[] values) => receiver.AppendJoin(string.Empty, values); - - /// - /// Appends the specified value, prefixed with the escape sequence to the current . - /// - /// The value to append. - /// The current instance. - /// Returns the current with the escape sequence and specified value appended. - internal static StringBuilder AppendEscaped(this StringBuilder receiver, char value) => receiver.Append(EscapeSequence).Append(value); - - /// - /// Prepends the specified value to the current - /// - /// The value to prepend. - /// The current instance. - /// Returns the current with the specified values prepended. - public static StringBuilder Prepend(this StringBuilder receiver, object value) => receiver.Insert(0, value); - - /// - /// Prepends the specified value to the current - /// - /// The value to prepend. - /// The current instance. - /// Returns the current with the specified values prepended. - public static StringBuilder Prepend(this StringBuilder receiver, char value) => receiver.Insert(0, value); - - /// - /// Prepends the specified value to the current - /// - /// The value to prepend. - /// The current instance. - /// Returns the current with the specified values prepended. - public static StringBuilder Prepend(this StringBuilder receiver, string value) => receiver.Insert(0, value); - - /// - /// Prepends the specified values to the current . - /// - /// The values to prepend. - /// The current instance. - /// Returns the current with the specified values prepended. - public static StringBuilder Prepend(this StringBuilder receiver, params object[] values) => receiver.PrependJoin(string.Empty, values); - - /// - /// Concatenates the string representations of the elements in the provided array of objects, using the specified separator between each member, then prepends the result to the current instance of the string builder. - /// - /// The string to use as a separator. is included in the joined strings only if has more than one element. - /// An array that contains the strings to concatenate and append to the current instance of the string builder. - /// The current instance. - /// Returns the current with the specified values joined and prepended. - public static StringBuilder PrependJoin(this StringBuilder receiver, string separator, params object?[] values) => receiver.Prepend(string.Join(separator, values)); - - /// - /// Trims the specified value from the start and end of the current . - /// - /// The value to trim. - /// The current instance. - /// Returns the current with the specified value trimmed from the start and end. - public static StringBuilder Trim(this StringBuilder receiver, char value) => receiver.TrimStart(value).TrimEnd(value); - - /// - /// Trims the specified value from the end of the current . - /// - /// The value to trim. - /// The current instance. - /// Returns the current with the specified value trimmed from the end. - public static StringBuilder TrimEnd(this StringBuilder receiver, char value) - { - while (receiver.Length > 0 && receiver[^1] == value) - receiver.Remove(receiver.Length - 1, 1); - - return receiver; - } - - /// - /// Trims the specified value from the start of the current . - /// - /// The value to trim. - /// The current instance. - /// Returns the current with the specified value trimmed from the start. - public static StringBuilder TrimStart(this StringBuilder receiver, char value) - { - while (receiver.Length > 0 && receiver[0] == value) - receiver.Remove(0, 1); - - return receiver; - } - - /// - /// Trims the specified value from the start and end of the current . - /// - /// The value to trim. - /// The current instance. - /// Returns the current with the specified value trimmed from the start and end. - public static StringBuilder Trim(this StringBuilder receiver, string value) => receiver.TrimStart(value).TrimEnd(value); - - /// - /// Trims the specified value from the end of the current . - /// - /// The value to trim. - /// The current instance. - /// Returns the current with the specified value trimmed from the end. - public static StringBuilder TrimEnd(this StringBuilder receiver, string value) - { - if (string.IsNullOrEmpty(value)) return receiver; - - while (receiver.Length >= value.Length && receiver.ToString(receiver.Length - value.Length, value.Length) == value) - receiver.Remove(receiver.Length - value.Length, value.Length); - - return receiver; - } - - /// - /// Trims the specified value from the start of the current . - /// - /// The value to trim. - /// The current instance. - /// Returns the current with the specified value trimmed from the start. - public static StringBuilder TrimStart(this StringBuilder receiver, string value) + extension(StringBuilder receiver) { - if (string.IsNullOrEmpty(value)) return receiver; - - while (receiver.Length >= value.Length && receiver.ToString(0, value.Length) == value) - receiver.Remove(0, value.Length); - - return receiver; + /// + /// Appends the specified values to the current . + /// + /// The values to append. + /// Returns the current with the specified values appended. + public StringBuilder Append(params object[] values) => receiver.AppendJoin(string.Empty, values); + + /// + /// Appends the specified value, prefixed with the escape sequence to the current . + /// + /// The value to append. + /// Returns the current with the escape sequence and specified value appended. + internal StringBuilder AppendEscaped(char value) => receiver.Append(EscapeSequence).Append(value); + + /// + /// Prepends the specified value to the current + /// + /// The value to prepend. + /// Returns the current with the specified values prepended. + public StringBuilder Prepend(object value) => receiver.Insert(0, value); + + /// + /// Prepends the specified value to the current + /// + /// The value to prepend. + /// Returns the current with the specified values prepended. + public StringBuilder Prepend(char value) => receiver.Insert(0, value); + + /// + /// Prepends the specified value to the current + /// + /// The value to prepend. + /// Returns the current with the specified values prepended. + public StringBuilder Prepend(string value) => receiver.Insert(0, value); + + /// + /// Prepends the specified values to the current . + /// + /// The values to prepend. + /// Returns the current with the specified values prepended. + public StringBuilder Prepend(params object[] values) => receiver.PrependJoin(string.Empty, values); + + /// + /// Concatenates the string representations of the elements in the provided array of objects, using the specified separator between each member, then prepends the result to the current instance of the string builder. + /// + /// The string to use as a separator. is included in the joined strings only if has more than one element. + /// An array that contains the strings to concatenate and append to the current instance of the string builder. + /// Returns the current with the specified values joined and prepended. + public StringBuilder PrependJoin(string separator, params object?[] values) => receiver.Prepend(string.Join(separator, values)); + + /// + /// Trims the specified value from the start and end of the current . + /// + /// The value to trim. + /// Returns the current with the specified value trimmed from the start and end. + public StringBuilder Trim(char value) => receiver.TrimStart(value).TrimEnd(value); + + /// + /// Trims the specified value from the end of the current . + /// + /// The value to trim. + /// Returns the current with the specified value trimmed from the end. + public StringBuilder TrimEnd(char value) + { + while (receiver.Length > 0 && receiver[^1] == value) + receiver.Remove(receiver.Length - 1, 1); + + return receiver; + } + + /// + /// Trims the specified value from the start of the current . + /// + /// The value to trim. + /// Returns the current with the specified value trimmed from the start. + public StringBuilder TrimStart(char value) + { + while (receiver.Length > 0 && receiver[0] == value) + receiver.Remove(0, 1); + + return receiver; + } + + /// + /// Trims the specified value from the start and end of the current . + /// + /// The value to trim. + /// Returns the current with the specified value trimmed from the start and end. + public StringBuilder Trim(string value) => receiver.TrimStart(value).TrimEnd(value); + + /// + /// Trims the specified value from the end of the current . + /// + /// The value to trim. + /// Returns the current with the specified value trimmed from the end. + public StringBuilder TrimEnd(string value) + { + if (string.IsNullOrEmpty(value)) return receiver; + + while (receiver.Length >= value.Length && receiver.ToString(receiver.Length - value.Length, value.Length) == value) + receiver.Remove(receiver.Length - value.Length, value.Length); + + return receiver; + } + + /// + /// Trims the specified value from the start of the current . + /// + /// The value to trim. + /// Returns the current with the specified value trimmed from the start. + public StringBuilder TrimStart(string value) + { + if (string.IsNullOrEmpty(value)) return receiver; + + while (receiver.Length >= value.Length && receiver.ToString(0, value.Length) == value) + receiver.Remove(0, value.Length); + + return receiver; + } + + /// + /// Wraps the current between the specified start and end values. + /// + /// The value to prepend. + /// The value to append. + /// Returns the current wrapped between the specified start and end values. + public StringBuilder Wrap(char start, char end) => receiver.Prepend(start).Append(end); + + /// + /// Wraps the current between the specified start and end values. + /// + /// The value to prepend. + /// The value to append. + /// Returns the current wrapped between the specified start and end values. + public StringBuilder Wrap(string start, string end) => receiver.Prepend(start).Append(end); } - - /// - /// Wraps the current between the specified start and end values. - /// - /// The value to prepend. - /// The value to append. - /// The current instance. - /// Returns the current wrapped between the specified start and end values. - public static StringBuilder Wrap(this StringBuilder receiver, char start, char end) => receiver.Prepend(start).Append(end); - - /// - /// Wraps the current between the specified start and end values. - /// - /// The value to prepend. - /// The value to append. - /// The current instance. - /// Returns the current wrapped between the specified start and end values. - public static StringBuilder Wrap(this StringBuilder receiver, string start, string end) => receiver.Prepend(start).Append(end); } diff --git a/OnixLabs.Core/Text/IBaseCodec.cs b/OnixLabs.Core/Text/IBaseCodec.cs index 397f2969..904439da 100644 --- a/OnixLabs.Core/Text/IBaseCodec.cs +++ b/OnixLabs.Core/Text/IBaseCodec.cs @@ -66,11 +66,9 @@ public interface IBaseCodec /// /// Returns a base representation of the specified value. /// If the specified value cannot be converted. - public static string GetString(ReadOnlySpan value, IFormatProvider provider) - { - if (TryGetString(value, provider, out string result)) return result; - throw new FormatException(EncodingFormatException); - } + public static string GetString(ReadOnlySpan value, IFormatProvider provider) => TryGetString(value, provider, out string result) + ? result + : throw new FormatException(EncodingFormatException); /// /// Obtains a new array array by converting the specified value. @@ -82,11 +80,9 @@ public static string GetString(ReadOnlySpan value, IFormatProvider provide /// /// Returns a new array array by converting the specified value. /// If the specified value cannot be converted. - public static byte[] GetBytes(ReadOnlySpan value, IFormatProvider provider) - { - if (TryGetBytes(value, provider, out byte[] result)) return result; - throw new FormatException(DecodingFormatException); - } + public static byte[] GetBytes(ReadOnlySpan value, IFormatProvider provider) => TryGetBytes(value, provider, out byte[] result) + ? result + : throw new FormatException(DecodingFormatException); /// /// Tries to obtain a base representation of the specified value. diff --git a/OnixLabs.Core/Text/IBaseValue.cs b/OnixLabs.Core/Text/IBaseValue.cs index 103c244a..255f78fe 100644 --- a/OnixLabs.Core/Text/IBaseValue.cs +++ b/OnixLabs.Core/Text/IBaseValue.cs @@ -26,7 +26,7 @@ public interface IBaseValue : IBinaryConvertible, ISpanFormattable /// /// The provider to use to format the value. /// The value of the current instance in the specified format. - string ToString(IFormatProvider? formatProvider); + string ToString(IFormatProvider? formatProvider = null); /// /// Formats the value of the current instance using the specified format. @@ -34,10 +34,23 @@ public interface IBaseValue : IBinaryConvertible, ISpanFormattable /// The format to use. /// The provider to use to format the value. /// The value of the current instance in the specified format. - string ToString(ReadOnlySpan format, IFormatProvider? formatProvider); + string ToString(ReadOnlySpan format, IFormatProvider? formatProvider = null); } /// /// Defines a generic base encoding representation. /// -public interface IBaseValue : IValueEquatable, ISpanParsable, IBaseValue where T : struct, IBaseValue; +public interface IBaseValue : IEquatable, ISpanParsable, IBaseValue where T : struct, IBaseValue +{ + /// + /// Determines whether the specified + /// value is equal to the specified value. + /// + /// The left-hand value to compare. + /// The right-hand value to compare. + /// + /// Returns if the specified value is equal to + /// the specified value; otherwise, . + /// + static abstract bool Equals(T left, T right); +} diff --git a/OnixLabs.Playground/Program.cs b/OnixLabs.Playground/Program.cs index d6298394..826ac1aa 100644 --- a/OnixLabs.Playground/Program.cs +++ b/OnixLabs.Playground/Program.cs @@ -12,11 +12,43 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; +using System.Collections.Generic; +using OnixLabs.Core; +using OnixLabs.Core.Linq; + namespace OnixLabs.Playground; internal static class Program { private static void Main() { + Person[] people = + [ + new("John Smith", 32), + new("Abu Akbar", 10), + new("Brenda Furlong", 41), + new("Charlie Chester", 77), + new("David Dickinson", 19) + ]; + + Specification spec1 = !(Specification.Empty + & new PersonNameEquals("John Smith") + | new PersonAgeGreaterThan(40)); + + IEnumerable filtered = people.Where(spec1); + + foreach (Person person in filtered) + { + Console.WriteLine($"{person.Name} {person.Age}"); + } } } + +internal sealed record Person(string Name, int Age); + +internal sealed class PersonNameEquals(string name) : CriteriaSpecification(person => person.Name == name); + +internal sealed class PersonAgeGreaterThan(int age) : CriteriaSpecification(person => person.Age >= age); + +internal sealed class PersonAgeLessThan(int age) : CriteriaSpecification(person => person.Age <= age); diff --git a/onixlabs-dotnet.sln b/onixlabs-dotnet.sln deleted file mode 100644 index 9c03580a..00000000 --- a/onixlabs-dotnet.sln +++ /dev/null @@ -1,126 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Core", "OnixLabs.Core\OnixLabs.Core.csproj", "{1EDC1164-0205-433D-A356-00DAD4686264}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Playground", "OnixLabs.Playground\OnixLabs.Playground.csproj", "{23F9EB42-D9D4-4C43-9C99-3D2A1F8866B7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Core.UnitTests", "OnixLabs.Core.UnitTests\OnixLabs.Core.UnitTests.csproj", "{893547DB-4EAA-4D1F-886F-0D6114F8601E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Security.Cryptography", "OnixLabs.Security.Cryptography\OnixLabs.Security.Cryptography.csproj", "{78FDB1BA-6545-41DE-99B8-F007C6A6B093}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Security.Cryptography.UnitTests", "OnixLabs.Security.Cryptography.UnitTests\OnixLabs.Security.Cryptography.UnitTests.csproj", "{C3DE665B-5B02-41DE-8BB0-C53A1326E162}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Core.UnitTests.Data", "OnixLabs.Core.UnitTests.Data\OnixLabs.Core.UnitTests.Data.csproj", "{E3FBC79F-7F5A-4ECF-9653-C0AB203FF5D5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Security.Cryptography.UnitTests.Data", "OnixLabs.Security.Cryptography.UnitTests.Data\OnixLabs.Security.Cryptography.UnitTests.Data.csproj", "{513CFC09-42E2-43C3-BB68-90640D78CDF4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Numerics", "OnixLabs.Numerics\OnixLabs.Numerics.csproj", "{571D23F3-BC70-4646-A63C-844AED8291E3}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Numerics.UnitTests", "OnixLabs.Numerics.UnitTests\OnixLabs.Numerics.UnitTests.csproj", "{5D14F804-600B-4CFF-8900-53F66D7821E8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Numerics.UnitTests.Data", "OnixLabs.Numerics.UnitTests.Data\OnixLabs.Numerics.UnitTests.Data.csproj", "{3A85C8CF-D5EF-4130-8CC0-8AAB07983707}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{45B3DB8D-3344-4CB5-A6B9-A587514056EA}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Numerics", "Numerics", "{95655D21-93CD-4A49-AAB2-E7A262E7B730}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Security.Cryptography", "Security.Cryptography", "{564C7FAB-BEA0-4B10-BE14-6C151E0ACE6E}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Security", "Security", "{98F9DF85-9761-48E4-91A9-27B7D9BF97ED}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Security", "OnixLabs.Security\OnixLabs.Security.csproj", "{7F50B989-B580-41B9-B29F-10467DE925F8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.Security.UnitTests", "OnixLabs.Security.UnitTests\OnixLabs.Security.UnitTests.csproj", "{B531B818-820C-4013-9B88-E8AA87ED25FB}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DependencyInjection", "DependencyInjection", "{B994A750-D259-4CEB-B913-BAFF4B57EC51}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.DependencyInjection", "OnixLabs.DependencyInjection\OnixLabs.DependencyInjection.csproj", "{DD205971-F1AB-4D9C-A83F-17BC70F4529E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.DependencyInjection.UnitTests", "OnixLabs.DependencyInjection.UnitTests\OnixLabs.DependencyInjection.UnitTests.csproj", "{FCC4E51B-F3D2-402F-A530-7C8FD6693952}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnixLabs.DependencyInjection.UnitTests.Data", "OnixLabs.DependencyInjection.UnitTests.Data\OnixLabs.DependencyInjection.UnitTests.Data.csproj", "{F1841D46-F428-4A54-BA74-6BD2D38812D9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {1EDC1164-0205-433D-A356-00DAD4686264} = {45B3DB8D-3344-4CB5-A6B9-A587514056EA} - {E3FBC79F-7F5A-4ECF-9653-C0AB203FF5D5} = {45B3DB8D-3344-4CB5-A6B9-A587514056EA} - {893547DB-4EAA-4D1F-886F-0D6114F8601E} = {45B3DB8D-3344-4CB5-A6B9-A587514056EA} - {571D23F3-BC70-4646-A63C-844AED8291E3} = {95655D21-93CD-4A49-AAB2-E7A262E7B730} - {5D14F804-600B-4CFF-8900-53F66D7821E8} = {95655D21-93CD-4A49-AAB2-E7A262E7B730} - {3A85C8CF-D5EF-4130-8CC0-8AAB07983707} = {95655D21-93CD-4A49-AAB2-E7A262E7B730} - {78FDB1BA-6545-41DE-99B8-F007C6A6B093} = {564C7FAB-BEA0-4B10-BE14-6C151E0ACE6E} - {C3DE665B-5B02-41DE-8BB0-C53A1326E162} = {564C7FAB-BEA0-4B10-BE14-6C151E0ACE6E} - {513CFC09-42E2-43C3-BB68-90640D78CDF4} = {564C7FAB-BEA0-4B10-BE14-6C151E0ACE6E} - {7F50B989-B580-41B9-B29F-10467DE925F8} = {98F9DF85-9761-48E4-91A9-27B7D9BF97ED} - {B531B818-820C-4013-9B88-E8AA87ED25FB} = {98F9DF85-9761-48E4-91A9-27B7D9BF97ED} - {DD205971-F1AB-4D9C-A83F-17BC70F4529E} = {B994A750-D259-4CEB-B913-BAFF4B57EC51} - {FCC4E51B-F3D2-402F-A530-7C8FD6693952} = {B994A750-D259-4CEB-B913-BAFF4B57EC51} - {F1841D46-F428-4A54-BA74-6BD2D38812D9} = {B994A750-D259-4CEB-B913-BAFF4B57EC51} - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1EDC1164-0205-433D-A356-00DAD4686264}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1EDC1164-0205-433D-A356-00DAD4686264}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1EDC1164-0205-433D-A356-00DAD4686264}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1EDC1164-0205-433D-A356-00DAD4686264}.Release|Any CPU.Build.0 = Release|Any CPU - {23F9EB42-D9D4-4C43-9C99-3D2A1F8866B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {23F9EB42-D9D4-4C43-9C99-3D2A1F8866B7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {23F9EB42-D9D4-4C43-9C99-3D2A1F8866B7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {23F9EB42-D9D4-4C43-9C99-3D2A1F8866B7}.Release|Any CPU.Build.0 = Release|Any CPU - {893547DB-4EAA-4D1F-886F-0D6114F8601E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {893547DB-4EAA-4D1F-886F-0D6114F8601E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {893547DB-4EAA-4D1F-886F-0D6114F8601E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {893547DB-4EAA-4D1F-886F-0D6114F8601E}.Release|Any CPU.Build.0 = Release|Any CPU - {78FDB1BA-6545-41DE-99B8-F007C6A6B093}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {78FDB1BA-6545-41DE-99B8-F007C6A6B093}.Debug|Any CPU.Build.0 = Debug|Any CPU - {78FDB1BA-6545-41DE-99B8-F007C6A6B093}.Release|Any CPU.ActiveCfg = Release|Any CPU - {78FDB1BA-6545-41DE-99B8-F007C6A6B093}.Release|Any CPU.Build.0 = Release|Any CPU - {C3DE665B-5B02-41DE-8BB0-C53A1326E162}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C3DE665B-5B02-41DE-8BB0-C53A1326E162}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C3DE665B-5B02-41DE-8BB0-C53A1326E162}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C3DE665B-5B02-41DE-8BB0-C53A1326E162}.Release|Any CPU.Build.0 = Release|Any CPU - {E3FBC79F-7F5A-4ECF-9653-C0AB203FF5D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E3FBC79F-7F5A-4ECF-9653-C0AB203FF5D5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E3FBC79F-7F5A-4ECF-9653-C0AB203FF5D5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E3FBC79F-7F5A-4ECF-9653-C0AB203FF5D5}.Release|Any CPU.Build.0 = Release|Any CPU - {513CFC09-42E2-43C3-BB68-90640D78CDF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {513CFC09-42E2-43C3-BB68-90640D78CDF4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {513CFC09-42E2-43C3-BB68-90640D78CDF4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {513CFC09-42E2-43C3-BB68-90640D78CDF4}.Release|Any CPU.Build.0 = Release|Any CPU - {571D23F3-BC70-4646-A63C-844AED8291E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {571D23F3-BC70-4646-A63C-844AED8291E3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {571D23F3-BC70-4646-A63C-844AED8291E3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {571D23F3-BC70-4646-A63C-844AED8291E3}.Release|Any CPU.Build.0 = Release|Any CPU - {5D14F804-600B-4CFF-8900-53F66D7821E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5D14F804-600B-4CFF-8900-53F66D7821E8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5D14F804-600B-4CFF-8900-53F66D7821E8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5D14F804-600B-4CFF-8900-53F66D7821E8}.Release|Any CPU.Build.0 = Release|Any CPU - {3A85C8CF-D5EF-4130-8CC0-8AAB07983707}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3A85C8CF-D5EF-4130-8CC0-8AAB07983707}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3A85C8CF-D5EF-4130-8CC0-8AAB07983707}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3A85C8CF-D5EF-4130-8CC0-8AAB07983707}.Release|Any CPU.Build.0 = Release|Any CPU - {7F50B989-B580-41B9-B29F-10467DE925F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7F50B989-B580-41B9-B29F-10467DE925F8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7F50B989-B580-41B9-B29F-10467DE925F8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7F50B989-B580-41B9-B29F-10467DE925F8}.Release|Any CPU.Build.0 = Release|Any CPU - {B531B818-820C-4013-9B88-E8AA87ED25FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B531B818-820C-4013-9B88-E8AA87ED25FB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B531B818-820C-4013-9B88-E8AA87ED25FB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B531B818-820C-4013-9B88-E8AA87ED25FB}.Release|Any CPU.Build.0 = Release|Any CPU - {DD205971-F1AB-4D9C-A83F-17BC70F4529E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DD205971-F1AB-4D9C-A83F-17BC70F4529E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DD205971-F1AB-4D9C-A83F-17BC70F4529E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DD205971-F1AB-4D9C-A83F-17BC70F4529E}.Release|Any CPU.Build.0 = Release|Any CPU - {FCC4E51B-F3D2-402F-A530-7C8FD6693952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FCC4E51B-F3D2-402F-A530-7C8FD6693952}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FCC4E51B-F3D2-402F-A530-7C8FD6693952}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FCC4E51B-F3D2-402F-A530-7C8FD6693952}.Release|Any CPU.Build.0 = Release|Any CPU - {F1841D46-F428-4A54-BA74-6BD2D38812D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F1841D46-F428-4A54-BA74-6BD2D38812D9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F1841D46-F428-4A54-BA74-6BD2D38812D9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F1841D46-F428-4A54-BA74-6BD2D38812D9}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/onixlabs-dotnet.slnx b/onixlabs-dotnet.slnx new file mode 100644 index 00000000..d46f864f --- /dev/null +++ b/onixlabs-dotnet.slnx @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/onixlabs-dotnet.sln.DotSettings b/onixlabs-dotnet.slnx.DotSettings similarity index 100% rename from onixlabs-dotnet.sln.DotSettings rename to onixlabs-dotnet.slnx.DotSettings