diff --git a/.editorconfig b/.editorconfig index 8a511277..9ca038c9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -51,8 +51,8 @@ dotnet_diagnostic.FAA0004.severity = error # Replace NUnit assertion with Fluen dotnet_diagnostic.NUnit1001.severity = none # The individual arguments provided by a TestCaseAttribute must match the type of the corresponding parameter of the method dotnet_diagnostic.NUnit2005.severity = suggestion # Consider using Assert.That(actual, Is.EqualTo(expected)) instead of Assert.AreEqual(expected, actual) dotnet_diagnostic.NUnit2021.severity = warning # Incompatible types for EqualTo constraint - - +dotnet_diagnostic.NUnit2005.severity = error # Consider using Assert.That instead of AreEqual +dotnet_diagnostic.NUnit2033.severity = error # Consider using Assert.That instead of NotZero dotnet_diagnostic.QW0001.severity = none # Use a testable Time Provider dotnet_diagnostic.QW0010.severity = none # Use DateOnly instead of Date @@ -113,7 +113,6 @@ dotnet_diagnostic.S3925.severity = none # "ISerializable" should be implemented dotnet_diagnostic.S4136.severity = none # Method overloads should be grouped together dotnet_diagnostic.S1133.severity = suggestion # Deprecated code should be removed -dotnet_diagnostic.S3900.severity = suggestion # Arguments of public methods should be validated against null dotnet_diagnostic.S107.severity = warning # Methods should not have too many parameters dotnet_diagnostic.S127.severity = warning # Methods should not have too many parameters @@ -136,6 +135,7 @@ dotnet_diagnostic.S3215.severity = warning # Interface instances should not be c dotnet_diagnostic.S3218.severity = warning # Inner class members should not shadow outer class "static" or type members dotnet_diagnostic.S3257.severity = warning # Declarations and initializations should be as concise as possible dotnet_diagnostic.S3776.severity = warning # Cognitive Complexity of methods should not be too high +dotnet_diagnostic.S3900.severity = warning # Arguments of public methods should be validated against null dotnet_diagnostic.S6354.severity = warning # Use a testable (date) time provider instead dotnet_diagnostic.VSSpell001.severity = silent # Correct spelling \ No newline at end of file diff --git a/specs/Qowaiv.Specs/Date_span_specs.cs b/specs/Qowaiv.Specs/Date_span_specs.cs index c222fc05..4482db9a 100644 --- a/specs/Qowaiv.Specs/Date_span_specs.cs +++ b/specs/Qowaiv.Specs/Date_span_specs.cs @@ -1,4 +1,6 @@ -namespace Date_span_specs; +using FluentAssertions.Extensions; + +namespace Date_span_specs; public class Is_comparable { @@ -141,6 +143,16 @@ public void plus_does_nothing() } } +public class Can_be_added_to +{ + [Test] + public void Date_times() + { + var date = 30.January(1999).At(13, 42).AsUtc(); + date.Add(DateSpan.FromMonths(1)).Should().Be(28.February(1999).At(13, 42).AsUtc()); + } +} + public class Can_create { [Test] diff --git a/specs/Qowaiv.Specs/Debug_SVO_specs.cs b/specs/Qowaiv.Specs/Debug_SVO_specs.cs index 68d4259d..509b61d3 100644 --- a/specs/Qowaiv.Specs/Debug_SVO_specs.cs +++ b/specs/Qowaiv.Specs/Debug_SVO_specs.cs @@ -42,7 +42,7 @@ public void display(Type svoType, object display) public class Unknown_value : SingleValueObjectSpecs { public static IEnumerable SvosWithDefaultUnknown - => SvosWithUnknown.Except(new[] { typeof(Sex), typeof(InternetMediaType) }); + => SvosWithUnknown.Except([typeof(Sex), typeof(InternetMediaType)]); [TestCaseSource(nameof(SvosWithDefaultUnknown))] public void displays_unknown_for(Type svoType) diff --git a/specs/Qowaiv.Specs/Formatting/Formatting_arguments_collection_specs.cs b/specs/Qowaiv.Specs/Formatting/Formatting_arguments_collection_specs.cs new file mode 100644 index 00000000..c9eec937 --- /dev/null +++ b/specs/Qowaiv.Specs/Formatting/Formatting_arguments_collection_specs.cs @@ -0,0 +1,338 @@ +namespace Formatting_arguments_collection_specs; + +public class Can_be_constructed +{ + [Test] + public void based_on_parent_collection() + { + var parent = new FormattingArgumentsCollection(TestCultures.nl) + { + { typeof(Date), "yyyy-MM" }, + }; + + var collection = new FormattingArgumentsCollection(TestCultures.nl_BE, parent); + collection.Should().ContainSingle(); + } +} + +public class Formats +{ + [Test] + public void indexes_up_to_1_000_000() + { + var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")); + var args = new object[1_000_001]; + args[1_000_000] = "Test"; + collection.Format("Begin {1000000} End", args).Should().Be("Begin Test End"); + } + + [Test] + public void with_allign_left() + { + var collection = new FormattingArgumentsCollection(); + collection.Format("{0,-4}", "a").Should().Be("a "); + } + + [Test] + public void with_allign_right() + { + var collection = new FormattingArgumentsCollection(); + collection.Format("{0,3}", "a").Should().Be(" a"); + } + + [Test] + public void null_arguments() + { + var collection = new FormattingArgumentsCollection(); + var args = new object?[] { null }; + collection.Format("Value: '{0}'", args).Should().Be("Value: ''"); + } + + [TestCase("{{", "{")] + [TestCase("}}", "}")] + public void with_escaped_placehodlers(string format, string formatted) + { + var collection = new FormattingArgumentsCollection(); + collection.Format(format).Should().Be(formatted); + } + + [Test] + public void applying_specified_formats() + { + using (CultureInfoScope.NewInvariant()) + { + var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")) + { + { typeof(Date), "yyyy-MM-dd HH:mm" }, + { typeof(decimal), "0.000" } + }; + + var formatted = collection.Format("{0:000.00} - {1} * {1:dd-MM-yyyy} - {2} - {3} - {4}", 3, new Date(2014, 10, 8), 666, 0.8m, 0.9); + formatted.Should().Be("003,00 - 2014-10-08 00:00 * 08-10-2014 - 666 - 0,800 - 0,9"); + } + } + + [Test] + public void applying_custom_format_provider() + { + using (CultureInfoScope.NewInvariant()) + { + var collection = new FormattingArgumentsCollection(FormatProvider.CustomFormatter) + { + { typeof(Date), "yyyy-MM-dd HH:mm" }, + { typeof(decimal), "0.000" } + }; + + var formattted = collection.Format("{0:yyyy-MM-dd} * {0}", new Date(2014, 10, 8)); + formattted.Should().Be("Unit Test Formatter, value: '2014-10-08', format: 'yyyy-MM-dd' * Unit Test Formatter, value: '10/08/2014', format: ''"); + } + } +} + +public class Does_not_support_formats +{ + private static readonly FormattingArgumentsCollection Collection = new(TestCultures.en_GB); + + [Test] + public void with_length_not_being_a_number() + => "{0,a}".Invoking(format => Collection.Format(format)).Should().Throw(); + + [Test] + public void with_index_not_being_a_number() + => "{x}".Invoking(format => Collection.Format(format)).Should().Throw(); + + [Test] + public void with_index_not_being_negative() + => "{-1}".Invoking(format => Collection.Format(format)).Should().Throw(); + + [TestCase("{")] + [TestCase("{0")] + [TestCase("}")] + public void with_mallformed_placeholders(string format) + => format.Invoking(f => Collection.Format(f)).Should().Throw(); + + [Test] + public void indexes_beging_out_of_range() + => "{0}{1}".Invoking(format => Collection.Format(format, 1)) + .Should() + .Throw() + .WithMessage("Index (zero based) must be greater than or equal to zero and less than the size of the argument list."); +} + +public class Stringifies +{ + [Test] + public void IFormattable_null_as_null() + { + IFormattable? obj = null; + var collection = new FormattingArgumentsCollection(); + collection.ToString(obj).Should().BeNull(); + } + [Test] + public void object_null_as_null() + { + var collection = new FormattingArgumentsCollection(); + collection.ToString((object?)null).Should().BeNull(); + } + [Test] + public void object_as_ToString_value() + { + var collection = new FormattingArgumentsCollection(); + collection.ToString(typeof(int)).Should().Be("System.Int32"); + } + + [Test] + public void appying_peferred_formats() + { + var collection = new FormattingArgumentsCollection + { + { typeof(int), "000" } + }; + collection.ToString((object)7).Should().Be("007"); + } +} + +public class Can_be_modified +{ + public class Adding + { + [Test] + public void format() + { + var collection = new FormattingArgumentsCollection(); + collection.Should().BeEmpty(); + collection.Add(typeof(int), "Int32Format"); + collection.Should().ContainSingle(); + } + + [Test] + public void IFormatProvider() + { + var collection = new FormattingArgumentsCollection(); + collection.Should().BeEmpty(); + collection.Add(typeof(int), new CultureInfo("nl-NL")); + collection.Should().ContainSingle(); + } + + [Test] + public void format_with_IFormatProvider() + { + var collection = new FormattingArgumentsCollection(); + collection.Should().BeEmpty(); + collection.Add(typeof(int), "Int32Format", new CultureInfo("nl-NL")); + collection.Should().ContainSingle(); + } + } + + public class Setting + { + [Test] + public void format() + { + var collection = new FormattingArgumentsCollection(); + collection.Should().BeEmpty(); + collection.Set(typeof(int), "Int32Format"); + collection.Should().ContainSingle(); + } + + [Test] + public void IFormatProvider() + { + var collection = new FormattingArgumentsCollection(); + collection.Should().BeEmpty(); + collection.Set(typeof(int), new CultureInfo("nl-NL")); + collection.Should().ContainSingle(); + } + + [Test] + public void format_with_IFormatProvider() + { + var collection = new FormattingArgumentsCollection(); + collection.Should().BeEmpty(); + collection.Set(typeof(int), "Int32Format", new CultureInfo("nl-NL")); + collection.Should().ContainSingle(); + } + + [Test] + public void same_key_twice() + { + var collection = new FormattingArgumentsCollection(); + collection.Set(typeof(int), "New"); + collection.Set(typeof(int), "Update"); + collection.Should().ContainSingle(); + } + } + + public class Removing + { + [Test] + public void non_cotained_key() + { + var collection = new FormattingArgumentsCollection(); + collection.Remove(typeof(int)).Should().BeFalse(); + } + + [Test] + public void contained_key() + { + var collection = new FormattingArgumentsCollection + { + { typeof(int), "Int32Format" }, + { typeof(long), "Int64Format" }, + }; + + collection.Remove(typeof(int)).Should().BeTrue(); + collection.Should().ContainSingle(); + } + } + + [Test] + public void Clear_CollectionWithTwoItems_0Items() + { + var collection = new FormattingArgumentsCollection + { + { typeof(int), "Int32Format" }, + { typeof(Date), "Date" } + }; + collection.Clear(); + + var act = collection.Count; + var exp = 0; + + act.Should().Be(exp); + } +} + +public class Can_be_queried +{ + [Test] + public void on_types() + { + var collection = new FormattingArgumentsCollection + { + { typeof(int), "Int32Format" }, + { typeof(Date), "Date" } + }; + + var act = collection.Types; + var exp = new[] { typeof(int), typeof(Date) }; + + act.Should().BeEquivalentTo(exp); + } + + [Test] + public void on_types_contained() + { + var collection = new FormattingArgumentsCollection + { + { typeof(int), "00" } + }; + collection.Contains(typeof(int)).Should().BeTrue(); + } + + [Test] + public void on_types_not_contained() + { + var collection = new FormattingArgumentsCollection(); + collection.Contains(typeof(int)).Should().BeFalse(); + } + + [Test] + public void via_enumerator() + { + var collection = new FormattingArgumentsCollection + { + { typeof(int), "Int32Format" }, + { typeof(Date), "Date" } + }; + + var ienumerable = collection as IEnumerable>; + ienumerable.Should().HaveCount(2); + } +} + +public class Does_not_support +{ + private static readonly FormattingArgumentsCollection Collection = new(TestCultures.en_GB); + + [Test] + public void types_who_are_not_formattable() + => Collection.Invoking(c => c.Add(typeof(Type), "")) + .Should() + .Throw() + .WithMessage("The argument must implement System.IFormattable.*"); + + [Test] + public void same_key_twice() + { + var collection = new FormattingArgumentsCollection + { + { typeof(int), "New" } + }; + + collection.Invoking(c => c.Add(typeof(int), "Update")) + .Should() + .Throw() + .WithMessage("An item with the same key has already been added.*"); + } +} \ No newline at end of file diff --git a/specs/Qowaiv.Specs/Formatting/String_formatter_specs.cs b/specs/Qowaiv.Specs/Formatting/String_formatter_specs.cs index b8ce9147..00d1a85f 100644 --- a/specs/Qowaiv.Specs/Formatting/String_formatter_specs.cs +++ b/specs/Qowaiv.Specs/Formatting/String_formatter_specs.cs @@ -1,6 +1,6 @@ namespace String_formatter_specs; -public class TryApplyCustomFormatter +public class Try_apply_custom_formatter { [Test] public void false_if_no_customformatter_could_be_found() @@ -38,3 +38,33 @@ public string Format(string? format, object? arg, IFormatProvider? formatProvide => formatType == typeof(ICustomFormatter) ? this : null; } } + +public class Apply +{ + + [Test] + public void Apply_InvalidFormat_ThrowsFormatException() + => int.MinValue.Invoking(v => StringFormatter.Apply(v, "\\", CultureInfo.InvariantCulture, [])) + .Should() + .Throw() + .WithMessage("Input string was not in a correct format."); +} + +public class To_non_diacritic +{ + [Test] + public void null_stays_null() + => StringFormatter.ToNonDiacritic(Nil.String).Should().Be(Nil.String); + + [Test] + public void string_empty_stays_string_empty() + => StringFormatter.ToNonDiacritic(string.Empty).Should().Be(string.Empty); + + [Test] + public void updates_diacritic() + => StringFormatter.ToNonDiacritic("Café & Straße").Should().Be("Cafe & Strasze"); + + [Test] + public void updates_diacritic_ignoring_specified() + => StringFormatter.ToNonDiacritic("Café & Straße", "é").Should().Be("Café & Strasze"); +} \ No newline at end of file diff --git a/specs/Qowaiv.Specs/Month_specs.cs b/specs/Qowaiv.Specs/Month_specs.cs index 1e52605b..b9c4e1a6 100644 --- a/specs/Qowaiv.Specs/Month_specs.cs +++ b/specs/Qowaiv.Specs/Month_specs.cs @@ -545,7 +545,7 @@ public void with_info() type: "string", example: "Jun", format: "month", - @enum: new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "?" }, + @enum: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "?"], nullable: true)); } diff --git a/specs/Qowaiv.Specs/Sex_specs.cs b/specs/Qowaiv.Specs/Sex_specs.cs index a6a470f5..2a9a118f 100644 --- a/specs/Qowaiv.Specs/Sex_specs.cs +++ b/specs/Qowaiv.Specs/Sex_specs.cs @@ -439,7 +439,7 @@ public void with_info() type: "string", example: "female", format: "sex", - @enum: new[] { "NotKnown", "Male", "Female", "NotApplicable" }, + @enum: ["NotKnown", "Male", "Female", "NotApplicable"], nullable: true)); } diff --git a/specs/Qowaiv.Specs/TestTools/SingleValueObjectSpecs.cs b/specs/Qowaiv.Specs/TestTools/SingleValueObjectSpecs.cs index 22a8d0de..31a994df 100644 --- a/specs/Qowaiv.Specs/TestTools/SingleValueObjectSpecs.cs +++ b/specs/Qowaiv.Specs/TestTools/SingleValueObjectSpecs.cs @@ -30,11 +30,11 @@ public static IEnumerable SvosWithUnknown public static IEnumerable JsonSerializable => AllSvos .Where(IsJsonSerializable) - .Except(new[] - { + .Except( + [ typeof(Secret), typeof(CryptographicSeed) - }); + ]); private static bool IsJsonSerializable(Type type) => type diff --git a/specs/Qowaiv.Specs/_Legacy/UuidComparerTest.cs b/specs/Qowaiv.Specs/UUID_comparer_specs.cs similarity index 53% rename from specs/Qowaiv.Specs/_Legacy/UuidComparerTest.cs rename to specs/Qowaiv.Specs/UUID_comparer_specs.cs index e601fc36..1cc19ad9 100644 --- a/specs/Qowaiv.Specs/_Legacy/UuidComparerTest.cs +++ b/specs/Qowaiv.Specs/UUID_comparer_specs.cs @@ -1,6 +1,6 @@ -namespace Qowaiv.UnitTests; +namespace UUID_comparer_specs; -public class UuidComparerTest +public class Compares { private readonly Guid guid = Guid.Parse("40E56044-F781-43BD-A4AE-AA08882B4E28"); private readonly Uuid uuid = Uuid.Parse("BD411BB9-D8C9-4A4F-B739-57F2312E0BC5"); @@ -23,13 +23,13 @@ public class UuidComparerTest [TestCase(00, 01)] [TestCase(01, 02)] [TestCase(02, 03)] - public void Compare_SqlServer(int index0, int index1) + public void SQL_Server(int index0, int index1) { var l = Simple(index0, index1, 1, 2); var r = Simple(index0, index1, 2, 1); var compare = UuidComparer.SqlServer.Compare(l, r); - Assert.AreEqual(-1, compare); + compare.Should().Be(-1); } private static Uuid Simple(int i0, int i1, byte v0, byte v1) @@ -54,50 +54,35 @@ public void Is_ordered_Comparer_Guid_Default() } [Test] - public void Compare_NullNull_Zero() - { - Assert.AreEqual(0, UuidComparer.Default.Compare(null, null)); - } + public void Null_with_null_as_zero() + => UuidComparer.Default.Compare(null, null).Should().Be(0); [Test] - public void Compare_NullGuid_Minus1() - { - Assert.AreEqual(-1, UuidComparer.Default.Compare(null, Guid.NewGuid())); - } + public void Null_with_GUID_as_minus_1() + => UuidComparer.Default.Compare(null, Guid.NewGuid()).Should().Be(-1); [Test] - public void Compare_NullUuid_Minus1() - { - Assert.AreEqual(-1, UuidComparer.Default.Compare(null, Uuid.NewUuid())); - } + public void Null_with_UUID_as_minus_1() + => UuidComparer.Default.Compare(null, Uuid.NewUuid()).Should().Be(-1); - [Test] - public void Compare_GuidNull_Plus1() - { - Assert.AreEqual(+1, UuidComparer.Default.Compare(Guid.NewGuid(), null)); - } + [Test] + public void GUID_with_null_as_plus_1() + => UuidComparer.Default.Compare(Guid.NewGuid(), null).Should().Be(+1); - [Test] - public void Compare_UuidNull_Plus1() - { - Assert.AreEqual(+1, UuidComparer.Default.Compare(Uuid.NewUuid(), null)); - } + [Test] + public void UUID_with_null_as_plus_1() + => UuidComparer.Default.Compare(Uuid.NewUuid(), null).Should().Be(+1); [Test] - public void Compare_GuidUuid_Minus1() - { - Assert.AreEqual(-1, UuidComparer.Default.Compare((object)guid, (object)uuid)); - } + public void GUID_with_UUID() + => UuidComparer.Default.Compare((object)guid, (object)uuid).Should().Be(-1); [Test] - public void Compare_UuidGuid_Plus1() - { - Assert.AreEqual(+1, UuidComparer.Default.Compare((object)uuid, (object)guid)); - } + public void UUID_with_GUIDF() + => UuidComparer.Default.Compare((object)uuid, (object)guid).Should().Be(+1); [Test] public void Compare_UuidObject_Throws() - { - Assert.Throws(() => UuidComparer.Default.Compare((object)uuid, new object())); - } + => new object().Invoking(o => UuidComparer.Default.Compare((object)uuid, o)) + .Should().Throw(); } diff --git a/specs/Qowaiv.Specs/YesNo_specs.cs b/specs/Qowaiv.Specs/YesNo_specs.cs index bc1daa3b..7093e406 100644 --- a/specs/Qowaiv.Specs/YesNo_specs.cs +++ b/specs/Qowaiv.Specs/YesNo_specs.cs @@ -524,7 +524,7 @@ public void with_info() example: "yes", type: "string", format: "yes-no", - @enum: new[] { "yes", "no", "?" }, + @enum: ["yes", "no", "?"], nullable: true)); } diff --git a/specs/Qowaiv.Specs/_Legacy/.editorconfig b/specs/Qowaiv.Specs/_Legacy/.editorconfig index 69c21a79..9c935aa6 100644 --- a/specs/Qowaiv.Specs/_Legacy/.editorconfig +++ b/specs/Qowaiv.Specs/_Legacy/.editorconfig @@ -1,3 +1,6 @@ # Static coce analysis [*] -dotnet_diagnostic.FAA0004.severity = suggestion # Replace NUnit assertion with Fluent Assertions equivalent \ No newline at end of file +dotnet_diagnostic.FAA0004.severity = suggestion # Replace NUnit assertion with Fluent Assertions equivalent + +dotnet_diagnostic.NUnit2005.severity = suggestion # Consider using Assert.That instead of AreEqual +dotnet_diagnostic.NUnit2033.severity = suggestion # Consider using Assert.That instead of NotZero diff --git a/specs/Qowaiv.Specs/_Legacy/DateSpanOperationTest.cs b/specs/Qowaiv.Specs/_Legacy/DateSpanOperationTest.cs deleted file mode 100644 index 0dea8524..00000000 --- a/specs/Qowaiv.Specs/_Legacy/DateSpanOperationTest.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Qowaiv.UnitTests; - -public class DateSpanOperationTest -{ - [Test] - public void Add_DateSpan_ShouldAddDaysSecond() - { - var date = new DateTime(1999, 01, 30, 00, 00, 00, 000, DateTimeKind.Utc); - var span = DateSpan.FromMonths(1); - date.Add(span).Should().Be(new DateTime(1999, 02, 28, 00, 00, 000, DateTimeKind.Utc)); - } -} diff --git a/specs/Qowaiv.Specs/_Legacy/Formatting/FormattingArgumentsCollectionTest.cs b/specs/Qowaiv.Specs/_Legacy/Formatting/FormattingArgumentsCollectionTest.cs deleted file mode 100644 index 8c5355a5..00000000 --- a/specs/Qowaiv.Specs/_Legacy/Formatting/FormattingArgumentsCollectionTest.cs +++ /dev/null @@ -1,426 +0,0 @@ -namespace Qowaiv.UnitTests.Formatting; - -public class FormattingArgumentsCollectionTest -{ - [Test] - public void Ctor_WithParent_ThrowsFormatException() - { - var parent = new FormattingArgumentsCollection(new CultureInfo("nl")) - { - { typeof(Date), "yyyy-MM" } - }; - - var act = new FormattingArgumentsCollection(new CultureInfo("nl-BE"), parent); - Assert.AreEqual(1, act.Count, "act.Count"); - - parent.Add(typeof(Sex), "f"); - Assert.AreEqual(2, parent.Count, "parent.Count"); - Assert.AreEqual(1, act.Count, "act.Count"); - } - - [Test] - public void Format_LengthPlus_ThrowsFormatException() - { - Assert.Catch(() => - { - var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")); - collection.Format("{0,+}", 1); - }, - "Input string was not in a correct format."); - } - [Test] - public void Format_LengthA_ThrowsFormatException() - { - Assert.Catch(() => - { - var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")); - collection.Format("{0,a}", 1); - }, - "Input string was not in a correct format."); - } - - [Test] - public void Format_IndexPlus_ThrowsFormatException() - { - Assert.Catch(() => - { - var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")); - collection.Format("{+}"); - }, - "Input string was not in a correct format."); - } - [Test] - public void Format_IndexA_ThrowsFormatException() - { - Assert.Catch(() => - { - var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")); - collection.Format("{a}"); - }, - "Input string was not in a correct format."); - } - - [Test] - public void Format_Index1000000_AreEqual() - { - var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")); - var args = new object[1000001]; - args[1000000] = "Test"; - var act = collection.Format("Begin {1000000} End", args); - var exp = "Begin Test End"; - - act.Should().Be(exp); - } - [Test] - public void Format_InvalidFormat_ThrowsFormatException() - { - Assert.Catch(() => - { - var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")); - collection.Format("}"); - }, - "Input string was not in a correct format."); - } - [Test] - public void Format_ElementStartedButNotClosed_ThrowsFormatException() - { - Assert.Catch(() => - { - var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")); - collection.Format("Test {0", 12); - }, - "Input string was not in a correct format."); - } - [Test] - public void Format_no_parsable_index_ThrowsFormatException() - { - Assert.Catch(() => - { - var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")); - collection.Format("{a}"); - }, - "Input string was not in a correct format."); - } - [Test] - public void Format_IndexOutOfRange_ThrowsFormatException() - { - Assert.Catch(() => - { - var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")); - collection.Format("{0}{1}", 1); - }, - "Index (zero based) must be greater than or equal to zero and less than the size of the argument list."); - } - - [Test] - public void Format_ArrayWithNullItem_String() - { - var collection = new FormattingArgumentsCollection(); - var args = new object?[] { null }; - var act = collection.Format("Value: '{0}'", args); - var exp = "Value: ''"; - - act.Should().Be(exp); - } - [Test] - public void Format_AlignLeft_String() - { - var collection = new FormattingArgumentsCollection(); - - var act = collection.Format("{0,-4}", "a"); - var exp = "a "; - - act.Should().Be(exp); - } - [Test] - public void Format_AlignRight_String() - { - var collection = new FormattingArgumentsCollection(); - - var act = collection.Format("{0,3}", "a"); - var exp = " a"; - - act.Should().Be(exp); - } - [Test] - public void Format_EscapeLeft_String() - { - var collection = new FormattingArgumentsCollection(); - - var act = collection.Format("{{"); - var exp = "{"; - - act.Should().Be(exp); - } - [Test] - public void Format_EscapeRight_String() - { - var collection = new FormattingArgumentsCollection(); - - var act = collection.Format("}}"); - var exp = "}"; - - act.Should().Be(exp); - } - [Test] - public void Format_ComplexPattern_AreEqual() - { - using (CultureInfoScope.NewInvariant()) - { - var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE")) - { - { typeof(Date), "yyyy-MM-dd HH:mm" }, - { typeof(decimal), "0.000" } - }; - - var act = collection.Format("{0:000.00} - {1} * {1:dd-MM-yyyy} - {2} - {3} - {4}", 3, new Date(2014, 10, 8), 666, 0.8m, 0.9); - var exp = "003,00 - 2014-10-08 00:00 * 08-10-2014 - 666 - 0,800 - 0,9"; - - act.Should().Be(exp); - } - } - [Test] - public void Format_ComplexPatternWithUnitTestFormatProvider_AreEqual() - { - using (CultureInfoScope.NewInvariant()) - { - var collection = new FormattingArgumentsCollection(FormatProvider.CustomFormatter) - { - { typeof(Date), "yyyy-MM-dd HH:mm" }, - { typeof(decimal), "0.000" } - }; - - var act = collection.Format("{0:yyyy-MM-dd} * {0}", new Date(2014, 10, 8)); - var exp = "Unit Test Formatter, value: '2014-10-08', format: 'yyyy-MM-dd' * Unit Test Formatter, value: '10/08/2014', format: ''"; - - act.Should().Be(exp); - } - } - - [Test] - public void ToString_IFormattableNull_IsNull() - { - IFormattable? obj = null; - var collection = new FormattingArgumentsCollection(); - collection.ToString(obj) - .Should().BeNull(); - } - [Test] - public void ToString_ObjectNull_IsNull() - { - var collection = new FormattingArgumentsCollection(); - collection.ToString((object?)null) - .Should().BeNull(); } - [Test] - public void ToString_TypeInt32_SystemInt32() - { - var collection = new FormattingArgumentsCollection(); - string act = collection.ToString((object)typeof(int)); - string exp = "System.Int32"; - - act.Should().Be(exp); - } - [Test] - public void ToString_7_007() - { - var collection = new FormattingArgumentsCollection - { - { typeof(int), "000" } - }; - collection.ToString((object)7).Should().Be("007"); - } - - #region Collection manipulation - - [Test] - public void Add_not_IFormattable_type_throws() - { - var collection = new FormattingArgumentsCollection(); - Action add = () => collection.Add(typeof(Type), ""); - add.Should() - .Throw() - .WithMessage("The argument must implement System.IFormattable.*"); - } - - [Test] - public void Add_DuplicateKey_ThrowsArgumentException() - { - var collection = new FormattingArgumentsCollection - { - { typeof(int), "New" } - }; - Action add = () => collection.Add(typeof(int), "Update"); - add.Should() - .Throw() - .WithMessage("An item with the same key has already been added.*"); - } - - [Test] - public void Add_Int32Format_Contains1Item() - { - var collection = new FormattingArgumentsCollection - { - { typeof(int), "Int32Format" } - }; - - Assert.AreEqual(1, collection.Count, "Count"); - } - [Test] - public void Add_Int32CultureInfo_Contains1Item() - { - var collection = new FormattingArgumentsCollection - { - { typeof(int), new CultureInfo("nl-NL") } - }; - - Assert.AreEqual(1, collection.Count, "Count"); - } - [Test] - public void Add_Int32FormatAndFormatProvider_Contains1Item() - { - var collection = new FormattingArgumentsCollection - { - { typeof(int), "Int32Format", new CultureInfo("nl-NL") } - }; - - Assert.AreEqual(1, collection.Count, "Count"); - } - - [Test] - public void Set_Int32Format_Contains1Item() - { - var collection = new FormattingArgumentsCollection(); - collection.Set(typeof(int), "Int32Format"); - - Assert.AreEqual(1, collection.Count, "Count"); - } - [Test] - public void Set_Int32CultureInfo_Contains1Item() - { - var collection = new FormattingArgumentsCollection(); - collection.Set(typeof(int), new CultureInfo("nl-NL")); - - Assert.AreEqual(1, collection.Count, "Count"); - } - [Test] - public void Set_Int32FormatAndFormatProviderContains1Item() - { - var collection = new FormattingArgumentsCollection(); - collection.Set(typeof(int), "Int32Format", new CultureInfo("nl-NL")); - - Assert.AreEqual(1, collection.Count, "Count"); - } - [Test] - public void Set_SameTypeTwice_Contains1Item() - { - var collection = new FormattingArgumentsCollection(); - collection.Set(typeof(int), "New"); - collection.Set(typeof(int), "Update"); - - Assert.AreEqual(1, collection.Count, "Count"); - } - - [Test] - public void Remove_Int32_Unsuccessful() - { - var collection = new FormattingArgumentsCollection(); - var act = collection.Remove(typeof(int)); - var exp = false; - - act.Should().Be(exp); - } - [Test] - public void Remove_AddedInt32_Successful() - { - var collection = new FormattingArgumentsCollection - { - { typeof(int), "Int32Format" } - }; - var act = collection.Remove(typeof(int)); - var exp = true; - - act.Should().Be(exp); - } - - [Test] - public void Types_CollectionWithTwoItems_Int32AndDate() - { - var collection = new FormattingArgumentsCollection - { - { typeof(int), "Int32Format" }, - { typeof(Date), "Date" } - }; - - var act = collection.Types; - var exp = new [] { typeof(int), typeof(Date) }; - - act.Should().BeEquivalentTo(exp); - } - - [Test] - public void GetEnumerator_IEnumerableKeyValuePair_IsNotNull() - { - var collection = new FormattingArgumentsCollection - { - { typeof(int), "Int32Format" }, - { typeof(Date), "Date" } - }; - - var ienumerable = collection as IEnumerable>; - - var act = ienumerable.GetEnumerator(); - act.Should().NotBeNull(); - } - [Test] - public void GetEnumerator_IEnumerable_IsNotNull() - { - var collection = new FormattingArgumentsCollection - { - { typeof(int), "Int32Format" }, - { typeof(Date), "Date" } - }; - - var ienumerable = collection as IEnumerable; - - var act = ienumerable.GetEnumerator(); - act.Should().NotBeNull(); - } - - [Test] - public void Clear_CollectionWithTwoItems_0Items() - { - var collection = new FormattingArgumentsCollection - { - { typeof(int), "Int32Format" }, - { typeof(Date), "Date" } - }; - collection.Clear(); - - var act = collection.Count; - var exp = 0; - - act.Should().Be(exp); - } - - [Test] - public void Contains_FilledCollectionInt32_IsTrue() - { - var collection = new FormattingArgumentsCollection - { - { typeof(int), "00" } - }; - var act = collection.Contains(typeof(int)); - var exp = true; - act.Should().Be(exp); - } - [Test] - public void Contains_EmptyCollectionInt32_IsFalse() - { - var collection = new FormattingArgumentsCollection(); - var act = collection.Contains(typeof(int)); - var exp = false; - act.Should().Be(exp); - } - - #endregion -} diff --git a/specs/Qowaiv.Specs/_Legacy/Formatting/StringFormatterTest.cs b/specs/Qowaiv.Specs/_Legacy/Formatting/StringFormatterTest.cs deleted file mode 100644 index 59978195..00000000 --- a/specs/Qowaiv.Specs/_Legacy/Formatting/StringFormatterTest.cs +++ /dev/null @@ -1,59 +0,0 @@ -namespace Qowaiv.UnitTests.Formatting; - -[TestFixture] -public class StringFormatterTest -{ - [Test] - public void Apply_InvalidFormat_ThrowsFormatException() - { - Assert.Catch(() => - { - StringFormatter.Apply(int.MinValue, "\\", CultureInfo.InvariantCulture, []); - }, - "Input string was not in a correct format."); - } - - [Test] - public void ToNonDiacritic_Null_AreEqual() - { - var str = Nil.String; - - var exp = Nil.String; - var act = StringFormatter.ToNonDiacritic(str); - - act.Should().Be(exp); - } - - [Test] - public void ToNonDiacritic_StringEmpty_AreEqual() - { - var str = string.Empty; - - var exp = string.Empty; - var act = StringFormatter.ToNonDiacritic(str); - - act.Should().Be(exp); - } - - [Test] - public void To_non_diacritic_Cafe_und_Straße_AreEqual() - { - var str = "Café & Straße"; - - var exp = "Cafe & Strasze"; - var act = StringFormatter.ToNonDiacritic(str); - - act.Should().Be(exp); - } - - [Test] - public void To_non_diacritic_Cafe_und_Straße_ignore_e() - { - var str = "Café & Straße"; - - var exp = "Café & Strasze"; - var act = StringFormatter.ToNonDiacritic(str, "é"); - - act.Should().Be(exp); - } -} diff --git a/specs/Qowaiv.Wikipedia/Properties/GlobalUsings.cs b/specs/Qowaiv.Wikipedia/Properties/GlobalUsings.cs index c2fe37c3..aa984147 100644 --- a/specs/Qowaiv.Wikipedia/Properties/GlobalUsings.cs +++ b/specs/Qowaiv.Wikipedia/Properties/GlobalUsings.cs @@ -1,49 +1,16 @@ global using FluentAssertions; global using NUnit.Framework; global using Qowaiv; -global using Qowaiv.Conversion.Security; -global using Qowaiv.Conversion.Security.Cryptography; -global using Qowaiv.Diagnostics.Contracts; -global using Qowaiv.Financial; -global using Qowaiv.Formatting; global using Qowaiv.Globalization; -global using Qowaiv.Hashing; -global using Qowaiv.Identifiers; -global using Qowaiv.IO; -global using Qowaiv.Mathematics; -global using Qowaiv.OpenApi; -global using Qowaiv.Security; -global using Qowaiv.Security.Cryptography; -global using Qowaiv.Sql; -global using Qowaiv.Statistics; global using Qowaiv.TestTools; global using Qowaiv.TestTools.Globalization; -global using Qowaiv.TestTools.IO; -global using Qowaiv.Text; -global using Qowaiv.Web; global using System; -global using System.Collections; global using System.Collections.Generic; -global using System.ComponentModel; -global using System.Diagnostics; global using System.Diagnostics.CodeAnalysis; global using System.Diagnostics.Contracts; global using System.Globalization; global using System.IO; global using System.Linq; -global using System.Reflection; -global using System.Runtime.Serialization; -global using System.Security.Cryptography; -global using System.Text; global using System.Text.RegularExpressions; global using System.Threading.Tasks; -global using System.Xml.Serialization; -global using CustomSvo = Qowaiv.Customization.Svo; -global using GenericSvo = Qowaiv.Customization.Svo; -global using CustomGuid = Qowaiv.Identifiers.Id; -global using Int32Id = Qowaiv.Identifiers.Id; -global using Int64Id = Qowaiv.Identifiers.Id; -global using StringId = Qowaiv.Identifiers.Id; -global using CustomUuid = Qowaiv.Identifiers.Id; -global using Svo = Qowaiv.TestTools.Svo; diff --git a/specs/Qowaiv.Wikipedia/Qowaiv.Wikipedia.csproj b/specs/Qowaiv.Wikipedia/Qowaiv.Wikipedia.csproj index e4d546f5..62caabb9 100644 --- a/specs/Qowaiv.Wikipedia/Qowaiv.Wikipedia.csproj +++ b/specs/Qowaiv.Wikipedia/Qowaiv.Wikipedia.csproj @@ -11,5 +11,11 @@ + + + + + + diff --git a/src/Qowaiv.Data.SqlClient/Data/SvoParameter.cs b/src/Qowaiv.Data.SqlClient/Data/SvoParameter.cs index 30ac5d60..bfa08ff4 100644 --- a/src/Qowaiv.Data.SqlClient/Data/SvoParameter.cs +++ b/src/Qowaiv.Data.SqlClient/Data/SvoParameter.cs @@ -45,7 +45,7 @@ public static SqlParameter CreateForSql(string parameterName, object? value) else { MethodInfo cast = GetCast(sourceType, attr); - var casted = cast.Invoke(null, new[] { value }); + var casted = cast.Invoke(null, [value]); return new SqlParameter(parameterName, casted); } } diff --git a/src/Qowaiv/Formatting/FormattingArgumentsCollection.cs b/src/Qowaiv/Formatting/FormattingArgumentsCollection.cs index 836db387..370d9169 100644 --- a/src/Qowaiv/Formatting/FormattingArgumentsCollection.cs +++ b/src/Qowaiv/Formatting/FormattingArgumentsCollection.cs @@ -484,6 +484,7 @@ public FormattingArguments Get(Type? type) /// Returns an enumerator that iterates through the collection. [Pure] + [ExcludeFromCodeCoverage/* Justification = "Legacy non-generic interface." */] IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); /// Returns an enumerator that iterates through the collection. diff --git a/src/Qowaiv/Globalization/CountryToCurrencyMappings.cs b/src/Qowaiv/Globalization/CountryToCurrencyMappings.cs index 472b16ef..8106a082 100644 --- a/src/Qowaiv/Globalization/CountryToCurrencyMappings.cs +++ b/src/Qowaiv/Globalization/CountryToCurrencyMappings.cs @@ -5,319 +5,319 @@ namespace Qowaiv.Globalization; internal readonly partial struct CountryToCurrency { - public static readonly ReadOnlyCollection All = new(new List - { - new(Country.AD, Currency.ADP), - new(Country.AD, Currency.EUR, new Date(2002, 01, 01)), - new(Country.AE, Currency.AED), - new(Country.AF, Currency.AFN), - new(Country.AG, Currency.XCD), - new(Country.AI, Currency.XCD), - new(Country.AL, Currency.ALL), - new(Country.AM, Currency.AMD), - new(Country.ANHH, Currency.ANG), - new(Country.AO, Currency.AOA), - new(Country.AR, Currency.ARS), - new(Country.AS, Currency.USD), - new(Country.AT, Currency.ATS), - new(Country.AT, Currency.EUR, new Date(2002, 01, 01)), - new(Country.AU, Currency.AUD), - new(Country.AW, Currency.AWG), - new(Country.AX, Currency.FIM), - new(Country.AX, Currency.EUR, new Date(2002, 01, 01)), - new(Country.AZ, Currency.AZN), - new(Country.BA, Currency.BAM), - new(Country.BB, Currency.BBD), - new(Country.BB, Currency.USD), - new(Country.BD, Currency.BDT), - new(Country.BE, Currency.BEF), - new(Country.BE, Currency.EUR, new Date(2002, 01, 01)), - new(Country.BF, Currency.XOF), - new(Country.BG, Currency.BGN), - new(Country.BH, Currency.BHD), - new(Country.BI, Currency.BIF), - new(Country.BJ, Currency.XOF), - new(Country.BL, Currency.FRF), - new(Country.BL, Currency.EUR, new Date(2002, 01, 01)), - new(Country.BM, Currency.BMD), - new(Country.BN, Currency.BND), - new(Country.BO, Currency.BOB), - new(Country.BQ, Currency.USD), - new(Country.BR, Currency.BRL), - new(Country.BS, Currency.BSD), - new(Country.BT, Currency.BTN), - new(Country.BUMM, Currency.MMK), - new(Country.BV, Currency.NOK), - new(Country.BW, Currency.BWP), - new(Country.BY, Currency.BYR), - new(Country.BZ, Currency.BZD), - new(Country.CA, Currency.CAD), - new(Country.CC, Currency.AUD), - new(Country.CD, Currency.CDF), - new(Country.CF, Currency.XAF), - new(Country.CG, Currency.XAF), - new(Country.CH, Currency.CHF), - new(Country.CI, Currency.XOF), - new(Country.CK, Currency.NZD), - new(Country.CL, Currency.CLP), - new(Country.CM, Currency.XAF), - new(Country.CN, Currency.CNY), - new(Country.CO, Currency.COP), - new(Country.CR, Currency.CRC), - new(Country.CSHH, Currency.CSK), - new(Country.CSXX, Currency.CSD), - new(Country.CU, Currency.CUC), - new(Country.CU, Currency.CUP), - new(Country.CV, Currency.CVE), - new(Country.CW, Currency.ANG), - new(Country.CX, Currency.AUD), - new(Country.CY, Currency.CYP), - new(Country.CY, Currency.EUR, new Date(2008, 01, 01)), - new(Country.CZ, Currency.CZK), - new(Country.DDDE, Currency.DDM), - new(Country.DDDE, Currency.DEM, new Date(1990, 07, 01)), - new(Country.DE, Currency.DEM), - new(Country.DE, Currency.EUR, new Date(2002, 01, 01)), - new(Country.DJ, Currency.DJF), - new(Country.DK, Currency.DKK), - new(Country.DM, Currency.XCD), - new(Country.DO, Currency.DOP), - new(Country.DZ, Currency.DZD), - new(Country.EC, Currency.ECS), - new(Country.EC, Currency.USD, new Date(2000, 03, 13)), - new(Country.EE, Currency.EEK), - new(Country.EE, Currency.EUR, new Date(2011, 01, 01)), - new(Country.EG, Currency.EGP), - new(Country.EH, Currency.MAD), - new(Country.ER, Currency.ERN), - new(Country.ES, Currency.ESP), - new(Country.ES, Currency.EUR, new Date(2002, 01, 01)), - new(Country.ET, Currency.ETB), - new(Country.FI, Currency.FIM), - new(Country.FI, Currency.EUR, new Date(2002, 01, 01)), - new(Country.FJ, Currency.FJD), - new(Country.FK, Currency.FKP), - new(Country.FM, Currency.USD), - new(Country.FO, Currency.DKK), - new(Country.FR, Currency.FRF), - new(Country.FR, Currency.EUR, new Date(2002, 01, 01)), - new(Country.GA, Currency.XAF), - new(Country.GB, Currency.GBP), - new(Country.GD, Currency.XCD), - new(Country.GE, Currency.GEL), - new(Country.GF, Currency.FRF), - new(Country.GF, Currency.EUR, new Date(2002, 01, 01)), - new(Country.GG, Currency.GBP), - new(Country.GH, Currency.GHS), - new(Country.GI, Currency.GIP), - new(Country.GL, Currency.DKK), - new(Country.GM, Currency.GMD), - new(Country.GN, Currency.GNF), - new(Country.GP, Currency.FRF), - new(Country.GP, Currency.EUR, new Date(2002, 01, 01)), - new(Country.GQ, Currency.XAF), - new(Country.GR, Currency.GRD), - new(Country.GR, Currency.EUR, new Date(2002, 01, 01)), - new(Country.GS, Currency.GBP), - new(Country.GT, Currency.GTQ), - new(Country.GU, Currency.USD), - new(Country.GW, Currency.XOF), - new(Country.GY, Currency.GYD), - new(Country.HK, Currency.HKD), - new(Country.HM, Currency.AUD), - new(Country.HN, Currency.HNL), - new(Country.HR, Currency.HRK), - new(Country.HT, Currency.HTG), - new(Country.HT, Currency.USD), - new(Country.HU, Currency.HUF), - new(Country.ID, Currency.IDR), - new(Country.IE, Currency.IEP), - new(Country.IE, Currency.EUR, new Date(2002, 01, 01)), - new(Country.IL, Currency.ILS), - new(Country.IM, Currency.GBP), - new(Country.IN, Currency.INR), - new(Country.IO, Currency.GBP), - new(Country.IQ, Currency.IQD), - new(Country.IR, Currency.IRR), - new(Country.IS, Currency.ISK), - new(Country.IT, Currency.ITL), - new(Country.IT, Currency.EUR, new Date(2002, 01, 01)), - new(Country.JE, Currency.GBP), - new(Country.JM, Currency.JMD), - new(Country.JO, Currency.JOD), - new(Country.JP, Currency.JPY), - new(Country.KE, Currency.KES), - new(Country.KG, Currency.KGS), - new(Country.KH, Currency.KHR), - new(Country.KI, Currency.AUD), - new(Country.KM, Currency.KMF), - new(Country.KN, Currency.XCD), - new(Country.KP, Currency.KPW), - new(Country.KR, Currency.KRW), - new(Country.KW, Currency.KWD), - new(Country.KY, Currency.KYD), - new(Country.KZ, Currency.KZT), - new(Country.LA, Currency.LAK), - new(Country.LB, Currency.LBP), - new(Country.LC, Currency.XCD), - new(Country.LI, Currency.CHF), - new(Country.LK, Currency.LKR), - new(Country.LR, Currency.LRD), - new(Country.LS, Currency.LSL), - new(Country.LT, Currency.LTL), - new(Country.LT, Currency.EUR, new Date(2015, 01, 01)), - new(Country.LU, Currency.LUF), - new(Country.LU, Currency.EUR, new Date(2002, 01, 01)), - new(Country.LV, Currency.LVL), - new(Country.LV, Currency.EUR, new Date(2014, 01, 01)), - new(Country.LY, Currency.LYD), - new(Country.MA, Currency.MAD), - new(Country.MC, Currency.MCF), - new(Country.MC, Currency.EUR, new Date(2002, 01, 01)), - new(Country.MD, Currency.MDL), - new(Country.ME, Currency.EUR, new Date(2002, 01, 01)), - new(Country.MF, Currency.EUR), - new(Country.MG, Currency.MGA), - new(Country.MH, Currency.USD), - new(Country.MK, Currency.MKD), - new(Country.ML, Currency.XOF), - new(Country.MM, Currency.MMK), - new(Country.MN, Currency.MNT), - new(Country.MO, Currency.HKD), - new(Country.MO, Currency.MOP), - new(Country.MP, Currency.USD), - new(Country.MQ, Currency.FRF), - new(Country.MQ, Currency.EUR, new Date(2002, 01, 01)), - new(Country.MR, Currency.MRO), - new(Country.MS, Currency.XCD), - new(Country.MT, Currency.MTL), - new(Country.MT, Currency.EUR, new Date(2008, 01, 01)), - new(Country.MU, Currency.MUR), - new(Country.MV, Currency.MVR), - new(Country.MW, Currency.MWK), - new(Country.MX, Currency.MXN), - new(Country.MX, Currency.MXV), - new(Country.MY, Currency.MYR), - new(Country.MZ, Currency.MZN), - new(Country.NA, Currency.NAD), - new(Country.NC, Currency.XPF), - new(Country.NE, Currency.XOF), - new(Country.NF, Currency.AUD), - new(Country.NG, Currency.NGN), - new(Country.NI, Currency.NIO), - new(Country.NL, Currency.NLG), - new(Country.NL, Currency.NLG), - new(Country.NL, Currency.EUR, new Date(2002, 01, 01)), - new(Country.NO, Currency.NOK), - new(Country.NP, Currency.NPR), - new(Country.NR, Currency.AUD), - new(Country.NU, Currency.NZD), - new(Country.NZ, Currency.NZD), - new(Country.OM, Currency.OMR), - new(Country.PA, Currency.PAB), - new(Country.PA, Currency.USD), - new(Country.PE, Currency.PEN), - new(Country.PF, Currency.XPF), - new(Country.PG, Currency.PGK), - new(Country.PH, Currency.PHP), - new(Country.PK, Currency.PKR), - new(Country.PL, Currency.PLN), - new(Country.PM, Currency.FRF), - new(Country.PM, Currency.EUR, new Date(2002, 01, 01)), - new(Country.PN, Currency.NZD), - new(Country.PR, Currency.USD), - new(Country.PS, Currency.ILS), - new(Country.PT, Currency.PTE), - new(Country.PT, Currency.EUR, new Date(2002, 01, 01)), - new(Country.PW, Currency.USD), - new(Country.PY, Currency.PYG), - new(Country.QA, Currency.QAR), - new(Country.RE, Currency.FRF), - new(Country.RE, Currency.EUR, new Date(2002, 01, 01)), - new(Country.RO, Currency.RON), - new(Country.RS, Currency.RSD), - new(Country.RU, Currency.RUB), - new(Country.RW, Currency.RWF), - new(Country.SA, Currency.SAR), - new(Country.SB, Currency.SBD), - new(Country.SC, Currency.SCR), - new(Country.SD, Currency.SDG), - new(Country.SE, Currency.SEK), - new(Country.SG, Currency.SGD), - new(Country.SH, Currency.GBP), - new(Country.SH, Currency.SHP), - new(Country.SI, Currency.SIT), - new(Country.SI, Currency.EUR, new Date(2007, 01, 01)), - new(Country.SJ, Currency.NOK), - new(Country.SK, Currency.SKK), - new(Country.SK, Currency.EUR, new Date(2009, 01, 01)), - new(Country.SL, Currency.SLL), - new(Country.SM, Currency.SML), - new(Country.SM, Currency.EUR, new Date(2002, 01, 01)), - new(Country.SN, Currency.XOF), - new(Country.SO, Currency.SOS), - new(Country.SR, Currency.SRD), - new(Country.SS, Currency.SSP), - new(Country.ST, Currency.STD), - new(Country.SUHH, Currency.SUR), - new(Country.SV, Currency.USD), - new(Country.SX, Currency.ANG), - new(Country.SY, Currency.SYP), - new(Country.SZ, Currency.SZL), - new(Country.TC, Currency.USD), - new(Country.TD, Currency.XAF), - new(Country.TF, Currency.FRF), - new(Country.TF, Currency.EUR, new Date(2002, 01, 01)), - new(Country.TG, Currency.XOF), - new(Country.TH, Currency.THB), - new(Country.TJ, Currency.TJS), - new(Country.TK, Currency.NZD), - new(Country.TL, Currency.USD), - new(Country.TM, Currency.TMT), - new(Country.TN, Currency.TND), - new(Country.TO, Currency.TOP), - new(Country.TR, Currency.TRY), - new(Country.TT, Currency.TTD), - new(Country.TV, Currency.AUD), - new(Country.TW, Currency.TWD), - new(Country.TZ, Currency.TZS), - new(Country.UA, Currency.UAH), - new(Country.UG, Currency.UGX), - new(Country.UM, Currency.USD), - new(Country.US, Currency.USD), - new(Country.UY, Currency.UYU), - new(Country.UZ, Currency.UZS), - new(Country.VA, Currency.VAL), - new(Country.VA, Currency.EUR, new Date(2002, 01, 01)), - new(Country.VC, Currency.XCD), - new(Country.VE, Currency.VEF), - new(Country.VG, Currency.USD), - new(Country.VI, Currency.USD), - new(Country.VN, Currency.VND), - new(Country.VU, Currency.VUV), - new(Country.WF, Currency.XPF), - new(Country.WS, Currency.WST), - new(Country.XK, Currency.EUR, new Date(2008, 02, 01)), - new(Country.YE, Currency.YER), - new(Country.YT, Currency.FRF), - new(Country.YT, Currency.EUR, new Date(2002, 01, 01)), - new(Country.YUCS, Currency.YUD, new Date(1961, 12, 31)), - new(Country.YUCS, Currency.YUN, new Date(1985, 12, 31)), - new(Country.YUCS, Currency.YUR, new Date(1988, 06, 30)), - new(Country.YUCS, Currency.YOU, new Date(1989, 09, 30)), - new(Country.YUCS, Currency.YUG, new Date(1989, 12, 31)), - new(Country.YUCS, Currency.YUM, new Date(1990, 01, 23)), - new(Country.ZA, Currency.ZAR), - new(Country.ZM, Currency.ZMW), - new(Country.ZRCD, Currency.ZRZ), - new(Country.ZRCD, Currency.ZRN, new Date(1993, 01, 01)), - new(Country.ZW, Currency.ZWC, new Date(1966, 02, 16)), - new(Country.ZW, Currency.ZWD, new Date(1976, 04, 17)), - new(Country.ZW, Currency.ZWN, new Date(2002, 07, 31)), - new(Country.ZW, Currency.ZWR, new Date(2004, 07, 31)), - new(Country.ZW, Currency.ZWL, new Date(2005, 02, 02)), - new(Country.ZW, Currency.USD, new Date(2009, 04, 12)), - new(Country.HVBF, Currency.XOF), - new(Country.BQAQ, Currency.GBP), - }); + public static readonly ReadOnlyCollection All = new( + [ + new(Country.AD, Currency.ADP), + new(Country.AD, Currency.EUR, new Date(2002, 01, 01)), + new(Country.AE, Currency.AED), + new(Country.AF, Currency.AFN), + new(Country.AG, Currency.XCD), + new(Country.AI, Currency.XCD), + new(Country.AL, Currency.ALL), + new(Country.AM, Currency.AMD), + new(Country.ANHH, Currency.ANG), + new(Country.AO, Currency.AOA), + new(Country.AR, Currency.ARS), + new(Country.AS, Currency.USD), + new(Country.AT, Currency.ATS), + new(Country.AT, Currency.EUR, new Date(2002, 01, 01)), + new(Country.AU, Currency.AUD), + new(Country.AW, Currency.AWG), + new(Country.AX, Currency.FIM), + new(Country.AX, Currency.EUR, new Date(2002, 01, 01)), + new(Country.AZ, Currency.AZN), + new(Country.BA, Currency.BAM), + new(Country.BB, Currency.BBD), + new(Country.BB, Currency.USD), + new(Country.BD, Currency.BDT), + new(Country.BE, Currency.BEF), + new(Country.BE, Currency.EUR, new Date(2002, 01, 01)), + new(Country.BF, Currency.XOF), + new(Country.BG, Currency.BGN), + new(Country.BH, Currency.BHD), + new(Country.BI, Currency.BIF), + new(Country.BJ, Currency.XOF), + new(Country.BL, Currency.FRF), + new(Country.BL, Currency.EUR, new Date(2002, 01, 01)), + new(Country.BM, Currency.BMD), + new(Country.BN, Currency.BND), + new(Country.BO, Currency.BOB), + new(Country.BQ, Currency.USD), + new(Country.BR, Currency.BRL), + new(Country.BS, Currency.BSD), + new(Country.BT, Currency.BTN), + new(Country.BUMM, Currency.MMK), + new(Country.BV, Currency.NOK), + new(Country.BW, Currency.BWP), + new(Country.BY, Currency.BYR), + new(Country.BZ, Currency.BZD), + new(Country.CA, Currency.CAD), + new(Country.CC, Currency.AUD), + new(Country.CD, Currency.CDF), + new(Country.CF, Currency.XAF), + new(Country.CG, Currency.XAF), + new(Country.CH, Currency.CHF), + new(Country.CI, Currency.XOF), + new(Country.CK, Currency.NZD), + new(Country.CL, Currency.CLP), + new(Country.CM, Currency.XAF), + new(Country.CN, Currency.CNY), + new(Country.CO, Currency.COP), + new(Country.CR, Currency.CRC), + new(Country.CSHH, Currency.CSK), + new(Country.CSXX, Currency.CSD), + new(Country.CU, Currency.CUC), + new(Country.CU, Currency.CUP), + new(Country.CV, Currency.CVE), + new(Country.CW, Currency.ANG), + new(Country.CX, Currency.AUD), + new(Country.CY, Currency.CYP), + new(Country.CY, Currency.EUR, new Date(2008, 01, 01)), + new(Country.CZ, Currency.CZK), + new(Country.DDDE, Currency.DDM), + new(Country.DDDE, Currency.DEM, new Date(1990, 07, 01)), + new(Country.DE, Currency.DEM), + new(Country.DE, Currency.EUR, new Date(2002, 01, 01)), + new(Country.DJ, Currency.DJF), + new(Country.DK, Currency.DKK), + new(Country.DM, Currency.XCD), + new(Country.DO, Currency.DOP), + new(Country.DZ, Currency.DZD), + new(Country.EC, Currency.ECS), + new(Country.EC, Currency.USD, new Date(2000, 03, 13)), + new(Country.EE, Currency.EEK), + new(Country.EE, Currency.EUR, new Date(2011, 01, 01)), + new(Country.EG, Currency.EGP), + new(Country.EH, Currency.MAD), + new(Country.ER, Currency.ERN), + new(Country.ES, Currency.ESP), + new(Country.ES, Currency.EUR, new Date(2002, 01, 01)), + new(Country.ET, Currency.ETB), + new(Country.FI, Currency.FIM), + new(Country.FI, Currency.EUR, new Date(2002, 01, 01)), + new(Country.FJ, Currency.FJD), + new(Country.FK, Currency.FKP), + new(Country.FM, Currency.USD), + new(Country.FO, Currency.DKK), + new(Country.FR, Currency.FRF), + new(Country.FR, Currency.EUR, new Date(2002, 01, 01)), + new(Country.GA, Currency.XAF), + new(Country.GB, Currency.GBP), + new(Country.GD, Currency.XCD), + new(Country.GE, Currency.GEL), + new(Country.GF, Currency.FRF), + new(Country.GF, Currency.EUR, new Date(2002, 01, 01)), + new(Country.GG, Currency.GBP), + new(Country.GH, Currency.GHS), + new(Country.GI, Currency.GIP), + new(Country.GL, Currency.DKK), + new(Country.GM, Currency.GMD), + new(Country.GN, Currency.GNF), + new(Country.GP, Currency.FRF), + new(Country.GP, Currency.EUR, new Date(2002, 01, 01)), + new(Country.GQ, Currency.XAF), + new(Country.GR, Currency.GRD), + new(Country.GR, Currency.EUR, new Date(2002, 01, 01)), + new(Country.GS, Currency.GBP), + new(Country.GT, Currency.GTQ), + new(Country.GU, Currency.USD), + new(Country.GW, Currency.XOF), + new(Country.GY, Currency.GYD), + new(Country.HK, Currency.HKD), + new(Country.HM, Currency.AUD), + new(Country.HN, Currency.HNL), + new(Country.HR, Currency.HRK), + new(Country.HT, Currency.HTG), + new(Country.HT, Currency.USD), + new(Country.HU, Currency.HUF), + new(Country.ID, Currency.IDR), + new(Country.IE, Currency.IEP), + new(Country.IE, Currency.EUR, new Date(2002, 01, 01)), + new(Country.IL, Currency.ILS), + new(Country.IM, Currency.GBP), + new(Country.IN, Currency.INR), + new(Country.IO, Currency.GBP), + new(Country.IQ, Currency.IQD), + new(Country.IR, Currency.IRR), + new(Country.IS, Currency.ISK), + new(Country.IT, Currency.ITL), + new(Country.IT, Currency.EUR, new Date(2002, 01, 01)), + new(Country.JE, Currency.GBP), + new(Country.JM, Currency.JMD), + new(Country.JO, Currency.JOD), + new(Country.JP, Currency.JPY), + new(Country.KE, Currency.KES), + new(Country.KG, Currency.KGS), + new(Country.KH, Currency.KHR), + new(Country.KI, Currency.AUD), + new(Country.KM, Currency.KMF), + new(Country.KN, Currency.XCD), + new(Country.KP, Currency.KPW), + new(Country.KR, Currency.KRW), + new(Country.KW, Currency.KWD), + new(Country.KY, Currency.KYD), + new(Country.KZ, Currency.KZT), + new(Country.LA, Currency.LAK), + new(Country.LB, Currency.LBP), + new(Country.LC, Currency.XCD), + new(Country.LI, Currency.CHF), + new(Country.LK, Currency.LKR), + new(Country.LR, Currency.LRD), + new(Country.LS, Currency.LSL), + new(Country.LT, Currency.LTL), + new(Country.LT, Currency.EUR, new Date(2015, 01, 01)), + new(Country.LU, Currency.LUF), + new(Country.LU, Currency.EUR, new Date(2002, 01, 01)), + new(Country.LV, Currency.LVL), + new(Country.LV, Currency.EUR, new Date(2014, 01, 01)), + new(Country.LY, Currency.LYD), + new(Country.MA, Currency.MAD), + new(Country.MC, Currency.MCF), + new(Country.MC, Currency.EUR, new Date(2002, 01, 01)), + new(Country.MD, Currency.MDL), + new(Country.ME, Currency.EUR, new Date(2002, 01, 01)), + new(Country.MF, Currency.EUR), + new(Country.MG, Currency.MGA), + new(Country.MH, Currency.USD), + new(Country.MK, Currency.MKD), + new(Country.ML, Currency.XOF), + new(Country.MM, Currency.MMK), + new(Country.MN, Currency.MNT), + new(Country.MO, Currency.HKD), + new(Country.MO, Currency.MOP), + new(Country.MP, Currency.USD), + new(Country.MQ, Currency.FRF), + new(Country.MQ, Currency.EUR, new Date(2002, 01, 01)), + new(Country.MR, Currency.MRO), + new(Country.MS, Currency.XCD), + new(Country.MT, Currency.MTL), + new(Country.MT, Currency.EUR, new Date(2008, 01, 01)), + new(Country.MU, Currency.MUR), + new(Country.MV, Currency.MVR), + new(Country.MW, Currency.MWK), + new(Country.MX, Currency.MXN), + new(Country.MX, Currency.MXV), + new(Country.MY, Currency.MYR), + new(Country.MZ, Currency.MZN), + new(Country.NA, Currency.NAD), + new(Country.NC, Currency.XPF), + new(Country.NE, Currency.XOF), + new(Country.NF, Currency.AUD), + new(Country.NG, Currency.NGN), + new(Country.NI, Currency.NIO), + new(Country.NL, Currency.NLG), + new(Country.NL, Currency.NLG), + new(Country.NL, Currency.EUR, new Date(2002, 01, 01)), + new(Country.NO, Currency.NOK), + new(Country.NP, Currency.NPR), + new(Country.NR, Currency.AUD), + new(Country.NU, Currency.NZD), + new(Country.NZ, Currency.NZD), + new(Country.OM, Currency.OMR), + new(Country.PA, Currency.PAB), + new(Country.PA, Currency.USD), + new(Country.PE, Currency.PEN), + new(Country.PF, Currency.XPF), + new(Country.PG, Currency.PGK), + new(Country.PH, Currency.PHP), + new(Country.PK, Currency.PKR), + new(Country.PL, Currency.PLN), + new(Country.PM, Currency.FRF), + new(Country.PM, Currency.EUR, new Date(2002, 01, 01)), + new(Country.PN, Currency.NZD), + new(Country.PR, Currency.USD), + new(Country.PS, Currency.ILS), + new(Country.PT, Currency.PTE), + new(Country.PT, Currency.EUR, new Date(2002, 01, 01)), + new(Country.PW, Currency.USD), + new(Country.PY, Currency.PYG), + new(Country.QA, Currency.QAR), + new(Country.RE, Currency.FRF), + new(Country.RE, Currency.EUR, new Date(2002, 01, 01)), + new(Country.RO, Currency.RON), + new(Country.RS, Currency.RSD), + new(Country.RU, Currency.RUB), + new(Country.RW, Currency.RWF), + new(Country.SA, Currency.SAR), + new(Country.SB, Currency.SBD), + new(Country.SC, Currency.SCR), + new(Country.SD, Currency.SDG), + new(Country.SE, Currency.SEK), + new(Country.SG, Currency.SGD), + new(Country.SH, Currency.GBP), + new(Country.SH, Currency.SHP), + new(Country.SI, Currency.SIT), + new(Country.SI, Currency.EUR, new Date(2007, 01, 01)), + new(Country.SJ, Currency.NOK), + new(Country.SK, Currency.SKK), + new(Country.SK, Currency.EUR, new Date(2009, 01, 01)), + new(Country.SL, Currency.SLL), + new(Country.SM, Currency.SML), + new(Country.SM, Currency.EUR, new Date(2002, 01, 01)), + new(Country.SN, Currency.XOF), + new(Country.SO, Currency.SOS), + new(Country.SR, Currency.SRD), + new(Country.SS, Currency.SSP), + new(Country.ST, Currency.STD), + new(Country.SUHH, Currency.SUR), + new(Country.SV, Currency.USD), + new(Country.SX, Currency.ANG), + new(Country.SY, Currency.SYP), + new(Country.SZ, Currency.SZL), + new(Country.TC, Currency.USD), + new(Country.TD, Currency.XAF), + new(Country.TF, Currency.FRF), + new(Country.TF, Currency.EUR, new Date(2002, 01, 01)), + new(Country.TG, Currency.XOF), + new(Country.TH, Currency.THB), + new(Country.TJ, Currency.TJS), + new(Country.TK, Currency.NZD), + new(Country.TL, Currency.USD), + new(Country.TM, Currency.TMT), + new(Country.TN, Currency.TND), + new(Country.TO, Currency.TOP), + new(Country.TR, Currency.TRY), + new(Country.TT, Currency.TTD), + new(Country.TV, Currency.AUD), + new(Country.TW, Currency.TWD), + new(Country.TZ, Currency.TZS), + new(Country.UA, Currency.UAH), + new(Country.UG, Currency.UGX), + new(Country.UM, Currency.USD), + new(Country.US, Currency.USD), + new(Country.UY, Currency.UYU), + new(Country.UZ, Currency.UZS), + new(Country.VA, Currency.VAL), + new(Country.VA, Currency.EUR, new Date(2002, 01, 01)), + new(Country.VC, Currency.XCD), + new(Country.VE, Currency.VEF), + new(Country.VG, Currency.USD), + new(Country.VI, Currency.USD), + new(Country.VN, Currency.VND), + new(Country.VU, Currency.VUV), + new(Country.WF, Currency.XPF), + new(Country.WS, Currency.WST), + new(Country.XK, Currency.EUR, new Date(2008, 02, 01)), + new(Country.YE, Currency.YER), + new(Country.YT, Currency.FRF), + new(Country.YT, Currency.EUR, new Date(2002, 01, 01)), + new(Country.YUCS, Currency.YUD, new Date(1961, 12, 31)), + new(Country.YUCS, Currency.YUN, new Date(1985, 12, 31)), + new(Country.YUCS, Currency.YUR, new Date(1988, 06, 30)), + new(Country.YUCS, Currency.YOU, new Date(1989, 09, 30)), + new(Country.YUCS, Currency.YUG, new Date(1989, 12, 31)), + new(Country.YUCS, Currency.YUM, new Date(1990, 01, 23)), + new(Country.ZA, Currency.ZAR), + new(Country.ZM, Currency.ZMW), + new(Country.ZRCD, Currency.ZRZ), + new(Country.ZRCD, Currency.ZRN, new Date(1993, 01, 01)), + new(Country.ZW, Currency.ZWC, new Date(1966, 02, 16)), + new(Country.ZW, Currency.ZWD, new Date(1976, 04, 17)), + new(Country.ZW, Currency.ZWN, new Date(2002, 07, 31)), + new(Country.ZW, Currency.ZWR, new Date(2004, 07, 31)), + new(Country.ZW, Currency.ZWL, new Date(2005, 02, 02)), + new(Country.ZW, Currency.USD, new Date(2009, 04, 12)), + new(Country.HVBF, Currency.XOF), + new(Country.BQAQ, Currency.GBP), + ]); } diff --git a/src/Qowaiv/Month.cs b/src/Qowaiv/Month.cs index c1afc586..14f41d2d 100644 --- a/src/Qowaiv/Month.cs +++ b/src/Qowaiv/Month.cs @@ -53,8 +53,8 @@ namespace Qowaiv; public static Month December /*..*/ => new(12); /// Represents all months (January till December). - public static IReadOnlyList All { get; } = new[] - { + public static IReadOnlyList All { get; } = + [ January, February, March, @@ -67,7 +67,7 @@ namespace Qowaiv; October, November, December, - }; + ]; /// Gets the full name of the month. public string FullName => GetFullName(formatProvider: null); diff --git a/src/Qowaiv/OpenApi/OpenApiDataTypes.cs b/src/Qowaiv/OpenApi/OpenApiDataTypes.cs index 2aaba22f..a8eec0be 100644 --- a/src/Qowaiv/OpenApi/OpenApiDataTypes.cs +++ b/src/Qowaiv/OpenApi/OpenApiDataTypes.cs @@ -17,7 +17,7 @@ public static IEnumerable FromAssemblies(params Assembly[] asse [ExcludeFromCodeCoverage] [Pure] public static IEnumerable FromTypes(params Type[] types) - => FromTypes(types?.AsEnumerable() ?? Array.Empty()); + => FromTypes(types?.AsEnumerable() ?? []); /// Gets all s of the /// specified types that are decorated as such. diff --git a/src/Qowaiv/Qowaiv.csproj b/src/Qowaiv/Qowaiv.csproj index cb6a7483..256c8f4d 100644 --- a/src/Qowaiv/Qowaiv.csproj +++ b/src/Qowaiv/Qowaiv.csproj @@ -7,11 +7,6 @@ true 6.6.2 Qowaiv - -v6.6.2 -- JSON-deserialization from decimal.MaxValue (as double) should not fail. #386 (fix) -v6.6.1 -- Add missing IParsable interface for Id. #372 7.0.0 Qowaiv @@ -42,6 +37,8 @@ v7.0.0 - Drop support for .NET 5 and .NET 7 STS's. #359 (breaking) - Deserializing ID's from JSON numeric nodes takes constrains into account. #374 - Move Qowaiv.Diagnostics.Contracs to a seperate package. (breaking) +v6.6.2 +- JSON-deserialization from decimal.MaxValue (as double) should not fail. #386 (fix) v6.6.1 - Add missing IParsable interface for Id. #372 v6.6.0 diff --git a/src/Qowaiv/Sex.cs b/src/Qowaiv/Sex.cs index b70231c8..ba06918b 100644 --- a/src/Qowaiv/Sex.cs +++ b/src/Qowaiv/Sex.cs @@ -44,13 +44,13 @@ namespace Qowaiv; public static Sex NotApplicable => new(18); /// Contains not known, male, female, not applicable. - public static IReadOnlyCollection All { get; } = new[] { Male, Female, NotApplicable, Unknown, }; + public static IReadOnlyCollection All { get; } = [Male, Female, NotApplicable, Unknown]; /// Contains male and female. - public static IReadOnlyCollection MaleAndFemale { get; } = new[] { Male, Female, }; + public static IReadOnlyCollection MaleAndFemale { get; } = [Male, Female]; /// Contains male, female, not applicable. - public static IReadOnlyCollection MaleFemaleAndNotApplicable { get; } = new[] { Male, Female, NotApplicable, }; + public static IReadOnlyCollection MaleFemaleAndNotApplicable { get; } = [Male, Female, NotApplicable]; /// Gets the display name. public string DisplayName => GetDisplayName(null); diff --git a/src/Qowaiv/UuidDefaultComparer.cs b/src/Qowaiv/UuidDefaultComparer.cs index 16d184a0..1ded3eb4 100644 --- a/src/Qowaiv/UuidDefaultComparer.cs +++ b/src/Qowaiv/UuidDefaultComparer.cs @@ -10,7 +10,7 @@ internal sealed class UuidDefaultComparer : UuidComparer /// 2 /// 8 . /// - public override IReadOnlyList Priority { get; } = new[] { 3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15 }; + public override IReadOnlyList Priority { get; } = [3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15]; /// [Pure] diff --git a/src/Qowaiv/UuidMongoDbComparer.cs b/src/Qowaiv/UuidMongoDbComparer.cs index 46bf50ea..fd210fc7 100644 --- a/src/Qowaiv/UuidMongoDbComparer.cs +++ b/src/Qowaiv/UuidMongoDbComparer.cs @@ -4,7 +4,7 @@ internal sealed class UuidMongoDbComparer : UuidComparer { /// - public override IReadOnlyList Priority { get; } = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + public override IReadOnlyList Priority { get; } = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; /// [Pure] diff --git a/src/Qowaiv/UuidSqlServerComparer.cs b/src/Qowaiv/UuidSqlServerComparer.cs index 1e1cbc9b..8c149fda 100644 --- a/src/Qowaiv/UuidSqlServerComparer.cs +++ b/src/Qowaiv/UuidSqlServerComparer.cs @@ -9,7 +9,7 @@ internal sealed class UuidSqlServerComparer : UuidComparer /// 10: the most significant byte in Guid ByteArray [for SQL Server ORDERY BY clause] /// 3: the least significant byte in Guid ByteArray [for SQL Server ORDER BY clause]. /// - public override IReadOnlyList Priority { get; } = new[] { 10, 11, 12, 13, 14, 15, 8, 9, 6, 7, 4, 5, 0, 1, 2, 3 }; + public override IReadOnlyList Priority { get; } = [10, 11, 12, 13, 14, 15, 8, 9, 6, 7, 4, 5, 0, 1, 2, 3]; /// [Pure] diff --git a/src/Qowaiv/YesNo.cs b/src/Qowaiv/YesNo.cs index c8316e39..feb8d4ae 100644 --- a/src/Qowaiv/YesNo.cs +++ b/src/Qowaiv/YesNo.cs @@ -32,7 +32,7 @@ namespace Qowaiv; public static YesNo Unknown => new(3); /// Contains yes and no. - public static readonly IReadOnlyCollection YesAndNo = new[] { Yes, No }; + public static readonly IReadOnlyCollection YesAndNo = [Yes, No]; /// Returns true if the yes-no value represents no, otherwise false. [Pure]