From 3b5fb7b2be66d881c4a92ce2827110ffdb16329c Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 13 Apr 2023 22:35:43 +0100 Subject: [PATCH 01/46] refactor: remove throw helpers in X10D.DSharpPlus (#80) --- .../src/DiscordChannelExtensions.cs | 9 ------ .../src/DiscordClientExtensions.cs | 8 ----- .../src/DiscordEmbedBuilderExtensions.cs | 31 ++----------------- X10D.DSharpPlus/src/DiscordGuildExtensions.cs | 13 -------- .../src/DiscordMemberExtensions.cs | 10 ------ .../src/DiscordMessageExtensions.cs | 13 -------- X10D.DSharpPlus/src/DiscordUserExtensions.cs | 19 ------------ 7 files changed, 2 insertions(+), 101 deletions(-) diff --git a/X10D.DSharpPlus/src/DiscordChannelExtensions.cs b/X10D.DSharpPlus/src/DiscordChannelExtensions.cs index 2734af9..820ced0 100644 --- a/X10D.DSharpPlus/src/DiscordChannelExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordChannelExtensions.cs @@ -19,14 +19,10 @@ public static class DiscordChannelExtensions /// is . public static DiscordChannel? GetCategory(this DiscordChannel channel) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(channel); -#else if (channel is null) { throw new ArgumentNullException(nameof(channel)); } -#endif while (true) { @@ -60,10 +56,6 @@ public static class DiscordChannelExtensions /// public static async Task NormalizeClientAsync(this DiscordChannel channel, DiscordClient client) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(channel); - ArgumentNullException.ThrowIfNull(client); -#else if (channel is null) { throw new ArgumentNullException(nameof(channel)); @@ -73,7 +65,6 @@ public static class DiscordChannelExtensions { throw new ArgumentNullException(nameof(client)); } -#endif return await client.GetChannelAsync(channel.Id).ConfigureAwait(false); } diff --git a/X10D.DSharpPlus/src/DiscordClientExtensions.cs b/X10D.DSharpPlus/src/DiscordClientExtensions.cs index f3d8964..5dfd415 100644 --- a/X10D.DSharpPlus/src/DiscordClientExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordClientExtensions.cs @@ -20,14 +20,10 @@ public static class DiscordClientExtensions /// is . public static void AutoJoinThreads(this DiscordClient client, bool rejoinIfRemoved = true) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(client); -#else if (client is null) { throw new ArgumentNullException(nameof(client)); } -#endif client.GuildAvailable += (_, args) => args.Guild.JoinAllThreadsAsync(); client.ThreadCreated += (_, args) => args.Thread.JoinThreadAsync(); @@ -53,14 +49,10 @@ public static class DiscordClientExtensions /// is . public static async Task GetUserOrNullAsync(this DiscordClient client, ulong userId) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(client); -#else if (client is null) { throw new ArgumentNullException(nameof(client)); } -#endif try { diff --git a/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs b/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs index 4a23a34..1c2c479 100644 --- a/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs @@ -23,14 +23,10 @@ public static class DiscordEmbedBuilderExtensions T? value, bool inline = false) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(builder); -#else if (builder is null) { throw new ArgumentNullException(nameof(builder)); } -#endif return builder.AddField(name, value?.ToString(), inline); } @@ -53,14 +49,10 @@ public static class DiscordEmbedBuilderExtensions T? value, bool inline = false) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(builder); -#else if (builder is null) { throw new ArgumentNullException(nameof(builder)); } -#endif if (condition) { @@ -92,10 +84,6 @@ public static class DiscordEmbedBuilderExtensions T? value, bool inline = false) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(builder); - ArgumentNullException.ThrowIfNull(predicate); -#else if (builder is null) { throw new ArgumentNullException(nameof(builder)); @@ -105,7 +93,6 @@ public static class DiscordEmbedBuilderExtensions { throw new ArgumentNullException(nameof(predicate)); } -#endif if (predicate.Invoke()) { @@ -139,11 +126,6 @@ public static class DiscordEmbedBuilderExtensions Func valueFactory, bool inline = false) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(builder); - ArgumentNullException.ThrowIfNull(predicate); - ArgumentNullException.ThrowIfNull(valueFactory); -#else if (builder is null) { throw new ArgumentNullException(nameof(builder)); @@ -158,7 +140,6 @@ public static class DiscordEmbedBuilderExtensions { throw new ArgumentNullException(nameof(valueFactory)); } -#endif if (predicate.Invoke()) { @@ -190,19 +171,15 @@ public static class DiscordEmbedBuilderExtensions Func valueFactory, bool inline = false) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(builder); - ArgumentNullException.ThrowIfNull(valueFactory); -#else if (builder is null) { throw new ArgumentNullException(nameof(builder)); } + if (valueFactory is null) { throw new ArgumentNullException(nameof(valueFactory)); } -#endif if (condition) { @@ -220,19 +197,15 @@ public static class DiscordEmbedBuilderExtensions /// The current instance of . public static DiscordEmbedBuilder WithAuthor(this DiscordEmbedBuilder builder, DiscordUser user) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(builder); - ArgumentNullException.ThrowIfNull(user); -#else if (builder is null) { throw new ArgumentNullException(nameof(builder)); } + if (user is null) { throw new ArgumentNullException(nameof(user)); } -#endif return builder.WithAuthor(user.GetUsernameWithDiscriminator(), iconUrl: user.AvatarUrl); } diff --git a/X10D.DSharpPlus/src/DiscordGuildExtensions.cs b/X10D.DSharpPlus/src/DiscordGuildExtensions.cs index c03016b..ff4636e 100644 --- a/X10D.DSharpPlus/src/DiscordGuildExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordGuildExtensions.cs @@ -16,14 +16,10 @@ public static class DiscordGuildExtensions /// is . public static async Task JoinAllThreadsAsync(this DiscordGuild guild) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(guild); -#else if (guild is null) { throw new ArgumentNullException(nameof(guild)); } -#endif await Task.WhenAll(guild.Threads.Values.Select(t => t.JoinThreadAsync())).ConfigureAwait(false); } @@ -37,14 +33,10 @@ public static class DiscordGuildExtensions /// is . public static async Task GetMemberOrNullAsync(this DiscordGuild guild, ulong userId) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(guild); -#else if (guild is null) { throw new ArgumentNullException(nameof(guild)); } -#endif try { @@ -77,10 +69,6 @@ public static class DiscordGuildExtensions /// public static async Task NormalizeClientAsync(this DiscordGuild guild, DiscordClient client) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(guild); - ArgumentNullException.ThrowIfNull(client); -#else if (guild is null) { throw new ArgumentNullException(nameof(guild)); @@ -90,7 +78,6 @@ public static class DiscordGuildExtensions { throw new ArgumentNullException(nameof(client)); } -#endif return await client.GetGuildAsync(guild.Id).ConfigureAwait(false); } diff --git a/X10D.DSharpPlus/src/DiscordMemberExtensions.cs b/X10D.DSharpPlus/src/DiscordMemberExtensions.cs index 3fd2020..7ec9925 100644 --- a/X10D.DSharpPlus/src/DiscordMemberExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordMemberExtensions.cs @@ -18,10 +18,6 @@ public static class DiscordMemberExtensions /// public static bool HasRole(this DiscordMember member, DiscordRole role) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(member); - ArgumentNullException.ThrowIfNull(role); -#else if (member is null) { throw new ArgumentNullException(nameof(member)); @@ -31,7 +27,6 @@ public static class DiscordMemberExtensions { throw new ArgumentNullException(nameof(role)); } -#endif return member.Roles.Contains(role); } @@ -52,10 +47,6 @@ public static class DiscordMemberExtensions /// public static async Task NormalizeClientAsync(this DiscordMember member, DiscordClient client) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(member); - ArgumentNullException.ThrowIfNull(client); -#else if (member is null) { throw new ArgumentNullException(nameof(member)); @@ -65,7 +56,6 @@ public static class DiscordMemberExtensions { throw new ArgumentNullException(nameof(client)); } -#endif DiscordGuild guild = await member.Guild.NormalizeClientAsync(client).ConfigureAwait(false); return await guild.GetMemberAsync(member.Id).ConfigureAwait(false); diff --git a/X10D.DSharpPlus/src/DiscordMessageExtensions.cs b/X10D.DSharpPlus/src/DiscordMessageExtensions.cs index f8317c7..f43116d 100644 --- a/X10D.DSharpPlus/src/DiscordMessageExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordMessageExtensions.cs @@ -17,14 +17,10 @@ public static class DiscordMessageExtensions /// is . public static async Task DeleteAfterAsync(this DiscordMessage message, TimeSpan delay, string? reason = null) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(message); -#else if (message is null) { throw new ArgumentNullException(nameof(message)); } -#endif await Task.Delay(delay).ConfigureAwait(false); await message.DeleteAsync(reason).ConfigureAwait(false); @@ -39,14 +35,10 @@ public static class DiscordMessageExtensions /// is . public static async Task DeleteAfterAsync(this Task task, TimeSpan delay, string? reason = null) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(task); -#else if (task is null) { throw new ArgumentNullException(nameof(task)); } -#endif DiscordMessage message = await task.ConfigureAwait(false); await message.DeleteAfterAsync(delay, reason).ConfigureAwait(false); @@ -68,10 +60,6 @@ public static class DiscordMessageExtensions /// public static async Task NormalizeClientAsync(this DiscordMessage message, DiscordClient client) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(message); - ArgumentNullException.ThrowIfNull(client); -#else if (message is null) { throw new ArgumentNullException(nameof(message)); @@ -81,7 +69,6 @@ public static class DiscordMessageExtensions { throw new ArgumentNullException(nameof(client)); } -#endif DiscordChannel channel = await message.Channel.NormalizeClientAsync(client).ConfigureAwait(false); return await channel.GetMessageAsync(message.Id).ConfigureAwait(false); diff --git a/X10D.DSharpPlus/src/DiscordUserExtensions.cs b/X10D.DSharpPlus/src/DiscordUserExtensions.cs index 6ab8314..adfd477 100644 --- a/X10D.DSharpPlus/src/DiscordUserExtensions.cs +++ b/X10D.DSharpPlus/src/DiscordUserExtensions.cs @@ -25,10 +25,6 @@ public static class DiscordUserExtensions /// public static async Task GetAsMemberOfAsync(this DiscordUser user, DiscordGuild guild) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(user); - ArgumentNullException.ThrowIfNull(guild); -#else if (user is null) { throw new ArgumentNullException(nameof(user)); @@ -38,7 +34,6 @@ public static class DiscordUserExtensions { throw new ArgumentNullException(nameof(guild)); } -#endif if (user is DiscordMember member && member.Guild == guild) { @@ -68,14 +63,10 @@ public static class DiscordUserExtensions /// is . public static string GetUsernameWithDiscriminator(this DiscordUser user) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(user); -#else if (user is null) { throw new ArgumentNullException(nameof(user)); } -#endif return $"{user.Username}#{user.Discriminator}"; } @@ -91,10 +82,6 @@ public static class DiscordUserExtensions /// public static async Task IsInGuildAsync(this DiscordUser user, DiscordGuild guild) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(user); - ArgumentNullException.ThrowIfNull(guild); -#else if (user is null) { throw new ArgumentNullException(nameof(user)); @@ -104,7 +91,6 @@ public static class DiscordUserExtensions { throw new ArgumentNullException(nameof(guild)); } -#endif if (guild.Members.TryGetValue(user.Id, out _)) { @@ -138,10 +124,6 @@ public static class DiscordUserExtensions /// public static async Task NormalizeClientAsync(this DiscordUser user, DiscordClient client) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(user); - ArgumentNullException.ThrowIfNull(client); -#else if (user is null) { throw new ArgumentNullException(nameof(user)); @@ -151,7 +133,6 @@ public static class DiscordUserExtensions { throw new ArgumentNullException(nameof(client)); } -#endif return await client.GetUserAsync(user.Id).ConfigureAwait(false); } From bb3659c0472fa701c4499ef79c5c500d573ddcf6 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 13 Apr 2023 22:52:46 +0100 Subject: [PATCH 02/46] refactor: remove throw helpers (#80) --- X10D/src/Collections/ArrayExtensions.cs | 12 --- X10D/src/Collections/BoolListExtensions.cs | 16 ---- X10D/src/Collections/CollectionExtensions.cs | 8 -- X10D/src/Collections/DictionaryExtensions.cs | 64 -------------- X10D/src/Collections/EnumerableExtensions.cs | 56 ------------- X10D/src/Collections/ListExtensions.cs | 45 ---------- X10D/src/Core/RandomExtensions.cs | 66 --------------- X10D/src/Drawing/Polygon.cs | 16 ---- X10D/src/Drawing/PolygonF.cs | 24 ------ X10D/src/Drawing/Polyhedron.cs | 16 ---- X10D/src/Drawing/RandomExtensions.cs | 8 -- X10D/src/IO/DirectoryInfoExtensions.cs | 4 - X10D/src/IO/FileInfoExtensions.cs | 8 -- X10D/src/IO/ListOfByteExtensions.cs | 41 --------- X10D/src/IO/StreamExtensions.cs | 80 ------------------ X10D/src/IO/TextReaderExtensions.cs | 8 -- ...riterExtensions.WriteLineNoAlloc.Double.cs | 12 --- ...WriterExtensions.WriteLineNoAlloc.Int32.cs | 12 --- ...WriterExtensions.WriteLineNoAlloc.Int64.cs | 12 --- ...riterExtensions.WriteLineNoAlloc.Single.cs | 12 --- ...riterExtensions.WriteLineNoAlloc.UInt32.cs | 12 --- ...riterExtensions.WriteLineNoAlloc.UInt64.cs | 12 --- ...extWriterExtensions.WriteNoAlloc.Double.cs | 12 --- ...TextWriterExtensions.WriteNoAlloc.Int32.cs | 12 --- ...TextWriterExtensions.WriteNoAlloc.Int64.cs | 12 --- ...extWriterExtensions.WriteNoAlloc.Single.cs | 12 --- ...extWriterExtensions.WriteNoAlloc.UInt32.cs | 12 --- ...extWriterExtensions.WriteNoAlloc.UInt64.cs | 12 --- X10D/src/Linq/ByteExtensions.cs | 16 ---- X10D/src/Linq/DecimalExtensions.cs | 8 -- X10D/src/Linq/DoubleExtensions.cs | 8 -- X10D/src/Linq/EnumerableExtensions.cs | 36 -------- X10D/src/Linq/Int32Extensions.cs | 16 ---- X10D/src/Linq/Int64Extensions.cs | 16 ---- X10D/src/Linq/ReadOnlySpanExtensions.cs | 12 --- X10D/src/Linq/SingleExtensions.cs | 8 -- X10D/src/Linq/SpanExtensions.cs | 12 --- X10D/src/Math/ComparableExtensions.cs | 32 ------- X10D/src/Net/EndPointExtensions.cs | 8 -- X10D/src/Net/IPAddressExtensions.cs | 8 -- X10D/src/Numerics/RandomExtensions.cs | 16 ---- X10D/src/Reactive/ObservableDisposer.cs | 19 +---- X10D/src/Reactive/ProgressExtensions.cs | 8 -- X10D/src/Reactive/ProgressObservable.cs | 4 - X10D/src/Reflection/MemberInfoExtensions.cs | 20 +---- X10D/src/Reflection/TypeExtensions.cs | 18 ---- X10D/src/Text/EnumerableExtensions.cs | 10 --- X10D/src/Text/StringBuilderReader.cs | 4 - X10D/src/Text/StringExtensions.cs | 83 ------------------- X10D/src/Time/StringExtensions.cs | 4 - 50 files changed, 3 insertions(+), 979 deletions(-) diff --git a/X10D/src/Collections/ArrayExtensions.cs b/X10D/src/Collections/ArrayExtensions.cs index c6ed75b..7dd5863 100644 --- a/X10D/src/Collections/ArrayExtensions.cs +++ b/X10D/src/Collections/ArrayExtensions.cs @@ -17,14 +17,10 @@ public static class ArrayExtensions [Pure] public static IReadOnlyCollection AsReadOnly(this T[] array) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(array); -#else if (array is null) { throw new ArgumentNullException(nameof(array)); } -#endif return Array.AsReadOnly(array); } @@ -49,14 +45,10 @@ public static class ArrayExtensions /// is . public static void Clear(this T?[] array, Range range) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(array); -#else if (array is null) { throw new ArgumentNullException(nameof(array)); } -#endif (int offset, int length) = range.GetOffsetAndLength(array.Length); array.Clear(offset, length); @@ -79,14 +71,10 @@ public static class ArrayExtensions /// public static void Clear(this T?[] array, int index, int length) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(array); -#else if (array is null) { throw new ArgumentNullException(nameof(array)); } -#endif if (length == 0 || array.Length == 0) { diff --git a/X10D/src/Collections/BoolListExtensions.cs b/X10D/src/Collections/BoolListExtensions.cs index 347d19b..6258617 100644 --- a/X10D/src/Collections/BoolListExtensions.cs +++ b/X10D/src/Collections/BoolListExtensions.cs @@ -18,14 +18,10 @@ public static class BoolListExtensions [Pure] public static byte PackByte(this IReadOnlyList source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif if (source.Count > 8) { @@ -52,14 +48,10 @@ public static class BoolListExtensions [Pure] public static short PackInt16(this IReadOnlyList source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif if (source.Count > 16) { @@ -86,14 +78,10 @@ public static class BoolListExtensions [Pure] public static int PackInt32(this IReadOnlyList source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif if (source.Count > 32) { @@ -120,14 +108,10 @@ public static class BoolListExtensions [Pure] public static long PackInt64(this IReadOnlyList source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif if (source.Count > 64) { diff --git a/X10D/src/Collections/CollectionExtensions.cs b/X10D/src/Collections/CollectionExtensions.cs index 3554586..e9b2c6e 100644 --- a/X10D/src/Collections/CollectionExtensions.cs +++ b/X10D/src/Collections/CollectionExtensions.cs @@ -16,14 +16,10 @@ public static class CollectionExtensions /// public static void ClearAndDisposeAll(this ICollection source) where T : IDisposable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif if (source.IsReadOnly) { @@ -55,14 +51,10 @@ public static class CollectionExtensions /// public static async Task ClearAndDisposeAllAsync(this ICollection source) where T : IAsyncDisposable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif if (source.IsReadOnly) { diff --git a/X10D/src/Collections/DictionaryExtensions.cs b/X10D/src/Collections/DictionaryExtensions.cs index 66823b0..241efe9 100644 --- a/X10D/src/Collections/DictionaryExtensions.cs +++ b/X10D/src/Collections/DictionaryExtensions.cs @@ -37,10 +37,6 @@ public static class DictionaryExtensions Func updateValueFactory) where TKey : notnull { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(dictionary); - ArgumentNullException.ThrowIfNull(updateValueFactory); -#else if (dictionary is null) { throw new ArgumentNullException(nameof(dictionary)); @@ -50,7 +46,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(updateValueFactory)); } -#endif #if NET6_0_OR_GREATER ref var value = ref CollectionsMarshal.GetValueRefOrAddDefault(dictionary, key, out bool exists); @@ -97,10 +92,6 @@ public static class DictionaryExtensions Func updateValueFactory) where TKey : notnull { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(dictionary); - ArgumentNullException.ThrowIfNull(updateValueFactory); -#else if (dictionary is null) { throw new ArgumentNullException(nameof(dictionary)); @@ -110,7 +101,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(updateValueFactory)); } -#endif if (dictionary.TryGetValue(key, out TValue? old)) { @@ -152,11 +142,6 @@ public static class DictionaryExtensions Func addValueFactory, Func updateValueFactory) where TKey : notnull { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(dictionary); - ArgumentNullException.ThrowIfNull(addValueFactory); - ArgumentNullException.ThrowIfNull(updateValueFactory); -#else if (dictionary is null) { throw new ArgumentNullException(nameof(dictionary)); @@ -171,7 +156,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(updateValueFactory)); } -#endif #if NET6_0_OR_GREATER ref TValue? value = ref CollectionsMarshal.GetValueRefOrAddDefault(dictionary, key, out bool exists); @@ -222,11 +206,6 @@ public static class DictionaryExtensions Func addValueFactory, Func updateValueFactory) where TKey : notnull { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(dictionary); - ArgumentNullException.ThrowIfNull(addValueFactory); - ArgumentNullException.ThrowIfNull(updateValueFactory); -#else if (dictionary is null) { throw new ArgumentNullException(nameof(dictionary)); @@ -241,7 +220,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(updateValueFactory)); } -#endif if (dictionary.TryGetValue(key, out TValue? old)) { @@ -291,11 +269,6 @@ public static class DictionaryExtensions Func addValueFactory, Func updateValueFactory, TArg factoryArgument) where TKey : notnull { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(dictionary); - ArgumentNullException.ThrowIfNull(addValueFactory); - ArgumentNullException.ThrowIfNull(updateValueFactory); -#else if (dictionary is null) { throw new ArgumentNullException(nameof(dictionary)); @@ -310,7 +283,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(updateValueFactory)); } -#endif #if NET6_0_OR_GREATER ref TValue? value = ref CollectionsMarshal.GetValueRefOrAddDefault(dictionary, key, out bool exists); @@ -367,11 +339,6 @@ public static class DictionaryExtensions Func addValueFactory, Func updateValueFactory, TArg factoryArgument) where TKey : notnull { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(dictionary); - ArgumentNullException.ThrowIfNull(addValueFactory); - ArgumentNullException.ThrowIfNull(updateValueFactory); -#else if (dictionary is null) { throw new ArgumentNullException(nameof(dictionary)); @@ -386,7 +353,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(updateValueFactory)); } -#endif if (dictionary.TryGetValue(key, out TValue? old)) { @@ -414,14 +380,10 @@ public static class DictionaryExtensions [Pure] public static string ToConnectionString(this IEnumerable> source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif static string SanitizeValue(string? value) { @@ -461,10 +423,6 @@ public static class DictionaryExtensions public static string ToConnectionString(this IEnumerable> source, Func selector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(selector); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -474,7 +432,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(selector)); } -#endif static string SanitizeValue(string? value) { @@ -520,11 +477,6 @@ public static class DictionaryExtensions Func keySelector, Func valueSelector) where TKey : notnull { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(keySelector); - ArgumentNullException.ThrowIfNull(valueSelector); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -539,7 +491,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(valueSelector)); } -#endif static string SanitizeValue(string? value) { @@ -571,14 +522,10 @@ public static class DictionaryExtensions public static string ToGetParameters(this IEnumerable> source) where TKey : notnull { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif static string GetQueryParameter(KeyValuePair pair) { @@ -610,10 +557,6 @@ public static class DictionaryExtensions Func selector) where TKey : notnull { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(selector); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -623,7 +566,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(selector)); } -#endif // can't static here because of 'selector' parameter string GetQueryParameter(KeyValuePair pair) @@ -661,11 +603,6 @@ public static class DictionaryExtensions Func keySelector, Func valueSelector) where TKey : notnull { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(keySelector); - ArgumentNullException.ThrowIfNull(valueSelector); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -680,7 +617,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(valueSelector)); } -#endif // can't static here because of selector parameters string GetQueryParameter(KeyValuePair pair) diff --git a/X10D/src/Collections/EnumerableExtensions.cs b/X10D/src/Collections/EnumerableExtensions.cs index c38e4df..a183c2b 100644 --- a/X10D/src/Collections/EnumerableExtensions.cs +++ b/X10D/src/Collections/EnumerableExtensions.cs @@ -24,10 +24,6 @@ public static class EnumerableExtensions [Pure] public static int CountWhereNot(this IEnumerable source, Func predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(predicate); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -37,7 +33,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(predicate)); } -#endif return source.Count(item => !predicate(item)); } @@ -58,10 +53,6 @@ public static class EnumerableExtensions [Pure] public static TSource FirstWhereNot(this IEnumerable source, Func predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(predicate); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -71,7 +62,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(predicate)); } -#endif return source.First(item => !predicate(item)); } @@ -91,10 +81,6 @@ public static class EnumerableExtensions [Pure] public static TSource? FirstWhereNotOrDefault(this IEnumerable source, Func predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(predicate); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -104,7 +90,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(predicate)); } -#endif return source.FirstOrDefault(item => !predicate(item)); } @@ -127,10 +112,6 @@ public static class EnumerableExtensions /// public static void For(this IEnumerable source, Action action) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(action); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -140,7 +121,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(action)); } -#endif var index = 0; foreach (T item in source) @@ -166,10 +146,6 @@ public static class EnumerableExtensions /// public static void ForEach(this IEnumerable source, Action action) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(action); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -179,7 +155,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(action)); } -#endif foreach (T item in source) { @@ -196,14 +171,10 @@ public static class EnumerableExtensions /// public static void DisposeAll(this IEnumerable source) where T : IDisposable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif foreach (T item in source) { @@ -227,14 +198,10 @@ public static class EnumerableExtensions /// public static async Task DisposeAllAsync(this IEnumerable source) where T : IAsyncDisposable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif foreach (T item in source) { @@ -264,10 +231,6 @@ public static class EnumerableExtensions [Pure] public static TSource LastWhereNot(this IEnumerable source, Func predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(predicate); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -277,7 +240,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(predicate)); } -#endif return source.Last(item => !predicate(item)); } @@ -297,10 +259,6 @@ public static class EnumerableExtensions [Pure] public static TSource? LastWhereNotOrDefault(this IEnumerable source, Func predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(predicate); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -310,7 +268,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(predicate)); } -#endif return source.LastOrDefault(item => !predicate(item)); } @@ -326,14 +283,10 @@ public static class EnumerableExtensions [Pure] public static IReadOnlyCollection Shuffled(this IEnumerable source, Random? random = null) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif var list = new List(source); list.Shuffle(random); @@ -355,10 +308,6 @@ public static class EnumerableExtensions [Pure] public static IEnumerable WhereNot(this IEnumerable source, Func predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(predicate); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -368,7 +317,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(predicate)); } -#endif return source.Where(item => !predicate(item)); } @@ -386,14 +334,10 @@ public static class EnumerableExtensions /// is . public static IEnumerable WhereNotNull(this IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Where(item => item is not null).Select(item => item!); } diff --git a/X10D/src/Collections/ListExtensions.cs b/X10D/src/Collections/ListExtensions.cs index 69292b4..be53ee8 100644 --- a/X10D/src/Collections/ListExtensions.cs +++ b/X10D/src/Collections/ListExtensions.cs @@ -19,14 +19,10 @@ public static class ListExtensions /// is . public static void Fill(this IList source, T value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif for (var i = 0; i < source.Count; i++) { @@ -53,14 +49,10 @@ public static class ListExtensions /// public static void Fill(this IList source, T value, int startIndex, int count) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif if (startIndex < 0) { @@ -105,14 +97,10 @@ public static class ListExtensions /// is . public static int IndexOf(this IReadOnlyList source, T? item) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.IndexOf(item, 0, source.Count); } @@ -138,14 +126,10 @@ public static class ListExtensions /// public static int IndexOf(this IReadOnlyList source, T? item, int startIndex) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.IndexOf(item, startIndex, source.Count - startIndex); } @@ -182,14 +166,10 @@ public static class ListExtensions /// public static int IndexOf(this IReadOnlyList source, T? item, int startIndex, int count) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif if (startIndex < 0 || startIndex > source.Count) { @@ -233,14 +213,10 @@ public static class ListExtensions [Pure] public static T Random(this IReadOnlyList source, Random? random = null) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif random ??= RandomExtensions.GetShared(); return random.NextFrom(source); @@ -260,14 +236,10 @@ public static class ListExtensions /// public static void RemoveRange(this IList source, Range range) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif int start = range.Start.IsFromEnd ? source.Count - range.Start.Value : range.Start.Value; int end = range.End.IsFromEnd ? source.Count - range.End.Value : range.End.Value; @@ -300,14 +272,10 @@ public static class ListExtensions /// is . public static void Shuffle(this IList source, Random? random = null) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif random ??= RandomExtensions.GetShared(); @@ -334,14 +302,10 @@ public static class ListExtensions /// public static IReadOnlyList Slice(this IReadOnlyList source, int start) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Slice(start, source.Count - start); } @@ -363,14 +327,10 @@ public static class ListExtensions /// public static IReadOnlyList Slice(this IReadOnlyList source, int start, int length) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif if (start < 0 || start > source.Count) { @@ -406,10 +366,6 @@ public static class ListExtensions /// public static void Swap(this IList source, IList other) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(other); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -419,7 +375,6 @@ public static class ListExtensions { throw new ArgumentNullException(nameof(other)); } -#endif int min = System.Math.Min(source.Count, other.Count); for (var index = 0; index < min; index++) diff --git a/X10D/src/Core/RandomExtensions.cs b/X10D/src/Core/RandomExtensions.cs index 32acc3b..49e8634 100644 --- a/X10D/src/Core/RandomExtensions.cs +++ b/X10D/src/Core/RandomExtensions.cs @@ -27,14 +27,10 @@ public static class RandomExtensions public static T Next(this Random random) where T : struct, Enum { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif var values = Enum.GetValues(typeof(T)); return (T)values.GetValue(random.Next(values.Length))!; @@ -54,14 +50,10 @@ public static class RandomExtensions /// is . public static bool NextBoolean(this Random random) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif return random.NextDouble() >= 0.5; } @@ -81,14 +73,10 @@ public static class RandomExtensions /// is less than 0. public static double NextDouble(this Random random, double maxValue) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif if (maxValue < 0) { @@ -117,14 +105,10 @@ public static class RandomExtensions /// public static double NextDouble(this Random random, double minValue, double maxValue) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif if (maxValue < minValue) { @@ -155,10 +139,6 @@ public static class RandomExtensions /// public static T NextFrom(this Random random, IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); - ArgumentNullException.ThrowIfNull(source); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); @@ -168,7 +148,6 @@ public static class RandomExtensions { throw new ArgumentNullException(nameof(source)); } -#endif if (source is T[] array) { @@ -206,14 +185,10 @@ public static class RandomExtensions /// public static T NextFrom(this Random random, Span source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif return source[random.Next(source.Length)]; } @@ -242,14 +217,10 @@ public static class RandomExtensions /// public static T NextFrom(this Random random, ReadOnlySpan source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif return source[random.Next(source.Length)]; } @@ -264,14 +235,10 @@ public static class RandomExtensions /// is . public static byte NextByte(this Random random) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif return random.NextByte(byte.MaxValue); } @@ -292,14 +259,10 @@ public static class RandomExtensions /// is . public static byte NextByte(this Random random, byte maxValue) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif return random.NextByte(0, maxValue); } @@ -325,14 +288,10 @@ public static class RandomExtensions /// public static byte NextByte(this Random random, byte minValue, byte maxValue) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif return (byte)random.Next(minValue, maxValue); } @@ -347,14 +306,10 @@ public static class RandomExtensions /// is . public static short NextInt16(this Random random) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif return random.NextInt16(short.MaxValue); } @@ -376,14 +331,10 @@ public static class RandomExtensions /// is less than 0. public static short NextInt16(this Random random, short maxValue) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif if (maxValue < 0) { @@ -414,14 +365,10 @@ public static class RandomExtensions /// is . public static short NextInt16(this Random random, short minValue, short maxValue) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif return (short)random.Next(minValue, maxValue); } @@ -459,14 +406,10 @@ public static class RandomExtensions /// is less than 0. public static float NextSingle(this Random random, float maxValue) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif if (maxValue < 0) { @@ -495,14 +438,10 @@ public static class RandomExtensions /// public static float NextSingle(this Random random, float minValue, float maxValue) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif if (maxValue < minValue) { @@ -530,10 +469,6 @@ public static class RandomExtensions /// is less than 0. public static string NextString(this Random random, IReadOnlyList source, int length) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); - ArgumentNullException.ThrowIfNull(source); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); @@ -543,7 +478,6 @@ public static class RandomExtensions { throw new ArgumentNullException(nameof(source)); } -#endif if (length < 0) { diff --git a/X10D/src/Drawing/Polygon.cs b/X10D/src/Drawing/Polygon.cs index 63abae8..9f03b58 100644 --- a/X10D/src/Drawing/Polygon.cs +++ b/X10D/src/Drawing/Polygon.cs @@ -22,14 +22,10 @@ public class Polygon : IEquatable /// public Polygon(Polygon polygon) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(polygon); -#else if (polygon is null) { throw new ArgumentNullException(nameof(polygon)); } -#endif _vertices = new List(); for (var index = 0; index < polygon._vertices.Count; index++) @@ -45,14 +41,10 @@ public class Polygon : IEquatable /// An enumerable collection of vertices from which the polygon should be constructed. public Polygon(IEnumerable vertices) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(vertices); -#else if (vertices is null) { throw new ArgumentNullException(nameof(vertices)); } -#endif _vertices = new List(vertices); } @@ -176,14 +168,10 @@ public class Polygon : IEquatable /// is . public static Polygon FromPolygonF(PolygonF polygon) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(polygon); -#else if (polygon is null) { throw new ArgumentNullException(nameof(polygon)); } -#endif var vertices = new List(); @@ -211,14 +199,10 @@ public class Polygon : IEquatable /// is . public void AddVertices(IEnumerable vertices) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(vertices); -#else if (vertices is null) { throw new ArgumentNullException(nameof(vertices)); } -#endif foreach (Point vertex in vertices) { diff --git a/X10D/src/Drawing/PolygonF.cs b/X10D/src/Drawing/PolygonF.cs index 51d9eeb..074edc3 100644 --- a/X10D/src/Drawing/PolygonF.cs +++ b/X10D/src/Drawing/PolygonF.cs @@ -25,14 +25,10 @@ public class PolygonF /// is . public PolygonF(PolygonF polygon) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(polygon); -#else if (polygon is null) { throw new ArgumentNullException(nameof(polygon)); } -#endif _vertices = new List(); for (var index = 0; index < polygon._vertices.Count; index++) { @@ -48,14 +44,10 @@ public class PolygonF /// is . public PolygonF(IEnumerable vertices) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(vertices); -#else if (vertices is null) { throw new ArgumentNullException(nameof(vertices)); } -#endif _vertices = new List(); foreach (Vector2 vertex in vertices) @@ -71,14 +63,10 @@ public class PolygonF /// is . public PolygonF(IEnumerable vertices) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(vertices); -#else if (vertices is null) { throw new ArgumentNullException(nameof(vertices)); } -#endif _vertices = new List(vertices); } @@ -202,14 +190,10 @@ public class PolygonF /// is . public static PolygonF FromPolygon(Polygon polygon) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(polygon); -#else if (polygon is null) { throw new ArgumentNullException(nameof(polygon)); } -#endif var vertices = new List(); @@ -246,14 +230,10 @@ public class PolygonF /// is . public void AddVertices(IEnumerable vertices) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(vertices); -#else if (vertices is null) { throw new ArgumentNullException(nameof(vertices)); } -#endif foreach (PointF vertex in vertices) { @@ -268,14 +248,10 @@ public class PolygonF /// is . public void AddVertices(IEnumerable vertices) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(vertices); -#else if (vertices is null) { throw new ArgumentNullException(nameof(vertices)); } -#endif foreach (Vector2 vertex in vertices) { diff --git a/X10D/src/Drawing/Polyhedron.cs b/X10D/src/Drawing/Polyhedron.cs index 2f46ca0..6be327e 100644 --- a/X10D/src/Drawing/Polyhedron.cs +++ b/X10D/src/Drawing/Polyhedron.cs @@ -34,14 +34,10 @@ public class Polyhedron : IEquatable /// is . public Polyhedron(IEnumerable vertices) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(vertices); -#else if (vertices is null) { throw new ArgumentNullException(nameof(vertices)); } -#endif _vertices = new List(vertices); } @@ -137,14 +133,10 @@ public class Polyhedron : IEquatable /// is . public static Polyhedron FromPolygon(Polygon polygon) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(polygon); -#else if (polygon is null) { throw new ArgumentNullException(nameof(polygon)); } -#endif var vertices = new List(); @@ -164,14 +156,10 @@ public class Polyhedron : IEquatable /// is . public static Polyhedron FromPolygonF(PolygonF polygon) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(polygon); -#else if (polygon is null) { throw new ArgumentNullException(nameof(polygon)); } -#endif var vertices = new List(); @@ -199,14 +187,10 @@ public class Polyhedron : IEquatable /// is . public void AddVertices(IEnumerable vertices) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(vertices); -#else if (vertices is null) { throw new ArgumentNullException(nameof(vertices)); } -#endif foreach (Vector3 vertex in vertices) { diff --git a/X10D/src/Drawing/RandomExtensions.cs b/X10D/src/Drawing/RandomExtensions.cs index 24c7419..880cd84 100644 --- a/X10D/src/Drawing/RandomExtensions.cs +++ b/X10D/src/Drawing/RandomExtensions.cs @@ -17,14 +17,10 @@ public static class RandomExtensions /// is . public static Color NextColorRgb(this Random random) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif int rgb = random.Next(); return Color.FromArgb(0xFF, (byte)(rgb >> 16 & 0xFF), (byte)(rgb >> 8 & 0xFF), (byte)(rgb & 0xFF)); @@ -38,14 +34,10 @@ public static class RandomExtensions /// is . public static Color NextColorArgb(this Random random) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif int argb = random.Next(); return Color.FromArgb(argb); diff --git a/X10D/src/IO/DirectoryInfoExtensions.cs b/X10D/src/IO/DirectoryInfoExtensions.cs index 5eb0a92..c6c7e81 100644 --- a/X10D/src/IO/DirectoryInfoExtensions.cs +++ b/X10D/src/IO/DirectoryInfoExtensions.cs @@ -33,14 +33,10 @@ public static class DirectoryInfoExtensions /// This directory or one of its children contain a read-only file. public static void Clear(this DirectoryInfo directory) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(directory); -#else if (directory is null) { throw new ArgumentNullException(nameof(directory)); } -#endif if (!directory.Exists) { diff --git a/X10D/src/IO/FileInfoExtensions.cs b/X10D/src/IO/FileInfoExtensions.cs index a0878bc..e1a4e69 100644 --- a/X10D/src/IO/FileInfoExtensions.cs +++ b/X10D/src/IO/FileInfoExtensions.cs @@ -29,14 +29,10 @@ public static class FileInfoExtensions public static byte[] GetHash(this FileInfo value) where T : HashAlgorithm { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif using FileStream stream = value.OpenRead(); return stream.GetHash(); @@ -69,14 +65,10 @@ public static class FileInfoExtensions public static bool TryWriteHash(this FileInfo value, Span destination, out int bytesWritten) where T : HashAlgorithm { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif using FileStream stream = value.OpenRead(); return stream.TryWriteHash(destination, out bytesWritten); diff --git a/X10D/src/IO/ListOfByteExtensions.cs b/X10D/src/IO/ListOfByteExtensions.cs index 3289fef..5d9122f 100644 --- a/X10D/src/IO/ListOfByteExtensions.cs +++ b/X10D/src/IO/ListOfByteExtensions.cs @@ -19,14 +19,10 @@ public static class ListOfByteExtensions /// is . public static string AsString(this IReadOnlyList source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return BitConverter.ToString(source.ToArray()); } @@ -54,14 +50,10 @@ public static class ListOfByteExtensions /// is . public static double ToDouble(this IReadOnlyList source, int startIndex) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return BitConverter.ToDouble(source.ToArray(), startIndex); } @@ -86,14 +78,10 @@ public static class ListOfByteExtensions /// is . public static short ToInt16(this IReadOnlyList source, int startIndex) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return BitConverter.ToInt16(source.ToArray(), startIndex); } @@ -118,14 +106,10 @@ public static class ListOfByteExtensions /// is . public static int ToInt32(this IReadOnlyList source, int startIndex) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return BitConverter.ToInt32(source.ToArray(), startIndex); } @@ -150,14 +134,10 @@ public static class ListOfByteExtensions /// is . public static long ToInt64(this IReadOnlyList source, int startIndex) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return BitConverter.ToInt64(source.ToArray(), startIndex); } @@ -183,14 +163,10 @@ public static class ListOfByteExtensions /// is . public static float ToSingle(this IReadOnlyList source, int startIndex) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return BitConverter.ToSingle(source.ToArray(), startIndex); } @@ -208,10 +184,6 @@ public static class ListOfByteExtensions /// public static string ToString(this IReadOnlyList source, Encoding encoding) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(encoding); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -221,7 +193,6 @@ public static class ListOfByteExtensions { throw new ArgumentNullException(nameof(encoding)); } -#endif return encoding.GetString(source.ToArray()); } @@ -248,14 +219,10 @@ public static class ListOfByteExtensions [CLSCompliant(false)] public static ushort ToUInt16(this IReadOnlyList source, int startIndex) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return BitConverter.ToUInt16(source.ToArray(), startIndex); } @@ -282,14 +249,10 @@ public static class ListOfByteExtensions [CLSCompliant(false)] public static uint ToUInt32(this IReadOnlyList source, int startIndex) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return BitConverter.ToUInt32(source.ToArray(), startIndex); } @@ -316,14 +279,10 @@ public static class ListOfByteExtensions [CLSCompliant(false)] public static ulong ToUInt64(this IReadOnlyList source, int startIndex) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return BitConverter.ToUInt64(source.ToArray(), startIndex); } diff --git a/X10D/src/IO/StreamExtensions.cs b/X10D/src/IO/StreamExtensions.cs index c55b784..d1d44db 100644 --- a/X10D/src/IO/StreamExtensions.cs +++ b/X10D/src/IO/StreamExtensions.cs @@ -33,14 +33,10 @@ public static class StreamExtensions public static byte[] GetHash(this Stream stream) where T : HashAlgorithm { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif if (!stream.CanRead) { @@ -87,14 +83,10 @@ public static class StreamExtensions /// A decimal value read from the stream. public static decimal ReadDecimal(this Stream stream, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -151,14 +143,10 @@ public static class StreamExtensions /// A double-precision floating point value read from the stream. public static double ReadDouble(this Stream stream, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -211,14 +199,10 @@ public static class StreamExtensions /// An two-byte unsigned integer read from the stream. public static short ReadInt16(this Stream stream, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -265,14 +249,10 @@ public static class StreamExtensions /// An four-byte unsigned integer read from the stream. public static int ReadInt32(this Stream stream, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -319,14 +299,10 @@ public static class StreamExtensions /// An eight-byte unsigned integer read from the stream. public static long ReadInt64(this Stream stream, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -373,14 +349,10 @@ public static class StreamExtensions /// A single-precision floating point value read from the stream. public static float ReadSingle(this Stream stream, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -435,14 +407,10 @@ public static class StreamExtensions [CLSCompliant(false)] public static ushort ReadUInt16(this Stream stream, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -491,14 +459,10 @@ public static class StreamExtensions [CLSCompliant(false)] public static uint ReadUInt32(this Stream stream, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -547,14 +511,10 @@ public static class StreamExtensions [CLSCompliant(false)] public static ulong ReadUInt64(this Stream stream, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -607,14 +567,10 @@ public static class StreamExtensions public static bool TryWriteHash(this Stream stream, Span destination, out int bytesWritten) where T : HashAlgorithm { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif if (!stream.CanRead) { @@ -671,14 +627,10 @@ public static class StreamExtensions /// The number of bytes written to the stream. public static int Write(this Stream stream, short value, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -735,14 +687,10 @@ public static class StreamExtensions /// is . public static int Write(this Stream stream, int value, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -800,14 +748,10 @@ public static class StreamExtensions /// is . public static int Write(this Stream stream, long value, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -867,14 +811,10 @@ public static class StreamExtensions [CLSCompliant(false)] public static int Write(this Stream stream, ushort value, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -934,14 +874,10 @@ public static class StreamExtensions [CLSCompliant(false)] public static int Write(this Stream stream, uint value, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -1001,14 +937,10 @@ public static class StreamExtensions [CLSCompliant(false)] public static int Write(this Stream stream, ulong value, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -1052,14 +984,10 @@ public static class StreamExtensions /// is . public static int Write(this Stream stream, float value, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -1135,14 +1063,10 @@ public static class StreamExtensions /// is . public static int Write(this Stream stream, double value, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) @@ -1219,14 +1143,10 @@ public static class StreamExtensions [ExcludeFromCodeCoverage] public static int Write(this Stream stream, decimal value, Endianness endianness) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(stream); -#else if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#endif #if NET5_0_OR_GREATER if (!Enum.IsDefined(endianness)) diff --git a/X10D/src/IO/TextReaderExtensions.cs b/X10D/src/IO/TextReaderExtensions.cs index 4ecb213..b8bef35 100644 --- a/X10D/src/IO/TextReaderExtensions.cs +++ b/X10D/src/IO/TextReaderExtensions.cs @@ -13,14 +13,10 @@ public static class TextReaderExtensions /// is . public static IEnumerable EnumerateLines(this TextReader reader) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(reader); -#else if (reader is null) { throw new ArgumentNullException(nameof(reader)); } -#endif while (reader.ReadLine() is { } line) { @@ -36,14 +32,10 @@ public static class TextReaderExtensions /// is . public static async IAsyncEnumerable EnumerateLinesAsync(this TextReader reader) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(reader); -#else if (reader is null) { throw new ArgumentNullException(nameof(reader)); } -#endif while (await reader.ReadLineAsync().ConfigureAwait(false) is { } line) { diff --git a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Double.cs b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Double.cs index 1a63f42..1317846 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Double.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Double.cs @@ -16,14 +16,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteLineNoAlloc(this TextWriter writer, double value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteLineNoAlloc(value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -41,14 +37,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteLineNoAlloc(this TextWriter writer, double value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteLineNoAlloc(writer, value, format, CultureInfo.CurrentCulture); } @@ -68,14 +60,10 @@ public static partial class TextWriterExtensions public static void WriteLineNoAlloc(this TextWriter writer, double value, ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteNoAlloc(value, format, formatProvider); writer.WriteLine(); diff --git a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Int32.cs b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Int32.cs index 8836d63..9640a6a 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Int32.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Int32.cs @@ -16,14 +16,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteLineNoAlloc(this TextWriter writer, int value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteLineNoAlloc(value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -41,14 +37,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteLineNoAlloc(this TextWriter writer, int value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteLineNoAlloc(writer, (long)value, format, CultureInfo.CurrentCulture); } @@ -68,14 +60,10 @@ public static partial class TextWriterExtensions public static void WriteLineNoAlloc(this TextWriter writer, int value, ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteNoAlloc(value, format, formatProvider); writer.WriteLine(); diff --git a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Int64.cs b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Int64.cs index 83deadd..8ca5855 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Int64.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Int64.cs @@ -16,14 +16,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteLineNoAlloc(this TextWriter writer, long value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteLineNoAlloc(value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -41,14 +37,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteLineNoAlloc(this TextWriter writer, long value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteLineNoAlloc(value, format, CultureInfo.CurrentCulture); } @@ -70,14 +62,10 @@ public static partial class TextWriterExtensions ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteNoAlloc(value, format, formatProvider); writer.WriteLine(); diff --git a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Single.cs b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Single.cs index bb6d2e0..9194c62 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Single.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Single.cs @@ -16,14 +16,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteLineNoAlloc(this TextWriter writer, float value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteLineNoAlloc(value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -41,14 +37,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteLineNoAlloc(this TextWriter writer, float value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteLineNoAlloc(writer, value, format, CultureInfo.CurrentCulture); } @@ -68,14 +60,10 @@ public static partial class TextWriterExtensions public static void WriteLineNoAlloc(this TextWriter writer, float value, ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteNoAlloc(value, format, formatProvider); writer.WriteLine(); diff --git a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.UInt32.cs b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.UInt32.cs index 98e9d42..b812afb 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.UInt32.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.UInt32.cs @@ -17,14 +17,10 @@ public static partial class TextWriterExtensions [CLSCompliant(false)] public static void WriteLineNoAlloc(this TextWriter writer, uint value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteLineNoAlloc(value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -43,14 +39,10 @@ public static partial class TextWriterExtensions [CLSCompliant(false)] public static void WriteLineNoAlloc(this TextWriter writer, uint value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteLineNoAlloc(writer, (long)value, format, CultureInfo.CurrentCulture); } @@ -73,14 +65,10 @@ public static partial class TextWriterExtensions ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteNoAlloc(value, format, formatProvider); writer.WriteLine(); diff --git a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.UInt64.cs b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.UInt64.cs index 68f397f..7b55571 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.UInt64.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.UInt64.cs @@ -17,14 +17,10 @@ public static partial class TextWriterExtensions [CLSCompliant(false)] public static void WriteLineNoAlloc(this TextWriter writer, ulong value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteLineNoAlloc(value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -43,14 +39,10 @@ public static partial class TextWriterExtensions [CLSCompliant(false)] public static void WriteLineNoAlloc(this TextWriter writer, ulong value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteLineNoAlloc(value, format, CultureInfo.CurrentCulture); } @@ -73,14 +65,10 @@ public static partial class TextWriterExtensions ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif writer.WriteNoAlloc(value, format, formatProvider); writer.WriteLine(); diff --git a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Double.cs b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Double.cs index 6b6de18..a8d5bbb 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Double.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Double.cs @@ -15,14 +15,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteNoAlloc(this TextWriter writer, double value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -39,14 +35,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteNoAlloc(this TextWriter writer, double value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, format, CultureInfo.CurrentCulture); } @@ -65,14 +57,10 @@ public static partial class TextWriterExtensions public static void WriteNoAlloc(this TextWriter writer, double value, ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif Span buffer = stackalloc char[100]; if (value.TryFormat(buffer, out int charsWritten, format, formatProvider)) diff --git a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Int32.cs b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Int32.cs index c2366bf..2018363 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Int32.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Int32.cs @@ -16,14 +16,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteNoAlloc(this TextWriter writer, int value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -40,14 +36,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteNoAlloc(this TextWriter writer, int value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, format, CultureInfo.CurrentCulture); } @@ -65,14 +57,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteNoAlloc(this TextWriter writer, int value, ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif int digitCount = value.CountDigits(); Span buffer = stackalloc char[System.Math.Max(value < 0 ? digitCount + 1 : digitCount, 100)]; diff --git a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Int64.cs b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Int64.cs index 049d891..c0cb32f 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Int64.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Int64.cs @@ -16,14 +16,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteNoAlloc(this TextWriter writer, long value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -40,14 +36,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteNoAlloc(this TextWriter writer, long value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, format, CultureInfo.CurrentCulture); } @@ -68,14 +60,10 @@ public static partial class TextWriterExtensions ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif int digitCount = value.CountDigits(); Span buffer = stackalloc char[System.Math.Max(value < 0 ? digitCount + 1 : digitCount, 100)]; diff --git a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Single.cs b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Single.cs index f595593..b48a415 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Single.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Single.cs @@ -15,14 +15,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteNoAlloc(this TextWriter writer, float value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -39,14 +35,10 @@ public static partial class TextWriterExtensions /// An I/O error occurs. public static void WriteNoAlloc(this TextWriter writer, float value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, format, CultureInfo.CurrentCulture); } @@ -65,14 +57,10 @@ public static partial class TextWriterExtensions public static void WriteNoAlloc(this TextWriter writer, float value, ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif Span buffer = stackalloc char[100]; if (value.TryFormat(buffer, out int charsWritten, format, formatProvider)) diff --git a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.UInt32.cs b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.UInt32.cs index f8d32a2..b38fa0a 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.UInt32.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.UInt32.cs @@ -17,14 +17,10 @@ public static partial class TextWriterExtensions [CLSCompliant(false)] public static void WriteNoAlloc(this TextWriter writer, uint value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -42,14 +38,10 @@ public static partial class TextWriterExtensions [CLSCompliant(false)] public static void WriteNoAlloc(this TextWriter writer, uint value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, format, CultureInfo.CurrentCulture); } @@ -71,14 +63,10 @@ public static partial class TextWriterExtensions ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif int digitCount = value.CountDigits(); Span buffer = stackalloc char[System.Math.Max(digitCount, 100)]; diff --git a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.UInt64.cs b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.UInt64.cs index 5e266e4..d9a48f4 100644 --- a/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.UInt64.cs +++ b/X10D/src/IO/TextWriterExtensions.WriteNoAlloc.UInt64.cs @@ -17,14 +17,10 @@ public static partial class TextWriterExtensions [CLSCompliant(false)] public static void WriteNoAlloc(this TextWriter writer, ulong value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, "N0".AsSpan(), CultureInfo.CurrentCulture); } @@ -42,14 +38,10 @@ public static partial class TextWriterExtensions [CLSCompliant(false)] public static void WriteNoAlloc(this TextWriter writer, ulong value, ReadOnlySpan format) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif WriteNoAlloc(writer, value, format, CultureInfo.CurrentCulture); } @@ -71,14 +63,10 @@ public static partial class TextWriterExtensions ReadOnlySpan format, IFormatProvider? formatProvider) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(writer); -#else if (writer is null) { throw new ArgumentNullException(nameof(writer)); } -#endif int digitCount = value.CountDigits(); Span buffer = stackalloc char[System.Math.Max(digitCount, 100)]; diff --git a/X10D/src/Linq/ByteExtensions.cs b/X10D/src/Linq/ByteExtensions.cs index 3d7524d..64d1c01 100644 --- a/X10D/src/Linq/ByteExtensions.cs +++ b/X10D/src/Linq/ByteExtensions.cs @@ -15,14 +15,10 @@ public static class ByteExtensions /// is . public static byte Product(this IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Aggregate((byte)1, (current, value) => (byte)(current * value)); } @@ -36,14 +32,10 @@ public static class ByteExtensions [CLSCompliant(false)] public static sbyte Product(this IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Aggregate((sbyte)1, (current, value) => (sbyte)(current * value)); } @@ -59,14 +51,10 @@ public static class ByteExtensions /// is . public static byte Product(this IEnumerable source, Func selector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Select(selector).Product(); } @@ -83,14 +71,10 @@ public static class ByteExtensions [CLSCompliant(false)] public static sbyte Product(this IEnumerable source, Func selector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Select(selector).Product(); } diff --git a/X10D/src/Linq/DecimalExtensions.cs b/X10D/src/Linq/DecimalExtensions.cs index 01dde51..c5e1bc7 100644 --- a/X10D/src/Linq/DecimalExtensions.cs +++ b/X10D/src/Linq/DecimalExtensions.cs @@ -13,14 +13,10 @@ public static class DecimalExtensions /// is . public static decimal Product(this IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Aggregate(1m, (current, value) => (current * value)); } @@ -36,14 +32,10 @@ public static class DecimalExtensions /// is . public static decimal Product(this IEnumerable source, Func selector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Select(selector).Product(); } diff --git a/X10D/src/Linq/DoubleExtensions.cs b/X10D/src/Linq/DoubleExtensions.cs index afb38ae..23628af 100644 --- a/X10D/src/Linq/DoubleExtensions.cs +++ b/X10D/src/Linq/DoubleExtensions.cs @@ -13,14 +13,10 @@ public static class DoubleExtensions /// is . public static double Product(this IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Aggregate(1.0, (current, value) => (current * value)); } @@ -36,14 +32,10 @@ public static class DoubleExtensions /// is . public static double Product(this IEnumerable source, Func selector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Select(selector).Product(); } diff --git a/X10D/src/Linq/EnumerableExtensions.cs b/X10D/src/Linq/EnumerableExtensions.cs index 92592bf..05004c9 100644 --- a/X10D/src/Linq/EnumerableExtensions.cs +++ b/X10D/src/Linq/EnumerableExtensions.cs @@ -22,14 +22,10 @@ public static class EnumerableExtensions /// is . public static IEnumerable ConcatOne(this IEnumerable source, TSource value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif foreach (TSource item in source) { @@ -52,14 +48,10 @@ public static class EnumerableExtensions /// is . public static IEnumerable Except(this IEnumerable source, TSource item) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Where(i => !Equals(i, item)); } @@ -74,14 +66,10 @@ public static class EnumerableExtensions /// contains no elements. public static (T? Minimum, T? Maximum) MinMax(this IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return MinMax(source, Comparer.Default); } @@ -97,14 +85,10 @@ public static class EnumerableExtensions /// contains no elements. public static (T? Minimum, T? Maximum) MinMax(this IEnumerable source, IComparer? comparer) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif comparer ??= Comparer.Default; @@ -160,10 +144,6 @@ public static class EnumerableExtensions public static (TResult? Minimum, TResult? Maximum) MinMax(this IEnumerable source, Func selector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(selector); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -173,7 +153,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(selector)); } -#endif return MinMax(source, selector, Comparer.Default); } @@ -194,10 +173,6 @@ public static class EnumerableExtensions Func selector, IComparer? comparer) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(selector); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -207,7 +182,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(selector)); } -#endif comparer ??= Comparer.Default; @@ -263,10 +237,6 @@ public static class EnumerableExtensions public static (TSource? Minimum, TSource? Maximum) MinMaxBy(this IEnumerable source, Func keySelector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(keySelector); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -276,7 +246,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(keySelector)); } -#endif return MinMaxBy(source, keySelector, Comparer.Default); } @@ -296,10 +265,6 @@ public static class EnumerableExtensions Func keySelector, IComparer? comparer) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(keySelector); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -309,7 +274,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(keySelector)); } -#endif comparer ??= Comparer.Default; TSource? minValue; diff --git a/X10D/src/Linq/Int32Extensions.cs b/X10D/src/Linq/Int32Extensions.cs index 871e422..876f373 100644 --- a/X10D/src/Linq/Int32Extensions.cs +++ b/X10D/src/Linq/Int32Extensions.cs @@ -15,14 +15,10 @@ public static class Int32Extensions /// is . public static int Product(this IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Aggregate(1, (current, value) => current * value); } @@ -36,14 +32,10 @@ public static class Int32Extensions [CLSCompliant(false)] public static uint Product(this IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Aggregate(1u, (current, value) => current * value); } @@ -59,14 +51,10 @@ public static class Int32Extensions /// is . public static int Product(this IEnumerable source, Func selector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Select(selector).Product(); } @@ -83,14 +71,10 @@ public static class Int32Extensions [CLSCompliant(false)] public static uint Product(this IEnumerable source, Func selector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Select(selector).Product(); } diff --git a/X10D/src/Linq/Int64Extensions.cs b/X10D/src/Linq/Int64Extensions.cs index 07b9802..00061d4 100644 --- a/X10D/src/Linq/Int64Extensions.cs +++ b/X10D/src/Linq/Int64Extensions.cs @@ -15,14 +15,10 @@ public static class Int64Extensions /// is . public static long Product(this IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Aggregate(1L, (current, value) => current * value); } @@ -36,14 +32,10 @@ public static class Int64Extensions [CLSCompliant(false)] public static ulong Product(this IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Aggregate(1UL, (current, value) => current * value); } @@ -59,14 +51,10 @@ public static class Int64Extensions /// is . public static long Product(this IEnumerable source, Func selector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Select(selector).Product(); } @@ -83,14 +71,10 @@ public static class Int64Extensions [CLSCompliant(false)] public static ulong Product(this IEnumerable source, Func selector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Select(selector).Product(); } diff --git a/X10D/src/Linq/ReadOnlySpanExtensions.cs b/X10D/src/Linq/ReadOnlySpanExtensions.cs index bf0d1d3..9d20ff8 100644 --- a/X10D/src/Linq/ReadOnlySpanExtensions.cs +++ b/X10D/src/Linq/ReadOnlySpanExtensions.cs @@ -21,14 +21,10 @@ public static class ReadOnlySpanExtensions [Pure] public static bool All(this ReadOnlySpan source, Predicate predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(predicate); -#else if (predicate is null) { throw new ArgumentNullException(nameof(predicate)); } -#endif if (source.IsEmpty) { @@ -60,14 +56,10 @@ public static class ReadOnlySpanExtensions [Pure] public static bool Any(this ReadOnlySpan source, Predicate predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(predicate); -#else if (predicate is null) { throw new ArgumentNullException(nameof(predicate)); } -#endif if (source.IsEmpty) { @@ -97,14 +89,10 @@ public static class ReadOnlySpanExtensions /// is . public static int Count(this ReadOnlySpan source, Predicate predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(predicate); -#else if (predicate is null) { throw new ArgumentNullException(nameof(predicate)); } -#endif if (source.IsEmpty) { diff --git a/X10D/src/Linq/SingleExtensions.cs b/X10D/src/Linq/SingleExtensions.cs index 9d48203..e80ed9b 100644 --- a/X10D/src/Linq/SingleExtensions.cs +++ b/X10D/src/Linq/SingleExtensions.cs @@ -13,14 +13,10 @@ public static class SingleExtensions /// is . public static float Product(this IEnumerable source) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Aggregate(1f, (current, value) => (current * value)); } @@ -36,14 +32,10 @@ public static class SingleExtensions /// is . public static float Product(this IEnumerable source, Func selector) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif return source.Select(selector).Product(); } diff --git a/X10D/src/Linq/SpanExtensions.cs b/X10D/src/Linq/SpanExtensions.cs index ce2e3f3..9b84308 100644 --- a/X10D/src/Linq/SpanExtensions.cs +++ b/X10D/src/Linq/SpanExtensions.cs @@ -21,14 +21,10 @@ public static class SpanExtensions [Pure] public static bool All(this Span source, Predicate predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(predicate); -#else if (predicate is null) { throw new ArgumentNullException(nameof(predicate)); } -#endif if (source.IsEmpty) { @@ -60,14 +56,10 @@ public static class SpanExtensions [Pure] public static bool Any(this Span source, Predicate predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(predicate); -#else if (predicate is null) { throw new ArgumentNullException(nameof(predicate)); } -#endif if (source.IsEmpty) { @@ -97,14 +89,10 @@ public static class SpanExtensions /// is . public static int Count(this Span source, Predicate predicate) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(predicate); -#else if (predicate is null) { throw new ArgumentNullException(nameof(predicate)); } -#endif if (source.IsEmpty) { diff --git a/X10D/src/Math/ComparableExtensions.cs b/X10D/src/Math/ComparableExtensions.cs index e1af91f..9aea7fc 100644 --- a/X10D/src/Math/ComparableExtensions.cs +++ b/X10D/src/Math/ComparableExtensions.cs @@ -56,14 +56,10 @@ public static class ComparableExtensions where T2 : IComparable where T3 : IComparable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif if (lower.GreaterThan(upper)) { @@ -114,14 +110,10 @@ public static class ComparableExtensions public static T Clamp(this T value, T lower, T upper) where T : IComparable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif if (lower.GreaterThan(upper)) { @@ -160,14 +152,10 @@ public static class ComparableExtensions public static bool GreaterThan(this T1 value, T2 other) where T1 : IComparable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return value.CompareTo(other) > 0; } @@ -199,14 +187,10 @@ public static class ComparableExtensions public static bool GreaterThanOrEqualTo(this T1 value, T2 other) where T1 : IComparable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return value.CompareTo(other) >= 0; } @@ -238,14 +222,10 @@ public static class ComparableExtensions public static bool LessThan(this T1 value, T2 other) where T1 : IComparable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return value.CompareTo(other) < 0; } @@ -277,14 +257,10 @@ public static class ComparableExtensions public static bool LessThanOrEqualTo(this T1 value, T2 other) where T1 : IComparable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return value.CompareTo(other) <= 0; } @@ -315,14 +291,10 @@ public static class ComparableExtensions public static T Max(this T value, T other) where T : IComparable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return value.GreaterThan(other) ? value : other; } @@ -353,14 +325,10 @@ public static class ComparableExtensions public static T Min(this T value, T other) where T : IComparable { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return value.LessThan(other) ? value : other; } diff --git a/X10D/src/Net/EndPointExtensions.cs b/X10D/src/Net/EndPointExtensions.cs index 4bbfacd..da4147f 100644 --- a/X10D/src/Net/EndPointExtensions.cs +++ b/X10D/src/Net/EndPointExtensions.cs @@ -26,14 +26,10 @@ public static class EndPointExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static string GetHost(this EndPoint endPoint) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(endPoint); -#else if (endPoint is null) { throw new ArgumentNullException(nameof(endPoint)); } -#endif return endPoint switch { @@ -59,14 +55,10 @@ public static class EndPointExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static int GetPort(this EndPoint endPoint) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(endPoint); -#else if (endPoint is null) { throw new ArgumentNullException(nameof(endPoint)); } -#endif return endPoint switch { diff --git a/X10D/src/Net/IPAddressExtensions.cs b/X10D/src/Net/IPAddressExtensions.cs index bd79612..6c6dc43 100644 --- a/X10D/src/Net/IPAddressExtensions.cs +++ b/X10D/src/Net/IPAddressExtensions.cs @@ -23,14 +23,10 @@ public static class IPAddressExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool IsIPv4(this IPAddress address) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(address); -#else if (address is null) { throw new ArgumentNullException(nameof(address)); } -#endif return address.AddressFamily == AddressFamily.InterNetwork; } @@ -47,14 +43,10 @@ public static class IPAddressExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool IsIPv6(this IPAddress address) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(address); -#else if (address is null) { throw new ArgumentNullException(nameof(address)); } -#endif return address.AddressFamily == AddressFamily.InterNetworkV6; } diff --git a/X10D/src/Numerics/RandomExtensions.cs b/X10D/src/Numerics/RandomExtensions.cs index 5a89e94..ea2a19c 100644 --- a/X10D/src/Numerics/RandomExtensions.cs +++ b/X10D/src/Numerics/RandomExtensions.cs @@ -21,14 +21,10 @@ public static class RandomExtensions /// is . public static Quaternion NextRotation(this Random random) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif int seed = random.Next(); var seededRandom = new Random(seed); @@ -48,14 +44,10 @@ public static class RandomExtensions /// is . public static Quaternion NextRotationUniform(this Random random) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif int seed = random.Next(); var seededRandom = new Random(seed); @@ -84,14 +76,10 @@ public static class RandomExtensions /// public static Vector2 NextUnitVector2(this Random random) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif // no need to construct a seeded random here, since we only call Next once @@ -112,14 +100,10 @@ public static class RandomExtensions /// public static Vector3 NextUnitVector3(this Random random) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(random); -#else if (random is null) { throw new ArgumentNullException(nameof(random)); } -#endif int seed = random.Next(); var seededRandom = new Random(seed); diff --git a/X10D/src/Reactive/ObservableDisposer.cs b/X10D/src/Reactive/ObservableDisposer.cs index 9073ff9..b935112 100644 --- a/X10D/src/Reactive/ObservableDisposer.cs +++ b/X10D/src/Reactive/ObservableDisposer.cs @@ -17,23 +17,8 @@ internal readonly struct ObservableDisposer : IDisposable /// The additional action to run on dispose. public ObservableDisposer(HashSet> observers, IObserver observer, Action? additionalAction) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(observers); - ArgumentNullException.ThrowIfNull(observer); -#else - if (observers is null) - { - throw new ArgumentNullException(nameof(observers)); - } - - if (observer is null) - { - throw new ArgumentNullException(nameof(observer)); - } -#endif - - _observers = observers; - _observer = observer; + _observers = observers ?? throw new ArgumentNullException(nameof(observers)); + _observer = observer ?? throw new ArgumentNullException(nameof(observer)); _additionalAction = additionalAction; } diff --git a/X10D/src/Reactive/ProgressExtensions.cs b/X10D/src/Reactive/ProgressExtensions.cs index 6128a72..2eecdd8 100644 --- a/X10D/src/Reactive/ProgressExtensions.cs +++ b/X10D/src/Reactive/ProgressExtensions.cs @@ -18,14 +18,10 @@ public static class ProgressExtensions /// is . public static IObservable OnProgressChanged(this Progress progress) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(progress); -#else if (progress is null) { throw new ArgumentNullException(nameof(progress)); } -#endif var progressObservable = new ProgressObservable(); @@ -59,14 +55,10 @@ public static class ProgressExtensions /// is . public static IObservable OnProgressChanged(this Progress progress, T completeValue) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(progress); -#else if (progress is null) { throw new ArgumentNullException(nameof(progress)); } -#endif var progressObservable = new ProgressObservable(); var comparer = EqualityComparer.Default; diff --git a/X10D/src/Reactive/ProgressObservable.cs b/X10D/src/Reactive/ProgressObservable.cs index 29a8243..32a0870 100644 --- a/X10D/src/Reactive/ProgressObservable.cs +++ b/X10D/src/Reactive/ProgressObservable.cs @@ -25,14 +25,10 @@ internal sealed class ProgressObservable : IObservable /// An object which can be disposed to unsubscribe from progress tracking. public IDisposable Subscribe(IObserver observer) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(observer); -#else if (observer is null) { throw new ArgumentNullException(nameof(observer)); } -#endif _observers.Add(observer); return new ObservableDisposer(_observers, observer, OnDispose); diff --git a/X10D/src/Reflection/MemberInfoExtensions.cs b/X10D/src/Reflection/MemberInfoExtensions.cs index afe4722..362fdd9 100644 --- a/X10D/src/Reflection/MemberInfoExtensions.cs +++ b/X10D/src/Reflection/MemberInfoExtensions.cs @@ -26,14 +26,11 @@ public static class MemberInfoExtensions public static bool HasCustomAttribute(this MemberInfo member) where T : Attribute { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(member); -#else if (member is null) { throw new ArgumentNullException(nameof(member)); } -#endif + return Attribute.IsDefined(member, typeof(T)); } @@ -51,10 +48,6 @@ public static class MemberInfoExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool HasCustomAttribute(this MemberInfo member, Type attribute) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(member); - ArgumentNullException.ThrowIfNull(attribute); -#else if (member is null) { throw new ArgumentNullException(nameof(member)); @@ -64,7 +57,6 @@ public static class MemberInfoExtensions { throw new ArgumentNullException(nameof(attribute)); } -#endif if (!attribute.Inherits()) { @@ -94,10 +86,6 @@ public static class MemberInfoExtensions Func selector) where TAttribute : Attribute { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(member); - ArgumentNullException.ThrowIfNull(selector); -#else if (member is null) { throw new ArgumentNullException(nameof(member)); @@ -107,7 +95,6 @@ public static class MemberInfoExtensions { throw new ArgumentNullException(nameof(selector)); } -#endif return member.SelectFromCustomAttribute(selector, default); } @@ -132,10 +119,6 @@ public static class MemberInfoExtensions Func selector, TReturn? defaultValue) where TAttribute : Attribute { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(member); - ArgumentNullException.ThrowIfNull(selector); -#else if (member is null) { throw new ArgumentNullException(nameof(member)); @@ -145,7 +128,6 @@ public static class MemberInfoExtensions { throw new ArgumentNullException(nameof(selector)); } -#endif return member.GetCustomAttribute() is { } attribute ? selector(attribute) diff --git a/X10D/src/Reflection/TypeExtensions.cs b/X10D/src/Reflection/TypeExtensions.cs index b336b06..32b4d75 100644 --- a/X10D/src/Reflection/TypeExtensions.cs +++ b/X10D/src/Reflection/TypeExtensions.cs @@ -21,14 +21,10 @@ public static class TypeExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool Implements(this Type value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return value.Implements(typeof(T)); } @@ -48,10 +44,6 @@ public static class TypeExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool Implements(this Type value, Type interfaceType) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); - ArgumentNullException.ThrowIfNull(interfaceType); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); @@ -61,7 +53,6 @@ public static class TypeExtensions { throw new ArgumentNullException(nameof(interfaceType)); } -#endif if (!interfaceType.IsInterface) { @@ -90,14 +81,10 @@ public static class TypeExtensions public static bool Inherits(this Type value) where T : class { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return value.Inherits(typeof(T)); } @@ -125,10 +112,6 @@ public static class TypeExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool Inherits(this Type value, Type type) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); - ArgumentNullException.ThrowIfNull(type); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); @@ -138,7 +121,6 @@ public static class TypeExtensions { throw new ArgumentNullException(nameof(type)); } -#endif if (!value.IsClass) { diff --git a/X10D/src/Text/EnumerableExtensions.cs b/X10D/src/Text/EnumerableExtensions.cs index c5552b3..e243ef0 100644 --- a/X10D/src/Text/EnumerableExtensions.cs +++ b/X10D/src/Text/EnumerableExtensions.cs @@ -18,10 +18,6 @@ public static class EnumerableExtensions /// public static IEnumerable Grep(this IEnumerable source, string pattern) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(pattern); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -31,7 +27,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(pattern)); } -#endif return Grep(source, pattern, false); } @@ -50,10 +45,6 @@ public static class EnumerableExtensions /// public static IEnumerable Grep(this IEnumerable source, string pattern, bool ignoreCase) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); - ArgumentNullException.ThrowIfNull(pattern); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); @@ -63,7 +54,6 @@ public static class EnumerableExtensions { throw new ArgumentNullException(nameof(pattern)); } -#endif #if NET6_0_OR_GREATER if (source.TryGetNonEnumeratedCount(out int count) && count == 0) diff --git a/X10D/src/Text/StringBuilderReader.cs b/X10D/src/Text/StringBuilderReader.cs index 337a22c..fe6e969 100644 --- a/X10D/src/Text/StringBuilderReader.cs +++ b/X10D/src/Text/StringBuilderReader.cs @@ -55,14 +55,10 @@ public class StringBuilderReader : TextReader /// public override int Read(char[] buffer, int index, int count) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(buffer); -#else if (buffer is null) { throw new ArgumentNullException(nameof(buffer)); } -#endif if (index < 0) { diff --git a/X10D/src/Text/StringExtensions.cs b/X10D/src/Text/StringExtensions.cs index 052b4c5..44db6bd 100644 --- a/X10D/src/Text/StringExtensions.cs +++ b/X10D/src/Text/StringExtensions.cs @@ -60,14 +60,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static string Base64Decode(this string value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return Convert.FromBase64String(value).ToString(Encoding.ASCII); } @@ -82,14 +78,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static string Base64Encode(this string value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return Convert.ToBase64String(value.GetBytes(Encoding.ASCII)); } @@ -115,11 +107,6 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static string ChangeEncoding(this string value, Encoding sourceEncoding, Encoding destinationEncoding) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); - ArgumentNullException.ThrowIfNull(sourceEncoding); - ArgumentNullException.ThrowIfNull(destinationEncoding); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); @@ -134,7 +121,6 @@ public static class StringExtensions { throw new ArgumentNullException(nameof(destinationEncoding)); } -#endif return value.GetBytes(sourceEncoding).ToString(destinationEncoding); } @@ -179,14 +165,10 @@ public static class StringExtensions /// An integer representing the count of inside . public static int CountSubstring(this string haystack, char needle) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(haystack); -#else if (haystack is null) { throw new ArgumentNullException(nameof(haystack)); } -#endif return haystack.AsSpan().CountSubstring(needle); } @@ -211,14 +193,10 @@ public static class StringExtensions /// An integer representing the count of inside . public static int CountSubstring(this string haystack, string? needle, StringComparison comparison) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(haystack); -#else if (haystack is null) { throw new ArgumentNullException(nameof(haystack)); } -#endif if (string.IsNullOrWhiteSpace(needle)) { @@ -374,14 +352,10 @@ public static class StringExtensions public static T EnumParse(this string value, bool ignoreCase) where T : struct, Enum { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif value = value.Trim(); @@ -437,10 +411,6 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static byte[] GetBytes(this string value, Encoding encoding) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); - ArgumentNullException.ThrowIfNull(encoding); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); @@ -450,7 +420,6 @@ public static class StringExtensions { throw new ArgumentNullException(nameof(encoding)); } -#endif return encoding.GetBytes(value); } @@ -464,14 +433,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool IsEmoji(this string value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return EmojiRegex.Value.IsMatch(value); } @@ -488,14 +453,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool IsEmpty(this string value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif return value.Length == 0; } @@ -512,14 +473,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool IsLower(this string value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif for (var index = 0; index < value.Length; index++) { @@ -599,14 +556,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool IsPalindrome(this string value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif if (string.IsNullOrWhiteSpace(value)) { @@ -673,14 +626,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool IsUpper(this string value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif for (var index = 0; index < value.Length; index++) { @@ -728,14 +677,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static bool IsWhiteSpace(this string value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif if (value.Length == 0) { @@ -765,14 +710,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static string Repeat(this string value, int count) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif switch (count) { @@ -810,14 +751,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static string Randomize(this string source, int length, Random? random = null) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(source); -#else if (source is null) { throw new ArgumentNullException(nameof(source)); } -#endif if (length < 0) { @@ -852,14 +789,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static string Reverse(this string value) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif if (value.Length < 2) { @@ -890,14 +823,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static string Shuffled(this string value, Random? random = null) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif random ??= RandomExtensions.GetShared(); @@ -920,14 +849,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static IEnumerable Split(this string value, int chunkSize) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(value); -#else if (value is null) { throw new ArgumentNullException(nameof(value)); } -#endif if (chunkSize == 0) { @@ -956,14 +881,10 @@ public static class StringExtensions /// public static bool StartsWithAny(this string? value, params string[] startValues) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(startValues); -#else if (startValues is null) { throw new ArgumentNullException(nameof(startValues)); } -#endif if (startValues.Length == 0 || string.IsNullOrWhiteSpace(value)) { @@ -989,14 +910,10 @@ public static class StringExtensions /// public static bool StartsWithAny(this string? value, StringComparison comparison, params string[] startValues) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(startValues); -#else if (startValues is null) { throw new ArgumentNullException(nameof(startValues)); } -#endif if (startValues.Length == 0 || string.IsNullOrWhiteSpace(value)) { diff --git a/X10D/src/Time/StringExtensions.cs b/X10D/src/Time/StringExtensions.cs index 4ebc4b0..668f26d 100644 --- a/X10D/src/Time/StringExtensions.cs +++ b/X10D/src/Time/StringExtensions.cs @@ -61,14 +61,10 @@ public static class StringExtensions [MethodImpl(CompilerResources.MethodImplOptions)] public static TimeSpan ToTimeSpan(this string input) { -#if NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(input); -#else if (input is null) { throw new ArgumentNullException(nameof(input)); } -#endif return TimeSpanParser.TryParse(input, out TimeSpan result) ? result From dbc63b9b2663afd3b515ff0bebac0d86135a4147 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 13 Apr 2023 23:14:32 +0100 Subject: [PATCH 03/46] [ci skip] docs: bump version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85d2dbb..2f38a60 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ X10D (pronounced *extend*), is a .NET package that provides extension methods fo ## Installation ### NuGet installation ```ps -Install-Package X10D -Version 3.2.0 +Install-Package X10D -Version 4.0.0 ``` ### Manual installation From 6f3a667e378eb77b87abffb820e51a55f66d603f Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Fri, 14 Apr 2023 13:55:52 +0100 Subject: [PATCH 04/46] feat: add string.ConcatIf --- CHANGELOG.md | 1 + X10D.Tests/src/Text/StringTests.cs | 38 +++++++++++++++ X10D/src/Text/StringExtensions.cs | 74 ++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9482e2e..61bb729 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - X10D: Added `TextWriter.WriteLineNoAlloc(uint[, ReadOnlySpan[, IFormatProvider]])`. - X10D: Added `TextWriter.WriteLineNoAlloc(long[, ReadOnlySpan[, IFormatProvider]])`. - X10D: Added `TextWriter.WriteLineNoAlloc(ulong[, ReadOnlySpan[, IFormatProvider]])`. +- X10D: Added `string.ConcatIf`. - X10D.Unity: Added `RaycastHit.GetComponent` and `RaycastHit.TryGetComponent`. - X10D.Unity: Added `DebugUtility.DrawFunction`, and `DebugUtility.DrawUnjoinedPolyhedron` on which it relies. diff --git a/X10D.Tests/src/Text/StringTests.cs b/X10D.Tests/src/Text/StringTests.cs index 99fca98..d462186 100644 --- a/X10D.Tests/src/Text/StringTests.cs +++ b/X10D.Tests/src/Text/StringTests.cs @@ -105,6 +105,44 @@ public class StringTests Assert.Throws(() => _ = "Hello World".ChangeEncoding(Encoding.UTF8, null!)); } + [Test] + public void ConcatIf_ShouldConcatenateString_GivenTrueCondition() + { + Assert.Multiple(() => + { + Assert.That("Hello".ConcatIf(true, " World"), Is.EqualTo("Hello World")); + Assert.That("Hello".ConcatIf(true, () => " World"), Is.EqualTo("Hello World")); + Assert.That("Hello".ConcatIf(() => true, " World"), Is.EqualTo("Hello World")); + Assert.That("Hello".ConcatIf(() => true, () => " World"), Is.EqualTo("Hello World")); + }); + } + + [Test] + public void ConcatIf_ShouldNotConcatenateString_GivenFalseCondition() + { + Assert.Multiple(() => + { + Assert.That("Hello".ConcatIf(false, " World"), Is.EqualTo("Hello")); + Assert.That("Hello".ConcatIf(false, () => " World"), Is.EqualTo("Hello")); + Assert.That("Hello".ConcatIf(() => false, " World"), Is.EqualTo("Hello")); + Assert.That("Hello".ConcatIf(() => false, () => " World"), Is.EqualTo("Hello")); + }); + } + + [Test] + public void ConcatIf_ShouldThrowArgumentNullException_GivenNullConditionFactory() + { + Assert.Throws(() => _ = "".ConcatIf(null!, "Hello World")); + Assert.Throws(() => _ = "".ConcatIf(null!, () => "Hello World")); + } + + [Test] + public void ConcatIf_ShouldThrowArgumentNullException_GivenNullValueFactory() + { + Assert.Throws(() => _ = "".ConcatIf(true, (Func?)null!)); + Assert.Throws(() => _ = "".ConcatIf(() => true, (Func?)null!)); + } + [Test] public void CountSubstring_ShouldHonor_StringComparison() { diff --git a/X10D/src/Text/StringExtensions.cs b/X10D/src/Text/StringExtensions.cs index 44db6bd..4600931 100644 --- a/X10D/src/Text/StringExtensions.cs +++ b/X10D/src/Text/StringExtensions.cs @@ -125,6 +125,80 @@ public static class StringExtensions return value.GetBytes(sourceEncoding).ToString(destinationEncoding); } + /// + /// Appends a string to the current string if the specified condition evaluates to . + /// + /// The current string. + /// The condition to evaluate. + /// The string to append if the condition is true. + /// The concatenated string. + [Pure] + public static string? ConcatIf(this string? value, bool condition, string? appendValue) + { + return condition ? value + appendValue : value; + } + + /// + /// Appends a string to the current string if the specified condition evaluates to . + /// + /// The current string. + /// The function that returns the condition to evaluate. + /// The string to append if the condition is true. + /// The concatenated string. + /// is . + [Pure] + public static string? ConcatIf(this string? value, Func conditionFactory, string? appendValue) + { + if (conditionFactory is null) + { + throw new ArgumentNullException(nameof(conditionFactory)); + } + + return conditionFactory() ? value + appendValue : value; + } + + /// + /// Appends a string to the current string if the specified condition evaluates to . + /// + /// The current string. + /// The condition to evaluate. + /// The function that returns the string to append if the condition is true. + /// The concatenated string. + [Pure] + public static string? ConcatIf(this string? value, bool condition, Func valueFactory) + { + if (valueFactory is null) + { + throw new ArgumentNullException(nameof(valueFactory)); + } + + return condition ? value + valueFactory() : value; + } + + /// + /// Appends a string to the current string if the specified condition evaluates to . + /// + /// The current string. + /// The function that returns the condition to evaluate. + /// The function that returns the string to append if the condition is true. + /// The concatenated string. + /// is . + [Pure] + public static string? ConcatIf(this string? value, Func conditionFactory, Func valueFactory) + { + if (conditionFactory is null) + { + throw new ArgumentNullException(nameof(conditionFactory)); + } + + if (valueFactory is null) + { + throw new ArgumentNullException(nameof(valueFactory)); + } + + return conditionFactory() ? value + valueFactory() : value; + } + /// /// Counts the occurrences of a character within the current character span. /// From 23dee3d2b8b1190f054681442491f43f923a76bb Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Fri, 14 Apr 2023 14:17:33 +0100 Subject: [PATCH 05/46] feat: add value-passthru overloads for ConcatIf --- X10D.Tests/src/Text/StringTests.cs | 23 ++++- X10D/src/Text/StringExtensions.cs | 136 ++++++++++++++++++++++++++++- 2 files changed, 154 insertions(+), 5 deletions(-) diff --git a/X10D.Tests/src/Text/StringTests.cs b/X10D.Tests/src/Text/StringTests.cs index d462186..6c94343 100644 --- a/X10D.Tests/src/Text/StringTests.cs +++ b/X10D.Tests/src/Text/StringTests.cs @@ -112,8 +112,10 @@ public class StringTests { Assert.That("Hello".ConcatIf(true, " World"), Is.EqualTo("Hello World")); Assert.That("Hello".ConcatIf(true, () => " World"), Is.EqualTo("Hello World")); + Assert.That("Hello".ConcatIf(true, _ => " World"), Is.EqualTo("Hello World")); Assert.That("Hello".ConcatIf(() => true, " World"), Is.EqualTo("Hello World")); Assert.That("Hello".ConcatIf(() => true, () => " World"), Is.EqualTo("Hello World")); + Assert.That("Hello".ConcatIf(() => true, _ => " World"), Is.EqualTo("Hello World")); }); } @@ -124,23 +126,36 @@ public class StringTests { Assert.That("Hello".ConcatIf(false, " World"), Is.EqualTo("Hello")); Assert.That("Hello".ConcatIf(false, () => " World"), Is.EqualTo("Hello")); + Assert.That("Hello".ConcatIf(false, _ => " World"), Is.EqualTo("Hello")); Assert.That("Hello".ConcatIf(() => false, " World"), Is.EqualTo("Hello")); Assert.That("Hello".ConcatIf(() => false, () => " World"), Is.EqualTo("Hello")); + Assert.That("Hello".ConcatIf(() => false, _ => " World"), Is.EqualTo("Hello")); + Assert.That("Hello".ConcatIf(_ => false, " World"), Is.EqualTo("Hello")); + Assert.That("Hello".ConcatIf(_ => false, () => " World"), Is.EqualTo("Hello")); + Assert.That("Hello".ConcatIf(_ => false, _ => " World"), Is.EqualTo("Hello")); }); } [Test] public void ConcatIf_ShouldThrowArgumentNullException_GivenNullConditionFactory() { - Assert.Throws(() => _ = "".ConcatIf(null!, "Hello World")); - Assert.Throws(() => _ = "".ConcatIf(null!, () => "Hello World")); + Assert.Throws(() => _ = "".ConcatIf((Func)null!, "Hello World")); + Assert.Throws(() => _ = "".ConcatIf((Func)null!, () => "Hello World")); + Assert.Throws(() => _ = "".ConcatIf((Func)null!, _ => "Hello World")); + Assert.Throws(() => _ = "".ConcatIf((Func)null!, "Hello World")); + Assert.Throws(() => _ = "".ConcatIf((Func)null!, () => "Hello World")); + Assert.Throws(() => _ = "".ConcatIf((Func)null!, _ => "Hello World")); } [Test] public void ConcatIf_ShouldThrowArgumentNullException_GivenNullValueFactory() { - Assert.Throws(() => _ = "".ConcatIf(true, (Func?)null!)); - Assert.Throws(() => _ = "".ConcatIf(() => true, (Func?)null!)); + Assert.Throws(() => _ = "".ConcatIf(true, (Func)null!)); + Assert.Throws(() => _ = "".ConcatIf(() => true, (Func)null!)); + Assert.Throws(() => _ = "".ConcatIf(_ => true, (Func)null!)); + Assert.Throws(() => _ = "".ConcatIf(true, (Func)null!)); + Assert.Throws(() => _ = "".ConcatIf(() => true, (Func)null!)); + Assert.Throws(() => _ = "".ConcatIf(_ => true, (Func)null!)); } [Test] diff --git a/X10D/src/Text/StringExtensions.cs b/X10D/src/Text/StringExtensions.cs index 4600931..16183f9 100644 --- a/X10D/src/Text/StringExtensions.cs +++ b/X10D/src/Text/StringExtensions.cs @@ -157,6 +157,27 @@ public static class StringExtensions return conditionFactory() ? value + appendValue : value; } + /// + /// Appends a string to the current string if the specified condition evaluates to . + /// + /// The current string. + /// + /// The function that returns the condition to evaluate, with given as an argument. + /// + /// The string to append if the condition is true. + /// The concatenated string. + /// is . + [Pure] + public static string? ConcatIf(this string? value, Func conditionFactory, string? appendValue) + { + if (conditionFactory is null) + { + throw new ArgumentNullException(nameof(conditionFactory)); + } + + return conditionFactory(value) ? value + appendValue : value; + } + /// /// Appends a string to the current string if the specified condition evaluates to . /// @@ -164,6 +185,7 @@ public static class StringExtensions /// The condition to evaluate. /// The function that returns the string to append if the condition is true. /// The concatenated string. + /// is . [Pure] public static string? ConcatIf(this string? value, bool condition, Func valueFactory) { @@ -175,6 +197,28 @@ public static class StringExtensions return condition ? value + valueFactory() : value; } + /// + /// Appends a string to the current string if the specified condition evaluates to . + /// + /// The current string. + /// The condition to evaluate. + /// + /// The function that returns the string to append if the condition is true, with given as an + /// argument. + /// + /// The concatenated string. + /// is . + [Pure] + public static string? ConcatIf(this string? value, bool condition, Func valueFactory) + { + if (valueFactory is null) + { + throw new ArgumentNullException(nameof(valueFactory)); + } + + return condition ? value + valueFactory(value) : value; + } + /// /// Appends a string to the current string if the specified condition evaluates to . /// @@ -182,7 +226,9 @@ public static class StringExtensions /// The function that returns the condition to evaluate. /// The function that returns the string to append if the condition is true. /// The concatenated string. - /// is . + /// + /// or is . + /// [Pure] public static string? ConcatIf(this string? value, Func conditionFactory, Func valueFactory) { @@ -199,6 +245,94 @@ public static class StringExtensions return conditionFactory() ? value + valueFactory() : value; } + /// + /// Appends a string to the current string if the specified condition evaluates to . + /// + /// The current string. + /// The function that returns the condition to evaluate. + /// + /// The function that returns the string to append if the condition is true, with given as an + /// argument. + /// + /// The concatenated string. + /// + /// or is . + /// + [Pure] + public static string? ConcatIf(this string? value, Func conditionFactory, Func valueFactory) + { + if (conditionFactory is null) + { + throw new ArgumentNullException(nameof(conditionFactory)); + } + + if (valueFactory is null) + { + throw new ArgumentNullException(nameof(valueFactory)); + } + + return conditionFactory() ? value + valueFactory(value) : value; + } + + /// + /// Appends a string to the current string if the specified condition evaluates to . + /// + /// The current string. + /// + /// The function that returns the condition to evaluate, with given as an argument. + /// + /// The function that returns the string to append if the condition is true. + /// The concatenated string. + /// + /// or is . + /// + [Pure] + public static string? ConcatIf(this string? value, Func conditionFactory, Func valueFactory) + { + if (conditionFactory is null) + { + throw new ArgumentNullException(nameof(conditionFactory)); + } + + if (valueFactory is null) + { + throw new ArgumentNullException(nameof(valueFactory)); + } + + return conditionFactory(value) ? value + valueFactory() : value; + } + + /// + /// Appends a string to the current string if the specified condition evaluates to . + /// + /// The current string. + /// + /// The function that returns the condition to evaluate, with given as an argument. + /// + /// + /// The function that returns the string to append if the condition is true, with given as an + /// argument. + /// + /// The concatenated string. + /// + /// or is . + /// + [Pure] + public static string? ConcatIf(this string? value, Func conditionFactory, Func valueFactory) + { + if (conditionFactory is null) + { + throw new ArgumentNullException(nameof(conditionFactory)); + } + + if (valueFactory is null) + { + throw new ArgumentNullException(nameof(valueFactory)); + } + + return conditionFactory(value) ? value + valueFactory(value) : value; + } + /// /// Counts the occurrences of a character within the current character span. /// From d8be85835981571e295d2b6c7b208a87815385b9 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sun, 14 May 2023 16:27:42 +0100 Subject: [PATCH 06/46] refactor: remove IEnumerable.ConcatOne --- CHANGELOG.md | 4 ++++ X10D/src/Linq/EnumerableExtensions.cs | 26 -------------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61bb729..eb88270 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - X10D: `DateTime.Age(DateTime)` and `DateTimeOffset.Age(DateTimeOffset)` parameter renamed from `asOf` to `referenceDate`. +### Removed + +- X10D: Removed `IEnumerable.ConcatOne` - this functionality already exists with `Append`. + ## [3.2.0] - 2023-04-03 ### Added diff --git a/X10D/src/Linq/EnumerableExtensions.cs b/X10D/src/Linq/EnumerableExtensions.cs index 05004c9..39d4002 100644 --- a/X10D/src/Linq/EnumerableExtensions.cs +++ b/X10D/src/Linq/EnumerableExtensions.cs @@ -9,32 +9,6 @@ namespace X10D.Linq; /// public static class EnumerableExtensions { - /// - /// Concatenates a single value to the end of a sequence. - /// - /// The source sequence. - /// The value to concatenate to the end of the source sequence. - /// The type of the elements in . - /// - /// An that contains the concatenated elements of the input sequence, and the specified - /// value. - /// - /// is . - public static IEnumerable ConcatOne(this IEnumerable source, TSource value) - { - if (source is null) - { - throw new ArgumentNullException(nameof(source)); - } - - foreach (TSource item in source) - { - yield return item; - } - - yield return value; - } - /// /// Filters a sequence of values by omitting elements that match a specified value. /// From 8d7ca6ea0a8f8999233f1843a3df872e355ba517 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sun, 14 May 2023 16:31:40 +0100 Subject: [PATCH 07/46] fix(tests): remove outdated tests This should have been part of d8be85835981571e295d2b6c7b208a87815385b9 --- X10D.Tests/src/Linq/EnumerableTests.cs | 31 -------------------------- 1 file changed, 31 deletions(-) diff --git a/X10D.Tests/src/Linq/EnumerableTests.cs b/X10D.Tests/src/Linq/EnumerableTests.cs index c478578..8189443 100644 --- a/X10D.Tests/src/Linq/EnumerableTests.cs +++ b/X10D.Tests/src/Linq/EnumerableTests.cs @@ -6,37 +6,6 @@ namespace X10D.Tests.Linq; [TestFixture] public class EnumerableTests { - [Test] - public void ConcatOne_ShouldReturnConcatenatedSequence_GivenValidSequenceAndValue() - { - IEnumerable source = new[] {"Hello"}; - string[] expected = {"Hello", "World"}; - - string[] actual = source.ConcatOne("World").ToArray(); - - Assert.That(actual, Has.Length.EqualTo(2)); - CollectionAssert.AreEqual(expected, actual); - } - - [Test] - public void ConcatOne_ShouldReturnSingletonSequence_GivenEmptySequenceAndValidValue() - { - IEnumerable source = Enumerable.Empty(); - string[] expected = {"Foobar"}; - - string[] actual = source.ConcatOne("Foobar").ToArray(); - - Assert.That(actual, Has.Length.EqualTo(1)); - CollectionAssert.AreEqual(expected, actual); - } - - [Test] - public void ConcatOne_ShouldThrowArgumentNullException_GivenNullSource() - { - IEnumerable? source = null; - Assert.Throws(() => source!.ConcatOne("Foobar").ToArray()); - } - [Test] public void Except_ShouldFilterElements_GivenMatchingElements() { From 9b995524dd6fa7b5c4b9497a9b08acfd723a9edf Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 21 Aug 2023 17:21:58 +0100 Subject: [PATCH 08/46] feat: add service/impl register for AddHostedSingleton --- CHANGELOG.md | 1 + .../ServiceCollectionExtensions.cs | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77c9538..27f75f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - X10D: Added `TextWriter.WriteLineNoAlloc(long[, ReadOnlySpan[, IFormatProvider]])`. - X10D: Added `TextWriter.WriteLineNoAlloc(ulong[, ReadOnlySpan[, IFormatProvider]])`. - X10D: Added `string.ConcatIf`. +- X10D.Hosting: Added support for service/implementation registration with `AddHostedSingleton`. - X10D.Unity: Added `RaycastHit.GetComponent` and `RaycastHit.TryGetComponent`. - X10D.Unity: Added `DebugUtility.DrawFunction`, and `DebugUtility.DrawUnjoinedPolyhedron` on which it relies. diff --git a/X10D.Hosting/src/DependencyInjection/ServiceCollectionExtensions.cs b/X10D.Hosting/src/DependencyInjection/ServiceCollectionExtensions.cs index 9a0bafe..8df216c 100644 --- a/X10D.Hosting/src/DependencyInjection/ServiceCollectionExtensions.cs +++ b/X10D.Hosting/src/DependencyInjection/ServiceCollectionExtensions.cs @@ -21,6 +21,21 @@ public static class ServiceCollectionExtensions return services.AddSingleton(provider => provider.GetRequiredService()); } + /// + /// Adds an registration for the given type, while simultaneously adding it as a singleton. + /// + /// The to add the service to. + /// The type of the service to add. + /// The type of the implementation to use. + /// A reference to this instance after the operation has completed. + public static IServiceCollection AddHostedSingleton(this IServiceCollection services) + where TService : class, IHostedService + where TImplementation : class, TService + { + services.AddSingleton(); + return services.AddSingleton(provider => provider.GetRequiredService()); + } + /// /// Adds an registration for the given type, while simultaneously adding it as a singleton. /// @@ -32,4 +47,19 @@ public static class ServiceCollectionExtensions services.AddSingleton(type); return services.AddSingleton(provider => (IHostedService)provider.GetRequiredService(type)); } + + /// + /// Adds an registration for the given type, while simultaneously adding it as a singleton. + /// + /// The to add the service to. + /// The type of the service to register. + /// The type of the implementation to use. + /// A reference to this instance after the operation has completed. + public static IServiceCollection AddHostedSingleton(this IServiceCollection services, + Type serviceType, + Type implementationType) + { + services.AddSingleton(serviceType, implementationType); + return services.AddSingleton(provider => (IHostedService)provider.GetRequiredService(serviceType)); + } } From e8a331ff9693432b1f2804d6099bd29f09d36cf6 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 17:11:20 +0100 Subject: [PATCH 09/46] chore: use shared Build.props for all projects --- Directory.Build.props | 67 ++++++++++++++++++++++++++ X10D.DSharpPlus/X10D.DSharpPlus.csproj | 58 ---------------------- X10D.Hosting/X10D.Hosting.csproj | 58 ---------------------- X10D.Tests/X10D.Tests.csproj | 5 +- X10D.Unity/X10D.Unity.csproj | 58 ---------------------- X10D.sln | 1 + X10D/X10D.csproj | 63 ------------------------ 7 files changed, 70 insertions(+), 240 deletions(-) create mode 100644 Directory.Build.props diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..be302ef --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,67 @@ + + + 11.0 + true + true + true + true + true + pdbonly + true + 4.0.0 + Oliver Booth + enable + en + https://github.com/oliverbooth/X10D + git + Extension methods on crack. + LICENSE.md + branding_Icon.png + + dotnet extension-methods + README.md + $([System.IO.File]::ReadAllText("$(SolutionDir)/CHANGELOG.md")) + true + + + + true + + + + $(VersionPrefix)-$(VersionSuffix) + $(VersionPrefix).0 + $(VersionPrefix).0 + + + + $(VersionPrefix)-$(VersionSuffix).$(BuildNumber) + $(VersionPrefix).$(BuildNumber) + $(VersionPrefix).$(BuildNumber) + + + + $(VersionPrefix) + $(VersionPrefix).0 + $(VersionPrefix).0 + + + + + True + + + + True + + + + True + + + + True + + + + \ No newline at end of file diff --git a/X10D.DSharpPlus/X10D.DSharpPlus.csproj b/X10D.DSharpPlus/X10D.DSharpPlus.csproj index 79b26aa..9128252 100644 --- a/X10D.DSharpPlus/X10D.DSharpPlus.csproj +++ b/X10D.DSharpPlus/X10D.DSharpPlus.csproj @@ -2,69 +2,11 @@ net7.0;net6.0;netstandard2.1 - 11.0 - true - true - Oliver Booth - en - https://github.com/oliverbooth/X10D - git - Extension methods on crack. - LICENSE.md - branding_Icon.png - - dotnet extension-methods - $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) - true - 4.0.0 - enable - true - true true - true - pdbonly - true - - - - true - - - - $(VersionPrefix)-$(VersionSuffix) - $(VersionPrefix).0 - $(VersionPrefix).0 - - - - $(VersionPrefix)-$(VersionSuffix).$(BuildNumber) - $(VersionPrefix).$(BuildNumber) - $(VersionPrefix).$(BuildNumber) - - - - $(VersionPrefix) - $(VersionPrefix).0 - $(VersionPrefix).0 - - - True - - - - True - - - - True - - - - diff --git a/X10D.Hosting/X10D.Hosting.csproj b/X10D.Hosting/X10D.Hosting.csproj index b8e4296..a534fa0 100644 --- a/X10D.Hosting/X10D.Hosting.csproj +++ b/X10D.Hosting/X10D.Hosting.csproj @@ -2,68 +2,10 @@ net7.0;net6.0;netstandard2.1 - 11.0 - true - true - Oliver Booth - en - https://github.com/oliverbooth/X10D - git - Extension methods on crack. - LICENSE.md - branding_Icon.png - - dotnet extension-methods - $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) - true - 4.0.0 - enable - true - true - true - pdbonly - true - - - - true - - - - $(VersionPrefix)-$(VersionSuffix) - $(VersionPrefix).0 - $(VersionPrefix).0 - - - - $(VersionPrefix)-$(VersionSuffix).$(BuildNumber) - $(VersionPrefix).$(BuildNumber) - $(VersionPrefix).$(BuildNumber) - - - - $(VersionPrefix) - $(VersionPrefix).0 - $(VersionPrefix).0 - - - True - - - - True - - - - True - - - - diff --git a/X10D.Tests/X10D.Tests.csproj b/X10D.Tests/X10D.Tests.csproj index aa5bbd2..567e11c 100644 --- a/X10D.Tests/X10D.Tests.csproj +++ b/X10D.Tests/X10D.Tests.csproj @@ -2,12 +2,11 @@ net7.0;net6.0;netcoreapp3.1 - 11.0 false - enable - true json,cobertura true + false + $(NoWarn);1591 diff --git a/X10D.Unity/X10D.Unity.csproj b/X10D.Unity/X10D.Unity.csproj index 90caf27..b1584ea 100644 --- a/X10D.Unity/X10D.Unity.csproj +++ b/X10D.Unity/X10D.Unity.csproj @@ -2,49 +2,6 @@ netstandard2.1 - 11.0 - true - true - Oliver Booth - en - https://github.com/oliverbooth/X10D - git - Extension methods on crack. - LICENSE.md - branding_Icon.png - - dotnet extension-methods - $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) - true - 4.0.0 - enable - true - true - true - pdbonly - true - - - - true - - - - $(VersionPrefix)-$(VersionSuffix) - $(VersionPrefix).0 - $(VersionPrefix).0 - - - - $(VersionPrefix)-$(VersionSuffix).$(BuildNumber) - $(VersionPrefix).$(BuildNumber) - $(VersionPrefix).$(BuildNumber) - - - - $(VersionPrefix) - $(VersionPrefix).0 - $(VersionPrefix).0 @@ -55,21 +12,6 @@ - - - True - - - - True - - - - True - - - - ResXFileCodeGenerator diff --git a/X10D.sln b/X10D.sln index dd11b7d..b1b36a2 100644 --- a/X10D.sln +++ b/X10D.sln @@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution LICENSE.md = LICENSE.md README.md = README.md branding_Icon.png = branding_Icon.png + Directory.Build.props = Directory.Build.props EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceValidator", "tools\SourceValidator\SourceValidator.csproj", "{84750149-9068-4780-AFDE-CDA1AC57007D}" diff --git a/X10D/X10D.csproj b/X10D/X10D.csproj index e034d06..7994902 100644 --- a/X10D/X10D.csproj +++ b/X10D/X10D.csproj @@ -2,71 +2,8 @@ net7.0;net6.0;netstandard2.1 - 11.0 - true - true - Oliver Booth - en - https://github.com/oliverbooth/X10D - git - Extension methods on crack. - LICENSE.md - branding_Icon.png - - dotnet extension-methods - README.md - $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) - true - 4.0.0 - enable - true - true - true - pdbonly - true - - true - - - - $(VersionPrefix)-$(VersionSuffix) - $(VersionPrefix).0 - $(VersionPrefix).0 - - - - $(VersionPrefix)-$(VersionSuffix).$(BuildNumber) - $(VersionPrefix).$(BuildNumber) - $(VersionPrefix).$(BuildNumber) - - - - $(VersionPrefix) - $(VersionPrefix).0 - $(VersionPrefix).0 - - - - - True - - - - True - - - - True - - - - True - - - - True From 24a7de7e8c116d8d12e0fd7301c99b1103bb0cec Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 17:32:47 +0100 Subject: [PATCH 10/46] refactor: define test fixtures as internal --- X10D.Tests/X10D.Tests.csproj | 1 - X10D.Tests/src/Assembly.cs | 2 +- .../src/Collections/ArrayTests.AsReadOnly.cs | 4 ++-- X10D.Tests/src/Collections/ArrayTests.Clear.cs | 2 +- X10D.Tests/src/Collections/ArrayTests.cs | 2 +- X10D.Tests/src/Collections/BoolListTests.cs | 2 +- X10D.Tests/src/Collections/ByteTests.cs | 2 +- .../CollectionTests.ClearAndDisposeAll.cs | 2 +- .../CollectionTests.ClearAndDisposeAllAsync.cs | 2 +- X10D.Tests/src/Collections/CollectionTests.cs | 2 +- X10D.Tests/src/Collections/DictionaryTests.cs | 2 +- .../Collections/EnumerableTests.DisposeAll.cs | 2 +- .../EnumerableTests.DisposeAllAsync.cs | 2 +- X10D.Tests/src/Collections/EnumerableTests.cs | 2 +- X10D.Tests/src/Collections/Int16Tests.cs | 2 +- X10D.Tests/src/Collections/Int32Tests.cs | 2 +- X10D.Tests/src/Collections/Int64Tests.cs | 7 ++++--- X10D.Tests/src/Collections/ListTests.cs | 8 +++----- X10D.Tests/src/Collections/SpanTest.cs | 2 +- X10D.Tests/src/Core/CoreTests.cs | 2 +- X10D.Tests/src/Core/EnumTests.cs | 2 +- X10D.Tests/src/Core/IntrinsicTests.cs | 2 +- X10D.Tests/src/Core/NullableTests.cs | 2 +- X10D.Tests/src/Core/RandomTests.cs | 2 +- X10D.Tests/src/Core/SpanTest.cs | 2 +- X10D.Tests/src/Drawing/CircleFTests.cs | 2 +- X10D.Tests/src/Drawing/CircleTests.cs | 2 +- X10D.Tests/src/Drawing/ColorTests.cs | 2 +- X10D.Tests/src/Drawing/CuboidTests.cs | 2 +- X10D.Tests/src/Drawing/EllipseFTests.cs | 2 +- X10D.Tests/src/Drawing/EllipseTests.cs | 2 +- X10D.Tests/src/Drawing/Line3DTests.cs | 2 +- X10D.Tests/src/Drawing/LineFTests.cs | 2 +- X10D.Tests/src/Drawing/LineTests.cs | 2 +- X10D.Tests/src/Drawing/PointFTests.cs | 2 +- X10D.Tests/src/Drawing/PointTests.cs | 2 +- X10D.Tests/src/Drawing/PolygonFTests.cs | 2 +- X10D.Tests/src/Drawing/PolygonTests.cs | 2 +- X10D.Tests/src/Drawing/PolyhedronTests.cs | 2 +- X10D.Tests/src/Drawing/RandomTests.cs | 2 +- X10D.Tests/src/Drawing/SizeTests.cs | 2 +- X10D.Tests/src/Drawing/SphereTests.cs | 2 +- .../src/Hosting/ServiceCollectionTests.cs | 2 +- X10D.Tests/src/IO/BooleanTests.cs | 2 +- X10D.Tests/src/IO/ByteTests.cs | 2 +- X10D.Tests/src/IO/DirectoryInfoTests.cs | 2 +- X10D.Tests/src/IO/DoubleTests.cs | 2 +- X10D.Tests/src/IO/FileInfoTests.cs | 2 +- X10D.Tests/src/IO/Int16Tests.cs | 2 +- X10D.Tests/src/IO/Int32Tests.cs | 2 +- X10D.Tests/src/IO/Int64Tests.cs | 2 +- X10D.Tests/src/IO/ListOfByteTests.cs | 2 +- X10D.Tests/src/IO/SByteTests.cs | 3 +-- X10D.Tests/src/IO/SingleTests.cs | 2 +- X10D.Tests/src/IO/StreamTests.ReadDecimal.cs | 2 +- X10D.Tests/src/IO/StreamTests.ReadDouble.cs | 2 +- X10D.Tests/src/IO/StreamTests.ReadInt16.cs | 2 +- X10D.Tests/src/IO/StreamTests.ReadInt32.cs | 2 +- X10D.Tests/src/IO/StreamTests.ReadInt64.cs | 2 +- X10D.Tests/src/IO/StreamTests.ReadSingle.cs | 2 +- X10D.Tests/src/IO/StreamTests.ReadUInt16.cs | 17 ++++++----------- X10D.Tests/src/IO/StreamTests.ReadUInt32.cs | 17 ++++++----------- X10D.Tests/src/IO/StreamTests.ReadUInt64.cs | 17 ++++++----------- X10D.Tests/src/IO/StreamTests.WriteDecimal.cs | 2 +- X10D.Tests/src/IO/StreamTests.WriteDouble.cs | 2 +- X10D.Tests/src/IO/StreamTests.WriteInt16.cs | 2 +- X10D.Tests/src/IO/StreamTests.WriteInt32.cs | 2 +- X10D.Tests/src/IO/StreamTests.WriteInt64.cs | 2 +- X10D.Tests/src/IO/StreamTests.WriteSingle.cs | 2 +- X10D.Tests/src/IO/StreamTests.WriteUInt16.cs | 17 ++++++----------- X10D.Tests/src/IO/StreamTests.WriteUInt32.cs | 17 ++++++----------- X10D.Tests/src/IO/StreamTests.WriteUInt64.cs | 17 ++++++----------- X10D.Tests/src/IO/StreamTests.cs | 2 +- X10D.Tests/src/IO/TextReaderTests.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.Double.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.Int32.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.Int64.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.Single.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.UInt32.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.UInt64.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.cs | 4 +++- X10D.Tests/src/IO/UInt16Tests.cs | 3 +-- X10D.Tests/src/IO/UInt32Tests.cs | 3 +-- X10D.Tests/src/IO/UInt64Tests.cs | 3 +-- X10D.Tests/src/Linq/ByteTests.cs | 2 +- X10D.Tests/src/Linq/DecimalTests.cs | 2 +- X10D.Tests/src/Linq/DoubleTests.cs | 2 +- X10D.Tests/src/Linq/EnumerableTests.cs | 2 +- X10D.Tests/src/Linq/Int16Tests.cs | 2 +- X10D.Tests/src/Linq/Int32Tests.cs | 2 +- X10D.Tests/src/Linq/Int64Tests.cs | 2 +- X10D.Tests/src/Linq/ReadOnlySpanTests.cs | 2 +- X10D.Tests/src/Linq/SByteTests.cs | 3 +-- X10D.Tests/src/Linq/SingleTests.cs | 2 +- X10D.Tests/src/Linq/SpanTests.cs | 2 +- X10D.Tests/src/Linq/UInt16Tests.cs | 3 +-- X10D.Tests/src/Linq/UInt32Tests.cs | 3 +-- X10D.Tests/src/Linq/UInt64Tests.cs | 3 +-- X10D.Tests/src/Math/BigIntegerTests.Wrap.cs | 2 +- X10D.Tests/src/Math/BigIntegerTests.cs | 2 +- X10D.Tests/src/Math/ByteTests.Wrap.cs | 2 +- X10D.Tests/src/Math/ByteTests.cs | 2 +- X10D.Tests/src/Math/ComparableTests.cs | 2 +- X10D.Tests/src/Math/DecimalTests.Wrap.cs | 2 +- X10D.Tests/src/Math/DecimalTests.cs | 2 +- X10D.Tests/src/Math/DoubleTests.Wrap.cs | 2 +- X10D.Tests/src/Math/DoubleTests.cs | 2 +- X10D.Tests/src/Math/Int16Tests.Wrap.cs | 2 +- X10D.Tests/src/Math/Int16Tests.cs | 2 +- X10D.Tests/src/Math/Int32Tests.Wrap.cs | 2 +- X10D.Tests/src/Math/Int32Tests.cs | 2 +- X10D.Tests/src/Math/Int64Tests.Wrap.cs | 2 +- X10D.Tests/src/Math/Int64Tests.cs | 2 +- X10D.Tests/src/Math/IsPrimeTests.cs | 2 +- X10D.Tests/src/Math/MathUtilityTests.cs | 2 +- X10D.Tests/src/Math/SByteTests.Wrap.cs | 2 +- X10D.Tests/src/Math/SByteTests.cs | 3 +-- X10D.Tests/src/Math/SingleTests.Wrap.cs | 2 +- X10D.Tests/src/Math/SingleTests.cs | 2 +- X10D.Tests/src/Math/UInt16Tests.Wrap.cs | 2 +- X10D.Tests/src/Math/UInt16Tests.cs | 3 +-- X10D.Tests/src/Math/UInt32Tests.Wrap.cs | 2 +- X10D.Tests/src/Math/UInt32Tests.cs | 3 +-- X10D.Tests/src/Math/UInt64Tests.Wrap.cs | 2 +- X10D.Tests/src/Math/UInt64Tests.cs | 3 +-- X10D.Tests/src/Net/EndPointTests.cs | 2 +- X10D.Tests/src/Net/IPAddressTests.cs | 2 +- X10D.Tests/src/Net/Int16Tests.cs | 2 +- X10D.Tests/src/Net/Int32Tests.cs | 2 +- X10D.Tests/src/Net/Int64Tests.cs | 2 +- X10D.Tests/src/Numerics/ByteTests.cs | 2 +- X10D.Tests/src/Numerics/Int16Tests.cs | 2 +- X10D.Tests/src/Numerics/Int32Tests.cs | 2 +- X10D.Tests/src/Numerics/Int64Tests.cs | 2 +- X10D.Tests/src/Numerics/QuaternionTests.cs | 2 +- X10D.Tests/src/Numerics/RandomTests.cs | 2 +- X10D.Tests/src/Numerics/SByteTests.cs | 3 +-- X10D.Tests/src/Numerics/UInt16Tests.cs | 3 +-- X10D.Tests/src/Numerics/UInt32Tests.cs | 3 +-- X10D.Tests/src/Numerics/UInt64Tests.cs | 3 +-- X10D.Tests/src/Numerics/Vector2Tests.cs | 2 +- X10D.Tests/src/Numerics/Vector3Tests.cs | 2 +- X10D.Tests/src/Numerics/Vector4Tests.cs | 2 +- X10D.Tests/src/Reactive/ProgressTests.cs | 2 +- X10D.Tests/src/Reflection/MemberInfoTests.cs | 2 +- X10D.Tests/src/Reflection/TypeTests.cs | 2 +- X10D.Tests/src/Text/CharSpanTests.cs | 2 +- X10D.Tests/src/Text/CharTests.cs | 2 +- X10D.Tests/src/Text/CoreTests.cs | 2 +- X10D.Tests/src/Text/EnumerableTests.cs | 2 +- X10D.Tests/src/Text/RuneTests.cs | 2 +- X10D.Tests/src/Text/StringBuilderReaderTests.cs | 2 +- X10D.Tests/src/Text/StringTests.cs | 2 +- X10D.Tests/src/Time/ByteTests.cs | 2 +- X10D.Tests/src/Time/CharSpanTests.cs | 2 +- X10D.Tests/src/Time/DateOnlyTests.cs | 2 +- X10D.Tests/src/Time/DateTimeOffsetTests.cs | 2 +- X10D.Tests/src/Time/DateTimeTests.cs | 2 +- X10D.Tests/src/Time/DecimalTests.cs | 2 +- X10D.Tests/src/Time/DoubleTests.cs | 2 +- X10D.Tests/src/Time/HalfTests.cs | 2 +- X10D.Tests/src/Time/Int16Tests.cs | 2 +- X10D.Tests/src/Time/Int32Tests.cs | 2 +- X10D.Tests/src/Time/Int64Tests.cs | 2 +- X10D.Tests/src/Time/SByteTests.cs | 3 +-- X10D.Tests/src/Time/SingleTests.cs | 2 +- X10D.Tests/src/Time/StringTests.cs | 2 +- X10D.Tests/src/Time/TimeSpanParserTests.cs | 2 +- X10D.Tests/src/Time/TimeSpanTests.cs | 2 +- X10D.Tests/src/Time/UInt16Tests.cs | 3 +-- X10D.Tests/src/Time/UInt32Tests.cs | 3 +-- X10D.Tests/src/Time/UInt64Tests.cs | 3 +-- 172 files changed, 209 insertions(+), 259 deletions(-) diff --git a/X10D.Tests/X10D.Tests.csproj b/X10D.Tests/X10D.Tests.csproj index 567e11c..4af78b2 100644 --- a/X10D.Tests/X10D.Tests.csproj +++ b/X10D.Tests/X10D.Tests.csproj @@ -6,7 +6,6 @@ json,cobertura true false - $(NoWarn);1591 diff --git a/X10D.Tests/src/Assembly.cs b/X10D.Tests/src/Assembly.cs index f547610..4e11466 100644 --- a/X10D.Tests/src/Assembly.cs +++ b/X10D.Tests/src/Assembly.cs @@ -1 +1 @@ -[assembly: CLSCompliant(true)] +[assembly: CLSCompliant(false)] diff --git a/X10D.Tests/src/Collections/ArrayTests.AsReadOnly.cs b/X10D.Tests/src/Collections/ArrayTests.AsReadOnly.cs index d576b26..e1d010d 100644 --- a/X10D.Tests/src/Collections/ArrayTests.AsReadOnly.cs +++ b/X10D.Tests/src/Collections/ArrayTests.AsReadOnly.cs @@ -3,10 +3,10 @@ using X10D.Collections; namespace X10D.Tests.Collections; -public partial class ArrayTests +internal static partial class ArrayTests { [TestFixture] - public class AsReadOnlyTests + internal class AsReadOnlyTests { [Test] public void AsReadOnly_ShouldReturnReadOnlyCollection_WhenArrayIsNotNull() diff --git a/X10D.Tests/src/Collections/ArrayTests.Clear.cs b/X10D.Tests/src/Collections/ArrayTests.Clear.cs index 4679b83..5608952 100644 --- a/X10D.Tests/src/Collections/ArrayTests.Clear.cs +++ b/X10D.Tests/src/Collections/ArrayTests.Clear.cs @@ -3,7 +3,7 @@ using X10D.Collections; namespace X10D.Tests.Collections; -public partial class ArrayTests +internal static partial class ArrayTests { [TestFixture] public class ClearTests diff --git a/X10D.Tests/src/Collections/ArrayTests.cs b/X10D.Tests/src/Collections/ArrayTests.cs index 90e5cd2..53c46f5 100644 --- a/X10D.Tests/src/Collections/ArrayTests.cs +++ b/X10D.Tests/src/Collections/ArrayTests.cs @@ -3,6 +3,6 @@ namespace X10D.Tests.Collections; [TestFixture] -public partial class ArrayTests +internal static partial class ArrayTests { } diff --git a/X10D.Tests/src/Collections/BoolListTests.cs b/X10D.Tests/src/Collections/BoolListTests.cs index a2ad121..c90bc16 100644 --- a/X10D.Tests/src/Collections/BoolListTests.cs +++ b/X10D.Tests/src/Collections/BoolListTests.cs @@ -4,7 +4,7 @@ using X10D.Collections; namespace X10D.Tests.Collections; [TestFixture] -public class BoolListTests +internal class BoolListTests { [Test] public void PackByte_Should_Pack_Correctly() diff --git a/X10D.Tests/src/Collections/ByteTests.cs b/X10D.Tests/src/Collections/ByteTests.cs index 088fa00..4f35f86 100644 --- a/X10D.Tests/src/Collections/ByteTests.cs +++ b/X10D.Tests/src/Collections/ByteTests.cs @@ -5,7 +5,7 @@ using X10D.Collections; namespace X10D.Tests.Collections; [TestFixture] -public class ByteTests +internal class ByteTests { [Test] public void Unpack_ShouldUnpackToArrayCorrectly() diff --git a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs index 3330de8..24c542f 100644 --- a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs +++ b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs @@ -5,7 +5,7 @@ using X10D.Collections; namespace X10D.Tests.Collections; -public partial class CollectionTests +internal partial class CollectionTests { [TestFixture] public class ClearAndDisposeAllTests diff --git a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs index c8b3c6a..e176fa0 100644 --- a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs +++ b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs @@ -5,7 +5,7 @@ using X10D.Collections; namespace X10D.Tests.Collections; -public partial class CollectionTests +internal partial class CollectionTests { [TestFixture] public class ClearAndDisposeAllAsyncTests diff --git a/X10D.Tests/src/Collections/CollectionTests.cs b/X10D.Tests/src/Collections/CollectionTests.cs index ba825f6..8452830 100644 --- a/X10D.Tests/src/Collections/CollectionTests.cs +++ b/X10D.Tests/src/Collections/CollectionTests.cs @@ -3,6 +3,6 @@ namespace X10D.Tests.Collections; [TestFixture] -public partial class CollectionTests +internal partial class CollectionTests { } diff --git a/X10D.Tests/src/Collections/DictionaryTests.cs b/X10D.Tests/src/Collections/DictionaryTests.cs index 1882dad..c420375 100644 --- a/X10D.Tests/src/Collections/DictionaryTests.cs +++ b/X10D.Tests/src/Collections/DictionaryTests.cs @@ -4,7 +4,7 @@ using X10D.Collections; namespace X10D.Tests.Collections; [TestFixture] -public class DictionaryTests +internal class DictionaryTests { [Test] public void AddOrUpdate_ShouldAddNewKey_IfNotExists_GivenConcreteDictionary() diff --git a/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs b/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs index a402ceb..6f8519b 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs @@ -4,7 +4,7 @@ using X10D.Collections; namespace X10D.Tests.Collections; -public partial class EnumerableTests +internal partial class EnumerableTests { [TestFixture] public class DisposeAllTests diff --git a/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs b/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs index 1510338..9cd238f 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs @@ -4,7 +4,7 @@ using X10D.Collections; namespace X10D.Tests.Collections; -public partial class EnumerableTests +internal partial class EnumerableTests { [TestFixture] public class DisposeAllAsyncTests diff --git a/X10D.Tests/src/Collections/EnumerableTests.cs b/X10D.Tests/src/Collections/EnumerableTests.cs index 0fbc23e..df6442c 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.cs @@ -5,7 +5,7 @@ using X10D.Core; namespace X10D.Tests.Collections; [TestFixture] -public partial class EnumerableTests +internal partial class EnumerableTests { [Test] public void CountWhereNot_ShouldReturnCorrectCount_GivenSequence() diff --git a/X10D.Tests/src/Collections/Int16Tests.cs b/X10D.Tests/src/Collections/Int16Tests.cs index 63c2cef..9e44f49 100644 --- a/X10D.Tests/src/Collections/Int16Tests.cs +++ b/X10D.Tests/src/Collections/Int16Tests.cs @@ -5,7 +5,7 @@ using X10D.Collections; namespace X10D.Tests.Collections; [TestFixture] -public class Int16Tests +internal class Int16Tests { [Test] public void Unpack_ShouldUnpackToArrayCorrectly() diff --git a/X10D.Tests/src/Collections/Int32Tests.cs b/X10D.Tests/src/Collections/Int32Tests.cs index 9aee1e8..219ecd3 100644 --- a/X10D.Tests/src/Collections/Int32Tests.cs +++ b/X10D.Tests/src/Collections/Int32Tests.cs @@ -5,7 +5,7 @@ using X10D.Collections; namespace X10D.Tests.Collections; [TestFixture] -public class Int32Tests +internal class Int32Tests { [Test] public void Unpack_ShouldUnpackToArrayCorrectly() diff --git a/X10D.Tests/src/Collections/Int64Tests.cs b/X10D.Tests/src/Collections/Int64Tests.cs index 02b89df..1cfee79 100644 --- a/X10D.Tests/src/Collections/Int64Tests.cs +++ b/X10D.Tests/src/Collections/Int64Tests.cs @@ -1,11 +1,12 @@ using System.Diagnostics; +using System.Globalization; using NUnit.Framework; using X10D.Collections; namespace X10D.Tests.Collections; [TestFixture] -public class Int64Tests +internal class Int64Tests { [Test] public void UnpackBits_ShouldUnpackToArrayCorrectly() @@ -29,7 +30,7 @@ public class Int64Tests for (var index = 8; index < 64; index++) { - Assert.That(bits[index], Is.False, index.ToString()); + Assert.That(bits[index], Is.False, index.ToString(CultureInfo.InvariantCulture)); } }); } @@ -53,7 +54,7 @@ public class Int64Tests for (var index = 8; index < 64; index++) { - Assert.That(bits[index], Is.False, index.ToString()); + Assert.That(bits[index], Is.False, index.ToString(CultureInfo.InvariantCulture)); } }); } diff --git a/X10D.Tests/src/Collections/ListTests.cs b/X10D.Tests/src/Collections/ListTests.cs index 095444f..bd62f8c 100644 --- a/X10D.Tests/src/Collections/ListTests.cs +++ b/X10D.Tests/src/Collections/ListTests.cs @@ -4,10 +4,9 @@ using X10D.Collections; namespace X10D.Tests.Collections; [TestFixture] -public class ListTests +internal class ListTests { - [CLSCompliant(false)] - [Test] + [Test] [TestCase(1)] [TestCase(1, 2, 3)] [TestCase(1, 2, 3, 4, 5)] @@ -26,8 +25,7 @@ public class ListTests CollectionAssert.AreEqual(all42, list); } - [CLSCompliant(false)] - [Test] + [Test] [TestCase(1)] [TestCase(1, 2, 3)] [TestCase(1, 2, 3, 4, 5)] diff --git a/X10D.Tests/src/Collections/SpanTest.cs b/X10D.Tests/src/Collections/SpanTest.cs index 0c59d1c..04f263a 100644 --- a/X10D.Tests/src/Collections/SpanTest.cs +++ b/X10D.Tests/src/Collections/SpanTest.cs @@ -4,7 +4,7 @@ using X10D.Collections; namespace X10D.Tests.Collections; [TestFixture] -public class SpanTest +internal class SpanTest { [Test] public void Count_ShouldReturn0_GivenEmptySpan() diff --git a/X10D.Tests/src/Core/CoreTests.cs b/X10D.Tests/src/Core/CoreTests.cs index 41f1436..fea360d 100644 --- a/X10D.Tests/src/Core/CoreTests.cs +++ b/X10D.Tests/src/Core/CoreTests.cs @@ -4,7 +4,7 @@ using X10D.Core; namespace X10D.Tests.Core; [TestFixture] -public class CoreTests +internal class CoreTests { [Test] [TestCase(1)] diff --git a/X10D.Tests/src/Core/EnumTests.cs b/X10D.Tests/src/Core/EnumTests.cs index 4469874..c335b9a 100644 --- a/X10D.Tests/src/Core/EnumTests.cs +++ b/X10D.Tests/src/Core/EnumTests.cs @@ -4,7 +4,7 @@ using X10D.Core; namespace X10D.Tests.Core; [TestFixture] -public class EnumTests +internal class EnumTests { // Microsoft wrongfully decided to have Sunday be 0, Monday be 1, etc. // I personally hate this, Sunday is not the first day of the week. diff --git a/X10D.Tests/src/Core/IntrinsicTests.cs b/X10D.Tests/src/Core/IntrinsicTests.cs index ecda634..da5fd8e 100644 --- a/X10D.Tests/src/Core/IntrinsicTests.cs +++ b/X10D.Tests/src/Core/IntrinsicTests.cs @@ -7,7 +7,7 @@ using X10D.Core; namespace X10D.Tests.Core; [TestFixture] -public class IntrinsicTests +internal class IntrinsicTests { [Test] public void CorrectBoolean_ShouldReturnExpectedVector64Result_GivenInputVector() diff --git a/X10D.Tests/src/Core/NullableTests.cs b/X10D.Tests/src/Core/NullableTests.cs index 4626e9c..db4c8ef 100644 --- a/X10D.Tests/src/Core/NullableTests.cs +++ b/X10D.Tests/src/Core/NullableTests.cs @@ -4,7 +4,7 @@ using X10D.Core; namespace X10D.Tests.Core; [TestFixture] -public class NullableTests +internal class NullableTests { [Test] public void TryGetValue_ShouldBeTrue_GivenValue() diff --git a/X10D.Tests/src/Core/RandomTests.cs b/X10D.Tests/src/Core/RandomTests.cs index 1e7b7bd..5e1022d 100644 --- a/X10D.Tests/src/Core/RandomTests.cs +++ b/X10D.Tests/src/Core/RandomTests.cs @@ -5,7 +5,7 @@ using X10D.Core; namespace X10D.Tests.Core; [TestFixture] -public class RandomTests +internal class RandomTests { [Test] public void NextBoolean_ShouldBeFalse_GivenSeed1234() diff --git a/X10D.Tests/src/Core/SpanTest.cs b/X10D.Tests/src/Core/SpanTest.cs index 6ef4f74..85fb460 100644 --- a/X10D.Tests/src/Core/SpanTest.cs +++ b/X10D.Tests/src/Core/SpanTest.cs @@ -8,7 +8,7 @@ using X10D.Core; namespace X10D.Tests.Core; [TestFixture] -public class SpanTest +internal class SpanTest { [Test] public void Contains_ShouldReturnFalse_GivenReadOnlySpanWithNoMatchingElements_UsingByteEnum() diff --git a/X10D.Tests/src/Drawing/CircleFTests.cs b/X10D.Tests/src/Drawing/CircleFTests.cs index fad7e5c..06a4de8 100644 --- a/X10D.Tests/src/Drawing/CircleFTests.cs +++ b/X10D.Tests/src/Drawing/CircleFTests.cs @@ -5,7 +5,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class CircleFTests +internal class CircleFTests { [Test] public void Area_ShouldBePiRadiusRadius_GivenUnitCircle() diff --git a/X10D.Tests/src/Drawing/CircleTests.cs b/X10D.Tests/src/Drawing/CircleTests.cs index 8ab4d18..e03fb0c 100644 --- a/X10D.Tests/src/Drawing/CircleTests.cs +++ b/X10D.Tests/src/Drawing/CircleTests.cs @@ -4,7 +4,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class CircleTests +internal class CircleTests { [Test] public void Area_ShouldBePiRadiusRadius_GivenUnitCircle() diff --git a/X10D.Tests/src/Drawing/ColorTests.cs b/X10D.Tests/src/Drawing/ColorTests.cs index ad29fb3..7868484 100644 --- a/X10D.Tests/src/Drawing/ColorTests.cs +++ b/X10D.Tests/src/Drawing/ColorTests.cs @@ -5,7 +5,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class ColorTests +internal class ColorTests { private static readonly Color Black = Color.FromArgb(0, 0, 0); private static readonly Color White = Color.FromArgb(255, 255, 255); diff --git a/X10D.Tests/src/Drawing/CuboidTests.cs b/X10D.Tests/src/Drawing/CuboidTests.cs index f2eafdc..37d006f 100644 --- a/X10D.Tests/src/Drawing/CuboidTests.cs +++ b/X10D.Tests/src/Drawing/CuboidTests.cs @@ -5,7 +5,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class CuboidTests +internal class CuboidTests { [Test] public void Corners_ShouldBeCorrect_GivenCubeOfSize1() diff --git a/X10D.Tests/src/Drawing/EllipseFTests.cs b/X10D.Tests/src/Drawing/EllipseFTests.cs index 7ca40aa..aecdcdc 100644 --- a/X10D.Tests/src/Drawing/EllipseFTests.cs +++ b/X10D.Tests/src/Drawing/EllipseFTests.cs @@ -6,7 +6,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class EllipseFTests +internal class EllipseFTests { [Test] public void Area_ShouldBePiRadiusRadius_GivenUnitEllipse() diff --git a/X10D.Tests/src/Drawing/EllipseTests.cs b/X10D.Tests/src/Drawing/EllipseTests.cs index 529f1c6..6f938cd 100644 --- a/X10D.Tests/src/Drawing/EllipseTests.cs +++ b/X10D.Tests/src/Drawing/EllipseTests.cs @@ -5,7 +5,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class EllipseTests +internal class EllipseTests { [Test] public void Area_ShouldBePiRadiusRadius_GivenUnitEllipse() diff --git a/X10D.Tests/src/Drawing/Line3DTests.cs b/X10D.Tests/src/Drawing/Line3DTests.cs index f7db299..1182a5b 100644 --- a/X10D.Tests/src/Drawing/Line3DTests.cs +++ b/X10D.Tests/src/Drawing/Line3DTests.cs @@ -6,7 +6,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class Line3DTests +internal class Line3DTests { [Test] public void CompareTo_ShouldBeNegativeOne_GivenEmptyAndOne() diff --git a/X10D.Tests/src/Drawing/LineFTests.cs b/X10D.Tests/src/Drawing/LineFTests.cs index 2c53cd4..412fff2 100644 --- a/X10D.Tests/src/Drawing/LineFTests.cs +++ b/X10D.Tests/src/Drawing/LineFTests.cs @@ -5,7 +5,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class LineFTests +internal class LineFTests { [Test] public void CompareTo_ShouldBeNegativeOne_GivenEmptyAndOne() diff --git a/X10D.Tests/src/Drawing/LineTests.cs b/X10D.Tests/src/Drawing/LineTests.cs index dfca225..24a985d 100644 --- a/X10D.Tests/src/Drawing/LineTests.cs +++ b/X10D.Tests/src/Drawing/LineTests.cs @@ -4,7 +4,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class LineTests +internal class LineTests { [Test] public void CompareTo_ShouldBeNegativeOne_GivenEmptyAndOne() diff --git a/X10D.Tests/src/Drawing/PointFTests.cs b/X10D.Tests/src/Drawing/PointFTests.cs index 9bcd0c9..aace160 100644 --- a/X10D.Tests/src/Drawing/PointFTests.cs +++ b/X10D.Tests/src/Drawing/PointFTests.cs @@ -8,7 +8,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class PointFTests +internal class PointFTests { [Test] public void IsOnLine_ShouldReturnTrue_GivenPointOnLine() diff --git a/X10D.Tests/src/Drawing/PointTests.cs b/X10D.Tests/src/Drawing/PointTests.cs index 818a3f5..ae07657 100644 --- a/X10D.Tests/src/Drawing/PointTests.cs +++ b/X10D.Tests/src/Drawing/PointTests.cs @@ -5,7 +5,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class PointTests +internal class PointTests { [Test] public void IsOnLine_ShouldReturnTrue_GivenPointOnLine() diff --git a/X10D.Tests/src/Drawing/PolygonFTests.cs b/X10D.Tests/src/Drawing/PolygonFTests.cs index 9b7e626..f6a09de 100644 --- a/X10D.Tests/src/Drawing/PolygonFTests.cs +++ b/X10D.Tests/src/Drawing/PolygonFTests.cs @@ -6,7 +6,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class PolygonFTests +internal class PolygonFTests { [Test] public void AddVertices_ShouldAddVertices() diff --git a/X10D.Tests/src/Drawing/PolygonTests.cs b/X10D.Tests/src/Drawing/PolygonTests.cs index 40e9da4..4d73cd8 100644 --- a/X10D.Tests/src/Drawing/PolygonTests.cs +++ b/X10D.Tests/src/Drawing/PolygonTests.cs @@ -5,7 +5,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class PolygonTests +internal class PolygonTests { [Test] public void AddVertices_ShouldAddVertices() diff --git a/X10D.Tests/src/Drawing/PolyhedronTests.cs b/X10D.Tests/src/Drawing/PolyhedronTests.cs index 608e7e1..8e85423 100644 --- a/X10D.Tests/src/Drawing/PolyhedronTests.cs +++ b/X10D.Tests/src/Drawing/PolyhedronTests.cs @@ -5,7 +5,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class PolyhedronTests +internal class PolyhedronTests { [Test] public void AddVertices_ShouldAddVertices() diff --git a/X10D.Tests/src/Drawing/RandomTests.cs b/X10D.Tests/src/Drawing/RandomTests.cs index cad12e4..349ca33 100644 --- a/X10D.Tests/src/Drawing/RandomTests.cs +++ b/X10D.Tests/src/Drawing/RandomTests.cs @@ -5,7 +5,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class RandomTests +internal class RandomTests { [Test] public void NextColorArgb_ShouldReturn331515e5_GivenSeed1234() diff --git a/X10D.Tests/src/Drawing/SizeTests.cs b/X10D.Tests/src/Drawing/SizeTests.cs index e72bbbb..47a2a42 100644 --- a/X10D.Tests/src/Drawing/SizeTests.cs +++ b/X10D.Tests/src/Drawing/SizeTests.cs @@ -5,7 +5,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class SizeTests +internal class SizeTests { [Test] public void ToPoint_ShouldReturnPoint_WithEquivalentMembers() diff --git a/X10D.Tests/src/Drawing/SphereTests.cs b/X10D.Tests/src/Drawing/SphereTests.cs index 2a61a8b..dcbf8ce 100644 --- a/X10D.Tests/src/Drawing/SphereTests.cs +++ b/X10D.Tests/src/Drawing/SphereTests.cs @@ -4,7 +4,7 @@ using X10D.Drawing; namespace X10D.Tests.Drawing; [TestFixture] -public class SphereTests +internal class SphereTests { [Test] public void Circumference_ShouldBe2PiRadius_GivenUnitCircle() diff --git a/X10D.Tests/src/Hosting/ServiceCollectionTests.cs b/X10D.Tests/src/Hosting/ServiceCollectionTests.cs index 63a3db6..0691914 100644 --- a/X10D.Tests/src/Hosting/ServiceCollectionTests.cs +++ b/X10D.Tests/src/Hosting/ServiceCollectionTests.cs @@ -6,7 +6,7 @@ using X10D.Hosting.DependencyInjection; namespace X10D.Tests.Hosting; [TestFixture] -public class ServiceCollectionTests +internal class ServiceCollectionTests { [Test] public void AddHostedSingleton_ShouldRegisterServiceAsSingletonAndAsHostedService() diff --git a/X10D.Tests/src/IO/BooleanTests.cs b/X10D.Tests/src/IO/BooleanTests.cs index 86ebdd9..2994e03 100644 --- a/X10D.Tests/src/IO/BooleanTests.cs +++ b/X10D.Tests/src/IO/BooleanTests.cs @@ -4,7 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class BooleanTests +internal class BooleanTests { [Test] public void GetBytes_ReturnsArrayContaining1() diff --git a/X10D.Tests/src/IO/ByteTests.cs b/X10D.Tests/src/IO/ByteTests.cs index 4c13411..433cc09 100644 --- a/X10D.Tests/src/IO/ByteTests.cs +++ b/X10D.Tests/src/IO/ByteTests.cs @@ -4,7 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class ByteTests +internal class ByteTests { [Test] public void GetBytes_ReturnsArrayContainingItself() diff --git a/X10D.Tests/src/IO/DirectoryInfoTests.cs b/X10D.Tests/src/IO/DirectoryInfoTests.cs index 62df128..925902a 100644 --- a/X10D.Tests/src/IO/DirectoryInfoTests.cs +++ b/X10D.Tests/src/IO/DirectoryInfoTests.cs @@ -4,7 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class DirectoryInfoTests +internal class DirectoryInfoTests { [Test] public void Clear_ShouldClear_GivenValidDirectory() diff --git a/X10D.Tests/src/IO/DoubleTests.cs b/X10D.Tests/src/IO/DoubleTests.cs index c327e9f..f58e26c 100644 --- a/X10D.Tests/src/IO/DoubleTests.cs +++ b/X10D.Tests/src/IO/DoubleTests.cs @@ -4,7 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class DoubleTests +internal class DoubleTests { [Test] public void GetBytes_ReturnsCorrectValue() diff --git a/X10D.Tests/src/IO/FileInfoTests.cs b/X10D.Tests/src/IO/FileInfoTests.cs index b182b94..319e864 100644 --- a/X10D.Tests/src/IO/FileInfoTests.cs +++ b/X10D.Tests/src/IO/FileInfoTests.cs @@ -5,7 +5,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class FileInfoTests +internal class FileInfoTests { [Test] public void GetHashSha1ShouldBeCorrect() diff --git a/X10D.Tests/src/IO/Int16Tests.cs b/X10D.Tests/src/IO/Int16Tests.cs index ae4dcbe..11d6bb1 100644 --- a/X10D.Tests/src/IO/Int16Tests.cs +++ b/X10D.Tests/src/IO/Int16Tests.cs @@ -4,7 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class Int16Tests +internal class Int16Tests { [Test] public void GetBytes_ReturnsCorrectValue() diff --git a/X10D.Tests/src/IO/Int32Tests.cs b/X10D.Tests/src/IO/Int32Tests.cs index d69b2be..c123980 100644 --- a/X10D.Tests/src/IO/Int32Tests.cs +++ b/X10D.Tests/src/IO/Int32Tests.cs @@ -4,7 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class Int32Tests +internal class Int32Tests { [Test] public void GetBytes_ReturnsCorrectValue() diff --git a/X10D.Tests/src/IO/Int64Tests.cs b/X10D.Tests/src/IO/Int64Tests.cs index ccd3673..6183d13 100644 --- a/X10D.Tests/src/IO/Int64Tests.cs +++ b/X10D.Tests/src/IO/Int64Tests.cs @@ -4,7 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class Int64Tests +internal class Int64Tests { [Test] public void GetBytes_ReturnsCorrectValue() diff --git a/X10D.Tests/src/IO/ListOfByteTests.cs b/X10D.Tests/src/IO/ListOfByteTests.cs index 17bd66d..998344d 100644 --- a/X10D.Tests/src/IO/ListOfByteTests.cs +++ b/X10D.Tests/src/IO/ListOfByteTests.cs @@ -5,7 +5,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class ListOfByteTests +internal class ListOfByteTests { [Test] public void AsString_ShouldReturnBytes_GivenBytes() diff --git a/X10D.Tests/src/IO/SByteTests.cs b/X10D.Tests/src/IO/SByteTests.cs index 23143ad..c9486e2 100644 --- a/X10D.Tests/src/IO/SByteTests.cs +++ b/X10D.Tests/src/IO/SByteTests.cs @@ -4,8 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -[CLSCompliant(false)] -public class SByteTests +internal class SByteTests { [Test] public void GetBytes_ReturnsArrayContainingItself() diff --git a/X10D.Tests/src/IO/SingleTests.cs b/X10D.Tests/src/IO/SingleTests.cs index b0b1bf3..5f753c4 100644 --- a/X10D.Tests/src/IO/SingleTests.cs +++ b/X10D.Tests/src/IO/SingleTests.cs @@ -4,7 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class SingleTests +internal class SingleTests { [Test] public void GetBytes_ReturnsCorrectValue() diff --git a/X10D.Tests/src/IO/StreamTests.ReadDecimal.cs b/X10D.Tests/src/IO/StreamTests.ReadDecimal.cs index 3209443..7f61b76 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadDecimal.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadDecimal.cs @@ -3,7 +3,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void ReadDecimal_ShouldThrowArgumentException_GivenNonReadableStream() diff --git a/X10D.Tests/src/IO/StreamTests.ReadDouble.cs b/X10D.Tests/src/IO/StreamTests.ReadDouble.cs index 6084984..b400ac1 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadDouble.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadDouble.cs @@ -3,7 +3,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void ReadDouble_ShouldThrowArgumentException_GivenNonReadableStream() diff --git a/X10D.Tests/src/IO/StreamTests.ReadInt16.cs b/X10D.Tests/src/IO/StreamTests.ReadInt16.cs index bdb045c..950f368 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadInt16.cs @@ -3,7 +3,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void ReadInt16_ShouldThrowArgumentException_GivenNonReadableStream() diff --git a/X10D.Tests/src/IO/StreamTests.ReadInt32.cs b/X10D.Tests/src/IO/StreamTests.ReadInt32.cs index 64f4c75..8b45594 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadInt32.cs @@ -3,7 +3,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void ReadInt32_ShouldThrowArgumentException_GivenNonReadableStream() diff --git a/X10D.Tests/src/IO/StreamTests.ReadInt64.cs b/X10D.Tests/src/IO/StreamTests.ReadInt64.cs index d9f938e..d094a56 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadInt64.cs @@ -3,7 +3,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void ReadInt64_ShouldThrowArgumentException_GivenNonReadableStream() diff --git a/X10D.Tests/src/IO/StreamTests.ReadSingle.cs b/X10D.Tests/src/IO/StreamTests.ReadSingle.cs index 2dc2292..7d5a396 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadSingle.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadSingle.cs @@ -3,7 +3,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void ReadSingle_ShouldThrowArgumentException_GivenNonReadableStream() diff --git a/X10D.Tests/src/IO/StreamTests.ReadUInt16.cs b/X10D.Tests/src/IO/StreamTests.ReadUInt16.cs index 23508dc..cd8d726 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadUInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadUInt16.cs @@ -3,11 +3,10 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - public void ReadUInt16_ShouldThrowArgumentException_GivenNonReadableStream() + public void ReadUInt16_ShouldThrowArgumentException_GivenNonReadableStream() { Stream stream = new DummyStream(); Assert.Throws(() => stream.ReadUInt16()); @@ -16,8 +15,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt16_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadUInt16_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; Assert.Throws(() => stream.ReadUInt16()); @@ -26,8 +24,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt16_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadUInt16_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() { // we don't need to enclose this stream in a using declaration, since disposing a // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. @@ -39,8 +36,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt16_ShouldReadBigEndian_GivenBigEndian() + public void ReadUInt16_ShouldReadBigEndian_GivenBigEndian() { using var stream = new MemoryStream(); ReadOnlySpan bytes = stackalloc byte[] {0x01, 0xA4}; @@ -55,8 +51,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt16_ShouldReadLittleEndian_GivenLittleEndian() + public void ReadUInt16_ShouldReadLittleEndian_GivenLittleEndian() { using var stream = new MemoryStream(); ReadOnlySpan bytes = stackalloc byte[] {0xA4, 0x01}; diff --git a/X10D.Tests/src/IO/StreamTests.ReadUInt32.cs b/X10D.Tests/src/IO/StreamTests.ReadUInt32.cs index 8bd57a3..cc5c67d 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadUInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadUInt32.cs @@ -3,11 +3,10 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - public void ReadUInt32_ShouldThrowArgumentException_GivenNonReadableStream() + public void ReadUInt32_ShouldThrowArgumentException_GivenNonReadableStream() { Stream stream = new DummyStream(); Assert.Throws(() => stream.ReadUInt32()); @@ -16,8 +15,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt32_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadUInt32_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; Assert.Throws(() => stream.ReadUInt32()); @@ -26,8 +24,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt32_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadUInt32_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() { // we don't need to enclose this stream in a using declaration, since disposing a // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. @@ -39,8 +36,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt32_ShouldReadBigEndian_GivenBigEndian() + public void ReadUInt32_ShouldReadBigEndian_GivenBigEndian() { using var stream = new MemoryStream(); ReadOnlySpan bytes = stackalloc byte[] {0x00, 0x00, 0x01, 0xA4}; @@ -55,8 +51,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt32_ShouldReadLittleEndian_GivenLittleEndian() + public void ReadUInt32_ShouldReadLittleEndian_GivenLittleEndian() { using var stream = new MemoryStream(); ReadOnlySpan bytes = stackalloc byte[] {0xA4, 0x01, 0x00, 0x00}; diff --git a/X10D.Tests/src/IO/StreamTests.ReadUInt64.cs b/X10D.Tests/src/IO/StreamTests.ReadUInt64.cs index f315b47..0d916a7 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadUInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadUInt64.cs @@ -3,11 +3,10 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - public void ReadUInt64_ShouldThrowArgumentException_GivenNonReadableStream() + public void ReadUInt64_ShouldThrowArgumentException_GivenNonReadableStream() { Stream stream = new DummyStream(); Assert.Throws(() => stream.ReadUInt64()); @@ -16,8 +15,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt64_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadUInt64_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; Assert.Throws(() => stream.ReadUInt64()); @@ -26,8 +24,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt64_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadUInt64_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() { // we don't need to enclose this stream in a using declaration, since disposing a // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. @@ -39,8 +36,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt64_ShouldReadBigEndian_GivenBigEndian() + public void ReadUInt64_ShouldReadBigEndian_GivenBigEndian() { using var stream = new MemoryStream(); ReadOnlySpan bytes = stackalloc byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4}; @@ -55,8 +51,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void ReadUInt64_ShouldWriteLittleEndian_GivenLittleEndian() + public void ReadUInt64_ShouldWriteLittleEndian_GivenLittleEndian() { using var stream = new MemoryStream(); ReadOnlySpan bytes = stackalloc byte[] {0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs b/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs index e34a816..3aaa113 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs @@ -4,7 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void WriteDecimal_ShouldThrowArgumentException_GivenNonWriteableStream() diff --git a/X10D.Tests/src/IO/StreamTests.WriteDouble.cs b/X10D.Tests/src/IO/StreamTests.WriteDouble.cs index b1b43e1..e933858 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteDouble.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteDouble.cs @@ -3,7 +3,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void WriteDouble_ShouldThrowArgumentException_GivenNonWriteableStream() diff --git a/X10D.Tests/src/IO/StreamTests.WriteInt16.cs b/X10D.Tests/src/IO/StreamTests.WriteInt16.cs index ce0bc8d..cc17549 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt16.cs @@ -3,7 +3,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void WriteInt16_ShouldThrowArgumentException_GivenNonWriteableStream() diff --git a/X10D.Tests/src/IO/StreamTests.WriteInt32.cs b/X10D.Tests/src/IO/StreamTests.WriteInt32.cs index bb8c982..95f748e 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt32.cs @@ -3,7 +3,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void WriteInt32_ShouldThrowArgumentException_GivenNonWriteableStream() diff --git a/X10D.Tests/src/IO/StreamTests.WriteInt64.cs b/X10D.Tests/src/IO/StreamTests.WriteInt64.cs index e0fda01..adb8ce2 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt64.cs @@ -3,7 +3,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void WriteInt64_ShouldThrowArgumentException_GivenNonWriteableStream() diff --git a/X10D.Tests/src/IO/StreamTests.WriteSingle.cs b/X10D.Tests/src/IO/StreamTests.WriteSingle.cs index 69d491b..4a7376e 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteSingle.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteSingle.cs @@ -3,7 +3,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] public void WriteSingle_ShouldThrowArgumentException_GivenNonWriteableStream() diff --git a/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs b/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs index 9747ca8..89a620f 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs @@ -3,11 +3,10 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - public void WriteUInt16_ShouldThrowArgumentException_GivenNonWriteableStream() + public void WriteUInt16_ShouldThrowArgumentException_GivenNonWriteableStream() { Stream stream = new DummyStream(); Assert.Throws(() => stream.Write((ushort)420, Endianness.LittleEndian)); @@ -15,8 +14,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt16_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteUInt16_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; Assert.Throws(() => stream.Write((ushort)420, Endianness.LittleEndian)); @@ -24,8 +22,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt16_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void WriteUInt16_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() { // we don't need to enclose this stream in a using declaration, since disposing a // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. @@ -38,8 +35,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt16_ShouldWriteBigEndian_GivenBigEndian() + public void WriteUInt16_ShouldWriteBigEndian_GivenBigEndian() { using var stream = new MemoryStream(); stream.Write((ushort)420, Endianness.BigEndian); @@ -55,8 +51,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt16_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteUInt16_ShouldWriteLittleEndian_GivenLittleEndian() { using var stream = new MemoryStream(); stream.Write((ushort)420, Endianness.LittleEndian); diff --git a/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs b/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs index 41d77a9..a9c3bb9 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs @@ -3,11 +3,10 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - public void WriteUInt32_ShouldThrowArgumentException_GivenNonWriteableStream() + public void WriteUInt32_ShouldThrowArgumentException_GivenNonWriteableStream() { Stream stream = new DummyStream(); Assert.Throws(() => stream.Write(420U, Endianness.LittleEndian)); @@ -15,8 +14,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt32_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteUInt32_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; Assert.Throws(() => stream.Write(420U, Endianness.LittleEndian)); @@ -24,8 +22,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt32_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void WriteUInt32_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() { // we don't need to enclose this stream in a using declaration, since disposing a // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. @@ -38,8 +35,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt32_ShouldWriteBigEndian_GivenBigEndian() + public void WriteUInt32_ShouldWriteBigEndian_GivenBigEndian() { using var stream = new MemoryStream(); stream.Write(420U, Endianness.BigEndian); @@ -55,8 +51,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt32_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteUInt32_ShouldWriteLittleEndian_GivenLittleEndian() { using var stream = new MemoryStream(); stream.Write(420U, Endianness.LittleEndian); diff --git a/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs b/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs index 51a44f5..dad8cc4 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs @@ -3,11 +3,10 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - public void WriteUInt64_ShouldThrowArgumentException_GivenNonWriteableStream() + public void WriteUInt64_ShouldThrowArgumentException_GivenNonWriteableStream() { Stream stream = new DummyStream(); Assert.Throws(() => stream.Write(420UL, Endianness.LittleEndian)); @@ -15,8 +14,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt64_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteUInt64_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; Assert.Throws(() => stream.Write(420UL, Endianness.LittleEndian)); @@ -24,8 +22,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt64_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void WriteUInt64_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() { // we don't need to enclose this stream in a using declaration, since disposing a // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. @@ -38,8 +35,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt64_ShouldWriteBigEndian_GivenBigEndian() + public void WriteUInt64_ShouldWriteBigEndian_GivenBigEndian() { using var stream = new MemoryStream(); stream.Write(420UL, Endianness.BigEndian); @@ -55,8 +51,7 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - public void WriteUInt64_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteUInt64_ShouldWriteLittleEndian_GivenLittleEndian() { using var stream = new MemoryStream(); stream.Write(420UL, Endianness.LittleEndian); diff --git a/X10D.Tests/src/IO/StreamTests.cs b/X10D.Tests/src/IO/StreamTests.cs index 01e4684..e240990 100644 --- a/X10D.Tests/src/IO/StreamTests.cs +++ b/X10D.Tests/src/IO/StreamTests.cs @@ -7,7 +7,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public partial class StreamTests +internal partial class StreamTests { [Test] public void GetHashSha1ShouldBeCorrect() diff --git a/X10D.Tests/src/IO/TextReaderTests.cs b/X10D.Tests/src/IO/TextReaderTests.cs index a2bafbc..a6ff77e 100644 --- a/X10D.Tests/src/IO/TextReaderTests.cs +++ b/X10D.Tests/src/IO/TextReaderTests.cs @@ -5,7 +5,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class TextReaderTests +internal class TextReaderTests { [Test] public void EnumerateLines_ShouldYield10Lines_Given10LineString() diff --git a/X10D.Tests/src/IO/TextWriterTests.Double.cs b/X10D.Tests/src/IO/TextWriterTests.Double.cs index 6f6ed7f..0eb9361 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Double.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Double.cs @@ -5,7 +5,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class TextWriterTests +internal partial class TextWriterTests { [Test] public void WriteNoAlloc_ShouldThrowArgumentNullException_GivenDouble_AndNullWriter() diff --git a/X10D.Tests/src/IO/TextWriterTests.Int32.cs b/X10D.Tests/src/IO/TextWriterTests.Int32.cs index 31bed11..46d13b6 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Int32.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Int32.cs @@ -5,7 +5,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class TextWriterTests +internal partial class TextWriterTests { [Test] public void WriteNoAlloc_ShouldThrowArgumentNullException_GivenInt32_AndNullWriter() diff --git a/X10D.Tests/src/IO/TextWriterTests.Int64.cs b/X10D.Tests/src/IO/TextWriterTests.Int64.cs index affd830..f9b10b4 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Int64.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Int64.cs @@ -5,7 +5,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class TextWriterTests +internal partial class TextWriterTests { [Test] public void WriteNoAlloc_ShouldThrowArgumentNullException_GivenInt64_AndNullWriter() diff --git a/X10D.Tests/src/IO/TextWriterTests.Single.cs b/X10D.Tests/src/IO/TextWriterTests.Single.cs index 3ccba4f..35629b3 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Single.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Single.cs @@ -5,7 +5,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class TextWriterTests +internal partial class TextWriterTests { [Test] public void WriteNoAlloc_ShouldThrowArgumentNullException_GivenSingle_AndNullWriter() diff --git a/X10D.Tests/src/IO/TextWriterTests.UInt32.cs b/X10D.Tests/src/IO/TextWriterTests.UInt32.cs index 8aab080..5b35c99 100644 --- a/X10D.Tests/src/IO/TextWriterTests.UInt32.cs +++ b/X10D.Tests/src/IO/TextWriterTests.UInt32.cs @@ -5,7 +5,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class TextWriterTests +internal partial class TextWriterTests { [Test] public void WriteNoAlloc_ShouldThrowArgumentNullException_GivenUInt32_AndNullWriter() diff --git a/X10D.Tests/src/IO/TextWriterTests.UInt64.cs b/X10D.Tests/src/IO/TextWriterTests.UInt64.cs index 57f5425..a7b4551 100644 --- a/X10D.Tests/src/IO/TextWriterTests.UInt64.cs +++ b/X10D.Tests/src/IO/TextWriterTests.UInt64.cs @@ -5,7 +5,7 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class TextWriterTests +internal partial class TextWriterTests { [Test] public void WriteNoAlloc_ShouldThrowArgumentNullException_GivenUInt64_AndNullWriter() diff --git a/X10D.Tests/src/IO/TextWriterTests.cs b/X10D.Tests/src/IO/TextWriterTests.cs index 750b352..6c0945b 100644 --- a/X10D.Tests/src/IO/TextWriterTests.cs +++ b/X10D.Tests/src/IO/TextWriterTests.cs @@ -1,11 +1,13 @@ using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Text; using NUnit.Framework; namespace X10D.Tests.IO; [TestFixture] -public partial class TextWriterTests +[SuppressMessage("Design", "CA1001:Types that own disposable fields should be disposable")] +internal partial class TextWriterTests { private MemoryStream _stream = null!; private StreamWriter _writer = null!; diff --git a/X10D.Tests/src/IO/UInt16Tests.cs b/X10D.Tests/src/IO/UInt16Tests.cs index 4e0e4bc..6085358 100644 --- a/X10D.Tests/src/IO/UInt16Tests.cs +++ b/X10D.Tests/src/IO/UInt16Tests.cs @@ -4,8 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -[CLSCompliant(false)] -public class UInt16Tests +internal class UInt16Tests { [Test] public void GetBytes_ReturnsCorrectValue() diff --git a/X10D.Tests/src/IO/UInt32Tests.cs b/X10D.Tests/src/IO/UInt32Tests.cs index 910aa50..a04ea4b 100644 --- a/X10D.Tests/src/IO/UInt32Tests.cs +++ b/X10D.Tests/src/IO/UInt32Tests.cs @@ -4,8 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -[CLSCompliant(false)] -public class UInt32Tests +internal class UInt32Tests { [Test] public void GetBytes_ReturnsCorrectValue() diff --git a/X10D.Tests/src/IO/UInt64Tests.cs b/X10D.Tests/src/IO/UInt64Tests.cs index 374444f..af5727d 100644 --- a/X10D.Tests/src/IO/UInt64Tests.cs +++ b/X10D.Tests/src/IO/UInt64Tests.cs @@ -4,8 +4,7 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -[CLSCompliant(false)] -public class UInt64Tests +internal class UInt64Tests { [Test] public void GetBytes_ReturnsCorrectValue() diff --git a/X10D.Tests/src/Linq/ByteTests.cs b/X10D.Tests/src/Linq/ByteTests.cs index ccaf696..0ece8b6 100644 --- a/X10D.Tests/src/Linq/ByteTests.cs +++ b/X10D.Tests/src/Linq/ByteTests.cs @@ -4,7 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class ByteTests +internal class ByteTests { [Test] public void ProductShouldBeCorrect() diff --git a/X10D.Tests/src/Linq/DecimalTests.cs b/X10D.Tests/src/Linq/DecimalTests.cs index 93a73b5..db0e66b 100644 --- a/X10D.Tests/src/Linq/DecimalTests.cs +++ b/X10D.Tests/src/Linq/DecimalTests.cs @@ -4,7 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class DecimalTests +internal class DecimalTests { [Test] public void ProductShouldBeCorrect() diff --git a/X10D.Tests/src/Linq/DoubleTests.cs b/X10D.Tests/src/Linq/DoubleTests.cs index b5234c2..01399ea 100644 --- a/X10D.Tests/src/Linq/DoubleTests.cs +++ b/X10D.Tests/src/Linq/DoubleTests.cs @@ -4,7 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class DoubleTests +internal class DoubleTests { [Test] public void ProductShouldBeCorrect() diff --git a/X10D.Tests/src/Linq/EnumerableTests.cs b/X10D.Tests/src/Linq/EnumerableTests.cs index 8189443..253690a 100644 --- a/X10D.Tests/src/Linq/EnumerableTests.cs +++ b/X10D.Tests/src/Linq/EnumerableTests.cs @@ -4,7 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class EnumerableTests +internal class EnumerableTests { [Test] public void Except_ShouldFilterElements_GivenMatchingElements() diff --git a/X10D.Tests/src/Linq/Int16Tests.cs b/X10D.Tests/src/Linq/Int16Tests.cs index 2a8459d..76a6a48 100644 --- a/X10D.Tests/src/Linq/Int16Tests.cs +++ b/X10D.Tests/src/Linq/Int16Tests.cs @@ -4,7 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class Int16Tests +internal class Int16Tests { [Test] public void ProductShouldBeCorrect() diff --git a/X10D.Tests/src/Linq/Int32Tests.cs b/X10D.Tests/src/Linq/Int32Tests.cs index 93b6f5a..5f8422a 100644 --- a/X10D.Tests/src/Linq/Int32Tests.cs +++ b/X10D.Tests/src/Linq/Int32Tests.cs @@ -4,7 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class Int32Tests +internal class Int32Tests { [Test] public void ProductShouldBeCorrect() diff --git a/X10D.Tests/src/Linq/Int64Tests.cs b/X10D.Tests/src/Linq/Int64Tests.cs index 61f1932..aad0738 100644 --- a/X10D.Tests/src/Linq/Int64Tests.cs +++ b/X10D.Tests/src/Linq/Int64Tests.cs @@ -4,7 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class Int64Tests +internal class Int64Tests { [Test] public void ProductShouldBeCorrect() diff --git a/X10D.Tests/src/Linq/ReadOnlySpanTests.cs b/X10D.Tests/src/Linq/ReadOnlySpanTests.cs index 05787b9..da74e71 100644 --- a/X10D.Tests/src/Linq/ReadOnlySpanTests.cs +++ b/X10D.Tests/src/Linq/ReadOnlySpanTests.cs @@ -4,7 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class ReadOnlySpanTests +internal class ReadOnlySpanTests { [Test] public void AllShouldReturnTrueForEmptySpan() diff --git a/X10D.Tests/src/Linq/SByteTests.cs b/X10D.Tests/src/Linq/SByteTests.cs index 5d5e0b8..a859279 100644 --- a/X10D.Tests/src/Linq/SByteTests.cs +++ b/X10D.Tests/src/Linq/SByteTests.cs @@ -4,8 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -[CLSCompliant(false)] -public class SByteTests +internal class SByteTests { [Test] public void ProductShouldBeCorrect() diff --git a/X10D.Tests/src/Linq/SingleTests.cs b/X10D.Tests/src/Linq/SingleTests.cs index 3a1a866..0bac265 100644 --- a/X10D.Tests/src/Linq/SingleTests.cs +++ b/X10D.Tests/src/Linq/SingleTests.cs @@ -4,7 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class SingleTests +internal class SingleTests { [Test] public void ProductShouldBeCorrect() diff --git a/X10D.Tests/src/Linq/SpanTests.cs b/X10D.Tests/src/Linq/SpanTests.cs index 624a399..05d60f5 100644 --- a/X10D.Tests/src/Linq/SpanTests.cs +++ b/X10D.Tests/src/Linq/SpanTests.cs @@ -4,7 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class SpanTests +internal class SpanTests { [Test] public void AllShouldReturnTrueForEmptySpan() diff --git a/X10D.Tests/src/Linq/UInt16Tests.cs b/X10D.Tests/src/Linq/UInt16Tests.cs index 2742fc0..8abfc97 100644 --- a/X10D.Tests/src/Linq/UInt16Tests.cs +++ b/X10D.Tests/src/Linq/UInt16Tests.cs @@ -4,8 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -[CLSCompliant(false)] -public class UInt16Tests +internal class UInt16Tests { [Test] public void ProductShouldBeCorrect() diff --git a/X10D.Tests/src/Linq/UInt32Tests.cs b/X10D.Tests/src/Linq/UInt32Tests.cs index 2435f17..20d1217 100644 --- a/X10D.Tests/src/Linq/UInt32Tests.cs +++ b/X10D.Tests/src/Linq/UInt32Tests.cs @@ -4,8 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -[CLSCompliant(false)] -public class UInt32Tests +internal class UInt32Tests { [Test] public void ProductShouldBeCorrect() diff --git a/X10D.Tests/src/Linq/UInt64Tests.cs b/X10D.Tests/src/Linq/UInt64Tests.cs index bbaa2fc..64710d3 100644 --- a/X10D.Tests/src/Linq/UInt64Tests.cs +++ b/X10D.Tests/src/Linq/UInt64Tests.cs @@ -4,8 +4,7 @@ using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -[CLSCompliant(false)] -public class UInt64Tests +internal class UInt64Tests { [Test] public void ProductShouldBeCorrect() diff --git a/X10D.Tests/src/Math/BigIntegerTests.Wrap.cs b/X10D.Tests/src/Math/BigIntegerTests.Wrap.cs index d3fff35..ecff3df 100644 --- a/X10D.Tests/src/Math/BigIntegerTests.Wrap.cs +++ b/X10D.Tests/src/Math/BigIntegerTests.Wrap.cs @@ -4,7 +4,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class BigIntegerTests +internal partial class BigIntegerTests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/BigIntegerTests.cs b/X10D.Tests/src/Math/BigIntegerTests.cs index 2151798..80c0cec 100644 --- a/X10D.Tests/src/Math/BigIntegerTests.cs +++ b/X10D.Tests/src/Math/BigIntegerTests.cs @@ -5,7 +5,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -public partial class BigIntegerTests +internal partial class BigIntegerTests { [Test] public void CountDigits_ShouldReturn1_Given0() diff --git a/X10D.Tests/src/Math/ByteTests.Wrap.cs b/X10D.Tests/src/Math/ByteTests.Wrap.cs index d7303e8..91c214f 100644 --- a/X10D.Tests/src/Math/ByteTests.Wrap.cs +++ b/X10D.Tests/src/Math/ByteTests.Wrap.cs @@ -3,7 +3,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class ByteTests +internal partial class ByteTests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/ByteTests.cs b/X10D.Tests/src/Math/ByteTests.cs index 3419f3e..0d80790 100644 --- a/X10D.Tests/src/Math/ByteTests.cs +++ b/X10D.Tests/src/Math/ByteTests.cs @@ -4,7 +4,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -public partial class ByteTests +internal partial class ByteTests { [Test] public void CountDigits_ShouldReturn1_Given0() diff --git a/X10D.Tests/src/Math/ComparableTests.cs b/X10D.Tests/src/Math/ComparableTests.cs index 80ee06a..cb90266 100644 --- a/X10D.Tests/src/Math/ComparableTests.cs +++ b/X10D.Tests/src/Math/ComparableTests.cs @@ -4,7 +4,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -public class ComparableTests +internal class ComparableTests { private class ComparableTestClass : IComparable { diff --git a/X10D.Tests/src/Math/DecimalTests.Wrap.cs b/X10D.Tests/src/Math/DecimalTests.Wrap.cs index 8b92e8c..1408043 100644 --- a/X10D.Tests/src/Math/DecimalTests.Wrap.cs +++ b/X10D.Tests/src/Math/DecimalTests.Wrap.cs @@ -3,7 +3,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class DecimalTests +internal partial class DecimalTests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/DecimalTests.cs b/X10D.Tests/src/Math/DecimalTests.cs index b93f415..8c4b31e 100644 --- a/X10D.Tests/src/Math/DecimalTests.cs +++ b/X10D.Tests/src/Math/DecimalTests.cs @@ -5,7 +5,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -public partial class DecimalTests +internal partial class DecimalTests { [Test] public void ComplexSqrt_ShouldBeCorrect_GivenReal() diff --git a/X10D.Tests/src/Math/DoubleTests.Wrap.cs b/X10D.Tests/src/Math/DoubleTests.Wrap.cs index b6c15f8..fdc5ada 100644 --- a/X10D.Tests/src/Math/DoubleTests.Wrap.cs +++ b/X10D.Tests/src/Math/DoubleTests.Wrap.cs @@ -3,7 +3,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class DoubleTests +internal partial class DoubleTests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/DoubleTests.cs b/X10D.Tests/src/Math/DoubleTests.cs index 07a7bff..3929b24 100644 --- a/X10D.Tests/src/Math/DoubleTests.cs +++ b/X10D.Tests/src/Math/DoubleTests.cs @@ -5,7 +5,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -public partial class DoubleTests +internal partial class DoubleTests { [Test] public void DegreesToRadians_ShouldBeCorrect() diff --git a/X10D.Tests/src/Math/Int16Tests.Wrap.cs b/X10D.Tests/src/Math/Int16Tests.Wrap.cs index bdd290a..b5f20d7 100644 --- a/X10D.Tests/src/Math/Int16Tests.Wrap.cs +++ b/X10D.Tests/src/Math/Int16Tests.Wrap.cs @@ -3,7 +3,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class Int16Tests +internal partial class Int16Tests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/Int16Tests.cs b/X10D.Tests/src/Math/Int16Tests.cs index 3823264..5612e4b 100644 --- a/X10D.Tests/src/Math/Int16Tests.cs +++ b/X10D.Tests/src/Math/Int16Tests.cs @@ -4,7 +4,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -public partial class Int16Tests +internal partial class Int16Tests { [Test] public void CountDigits_ShouldReturn1_Given0() diff --git a/X10D.Tests/src/Math/Int32Tests.Wrap.cs b/X10D.Tests/src/Math/Int32Tests.Wrap.cs index 306ac09..754ae48 100644 --- a/X10D.Tests/src/Math/Int32Tests.Wrap.cs +++ b/X10D.Tests/src/Math/Int32Tests.Wrap.cs @@ -3,7 +3,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class Int32Tests +internal partial class Int32Tests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/Int32Tests.cs b/X10D.Tests/src/Math/Int32Tests.cs index 7711d3d..0bfbf25 100644 --- a/X10D.Tests/src/Math/Int32Tests.cs +++ b/X10D.Tests/src/Math/Int32Tests.cs @@ -4,7 +4,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -public partial class Int32Tests +internal partial class Int32Tests { [Test] public void CountDigits_ShouldReturn1_Given0() diff --git a/X10D.Tests/src/Math/Int64Tests.Wrap.cs b/X10D.Tests/src/Math/Int64Tests.Wrap.cs index c8985d3..6434295 100644 --- a/X10D.Tests/src/Math/Int64Tests.Wrap.cs +++ b/X10D.Tests/src/Math/Int64Tests.Wrap.cs @@ -3,7 +3,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class Int64Tests +internal partial class Int64Tests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/Int64Tests.cs b/X10D.Tests/src/Math/Int64Tests.cs index 557e0b0..bd5f524 100644 --- a/X10D.Tests/src/Math/Int64Tests.cs +++ b/X10D.Tests/src/Math/Int64Tests.cs @@ -4,7 +4,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -public partial class Int64Tests +internal partial class Int64Tests { [Test] public void CountDigits_ShouldReturn1_Given0() diff --git a/X10D.Tests/src/Math/IsPrimeTests.cs b/X10D.Tests/src/Math/IsPrimeTests.cs index 3af4499..4d50e68 100644 --- a/X10D.Tests/src/Math/IsPrimeTests.cs +++ b/X10D.Tests/src/Math/IsPrimeTests.cs @@ -7,7 +7,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -public class IsPrimeTests +internal class IsPrimeTests { private IReadOnlyList _primeNumbers = ArraySegment.Empty; diff --git a/X10D.Tests/src/Math/MathUtilityTests.cs b/X10D.Tests/src/Math/MathUtilityTests.cs index 0989e44..01028a2 100644 --- a/X10D.Tests/src/Math/MathUtilityTests.cs +++ b/X10D.Tests/src/Math/MathUtilityTests.cs @@ -7,7 +7,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -public class MathUtilityTests +internal class MathUtilityTests { [Test] public void Bias_ReturnsCorrectResult_WhenBiasIsLessThanPointFive() diff --git a/X10D.Tests/src/Math/SByteTests.Wrap.cs b/X10D.Tests/src/Math/SByteTests.Wrap.cs index eaecb3c..dd7b9b9 100644 --- a/X10D.Tests/src/Math/SByteTests.Wrap.cs +++ b/X10D.Tests/src/Math/SByteTests.Wrap.cs @@ -3,7 +3,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class SByteTests +internal partial class SByteTests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/SByteTests.cs b/X10D.Tests/src/Math/SByteTests.cs index 454e35f..9550cfb 100644 --- a/X10D.Tests/src/Math/SByteTests.cs +++ b/X10D.Tests/src/Math/SByteTests.cs @@ -4,8 +4,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -[CLSCompliant(false)] -public partial class SByteTests +internal partial class SByteTests { [Test] public void CountDigits_ShouldReturn1_Given0() diff --git a/X10D.Tests/src/Math/SingleTests.Wrap.cs b/X10D.Tests/src/Math/SingleTests.Wrap.cs index 9430e9a..596a40a 100644 --- a/X10D.Tests/src/Math/SingleTests.Wrap.cs +++ b/X10D.Tests/src/Math/SingleTests.Wrap.cs @@ -3,7 +3,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class SingleTests +internal partial class SingleTests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/SingleTests.cs b/X10D.Tests/src/Math/SingleTests.cs index f13ec65..5e50fe7 100644 --- a/X10D.Tests/src/Math/SingleTests.cs +++ b/X10D.Tests/src/Math/SingleTests.cs @@ -5,7 +5,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -public partial class SingleTests +internal partial class SingleTests { [Test] public void DegreesToRadians_ShouldBeCorrect() diff --git a/X10D.Tests/src/Math/UInt16Tests.Wrap.cs b/X10D.Tests/src/Math/UInt16Tests.Wrap.cs index 6f21662..e5be525 100644 --- a/X10D.Tests/src/Math/UInt16Tests.Wrap.cs +++ b/X10D.Tests/src/Math/UInt16Tests.Wrap.cs @@ -3,7 +3,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class UInt16Tests +internal partial class UInt16Tests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/UInt16Tests.cs b/X10D.Tests/src/Math/UInt16Tests.cs index f123de7..c6f38ad 100644 --- a/X10D.Tests/src/Math/UInt16Tests.cs +++ b/X10D.Tests/src/Math/UInt16Tests.cs @@ -4,8 +4,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -[CLSCompliant(false)] -public partial class UInt16Tests +internal partial class UInt16Tests { [Test] public void CountDigits_ShouldReturn1_Given0() diff --git a/X10D.Tests/src/Math/UInt32Tests.Wrap.cs b/X10D.Tests/src/Math/UInt32Tests.Wrap.cs index a46ee45..572f71c 100644 --- a/X10D.Tests/src/Math/UInt32Tests.Wrap.cs +++ b/X10D.Tests/src/Math/UInt32Tests.Wrap.cs @@ -3,7 +3,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class UInt32Tests +internal partial class UInt32Tests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/UInt32Tests.cs b/X10D.Tests/src/Math/UInt32Tests.cs index a6c2911..5c161ff 100644 --- a/X10D.Tests/src/Math/UInt32Tests.cs +++ b/X10D.Tests/src/Math/UInt32Tests.cs @@ -4,8 +4,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -[CLSCompliant(false)] -public partial class UInt32Tests +internal partial class UInt32Tests { [Test] public void CountDigits_ShouldReturn1_Given0() diff --git a/X10D.Tests/src/Math/UInt64Tests.Wrap.cs b/X10D.Tests/src/Math/UInt64Tests.Wrap.cs index a99e8ad..7307589 100644 --- a/X10D.Tests/src/Math/UInt64Tests.Wrap.cs +++ b/X10D.Tests/src/Math/UInt64Tests.Wrap.cs @@ -3,7 +3,7 @@ using X10D.Math; namespace X10D.Tests.Math; -public partial class UInt64Tests +internal partial class UInt64Tests { [TestFixture] public class WrapTests diff --git a/X10D.Tests/src/Math/UInt64Tests.cs b/X10D.Tests/src/Math/UInt64Tests.cs index 6d05b4d..909548f 100644 --- a/X10D.Tests/src/Math/UInt64Tests.cs +++ b/X10D.Tests/src/Math/UInt64Tests.cs @@ -4,8 +4,7 @@ using X10D.Math; namespace X10D.Tests.Math; [TestFixture] -[CLSCompliant(false)] -public partial class UInt64Tests +internal partial class UInt64Tests { [Test] public void CountDigits_ShouldReturn1_Given0() diff --git a/X10D.Tests/src/Net/EndPointTests.cs b/X10D.Tests/src/Net/EndPointTests.cs index eb69138..7dca5cf 100644 --- a/X10D.Tests/src/Net/EndPointTests.cs +++ b/X10D.Tests/src/Net/EndPointTests.cs @@ -5,7 +5,7 @@ using X10D.Net; namespace X10D.Tests.Net; [TestFixture] -public class EndPointTests +internal class EndPointTests { [Test] public void GetHost_ShouldBeLocalhost_GivenLocalhostDnsEndPoint() diff --git a/X10D.Tests/src/Net/IPAddressTests.cs b/X10D.Tests/src/Net/IPAddressTests.cs index de0f8eb..ab48f24 100644 --- a/X10D.Tests/src/Net/IPAddressTests.cs +++ b/X10D.Tests/src/Net/IPAddressTests.cs @@ -5,7 +5,7 @@ using X10D.Net; namespace X10D.Tests.Net; [TestFixture] -public class IPAddressTests +internal class IPAddressTests { private IPAddress _ipv4Address = null!; private IPAddress _ipv6Address = null!; diff --git a/X10D.Tests/src/Net/Int16Tests.cs b/X10D.Tests/src/Net/Int16Tests.cs index 4a850c7..310a183 100644 --- a/X10D.Tests/src/Net/Int16Tests.cs +++ b/X10D.Tests/src/Net/Int16Tests.cs @@ -4,7 +4,7 @@ using X10D.Net; namespace X10D.Tests.Net; [TestFixture] -public class Int16Tests +internal class Int16Tests { [Test] public void HostToNetworkOrder_ReturnsCorrectValue() diff --git a/X10D.Tests/src/Net/Int32Tests.cs b/X10D.Tests/src/Net/Int32Tests.cs index 7e876ec..50b8899 100644 --- a/X10D.Tests/src/Net/Int32Tests.cs +++ b/X10D.Tests/src/Net/Int32Tests.cs @@ -4,7 +4,7 @@ using X10D.Net; namespace X10D.Tests.Net; [TestFixture] -public class Int32Tests +internal class Int32Tests { [Test] public void HostToNetworkOrder_ReturnsCorrectValue() diff --git a/X10D.Tests/src/Net/Int64Tests.cs b/X10D.Tests/src/Net/Int64Tests.cs index 2e1bc76..a2150e1 100644 --- a/X10D.Tests/src/Net/Int64Tests.cs +++ b/X10D.Tests/src/Net/Int64Tests.cs @@ -4,7 +4,7 @@ using X10D.Net; namespace X10D.Tests.Net; [TestFixture] -public class Int64Tests +internal class Int64Tests { [Test] public void HostToNetworkOrder_ReturnsCorrectValue() diff --git a/X10D.Tests/src/Numerics/ByteTests.cs b/X10D.Tests/src/Numerics/ByteTests.cs index 6257ea3..4a191b7 100644 --- a/X10D.Tests/src/Numerics/ByteTests.cs +++ b/X10D.Tests/src/Numerics/ByteTests.cs @@ -4,7 +4,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -public class ByteTests +internal class ByteTests { [Test] public void PopCount_ShouldBe0_Given0() diff --git a/X10D.Tests/src/Numerics/Int16Tests.cs b/X10D.Tests/src/Numerics/Int16Tests.cs index 3058845..73a0025 100644 --- a/X10D.Tests/src/Numerics/Int16Tests.cs +++ b/X10D.Tests/src/Numerics/Int16Tests.cs @@ -4,7 +4,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -public class Int16Tests +internal class Int16Tests { [Test] public void PopCount_ShouldBe0_Given0() diff --git a/X10D.Tests/src/Numerics/Int32Tests.cs b/X10D.Tests/src/Numerics/Int32Tests.cs index db0d7a3..36b3c1d 100644 --- a/X10D.Tests/src/Numerics/Int32Tests.cs +++ b/X10D.Tests/src/Numerics/Int32Tests.cs @@ -4,7 +4,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -public class Int32Tests +internal class Int32Tests { [Test] public void PopCount_ShouldBe0_Given0() diff --git a/X10D.Tests/src/Numerics/Int64Tests.cs b/X10D.Tests/src/Numerics/Int64Tests.cs index e6253ca..c4c7c7b 100644 --- a/X10D.Tests/src/Numerics/Int64Tests.cs +++ b/X10D.Tests/src/Numerics/Int64Tests.cs @@ -4,7 +4,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -public class Int64Tests +internal class Int64Tests { [Test] public void PopCount_ShouldBe0_Given0() diff --git a/X10D.Tests/src/Numerics/QuaternionTests.cs b/X10D.Tests/src/Numerics/QuaternionTests.cs index 3d81754..ce33ad2 100644 --- a/X10D.Tests/src/Numerics/QuaternionTests.cs +++ b/X10D.Tests/src/Numerics/QuaternionTests.cs @@ -5,7 +5,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -public class QuaternionTests +internal class QuaternionTests { [Test] public void ToAxisAngle_ShouldGiveAngle180VectorZero_GivenQuaternion() diff --git a/X10D.Tests/src/Numerics/RandomTests.cs b/X10D.Tests/src/Numerics/RandomTests.cs index 5f70b31..38b1716 100644 --- a/X10D.Tests/src/Numerics/RandomTests.cs +++ b/X10D.Tests/src/Numerics/RandomTests.cs @@ -4,7 +4,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -public class RandomTests +internal class RandomTests { [Test] public void NextUnitVector2_ShouldReturnVector_WithMagnitude1() diff --git a/X10D.Tests/src/Numerics/SByteTests.cs b/X10D.Tests/src/Numerics/SByteTests.cs index a161831..72132bc 100644 --- a/X10D.Tests/src/Numerics/SByteTests.cs +++ b/X10D.Tests/src/Numerics/SByteTests.cs @@ -4,8 +4,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -[CLSCompliant(false)] -public class SByteTests +internal class SByteTests { [Test] public void PopCount_ShouldBe0_Given0() diff --git a/X10D.Tests/src/Numerics/UInt16Tests.cs b/X10D.Tests/src/Numerics/UInt16Tests.cs index 89553d7..585f479 100644 --- a/X10D.Tests/src/Numerics/UInt16Tests.cs +++ b/X10D.Tests/src/Numerics/UInt16Tests.cs @@ -4,8 +4,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -[CLSCompliant(false)] -public class UInt16Tests +internal class UInt16Tests { [Test] public void PopCount_ShouldBe0_Given0() diff --git a/X10D.Tests/src/Numerics/UInt32Tests.cs b/X10D.Tests/src/Numerics/UInt32Tests.cs index eb15df5..da77d5b 100644 --- a/X10D.Tests/src/Numerics/UInt32Tests.cs +++ b/X10D.Tests/src/Numerics/UInt32Tests.cs @@ -4,8 +4,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -[CLSCompliant(false)] -public class UInt32Tests +internal class UInt32Tests { [Test] public void PopCount_ShouldBe0_Given0() diff --git a/X10D.Tests/src/Numerics/UInt64Tests.cs b/X10D.Tests/src/Numerics/UInt64Tests.cs index 7663aa3..d01bd39 100644 --- a/X10D.Tests/src/Numerics/UInt64Tests.cs +++ b/X10D.Tests/src/Numerics/UInt64Tests.cs @@ -4,8 +4,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -[CLSCompliant(false)] -public class UInt64Tests +internal class UInt64Tests { [Test] public void PopCount_ShouldBe0_Given0() diff --git a/X10D.Tests/src/Numerics/Vector2Tests.cs b/X10D.Tests/src/Numerics/Vector2Tests.cs index cef7bc7..e18688e 100644 --- a/X10D.Tests/src/Numerics/Vector2Tests.cs +++ b/X10D.Tests/src/Numerics/Vector2Tests.cs @@ -9,7 +9,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -public class Vector2Tests +internal class Vector2Tests { [Test] public void Deconstruct_ShouldReturnCorrectValues() diff --git a/X10D.Tests/src/Numerics/Vector3Tests.cs b/X10D.Tests/src/Numerics/Vector3Tests.cs index 402f94b..23c1795 100644 --- a/X10D.Tests/src/Numerics/Vector3Tests.cs +++ b/X10D.Tests/src/Numerics/Vector3Tests.cs @@ -5,7 +5,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -public class Vector3Tests +internal class Vector3Tests { [Test] public void Deconstruct_ShouldReturnCorrectValues() diff --git a/X10D.Tests/src/Numerics/Vector4Tests.cs b/X10D.Tests/src/Numerics/Vector4Tests.cs index 3c1ba1f..108fb47 100644 --- a/X10D.Tests/src/Numerics/Vector4Tests.cs +++ b/X10D.Tests/src/Numerics/Vector4Tests.cs @@ -5,7 +5,7 @@ using X10D.Numerics; namespace X10D.Tests.Numerics; [TestFixture] -public class Vector4Tests +internal class Vector4Tests { [Test] public void Deconstruct_ShouldReturnCorrectValues() diff --git a/X10D.Tests/src/Reactive/ProgressTests.cs b/X10D.Tests/src/Reactive/ProgressTests.cs index fce2683..e18ed39 100644 --- a/X10D.Tests/src/Reactive/ProgressTests.cs +++ b/X10D.Tests/src/Reactive/ProgressTests.cs @@ -4,7 +4,7 @@ using X10D.Reactive; namespace X10D.Tests.Reactive; [TestFixture] -public class ProgressTests +internal class ProgressTests { [Test] public void OnProgressChanged_ShouldCallCompletionDelegate_GivenCompletionValue() diff --git a/X10D.Tests/src/Reflection/MemberInfoTests.cs b/X10D.Tests/src/Reflection/MemberInfoTests.cs index edc2ebf..bbb0952 100644 --- a/X10D.Tests/src/Reflection/MemberInfoTests.cs +++ b/X10D.Tests/src/Reflection/MemberInfoTests.cs @@ -5,7 +5,7 @@ using X10D.Reflection; namespace X10D.Tests.Reflection; [TestFixture] -public class MemberInfoTests +internal class MemberInfoTests { [Test] public void HasCustomAttribute_ShouldBeTrue_GivenCLSCompliantAttributeOnUnsignedTypes() diff --git a/X10D.Tests/src/Reflection/TypeTests.cs b/X10D.Tests/src/Reflection/TypeTests.cs index 0dc24a1..f474b97 100644 --- a/X10D.Tests/src/Reflection/TypeTests.cs +++ b/X10D.Tests/src/Reflection/TypeTests.cs @@ -4,7 +4,7 @@ using X10D.Reflection; namespace X10D.Tests.Reflection; [TestFixture] -public class TypeTests +internal class TypeTests { [Test] public void Inherits_ShouldBeTrue_GivenStringInheritsObject() diff --git a/X10D.Tests/src/Text/CharSpanTests.cs b/X10D.Tests/src/Text/CharSpanTests.cs index 27d9dc5..683f7c0 100644 --- a/X10D.Tests/src/Text/CharSpanTests.cs +++ b/X10D.Tests/src/Text/CharSpanTests.cs @@ -4,7 +4,7 @@ using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class CharSpanTests +internal class CharSpanTests { [Test] public void CountSubstring_ShouldHonor_StringComparison() diff --git a/X10D.Tests/src/Text/CharTests.cs b/X10D.Tests/src/Text/CharTests.cs index 602acba..cf17cdf 100644 --- a/X10D.Tests/src/Text/CharTests.cs +++ b/X10D.Tests/src/Text/CharTests.cs @@ -4,7 +4,7 @@ using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class CharTests +internal class CharTests { [Test] public void IsEmoji_ShouldReturnTrue_GivenBasicEmoji() diff --git a/X10D.Tests/src/Text/CoreTests.cs b/X10D.Tests/src/Text/CoreTests.cs index 4ed8903..bbd114c 100644 --- a/X10D.Tests/src/Text/CoreTests.cs +++ b/X10D.Tests/src/Text/CoreTests.cs @@ -4,7 +4,7 @@ using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class CoreTests +internal class CoreTests { #if NET5_0_OR_GREATER [Test] diff --git a/X10D.Tests/src/Text/EnumerableTests.cs b/X10D.Tests/src/Text/EnumerableTests.cs index a7b7c86..8e6ecd1 100644 --- a/X10D.Tests/src/Text/EnumerableTests.cs +++ b/X10D.Tests/src/Text/EnumerableTests.cs @@ -4,7 +4,7 @@ using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class EnumerableTests +internal class EnumerableTests { [Test] public void Grep_ShouldFilterCorrectly_GivenPattern() diff --git a/X10D.Tests/src/Text/RuneTests.cs b/X10D.Tests/src/Text/RuneTests.cs index d5a6946..49c13e4 100644 --- a/X10D.Tests/src/Text/RuneTests.cs +++ b/X10D.Tests/src/Text/RuneTests.cs @@ -6,7 +6,7 @@ using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class RuneTests +internal class RuneTests { [Test] public void IsEmoji_ShouldReturnTrue_GivenBasicEmoji() diff --git a/X10D.Tests/src/Text/StringBuilderReaderTests.cs b/X10D.Tests/src/Text/StringBuilderReaderTests.cs index b6557ad..07e8849 100644 --- a/X10D.Tests/src/Text/StringBuilderReaderTests.cs +++ b/X10D.Tests/src/Text/StringBuilderReaderTests.cs @@ -5,7 +5,7 @@ using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class StringBuilderReaderTests +internal class StringBuilderReaderTests { [Test] public void Peek_ShouldReturnNextChar_GivenBuilder() diff --git a/X10D.Tests/src/Text/StringTests.cs b/X10D.Tests/src/Text/StringTests.cs index 6c94343..336cafb 100644 --- a/X10D.Tests/src/Text/StringTests.cs +++ b/X10D.Tests/src/Text/StringTests.cs @@ -8,7 +8,7 @@ using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class StringTests +internal class StringTests { [Test] public void AsNullIfEmpty_ShouldBeCorrect() diff --git a/X10D.Tests/src/Time/ByteTests.cs b/X10D.Tests/src/Time/ByteTests.cs index c046241..7c3a3ed 100644 --- a/X10D.Tests/src/Time/ByteTests.cs +++ b/X10D.Tests/src/Time/ByteTests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class ByteTests +internal class ByteTests { [Test] public void FromUnixTimeMilliseconds_ShouldBeEpoch_GivenZero() diff --git a/X10D.Tests/src/Time/CharSpanTests.cs b/X10D.Tests/src/Time/CharSpanTests.cs index ec35528..f420cf0 100644 --- a/X10D.Tests/src/Time/CharSpanTests.cs +++ b/X10D.Tests/src/Time/CharSpanTests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class CharSpanTests +internal class CharSpanTests { [Test] public void ToTimeSpan_ShouldReturnCorrectTimeSpan_GivenSpanOfCharacters() diff --git a/X10D.Tests/src/Time/DateOnlyTests.cs b/X10D.Tests/src/Time/DateOnlyTests.cs index 5135446..bae376b 100644 --- a/X10D.Tests/src/Time/DateOnlyTests.cs +++ b/X10D.Tests/src/Time/DateOnlyTests.cs @@ -5,7 +5,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class DateOnlyTests +internal class DateOnlyTests { [Test] public void Age_ShouldBe17_Given31December1991Birthday_And30December2017Date() diff --git a/X10D.Tests/src/Time/DateTimeOffsetTests.cs b/X10D.Tests/src/Time/DateTimeOffsetTests.cs index 77c8fff..095f988 100644 --- a/X10D.Tests/src/Time/DateTimeOffsetTests.cs +++ b/X10D.Tests/src/Time/DateTimeOffsetTests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class DateTimeOffsetTests +internal class DateTimeOffsetTests { [Test] public void Age_ShouldBe17_Given31December1991Birthday_And30December2017Date() diff --git a/X10D.Tests/src/Time/DateTimeTests.cs b/X10D.Tests/src/Time/DateTimeTests.cs index ed834b3..7dd437c 100644 --- a/X10D.Tests/src/Time/DateTimeTests.cs +++ b/X10D.Tests/src/Time/DateTimeTests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class DateTimeTests +internal class DateTimeTests { [Test] public void Age_ShouldBe17_Given31December1991Birthday_And30December2017Date() diff --git a/X10D.Tests/src/Time/DecimalTests.cs b/X10D.Tests/src/Time/DecimalTests.cs index 6ca948c..f1a2b02 100644 --- a/X10D.Tests/src/Time/DecimalTests.cs +++ b/X10D.Tests/src/Time/DecimalTests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class DecimalTests +internal class DecimalTests { [Test] public void TicksMillisecondsSecondsMinutesDaysHoursWeeks_ShouldBeZero_GivenZero() diff --git a/X10D.Tests/src/Time/DoubleTests.cs b/X10D.Tests/src/Time/DoubleTests.cs index 32164c9..093e466 100644 --- a/X10D.Tests/src/Time/DoubleTests.cs +++ b/X10D.Tests/src/Time/DoubleTests.cs @@ -5,7 +5,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class DoubleTests +internal class DoubleTests { private Half _negativeOne; private Half _one; diff --git a/X10D.Tests/src/Time/HalfTests.cs b/X10D.Tests/src/Time/HalfTests.cs index 7e8acc7..b2f7faf 100644 --- a/X10D.Tests/src/Time/HalfTests.cs +++ b/X10D.Tests/src/Time/HalfTests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class HalfTests +internal class HalfTests { [Test] public void TicksMillisecondsSecondsMinutesDaysHoursWeeks_ShouldBeZero_GivenZero() diff --git a/X10D.Tests/src/Time/Int16Tests.cs b/X10D.Tests/src/Time/Int16Tests.cs index 58ed0e9..f6c40ed 100644 --- a/X10D.Tests/src/Time/Int16Tests.cs +++ b/X10D.Tests/src/Time/Int16Tests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class Int16Tests +internal class Int16Tests { [Test] public void FromUnixTimeMilliseconds_ShouldBeEpoch_GivenZero() diff --git a/X10D.Tests/src/Time/Int32Tests.cs b/X10D.Tests/src/Time/Int32Tests.cs index 6cbad58..f0c258b 100644 --- a/X10D.Tests/src/Time/Int32Tests.cs +++ b/X10D.Tests/src/Time/Int32Tests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class Int32Tests +internal class Int32Tests { [Test] public void FromUnixTimeMilliseconds_ShouldBeEpoch_GivenZero() diff --git a/X10D.Tests/src/Time/Int64Tests.cs b/X10D.Tests/src/Time/Int64Tests.cs index 9b83e67..bf317e8 100644 --- a/X10D.Tests/src/Time/Int64Tests.cs +++ b/X10D.Tests/src/Time/Int64Tests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class Int64Tests +internal class Int64Tests { [Test] public void FromUnixTimeMilliseconds_ShouldBeEpoch_GivenZero() diff --git a/X10D.Tests/src/Time/SByteTests.cs b/X10D.Tests/src/Time/SByteTests.cs index 278469b..7a7de18 100644 --- a/X10D.Tests/src/Time/SByteTests.cs +++ b/X10D.Tests/src/Time/SByteTests.cs @@ -4,8 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -[CLSCompliant(false)] -public class SByteTests +internal class SByteTests { [Test] public void FromUnixTimeMilliseconds_ShouldBeEpoch_GivenZero() diff --git a/X10D.Tests/src/Time/SingleTests.cs b/X10D.Tests/src/Time/SingleTests.cs index cc2f39b..52fbe24 100644 --- a/X10D.Tests/src/Time/SingleTests.cs +++ b/X10D.Tests/src/Time/SingleTests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class SingleTests +internal class SingleTests { [Test] public void TicksMillisecondsSecondsMinutesDaysHoursWeeks_ShouldBeZero_GivenZero() diff --git a/X10D.Tests/src/Time/StringTests.cs b/X10D.Tests/src/Time/StringTests.cs index 8cad134..c74658e 100644 --- a/X10D.Tests/src/Time/StringTests.cs +++ b/X10D.Tests/src/Time/StringTests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class StringTests +internal class StringTests { [Test] public void ToTimeSpan_ShouldReturnCorrectTimeSpan_GivenString() diff --git a/X10D.Tests/src/Time/TimeSpanParserTests.cs b/X10D.Tests/src/Time/TimeSpanParserTests.cs index aa065ce..a5a3aef 100644 --- a/X10D.Tests/src/Time/TimeSpanParserTests.cs +++ b/X10D.Tests/src/Time/TimeSpanParserTests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class TimeSpanParserTests +internal class TimeSpanParserTests { [Test] public void TryParse_ShouldReturnTrue_GivenWellFormedTimeSpan() diff --git a/X10D.Tests/src/Time/TimeSpanTests.cs b/X10D.Tests/src/Time/TimeSpanTests.cs index 20456d5..ca68da3 100644 --- a/X10D.Tests/src/Time/TimeSpanTests.cs +++ b/X10D.Tests/src/Time/TimeSpanTests.cs @@ -4,7 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class TimeSpanTests +internal class TimeSpanTests { private TimeSpan _timeSpan; diff --git a/X10D.Tests/src/Time/UInt16Tests.cs b/X10D.Tests/src/Time/UInt16Tests.cs index 64d327e..d93f58a 100644 --- a/X10D.Tests/src/Time/UInt16Tests.cs +++ b/X10D.Tests/src/Time/UInt16Tests.cs @@ -4,8 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -[CLSCompliant(false)] -public class UInt16Tests +internal class UInt16Tests { [Test] public void FromUnixTimeMilliseconds_ShouldBeEpoch_GivenZero() diff --git a/X10D.Tests/src/Time/UInt32Tests.cs b/X10D.Tests/src/Time/UInt32Tests.cs index 0063fe2..605110f 100644 --- a/X10D.Tests/src/Time/UInt32Tests.cs +++ b/X10D.Tests/src/Time/UInt32Tests.cs @@ -4,8 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -[CLSCompliant(false)] -public class UInt32Tests +internal class UInt32Tests { [Test] public void FromUnixTimeMilliseconds_ShouldBeEpoch_GivenZero() diff --git a/X10D.Tests/src/Time/UInt64Tests.cs b/X10D.Tests/src/Time/UInt64Tests.cs index 48642be..dcd08cd 100644 --- a/X10D.Tests/src/Time/UInt64Tests.cs +++ b/X10D.Tests/src/Time/UInt64Tests.cs @@ -4,8 +4,7 @@ using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -[CLSCompliant(false)] -public class UInt64Tests +internal class UInt64Tests { [Test] public void FromUnixTimeMilliseconds_ShouldBeEpoch_GivenZero() From d17d94a8c1818f0ff18c35a355c2bb4e38c7ea7f Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 17:39:45 +0100 Subject: [PATCH 11/46] chore: suppress NU1701 (#77) --- X10D.Unity/X10D.Unity.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/X10D.Unity/X10D.Unity.csproj b/X10D.Unity/X10D.Unity.csproj index b1584ea..e1ac766 100644 --- a/X10D.Unity/X10D.Unity.csproj +++ b/X10D.Unity/X10D.Unity.csproj @@ -2,6 +2,7 @@ netstandard2.1 + $(NoWarn);NU1701 From 4593a21065472b7a25720205cbc81db37563dfec Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 17:43:16 +0100 Subject: [PATCH 12/46] fix(tools): clear Package property groups --- tools/Benchmarks/Benchmarks.csproj | 6 ++++++ tools/SourceGenerator/SourceGenerator.csproj | 6 ++++++ tools/SourceValidator/SourceValidator.csproj | 6 ++++++ tools/UpmPackageGenerator/UpmPackageGenerator.csproj | 6 ++++++ tools/X10D.MetaServices/X10D.MetaServices.csproj | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/tools/Benchmarks/Benchmarks.csproj b/tools/Benchmarks/Benchmarks.csproj index e5b1c6e..5cc5fa9 100644 --- a/tools/Benchmarks/Benchmarks.csproj +++ b/tools/Benchmarks/Benchmarks.csproj @@ -10,6 +10,12 @@ true true true + + + + + + diff --git a/tools/SourceGenerator/SourceGenerator.csproj b/tools/SourceGenerator/SourceGenerator.csproj index 266d229..2284922 100644 --- a/tools/SourceGenerator/SourceGenerator.csproj +++ b/tools/SourceGenerator/SourceGenerator.csproj @@ -7,6 +7,12 @@ enable true true + + + + + + diff --git a/tools/SourceValidator/SourceValidator.csproj b/tools/SourceValidator/SourceValidator.csproj index 1d72f7d..5a5e699 100644 --- a/tools/SourceValidator/SourceValidator.csproj +++ b/tools/SourceValidator/SourceValidator.csproj @@ -8,6 +8,12 @@ enable true true + + + + + + diff --git a/tools/UpmPackageGenerator/UpmPackageGenerator.csproj b/tools/UpmPackageGenerator/UpmPackageGenerator.csproj index 277ab31..1424dbd 100644 --- a/tools/UpmPackageGenerator/UpmPackageGenerator.csproj +++ b/tools/UpmPackageGenerator/UpmPackageGenerator.csproj @@ -7,6 +7,12 @@ enable true true + + + + + + diff --git a/tools/X10D.MetaServices/X10D.MetaServices.csproj b/tools/X10D.MetaServices/X10D.MetaServices.csproj index aa845a6..8cec64e 100644 --- a/tools/X10D.MetaServices/X10D.MetaServices.csproj +++ b/tools/X10D.MetaServices/X10D.MetaServices.csproj @@ -5,6 +5,12 @@ 11.0 enable enable + + + + + + From 1b71d94084be3a3766747ac5f01cecdab137be63 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 17:44:29 +0100 Subject: [PATCH 13/46] chore: remove redundant shared props --- tools/Benchmarks/Benchmarks.csproj | 4 ---- tools/SourceGenerator/SourceGenerator.csproj | 4 ---- tools/SourceValidator/SourceValidator.csproj | 4 ---- tools/UpmPackageGenerator/UpmPackageGenerator.csproj | 3 --- tools/X10D.MetaServices/X10D.MetaServices.csproj | 3 --- 5 files changed, 18 deletions(-) diff --git a/tools/Benchmarks/Benchmarks.csproj b/tools/Benchmarks/Benchmarks.csproj index 5cc5fa9..84941d0 100644 --- a/tools/Benchmarks/Benchmarks.csproj +++ b/tools/Benchmarks/Benchmarks.csproj @@ -4,11 +4,7 @@ Release Exe net7.0;net6.0;netcoreapp3.1 - 11.0 - enable - enable true - true true diff --git a/tools/SourceGenerator/SourceGenerator.csproj b/tools/SourceGenerator/SourceGenerator.csproj index 2284922..1e60846 100644 --- a/tools/SourceGenerator/SourceGenerator.csproj +++ b/tools/SourceGenerator/SourceGenerator.csproj @@ -2,11 +2,7 @@ netstandard2.0 - 11.0 - enable - enable true - true diff --git a/tools/SourceValidator/SourceValidator.csproj b/tools/SourceValidator/SourceValidator.csproj index 5a5e699..d8ec2f0 100644 --- a/tools/SourceValidator/SourceValidator.csproj +++ b/tools/SourceValidator/SourceValidator.csproj @@ -3,11 +3,7 @@ Exe net7.0 - 11.0 - enable - enable true - true diff --git a/tools/UpmPackageGenerator/UpmPackageGenerator.csproj b/tools/UpmPackageGenerator/UpmPackageGenerator.csproj index 1424dbd..1629a36 100644 --- a/tools/UpmPackageGenerator/UpmPackageGenerator.csproj +++ b/tools/UpmPackageGenerator/UpmPackageGenerator.csproj @@ -3,10 +3,7 @@ Exe net7.0 - enable - enable true - true diff --git a/tools/X10D.MetaServices/X10D.MetaServices.csproj b/tools/X10D.MetaServices/X10D.MetaServices.csproj index 8cec64e..0a38293 100644 --- a/tools/X10D.MetaServices/X10D.MetaServices.csproj +++ b/tools/X10D.MetaServices/X10D.MetaServices.csproj @@ -2,9 +2,6 @@ netstandard2.0 - 11.0 - enable - enable From 27e0ec54be62238e4d5be683f4b0d9eb8321ba09 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 17:46:44 +0100 Subject: [PATCH 14/46] chore: extract shared build props --- X10D.sln | 3 +++ tools/Benchmarks/Benchmarks.csproj | 7 ------- tools/Directory.Build.props | 13 +++++++++++++ tools/SourceGenerator/SourceGenerator.csproj | 7 ------- tools/SourceValidator/SourceValidator.csproj | 7 ------- .../UpmPackageGenerator/UpmPackageGenerator.csproj | 7 ------- tools/X10D.MetaServices/X10D.MetaServices.csproj | 6 ------ 7 files changed, 16 insertions(+), 34 deletions(-) create mode 100644 tools/Directory.Build.props diff --git a/X10D.sln b/X10D.sln index b1b36a2..b114966 100644 --- a/X10D.sln +++ b/X10D.sln @@ -45,6 +45,9 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpmPackageGenerator", "tools\UpmPackageGenerator\UpmPackageGenerator.csproj", "{CCBF047D-1B01-45EC-8D89-B00B4AC482CA}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{4B8969E6-27D2-4357-964E-9979FF7CC805}" + ProjectSection(SolutionItems) = preProject + tools\Directory.Build.props = tools\Directory.Build.props + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarks", "tools\Benchmarks\Benchmarks.csproj", "{259450A0-9964-403A-91E1-E9111B92C293}" EndProject diff --git a/tools/Benchmarks/Benchmarks.csproj b/tools/Benchmarks/Benchmarks.csproj index 84941d0..fb326bc 100644 --- a/tools/Benchmarks/Benchmarks.csproj +++ b/tools/Benchmarks/Benchmarks.csproj @@ -4,14 +4,7 @@ Release Exe net7.0;net6.0;netcoreapp3.1 - true true - - - - - - diff --git a/tools/Directory.Build.props b/tools/Directory.Build.props new file mode 100644 index 0000000..b933b03 --- /dev/null +++ b/tools/Directory.Build.props @@ -0,0 +1,13 @@ + + + 11.0 + true + true + + + + + + + + \ No newline at end of file diff --git a/tools/SourceGenerator/SourceGenerator.csproj b/tools/SourceGenerator/SourceGenerator.csproj index 1e60846..29d8a3c 100644 --- a/tools/SourceGenerator/SourceGenerator.csproj +++ b/tools/SourceGenerator/SourceGenerator.csproj @@ -2,13 +2,6 @@ netstandard2.0 - true - - - - - - diff --git a/tools/SourceValidator/SourceValidator.csproj b/tools/SourceValidator/SourceValidator.csproj index d8ec2f0..5059923 100644 --- a/tools/SourceValidator/SourceValidator.csproj +++ b/tools/SourceValidator/SourceValidator.csproj @@ -3,13 +3,6 @@ Exe net7.0 - true - - - - - - diff --git a/tools/UpmPackageGenerator/UpmPackageGenerator.csproj b/tools/UpmPackageGenerator/UpmPackageGenerator.csproj index 1629a36..82cad6d 100644 --- a/tools/UpmPackageGenerator/UpmPackageGenerator.csproj +++ b/tools/UpmPackageGenerator/UpmPackageGenerator.csproj @@ -3,13 +3,6 @@ Exe net7.0 - true - - - - - - diff --git a/tools/X10D.MetaServices/X10D.MetaServices.csproj b/tools/X10D.MetaServices/X10D.MetaServices.csproj index 0a38293..2756020 100644 --- a/tools/X10D.MetaServices/X10D.MetaServices.csproj +++ b/tools/X10D.MetaServices/X10D.MetaServices.csproj @@ -2,12 +2,6 @@ netstandard2.0 - - - - - - From 1e71029f384d7bea35f729ad7eb35146ccca18a7 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 17:51:51 +0100 Subject: [PATCH 15/46] refactor: remove X10D.DSharpPlus --- .github/workflows/nightly.yml | 1 - .github/workflows/prerelease.yml | 1 - .github/workflows/release.yml | 1 - CHANGELOG.md | 1 + X10D.DSharpPlus/X10D.DSharpPlus.csproj | 12 - X10D.DSharpPlus/src/Assembly.cs | 1 - .../src/DiscordChannelExtensions.cs | 71 ---- .../src/DiscordClientExtensions.cs | 71 ---- .../src/DiscordEmbedBuilderExtensions.cs | 212 ----------- X10D.DSharpPlus/src/DiscordGuildExtensions.cs | 84 ----- .../src/DiscordMemberExtensions.cs | 63 ---- .../src/DiscordMessageExtensions.cs | 76 ---- X10D.DSharpPlus/src/DiscordUserExtensions.cs | 145 -------- X10D.DSharpPlus/src/MentionUtility.cs | 329 ------------------ X10D.sln | 6 - 15 files changed, 1 insertion(+), 1073 deletions(-) delete mode 100644 X10D.DSharpPlus/X10D.DSharpPlus.csproj delete mode 100644 X10D.DSharpPlus/src/Assembly.cs delete mode 100644 X10D.DSharpPlus/src/DiscordChannelExtensions.cs delete mode 100644 X10D.DSharpPlus/src/DiscordClientExtensions.cs delete mode 100644 X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs delete mode 100644 X10D.DSharpPlus/src/DiscordGuildExtensions.cs delete mode 100644 X10D.DSharpPlus/src/DiscordMemberExtensions.cs delete mode 100644 X10D.DSharpPlus/src/DiscordMessageExtensions.cs delete mode 100644 X10D.DSharpPlus/src/DiscordUserExtensions.cs delete mode 100644 X10D.DSharpPlus/src/MentionUtility.cs diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ca14ed1..9f1a02d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -33,7 +33,6 @@ jobs: run: | mkdir build dotnet pack X10D --configuration Debug --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build -p:VersionSuffix='nightly' -p:BuildNumber=${{ github.run_number }} - dotnet pack X10D.DSharpPlus --configuration Debug --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build -p:VersionSuffix='nightly' -p:BuildNumber=${{ github.run_number }} dotnet pack X10D.Hosting --configuration Debug --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build -p:VersionSuffix='nightly' -p:BuildNumber=${{ github.run_number }} dotnet pack X10D.Unity --configuration Debug --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build -p:VersionSuffix='nightly' -p:BuildNumber=${{ github.run_number }} diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 7b9940b..01af506 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -32,7 +32,6 @@ jobs: run: | mkdir build dotnet pack X10D --configuration Release --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build -p:VersionSuffix='prerelease' -p:BuildNumber=${{ github.run_number }} - dotnet pack X10D.DSharpPlus --configuration Release --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build -p:VersionSuffix='prerelease' -p:BuildNumber=${{ github.run_number }} dotnet pack X10D.Hosting --configuration Release --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build -p:VersionSuffix='prerelease' -p:BuildNumber=${{ github.run_number }} dotnet pack X10D.Unity --configuration Release --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build -p:VersionSuffix='prerelease' -p:BuildNumber=${{ github.run_number }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0bdbb14..c5fd973 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,6 @@ jobs: run: | mkdir build dotnet pack X10D --configuration Release --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build - dotnet pack X10D.DSharpPlus --configuration Release --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build dotnet pack X10D.Hosting --configuration Release --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build dotnet pack X10D.Unity --configuration Release --no-build -p:SymbolPackageFormat=snupkg --include-symbols --include-source -o build diff --git a/CHANGELOG.md b/CHANGELOG.md index 23f6c22..c1d3e44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed - X10D: Removed `IEnumerable.ConcatOne` - this functionality already exists with `Append`. +- X10D.DSharpPlus: Complete sunset of library. This library will not be updated to support DSharpPlus v5.0.0. ## [3.3.1] - 2023-08-21 diff --git a/X10D.DSharpPlus/X10D.DSharpPlus.csproj b/X10D.DSharpPlus/X10D.DSharpPlus.csproj deleted file mode 100644 index 9128252..0000000 --- a/X10D.DSharpPlus/X10D.DSharpPlus.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - net7.0;net6.0;netstandard2.1 - true - - - - - - - diff --git a/X10D.DSharpPlus/src/Assembly.cs b/X10D.DSharpPlus/src/Assembly.cs deleted file mode 100644 index 4e11466..0000000 --- a/X10D.DSharpPlus/src/Assembly.cs +++ /dev/null @@ -1 +0,0 @@ -[assembly: CLSCompliant(false)] diff --git a/X10D.DSharpPlus/src/DiscordChannelExtensions.cs b/X10D.DSharpPlus/src/DiscordChannelExtensions.cs deleted file mode 100644 index 820ced0..0000000 --- a/X10D.DSharpPlus/src/DiscordChannelExtensions.cs +++ /dev/null @@ -1,71 +0,0 @@ -using DSharpPlus; -using DSharpPlus.Entities; - -namespace X10D.DSharpPlus; - -/// -/// Extension methods for . -/// -public static class DiscordChannelExtensions -{ - /// - /// Gets the category of this channel. - /// - /// The channel whose category to retrieve. - /// - /// The category of , or itself if it is already a category; - /// if this channel is not defined in a category. - /// - /// is . - public static DiscordChannel? GetCategory(this DiscordChannel channel) - { - if (channel is null) - { - throw new ArgumentNullException(nameof(channel)); - } - - while (true) - { - if (channel.IsCategory) - { - return channel; - } - - if (channel.Parent is not { } parent) - { - return null; - } - - channel = parent; - } - } - - /// - /// Normalizes a so that the internal client is assured to be a specified value. - /// - /// The to normalize. - /// The target client. - /// - /// A whose public values will match , but whose internal client - /// is . - /// - /// - /// is - /// -or- - /// is - /// - public static async Task NormalizeClientAsync(this DiscordChannel channel, DiscordClient client) - { - if (channel is null) - { - throw new ArgumentNullException(nameof(channel)); - } - - if (client is null) - { - throw new ArgumentNullException(nameof(client)); - } - - return await client.GetChannelAsync(channel.Id).ConfigureAwait(false); - } -} diff --git a/X10D.DSharpPlus/src/DiscordClientExtensions.cs b/X10D.DSharpPlus/src/DiscordClientExtensions.cs deleted file mode 100644 index 5dfd415..0000000 --- a/X10D.DSharpPlus/src/DiscordClientExtensions.cs +++ /dev/null @@ -1,71 +0,0 @@ -using DSharpPlus; -using DSharpPlus.Entities; -using DSharpPlus.Exceptions; - -namespace X10D.DSharpPlus; - -/// -/// Extension methods for . -/// -public static class DiscordClientExtensions -{ - /// - /// Instructs the client to automatically join all existing threads, and any newly-created threads. - /// - /// The whose events should be subscribed. - /// - /// to automatically rejoin a thread if this client was removed; otherwise, - /// . - /// - /// is . - public static void AutoJoinThreads(this DiscordClient client, bool rejoinIfRemoved = true) - { - if (client is null) - { - throw new ArgumentNullException(nameof(client)); - } - - client.GuildAvailable += (_, args) => args.Guild.JoinAllThreadsAsync(); - client.ThreadCreated += (_, args) => args.Thread.JoinThreadAsync(); - - if (rejoinIfRemoved) - { - client.ThreadMembersUpdated += (_, args) => - { - if (args.RemovedMembers.Any(m => m.Id == client.CurrentUser.Id)) - return args.Thread.JoinThreadAsync(); - - return Task.CompletedTask; - }; - } - } - - /// - /// Gets a user by their ID. If the user is not found, is returned instead of - /// being thrown. - /// - /// The Discord client. - /// The ID of the user to retrieve. - /// is . - public static async Task GetUserOrNullAsync(this DiscordClient client, ulong userId) - { - if (client is null) - { - throw new ArgumentNullException(nameof(client)); - } - - try - { - // we should never use exceptions for flow control but this is D#+ we're talking about. - // NotFoundException isn't even documented, and yet it gets thrown when a user doesn't exist. - // so this method should hopefully clearly express that - and at least using exceptions for flow control *here*, - // removes the need to do the same in consumer code. - // god I hate this. - return await client.GetUserAsync(userId).ConfigureAwait(false); - } - catch (NotFoundException) - { - return null; - } - } -} diff --git a/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs b/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs deleted file mode 100644 index 1c2c479..0000000 --- a/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs +++ /dev/null @@ -1,212 +0,0 @@ -using DSharpPlus.Entities; - -namespace X10D.DSharpPlus; - -/// -/// Extension methods for . -/// -public static class DiscordEmbedBuilderExtensions -{ - /// - /// Adds a field of any value type to the embed. - /// - /// The to modify. - /// The name of the embed field. - /// The value of the embed field. - /// to display this field inline; otherwise, . - /// The type of . - /// The current instance of ; that is, . - /// is . - public static DiscordEmbedBuilder AddField( - this DiscordEmbedBuilder builder, - string name, - T? value, - bool inline = false) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - return builder.AddField(name, value?.ToString(), inline); - } - - /// - /// Conditionally adds a field to the embed. - /// - /// The to modify. - /// The condition whose value is used to determine whether the field will be added. - /// The name of the embed field. - /// The value of the embed field. - /// to display this field inline; otherwise, . - /// The type of . - /// The current instance of ; that is, . - /// is . - public static DiscordEmbedBuilder AddFieldIf( - this DiscordEmbedBuilder builder, - bool condition, - string name, - T? value, - bool inline = false) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (condition) - { - builder.AddField(name, value?.ToString(), inline); - } - - return builder; - } - - /// - /// Conditionally adds a field to the embed. - /// - /// The to modify. - /// The predicate whose return value is used to determine whether the field will be added. - /// The name of the embed field. - /// The value of the embed field. - /// to display this field inline; otherwise, . - /// The type of . - /// The current instance of ; that is, . - /// - /// is . - /// -or- - /// is . - /// - public static DiscordEmbedBuilder AddFieldIf( - this DiscordEmbedBuilder builder, - Func predicate, - string name, - T? value, - bool inline = false) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (predicate is null) - { - throw new ArgumentNullException(nameof(predicate)); - } - - if (predicate.Invoke()) - { - builder.AddField(name, value?.ToString(), inline); - } - - return builder; - } - - /// - /// Conditionally adds a field to the embed. - /// - /// The to modify. - /// The predicate whose return value is used to determine whether the field will be added. - /// The name of the embed field. - /// The delegate whose return value will be used as the value of the embed field. - /// to display this field inline; otherwise, . - /// The return type of . - /// The current instance of ; that is, . - /// - /// is . - /// -or- - /// is . - /// -or- - /// is . - /// - public static DiscordEmbedBuilder AddFieldIf( - this DiscordEmbedBuilder builder, - Func predicate, - string name, - Func valueFactory, - bool inline = false) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (predicate is null) - { - throw new ArgumentNullException(nameof(predicate)); - } - - if (valueFactory is null) - { - throw new ArgumentNullException(nameof(valueFactory)); - } - - if (predicate.Invoke()) - { - builder.AddField(name, valueFactory.Invoke()?.ToString(), inline); - } - - return builder; - } - - /// - /// Conditionally adds a field to the embed. - /// - /// The to modify. - /// The condition whose value is used to determine whether the field will be added. - /// The name of the embed field. - /// The delegate whose return value will be used as the value of the embed field. - /// to display this field inline; otherwise, . - /// The return type of . - /// The current instance of ; that is, . - /// - /// is . - /// -or- - /// is . - /// - public static DiscordEmbedBuilder AddFieldIf( - this DiscordEmbedBuilder builder, - bool condition, - string name, - Func valueFactory, - bool inline = false) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (valueFactory is null) - { - throw new ArgumentNullException(nameof(valueFactory)); - } - - if (condition) - { - builder.AddField(name, valueFactory.Invoke()?.ToString(), inline); - } - - return builder; - } - - /// - /// Sets the embed's author. - /// - /// The embed builder to modify. - /// The author. - /// The current instance of . - public static DiscordEmbedBuilder WithAuthor(this DiscordEmbedBuilder builder, DiscordUser user) - { - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (user is null) - { - throw new ArgumentNullException(nameof(user)); - } - - return builder.WithAuthor(user.GetUsernameWithDiscriminator(), iconUrl: user.AvatarUrl); - } -} diff --git a/X10D.DSharpPlus/src/DiscordGuildExtensions.cs b/X10D.DSharpPlus/src/DiscordGuildExtensions.cs deleted file mode 100644 index ff4636e..0000000 --- a/X10D.DSharpPlus/src/DiscordGuildExtensions.cs +++ /dev/null @@ -1,84 +0,0 @@ -using DSharpPlus; -using DSharpPlus.Entities; -using DSharpPlus.Exceptions; - -namespace X10D.DSharpPlus; - -/// -/// Extension methods for . -/// -public static class DiscordGuildExtensions -{ - /// - /// Joins all active threads in the guild that this client has permission to view. - /// - /// The guild whose active threads to join. - /// is . - public static async Task JoinAllThreadsAsync(this DiscordGuild guild) - { - if (guild is null) - { - throw new ArgumentNullException(nameof(guild)); - } - - await Task.WhenAll(guild.Threads.Values.Select(t => t.JoinThreadAsync())).ConfigureAwait(false); - } - - /// - /// Gets a guild member by their ID. If the member is not found, is returned instead of - /// being thrown. - /// - /// The guild whose member list to search. - /// The ID of the member to retrieve. - /// is . - public static async Task GetMemberOrNullAsync(this DiscordGuild guild, ulong userId) - { - if (guild is null) - { - throw new ArgumentNullException(nameof(guild)); - } - - try - { - // we should never use exceptions for flow control but this is D#+ we're talking about. - // NotFoundException isn't even documented, and yet it gets thrown when a member doesn't exist. - // so this method should hopefully clearly express that - and at least using exceptions for flow control *here*, - // removes the need to do the same in consumer code. - // god I hate this. - return await guild.GetMemberAsync(userId).ConfigureAwait(false); - } - catch (NotFoundException) - { - return null; - } - } - - /// - /// Normalizes a so that the internal client is assured to be a specified value. - /// - /// The to normalize. - /// The target client. - /// - /// A whose public values will match , but whose internal client is - /// . - /// - /// - /// is - /// -or- - /// is - /// - public static async Task NormalizeClientAsync(this DiscordGuild guild, DiscordClient client) - { - if (guild is null) - { - throw new ArgumentNullException(nameof(guild)); - } - - if (client is null) - { - throw new ArgumentNullException(nameof(client)); - } - - return await client.GetGuildAsync(guild.Id).ConfigureAwait(false); - } -} diff --git a/X10D.DSharpPlus/src/DiscordMemberExtensions.cs b/X10D.DSharpPlus/src/DiscordMemberExtensions.cs deleted file mode 100644 index 7ec9925..0000000 --- a/X10D.DSharpPlus/src/DiscordMemberExtensions.cs +++ /dev/null @@ -1,63 +0,0 @@ -using DSharpPlus; -using DSharpPlus.Entities; - -namespace X10D.DSharpPlus; - -/// -/// Extension methods for . -/// -public static class DiscordMemberExtensions -{ - /// - /// Returns a value indicating whether this member has the specified role. - /// - /// The member whose roles to search. - /// The role for which to check. - /// - /// if has the role; otherwise, . - /// - public static bool HasRole(this DiscordMember member, DiscordRole role) - { - if (member is null) - { - throw new ArgumentNullException(nameof(member)); - } - - if (role is null) - { - throw new ArgumentNullException(nameof(role)); - } - - return member.Roles.Contains(role); - } - - /// - /// Normalizes a so that the internal client is assured to be a specified value. - /// - /// The to normalize. - /// The target client. - /// - /// A whose public values will match , but whose internal client - /// is . - /// - /// - /// is - /// -or- - /// is - /// - public static async Task NormalizeClientAsync(this DiscordMember member, DiscordClient client) - { - if (member is null) - { - throw new ArgumentNullException(nameof(member)); - } - - if (client is null) - { - throw new ArgumentNullException(nameof(client)); - } - - DiscordGuild guild = await member.Guild.NormalizeClientAsync(client).ConfigureAwait(false); - return await guild.GetMemberAsync(member.Id).ConfigureAwait(false); - } -} diff --git a/X10D.DSharpPlus/src/DiscordMessageExtensions.cs b/X10D.DSharpPlus/src/DiscordMessageExtensions.cs deleted file mode 100644 index f43116d..0000000 --- a/X10D.DSharpPlus/src/DiscordMessageExtensions.cs +++ /dev/null @@ -1,76 +0,0 @@ -using DSharpPlus; -using DSharpPlus.Entities; - -namespace X10D.DSharpPlus; - -/// -/// Extension methods for . -/// -public static class DiscordMessageExtensions -{ - /// - /// Deletes this message after a specified delay. - /// - /// The message to delete. - /// The delay before deletion. - /// The reason for the deletion. - /// is . - public static async Task DeleteAfterAsync(this DiscordMessage message, TimeSpan delay, string? reason = null) - { - if (message is null) - { - throw new ArgumentNullException(nameof(message)); - } - - await Task.Delay(delay).ConfigureAwait(false); - await message.DeleteAsync(reason).ConfigureAwait(false); - } - - /// - /// Deletes the message as created by this task after a specified delay. - /// - /// The task whose result should be deleted. - /// The delay before deletion. - /// The reason for the deletion. - /// is . - public static async Task DeleteAfterAsync(this Task task, TimeSpan delay, string? reason = null) - { - if (task is null) - { - throw new ArgumentNullException(nameof(task)); - } - - DiscordMessage message = await task.ConfigureAwait(false); - await message.DeleteAfterAsync(delay, reason).ConfigureAwait(false); - } - - /// - /// Normalizes a so that the internal client is assured to be a specified value. - /// - /// The to normalize. - /// The target client. - /// - /// A whose public values will match , but whose internal client - /// is . - /// - /// - /// is - /// -or- - /// is - /// - public static async Task NormalizeClientAsync(this DiscordMessage message, DiscordClient client) - { - if (message is null) - { - throw new ArgumentNullException(nameof(message)); - } - - if (client is null) - { - throw new ArgumentNullException(nameof(client)); - } - - DiscordChannel channel = await message.Channel.NormalizeClientAsync(client).ConfigureAwait(false); - return await channel.GetMessageAsync(message.Id).ConfigureAwait(false); - } -} diff --git a/X10D.DSharpPlus/src/DiscordUserExtensions.cs b/X10D.DSharpPlus/src/DiscordUserExtensions.cs deleted file mode 100644 index 33eaa6e..0000000 --- a/X10D.DSharpPlus/src/DiscordUserExtensions.cs +++ /dev/null @@ -1,145 +0,0 @@ -using DSharpPlus; -using DSharpPlus.Entities; -using DSharpPlus.Exceptions; - -namespace X10D.DSharpPlus; - -/// -/// Extension methods for . -/// -public static class DiscordUserExtensions -{ - /// - /// Returns the current as a member of the specified guild. - /// - /// The user to transform. - /// The guild whose member list to search. - /// - /// A whose is equal to , or - /// if this user is not in the specified . - /// - /// - /// is . - /// -or- - /// is . - /// - public static async Task GetAsMemberOfAsync(this DiscordUser user, DiscordGuild guild) - { - if (user is null) - { - throw new ArgumentNullException(nameof(user)); - } - - if (guild is null) - { - throw new ArgumentNullException(nameof(guild)); - } - - if (user is DiscordMember member && member.Guild == guild) - { - return member; - } - - if (guild.Members.TryGetValue(user.Id, out member!)) - { - return member; - } - - try - { - return await guild.GetMemberAsync(user.Id).ConfigureAwait(false); - } - catch (NotFoundException) - { - return null; - } - } - - /// - /// Returns the user's username with the discriminator, in the format username#discriminator. - /// - /// The user whose username and discriminator to retrieve. - /// A string in the format username#discriminator - /// is . - public static string GetUsernameWithDiscriminator(this DiscordUser user) - { - if (user is null) - { - throw new ArgumentNullException(nameof(user)); - } - - if (user.Discriminator == "0") - { - // user has a new username. see: https://discord.com/blog/usernames - return user.Username; - } - - return $"{user.Username}#{user.Discriminator}"; - } - - /// - /// Returns a value indicating whether the current user is in the specified guild. - /// - /// The user to check. - /// The guild whose member list to search. - /// - /// if is a member of ; otherwise, - /// . - /// - public static async Task IsInGuildAsync(this DiscordUser user, DiscordGuild guild) - { - if (user is null) - { - throw new ArgumentNullException(nameof(user)); - } - - if (guild is null) - { - throw new ArgumentNullException(nameof(guild)); - } - - if (guild.Members.TryGetValue(user.Id, out _)) - { - return true; - } - - try - { - DiscordMember? member = await guild.GetMemberAsync(user.Id).ConfigureAwait(false); - return member is not null; - } - catch (NotFoundException) - { - return false; - } - } - - /// - /// Normalizes a so that the internal client is assured to be a specified value. - /// - /// The to normalize. - /// The target client. - /// - /// A whose public values will match , but whose internal client is - /// . - /// - /// - /// is - /// -or- - /// is - /// - public static async Task NormalizeClientAsync(this DiscordUser user, DiscordClient client) - { - if (user is null) - { - throw new ArgumentNullException(nameof(user)); - } - - if (client is null) - { - throw new ArgumentNullException(nameof(client)); - } - - return await client.GetUserAsync(user.Id).ConfigureAwait(false); - } -} diff --git a/X10D.DSharpPlus/src/MentionUtility.cs b/X10D.DSharpPlus/src/MentionUtility.cs deleted file mode 100644 index efda930..0000000 --- a/X10D.DSharpPlus/src/MentionUtility.cs +++ /dev/null @@ -1,329 +0,0 @@ -using System.Globalization; - -namespace X10D.DSharpPlus; - -/// -/// Provides methods for encoding and decoding Discord mention strings. -/// -/// -/// The implementations in this class are designed to resemble MentionUtils as provided by Discord.NET. The source is -/// available -/// -/// here -/// . -/// -public static class MentionUtility -{ - /// - /// Returns a channel mention string built from the specified channel ID. - /// - /// The ID of the channel to mention. - /// A channel mention string in the format <#123>. - public static string MentionChannel(decimal id) - { - return $"<#{id:N0}>"; - } - - /// - /// Returns a channel mention string built from the specified channel ID. - /// - /// The ID of the channel to mention. - /// A channel mention string in the format <#123>. - [CLSCompliant(false)] - public static string MentionChannel(ulong id) - { - return $"<#{id}>"; - } - - /// - /// Returns a role mention string built from the specified channel ID. - /// - /// The ID of the role to mention. - /// A role mention string in the format <@&123>. - public static string MentionRole(decimal id) - { - return $"<@&{id:N0}>"; - } - - /// - /// Returns a role mention string built from the specified role ID. - /// - /// The ID of the role to mention. - /// A role mention string in the format <@&123>. - [CLSCompliant(false)] - public static string MentionRole(ulong id) - { - return $"<@&{id}>"; - } - - /// - /// Returns a user mention string built from the specified user ID. - /// - /// The ID of the user to mention. - /// A user mention string in the format <@123>. - [CLSCompliant(false)] - public static string MentionUser(decimal id) - { - return MentionUser(id, false); - } - - /// - /// Returns a user mention string built from the specified user ID. - /// - /// The ID of the user to mention. - /// - /// if the mention string should account for nicknames; otherwise, . - /// - /// - /// A user mention string in the format <@!123> if is , - /// or in the format <@123> if is . - /// - [CLSCompliant(false)] - public static string MentionUser(decimal id, bool nickname) - { - return nickname ? $"<@!{id:N0}>" : $"<@{id:N0}>"; - } - - /// - /// Returns a user mention string built from the specified user ID. - /// - /// The ID of the user to mention. - /// A user mention string in the format <@123>. - [CLSCompliant(false)] - public static string MentionUser(ulong id) - { - return MentionUser(id, false); - } - - /// - /// Returns a user mention string built from the specified user ID. - /// - /// The ID of the user to mention. - /// - /// if the mention string should account for nicknames; otherwise, . - /// - /// - /// A user mention string in the format <@!123> if is , - /// or in the format <@123> if is . - /// - [CLSCompliant(false)] - public static string MentionUser(ulong id, bool nickname) - { - return nickname ? $"<@!{id}>" : $"<@{id}>"; - } - - /// - /// Parses a provided channel mention string to a decimal value representing the channel ID. A return value indicates - /// whether the parse succeeded. - /// - /// A string containing a mention string to parse, in the format <#123>. - /// - /// When this method returns, contains the decimal value representing the channel ID contained within - /// , if the conversion succeeded, or zero if the conversion failed. The conversion fails if the - /// parameter is or , is not of the correct - /// format, or represents a number less than or greater than . - /// - /// if the parse was successful; otherwise, . - public static bool TryParseChannel(string? value, out decimal result) - { - result = 0; - if (string.IsNullOrWhiteSpace(value)) - { - return false; - } - - if (value.Length < 3 || value[0] != '<' || value[1] != '#' || value[^1] != '>') - { - return false; - } - - value = value.Substring(2, value.Length - 3); // <#123> - if (!ulong.TryParse(value, NumberStyles.None, CultureInfo.InvariantCulture, out ulong actual)) - { - return false; - } - - result = actual; - return true; - } - - /// - /// Parses a provided channel mention string to a 64-bit unsigned integer representing the channel ID. A return value - /// indicates whether the parse succeeded. - /// - /// A string containing a mention string to parse, in the format <#123>. - /// - /// When this method returns, contains the 64-bit unsigned integer value representing the channel ID contained within - /// , if the conversion succeeded, or zero if the conversion failed. The conversion fails if the - /// parameter is or , is not of the correct - /// format, or represents a number less than or greater than . - /// - /// if the parse was successful; otherwise, . - [CLSCompliant(false)] - public static bool TryParseChannel(string? value, out ulong result) - { - result = 0; - if (string.IsNullOrWhiteSpace(value)) - { - return false; - } - - if (value.Length < 3 || value[0] != '<' || value[1] != '#' || value[^1] != '>') - { - return false; - } - - value = value.Substring(2, value.Length - 3); // <#123> - return ulong.TryParse(value, NumberStyles.None, CultureInfo.InvariantCulture, out result); - } - - /// - /// Parses a provided role mention string to a decimal value representing the role ID. A return value indicates whether - /// the parse succeeded. - /// - /// A string containing a mention string to parse, in the format <@&123>. - /// - /// When this method returns, contains the decimal value representing the role ID contained within - /// , if the conversion succeeded, or zero if the conversion failed. The conversion fails if the - /// parameter is or , is not of the correct - /// format, or represents a number less than or greater than . - /// - /// if the parse was successful; otherwise, . - public static bool TryParseRole(string? value, out decimal result) - { - result = 0; - if (string.IsNullOrWhiteSpace(value)) - { - return false; - } - - if (value.Length < 4 || value[0] != '<' || value[1] != '@' || value[2] != '&' || value[^1] != '>') - { - return false; - } - - value = value.Substring(3, value.Length - 4); // <@&123> - if (!ulong.TryParse(value, NumberStyles.None, CultureInfo.InvariantCulture, out ulong actual)) - { - return false; - } - - result = actual; - return true; - } - - /// - /// Parses a provided role mention string to a 64-bit unsigned integer representing the role ID. A return value indicates - /// whether the parse succeeded. - /// - /// A string containing a mention string to parse, in the format <@&123>. - /// - /// When this method returns, contains the 64-bit unsigned integer value representing the role ID contained within - /// , if the conversion succeeded, or zero if the conversion failed. The conversion fails if the - /// parameter is or , is not of the correct - /// format, or represents a number less than or greater than . - /// - /// if the parse was successful; otherwise, . - [CLSCompliant(false)] - public static bool TryParseRole(string? value, out ulong result) - { - result = 0; - if (string.IsNullOrWhiteSpace(value)) - { - return false; - } - - if (value.Length < 4 || value[0] != '<' || value[1] != '@' || value[2] != '&' || value[^1] != '>') - { - return false; - } - - value = value.Substring(3, value.Length - 4); // <@&123> - return ulong.TryParse(value, NumberStyles.None, CultureInfo.InvariantCulture, out result); - } - - /// - /// Parses a provided user mention string to a decimal value representing the user ID. A return value indicates whether - /// the parse succeeded. - /// - /// - /// A string containing a mention string to parse, in the format <@123> or <@!123>. - /// - /// - /// When this method returns, contains the decimal value representing the user ID contained within - /// , if the conversion succeeded, or zero if the conversion failed. The conversion fails if the - /// parameter is or , is not of the correct - /// format, or represents a number less than or greater than . - /// - /// if the parse was successful; otherwise, . - public static bool TryParseUser(string? value, out decimal result) - { - result = 0; - if (string.IsNullOrWhiteSpace(value)) - { - return false; - } - - if (value.Length < 3 || value[0] != '<' || value[1] != '@' || value[^1] != '>') - { - return false; - } - - if (value.Length >= 4 && value[2] == '!') - { - value = value.Substring(3, value.Length - 4); // <@!123> - } - else - { - value = value.Substring(2, value.Length - 3); // <@123> - } - - if (!ulong.TryParse(value, NumberStyles.None, CultureInfo.InvariantCulture, out ulong actual)) - { - return false; - } - - result = actual; - return true; - } - - /// - /// Parses a provided user mention string to a 64-bit unsigned integer representing the user ID. A return value indicates - /// whether the parse succeeded. - /// - /// - /// A string containing a mention string to parse, in the format <@123> or <@!123>. - /// - /// - /// When this method returns, contains the 64-bit unsigned integer value representing the user ID contained within - /// , if the conversion succeeded, or zero if the conversion failed. The conversion fails if the - /// parameter is or , is not of the correct - /// format, or represents a number less than or greater than . - /// - /// if the parse was successful; otherwise, . - [CLSCompliant(false)] - public static bool TryParseUser(string? value, out ulong result) - { - result = 0; - if (string.IsNullOrWhiteSpace(value)) - { - return false; - } - - if (value.Length < 3 || value[0] != '<' || value[1] != '@' || value[^1] != '>') - { - return false; - } - - if (value.Length >= 4 && value[2] == '!') - { - value = value.Substring(3, value.Length - 4); // <@!123> - } - else - { - value = value.Substring(2, value.Length - 3); // <@123> - } - - return ulong.TryParse(value, NumberStyles.None, CultureInfo.InvariantCulture, out result); - } -} diff --git a/X10D.sln b/X10D.sln index b114966..d552642 100644 --- a/X10D.sln +++ b/X10D.sln @@ -25,8 +25,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X10D.Unity", "X10D.Unity\X1 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceGenerator", "tools\SourceGenerator\SourceGenerator.csproj", "{077A5D33-AD55-4C55-8A67-972CEBC32C7A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X10D.DSharpPlus", "X10D.DSharpPlus\X10D.DSharpPlus.csproj", "{675D3B25-7EA0-4FC3-B513-8DF27874F2CF}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X10D.Hosting", "X10D.Hosting\X10D.Hosting.csproj", "{B04AF429-30CF-4B69-81BA-38F560CA9126}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{1FC74E58-F3BA-4F1A-8693-5F80895DA69D}" @@ -79,10 +77,6 @@ Global {077A5D33-AD55-4C55-8A67-972CEBC32C7A}.Debug|Any CPU.Build.0 = Debug|Any CPU {077A5D33-AD55-4C55-8A67-972CEBC32C7A}.Release|Any CPU.ActiveCfg = Release|Any CPU {077A5D33-AD55-4C55-8A67-972CEBC32C7A}.Release|Any CPU.Build.0 = Release|Any CPU - {675D3B25-7EA0-4FC3-B513-8DF27874F2CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {675D3B25-7EA0-4FC3-B513-8DF27874F2CF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {675D3B25-7EA0-4FC3-B513-8DF27874F2CF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {675D3B25-7EA0-4FC3-B513-8DF27874F2CF}.Release|Any CPU.Build.0 = Release|Any CPU {B04AF429-30CF-4B69-81BA-38F560CA9126}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B04AF429-30CF-4B69-81BA-38F560CA9126}.Debug|Any CPU.Build.0 = Debug|Any CPU {B04AF429-30CF-4B69-81BA-38F560CA9126}.Release|Any CPU.ActiveCfg = Release|Any CPU From 5b2c83e2eb138f9133eb73de2c757d71c7efeb9f Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 22:40:49 +0100 Subject: [PATCH 16/46] chore: define TargetFrameworks in shared props --- Directory.Build.props | 1 + X10D.Hosting/X10D.Hosting.csproj | 4 ---- X10D/X10D.csproj | 4 ---- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index be302ef..3250f61 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,6 @@ + net7.0;net6.0;netstandard2.1 11.0 true true diff --git a/X10D.Hosting/X10D.Hosting.csproj b/X10D.Hosting/X10D.Hosting.csproj index a534fa0..0d99bec 100644 --- a/X10D.Hosting/X10D.Hosting.csproj +++ b/X10D.Hosting/X10D.Hosting.csproj @@ -1,9 +1,5 @@ - - net7.0;net6.0;netstandard2.1 - - diff --git a/X10D/X10D.csproj b/X10D/X10D.csproj index 7994902..c288f87 100644 --- a/X10D/X10D.csproj +++ b/X10D/X10D.csproj @@ -1,9 +1,5 @@ - - net7.0;net6.0;netstandard2.1 - - True From 9c5ed12cadd9aaa202c06fae66af8a85fc027b36 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 22:40:59 +0100 Subject: [PATCH 17/46] chore: enable NRT for tools --- tools/Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/Directory.Build.props b/tools/Directory.Build.props index b933b03..39e3440 100644 --- a/tools/Directory.Build.props +++ b/tools/Directory.Build.props @@ -1,6 +1,7 @@  11.0 + enable true true From 0868b698c50e773cc8557d269262ceeb3e974443 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 22:42:07 +0100 Subject: [PATCH 18/46] [ci skip] docs: fix README branding header in X10D.Unity --- X10D.Unity/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/X10D.Unity/README.md b/X10D.Unity/README.md index 2e4e1f6..888c724 100644 --- a/X10D.Unity/README.md +++ b/X10D.Unity/README.md @@ -1,4 +1,4 @@ -

+

GitHub Workflow Status From fa375e77580bb5e211c6a75f1c2c7fbd55d922be Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 23:38:18 +0100 Subject: [PATCH 19/46] refactor: conditionally import System.Runtime.Intrinsics.X86 --- X10D.Tests/src/Collections/Int16Tests.cs | 4 +++- X10D.Tests/src/Collections/Int32Tests.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/X10D.Tests/src/Collections/Int16Tests.cs b/X10D.Tests/src/Collections/Int16Tests.cs index 9e44f49..8672a0a 100644 --- a/X10D.Tests/src/Collections/Int16Tests.cs +++ b/X10D.Tests/src/Collections/Int16Tests.cs @@ -1,4 +1,6 @@ -using System.Runtime.Intrinsics.X86; +#if NET5_0_OR_GREATER +using System.Runtime.Intrinsics.X86; +#endif using NUnit.Framework; using X10D.Collections; diff --git a/X10D.Tests/src/Collections/Int32Tests.cs b/X10D.Tests/src/Collections/Int32Tests.cs index 219ecd3..97485e1 100644 --- a/X10D.Tests/src/Collections/Int32Tests.cs +++ b/X10D.Tests/src/Collections/Int32Tests.cs @@ -1,4 +1,6 @@ -using System.Runtime.Intrinsics.X86; +#if NET5_0_OR_GREATER +using System.Runtime.Intrinsics.X86; +#endif using NUnit.Framework; using X10D.Collections; From 15107ea90fde3dccaf9ee39793106587851cf36c Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 22 Aug 2023 23:53:13 +0100 Subject: [PATCH 20/46] docs: fix xmldoc for Line3D --- CHANGELOG.md | 4 ++++ X10D/src/Drawing/Line3D.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1d3e44..14b8711 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - X10D.Unity: Added `RaycastHit.GetComponent` and `RaycastHit.TryGetComponent`. - X10D.Unity: Added `DebugUtility.DrawFunction`, and `DebugUtility.DrawUnjoinedPolyhedron` on which it relies. +### Fixed + +- X10D: Fixed XMLDoc for `Line3D` to read "single-precision floating-point" instead of "32-bit signed integer". + ### Changed - X10D: DateTime.Age(DateTime) and DateTimeOffset.Age(DateTimeOffset) parameter renamed from asOf to referenceDate. diff --git a/X10D/src/Drawing/Line3D.cs b/X10D/src/Drawing/Line3D.cs index d2e4177..9775c72 100644 --- a/X10D/src/Drawing/Line3D.cs +++ b/X10D/src/Drawing/Line3D.cs @@ -4,7 +4,7 @@ using System.Numerics; namespace X10D.Drawing; ///

-/// Represents a line in 3D space that is composed of 32-bit signed integer X, Y and Z coordinates. +/// Represents a line in 3D space that is composed of single-precision floating-point X, Y and Z coordinates. /// public readonly struct Line3D : IEquatable, IComparable, IComparable { From 5c21c86a5207cb935287657a19dd8d45b4528c34 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 23 Aug 2023 14:15:52 +0100 Subject: [PATCH 21/46] refactor!: replace Endianness enum with explicit Big/Little methods --- CHANGELOG.md | 3 + X10D.Tests/src/IO/DoubleTests.cs | 58 +- X10D.Tests/src/IO/Int16Tests.cs | 54 +- X10D.Tests/src/IO/Int32Tests.cs | 54 +- X10D.Tests/src/IO/Int64Tests.cs | 58 +- X10D.Tests/src/IO/SingleTests.cs | 58 +- X10D.Tests/src/IO/StreamTests.ReadDecimal.cs | 53 +- X10D.Tests/src/IO/StreamTests.ReadDouble.cs | 57 +- X10D.Tests/src/IO/StreamTests.ReadInt16.cs | 57 +- X10D.Tests/src/IO/StreamTests.ReadInt32.cs | 57 +- X10D.Tests/src/IO/StreamTests.ReadInt64.cs | 52 +- X10D.Tests/src/IO/StreamTests.ReadSingle.cs | 57 +- X10D.Tests/src/IO/StreamTests.ReadUInt16.cs | 57 +- X10D.Tests/src/IO/StreamTests.ReadUInt32.cs | 57 +- X10D.Tests/src/IO/StreamTests.ReadUInt64.cs | 57 +- X10D.Tests/src/IO/StreamTests.WriteDecimal.cs | 52 +- X10D.Tests/src/IO/StreamTests.WriteDouble.cs | 56 +- X10D.Tests/src/IO/StreamTests.WriteInt16.cs | 56 +- X10D.Tests/src/IO/StreamTests.WriteInt32.cs | 56 +- X10D.Tests/src/IO/StreamTests.WriteInt64.cs | 56 +- X10D.Tests/src/IO/StreamTests.WriteSingle.cs | 56 +- X10D.Tests/src/IO/StreamTests.WriteUInt16.cs | 56 +- X10D.Tests/src/IO/StreamTests.WriteUInt32.cs | 56 +- X10D.Tests/src/IO/StreamTests.WriteUInt64.cs | 56 +- X10D.Tests/src/IO/UInt16Tests.cs | 54 +- X10D.Tests/src/IO/UInt32Tests.cs | 54 +- X10D.Tests/src/IO/UInt64Tests.cs | 58 +- X10D/src/Endianness.cs | 19 - X10D/src/IO/DecimalExtensions.cs | 111 ++ X10D/src/IO/DoubleExtensions.cs | 82 +- X10D/src/IO/Int16Extensions.cs | 76 +- X10D/src/IO/Int32Extensions.cs | 60 +- X10D/src/IO/Int64Extensions.cs | 36 +- X10D/src/IO/SingleExtensions.cs | 70 +- X10D/src/IO/StreamExtensions.cs | 1585 ++++++++--------- X10D/src/IO/UInt16Extensions.cs | 40 +- X10D/src/IO/UInt32Extensions.cs | 40 +- X10D/src/IO/UInt64Extensions.cs | 36 +- 38 files changed, 1835 insertions(+), 1775 deletions(-) delete mode 100644 X10D/src/Endianness.cs create mode 100644 X10D/src/IO/DecimalExtensions.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 14b8711..1957cf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,10 +34,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - X10D: DateTime.Age(DateTime) and DateTimeOffset.Age(DateTimeOffset) parameter renamed from asOf to referenceDate. +- X10D: Methods which accepted the `Endianness` enum as an argument have been replaced with explicit +BigEndian/LittleEndian methods. ### Removed - X10D: Removed `IEnumerable.ConcatOne` - this functionality already exists with `Append`. +- X10D: Removed `Endianness` enum. - X10D.DSharpPlus: Complete sunset of library. This library will not be updated to support DSharpPlus v5.0.0. ## [3.3.1] - 2023-08-21 diff --git a/X10D.Tests/src/IO/DoubleTests.cs b/X10D.Tests/src/IO/DoubleTests.cs index f58e26c..9b8a43a 100644 --- a/X10D.Tests/src/IO/DoubleTests.cs +++ b/X10D.Tests/src/IO/DoubleTests.cs @@ -7,60 +7,60 @@ namespace X10D.Tests.IO; internal class DoubleTests { [Test] - public void GetBytes_ReturnsCorrectValue() + public void GetBigEndianBytes_ReturnsCorrectValue() { const double value = 42.5; - byte[] bytes = BitConverter.IsLittleEndian - ? new byte[] {0, 0, 0, 0, 0, 0x40, 0x45, 0x40} - : new byte[] {0x40, 0x45, 0x40, 0, 0, 0, 0, 0}; - CollectionAssert.AreEqual(bytes, value.GetBytes()); + + var expected = new byte[] { 0x40, 0x45, 0x40, 0, 0, 0, 0, 0 }; + byte[] actual = value.GetBigEndianBytes(); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void GetBytes_ReturnsCorrectValue_WithEndianness() + public void GetLittleEndianBytes_ReturnsCorrectValue() { const double value = 42.5; - byte[] littleEndian = {0, 0, 0, 0, 0, 0x40, 0x45, 0x40}; - byte[] bigEndian = {0x40, 0x45, 0x40, 0, 0, 0, 0, 0}; - CollectionAssert.AreEqual(littleEndian, value.GetBytes(Endianness.LittleEndian)); - CollectionAssert.AreEqual(bigEndian, value.GetBytes(Endianness.BigEndian)); + var expected = new byte[] { 0, 0, 0, 0, 0, 0x40, 0x45, 0x40 }; + byte[] actual = value.GetLittleEndianBytes(); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() + public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly() { const double value = 42.5; - byte[] bytes = BitConverter.IsLittleEndian - ? new byte[] {0, 0, 0, 0, 0, 0x40, 0x45, 0x40} - : new byte[] {0x40, 0x45, 0x40, 0, 0, 0, 0, 0}; - Span buffer = stackalloc byte[8]; - Assert.That(value.TryWriteBytes(buffer)); - CollectionAssert.AreEqual(bytes, buffer.ToArray()); + var expected = new byte[] { 0x40, 0x45, 0x40, 0, 0, 0, 0, 0 }; + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteBigEndian(actual)); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan_WithEndianness() + public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly() { const double value = 42.5; - byte[] littleEndian = {0, 0, 0, 0, 0, 0x40, 0x45, 0x40}; - byte[] bigEndian = {0x40, 0x45, 0x40, 0, 0, 0, 0, 0}; - Span buffer = stackalloc byte[8]; - - Assert.That(value.TryWriteBytes(buffer, Endianness.LittleEndian)); - CollectionAssert.AreEqual(littleEndian, buffer.ToArray()); - - Assert.That(value.TryWriteBytes(buffer, Endianness.BigEndian)); - CollectionAssert.AreEqual(bigEndian, buffer.ToArray()); + var expected = new byte[] { 0, 0, 0, 0, 0, 0x40, 0x45, 0x40 }; + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteLittleEndian(actual)); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsFalse_GivenSmallSpan() + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() { const double value = 42.5; Span buffer = stackalloc byte[0]; - Assert.That(value.TryWriteBytes(buffer), Is.False); + Assert.That(value.TryWriteBigEndian(buffer), Is.False); + } + + [Test] + public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan() + { + const double value = 42.5; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteLittleEndian(buffer), Is.False); } } diff --git a/X10D.Tests/src/IO/Int16Tests.cs b/X10D.Tests/src/IO/Int16Tests.cs index 11d6bb1..8d64f97 100644 --- a/X10D.Tests/src/IO/Int16Tests.cs +++ b/X10D.Tests/src/IO/Int16Tests.cs @@ -7,56 +7,60 @@ namespace X10D.Tests.IO; internal class Int16Tests { [Test] - public void GetBytes_ReturnsCorrectValue() + public void GetLittleEndianBytes_ReturnsCorrectValue() { const short value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian ? new byte[] {0x0F, 0} : new byte[] {0, 0x0F}; - CollectionAssert.AreEqual(bytes, value.GetBytes()); + + byte[] expected = { 0x0F, 0 }; + byte[] actual = value.GetLittleEndianBytes(); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void GetBytes_ReturnsCorrectValue_WithEndianness() + public void GetBigEndianBytes_ReturnsCorrectValue() { const short value = 0x0F; - byte[] littleEndian = {0x0F, 0}; - byte[] bigEndian = {0, 0x0F}; - CollectionAssert.AreEqual(littleEndian, value.GetBytes(Endianness.LittleEndian)); - CollectionAssert.AreEqual(bigEndian, value.GetBytes(Endianness.BigEndian)); + byte[] expected = { 0, 0x0F }; + byte[] actual = value.GetBigEndianBytes(); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() + public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly() { const short value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian ? new byte[] {0x0F, 0} : new byte[] {0, 0x0F}; - Span buffer = stackalloc byte[2]; - Assert.That(value.TryWriteBytes(buffer)); - CollectionAssert.AreEqual(bytes, buffer.ToArray()); + byte[] expected = { 0x0F, 0 }; + Span actual = stackalloc byte[2]; + Assert.That(value.TryWriteLittleEndian(actual)); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan_WithEndianness() + public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly() { const short value = 0x0F; - byte[] littleEndian = {0x0F, 0}; - byte[] bigEndian = {0, 0x0F}; - Span buffer = stackalloc byte[2]; - - Assert.That(value.TryWriteBytes(buffer, Endianness.LittleEndian)); - CollectionAssert.AreEqual(littleEndian, buffer.ToArray()); - - Assert.That(value.TryWriteBytes(buffer, Endianness.BigEndian)); - CollectionAssert.AreEqual(bigEndian, buffer.ToArray()); + byte[] expected = { 0, 0x0F }; + Span actual = stackalloc byte[2]; + Assert.That(value.TryWriteBigEndian(actual)); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsFalse_GivenSmallSpan() + public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan() { const short value = 0x0F; Span buffer = stackalloc byte[0]; - Assert.That(value.TryWriteBytes(buffer), Is.False); + Assert.That(value.TryWriteLittleEndian(buffer), Is.False); + } + + [Test] + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() + { + const short value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteBigEndian(buffer), Is.False); } } diff --git a/X10D.Tests/src/IO/Int32Tests.cs b/X10D.Tests/src/IO/Int32Tests.cs index c123980..31898a0 100644 --- a/X10D.Tests/src/IO/Int32Tests.cs +++ b/X10D.Tests/src/IO/Int32Tests.cs @@ -7,56 +7,60 @@ namespace X10D.Tests.IO; internal class Int32Tests { [Test] - public void GetBytes_ReturnsCorrectValue() + public void GetBigEndianBytes_ReturnsCorrectValue() { const int value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian ? new byte[] {0x0F, 0, 0, 0} : new byte[] {0, 0, 0, 0x0F}; - CollectionAssert.AreEqual(bytes, value.GetBytes()); + + var expected = new byte[] { 0, 0, 0, 0x0F }; + byte[] actual = value.GetBigEndianBytes(); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void GetBytes_ReturnsCorrectValue_WithEndianness() + public void GetLittleEndianBytes_ReturnsCorrectValue() { const int value = 0x0F; - byte[] littleEndian = {0x0F, 0, 0, 0}; - byte[] bigEndian = {0, 0, 0, 0x0F}; - CollectionAssert.AreEqual(littleEndian, value.GetBytes(Endianness.LittleEndian)); - CollectionAssert.AreEqual(bigEndian, value.GetBytes(Endianness.BigEndian)); + var expected = new byte[] { 0x0F, 0, 0, 0 }; + byte[] actual = value.GetLittleEndianBytes(); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() + public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly() { const int value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian ? new byte[] {0x0F, 0, 0, 0} : new byte[] {0, 0, 0, 0x0F}; - Span buffer = stackalloc byte[4]; - Assert.That(value.TryWriteBytes(buffer)); - CollectionAssert.AreEqual(bytes, buffer.ToArray()); + var expected = new byte[] { 0, 0, 0, 0x0F }; + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteBigEndian(actual)); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan_WithEndianness() + public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly() { const int value = 0x0F; - byte[] littleEndian = {0x0F, 0, 0, 0}; - byte[] bigEndian = {0, 0, 0, 0x0F}; - Span buffer = stackalloc byte[4]; - - Assert.That(value.TryWriteBytes(buffer, Endianness.LittleEndian)); - CollectionAssert.AreEqual(littleEndian, buffer.ToArray()); - - Assert.That(value.TryWriteBytes(buffer, Endianness.BigEndian)); - CollectionAssert.AreEqual(bigEndian, buffer.ToArray()); + var expected = new byte[] { 0x0F, 0, 0, 0 }; + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteLittleEndian(actual)); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsFalse_GivenSmallSpan() + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() { const int value = 0x0F; Span buffer = stackalloc byte[0]; - Assert.That(value.TryWriteBytes(buffer), Is.False); + Assert.That(value.TryWriteBigEndian(buffer), Is.False); + } + + [Test] + public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan() + { + const int value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteLittleEndian(buffer), Is.False); } } diff --git a/X10D.Tests/src/IO/Int64Tests.cs b/X10D.Tests/src/IO/Int64Tests.cs index 6183d13..393b9e0 100644 --- a/X10D.Tests/src/IO/Int64Tests.cs +++ b/X10D.Tests/src/IO/Int64Tests.cs @@ -7,60 +7,60 @@ namespace X10D.Tests.IO; internal class Int64Tests { [Test] - public void GetBytes_ReturnsCorrectValue() + public void GetLittleEndianBytes_ReturnsCorrectValue() { const long value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian - ? new byte[] {0x0F, 0, 0, 0, 0, 0, 0, 0} - : new byte[] {0, 0, 0, 0, 0, 0, 0, 0x0F}; - CollectionAssert.AreEqual(bytes, value.GetBytes()); + + byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 }; + byte[] actual = value.GetLittleEndianBytes(); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void GetBytes_ReturnsCorrectValue_WithEndianness() + public void GetBigEndianBytes_ReturnsCorrectValue() { const long value = 0x0F; - byte[] littleEndian = {0x0F, 0, 0, 0, 0, 0, 0, 0}; - byte[] bigEndian = {0, 0, 0, 0, 0, 0, 0, 0x0F}; - CollectionAssert.AreEqual(littleEndian, value.GetBytes(Endianness.LittleEndian)); - CollectionAssert.AreEqual(bigEndian, value.GetBytes(Endianness.BigEndian)); + byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F }; + byte[] actual = value.GetBigEndianBytes(); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() + public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly() { const long value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian - ? new byte[] {0x0F, 0, 0, 0, 0, 0, 0, 0} - : new byte[] {0, 0, 0, 0, 0, 0, 0, 0x0F}; - Span buffer = stackalloc byte[8]; - Assert.That(value.TryWriteBytes(buffer)); - CollectionAssert.AreEqual(bytes, buffer.ToArray()); + byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 }; + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteLittleEndian(actual)); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan_WithEndianness() + public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly() { const long value = 0x0F; - byte[] littleEndian = {0x0F, 0, 0, 0, 0, 0, 0, 0}; - byte[] bigEndian = {0, 0, 0, 0, 0, 0, 0, 0x0F}; - Span buffer = stackalloc byte[8]; - - Assert.That(value.TryWriteBytes(buffer, Endianness.LittleEndian)); - CollectionAssert.AreEqual(littleEndian, buffer.ToArray()); - - Assert.That(value.TryWriteBytes(buffer, Endianness.BigEndian)); - CollectionAssert.AreEqual(bigEndian, buffer.ToArray()); + byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F }; + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteBigEndian(actual)); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsFalse_GivenSmallSpan() + public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan() { const long value = 0x0F; Span buffer = stackalloc byte[0]; - Assert.That(value.TryWriteBytes(buffer), Is.False); + Assert.That(value.TryWriteLittleEndian(buffer), Is.False); + } + + [Test] + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() + { + const long value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteBigEndian(buffer), Is.False); } } diff --git a/X10D.Tests/src/IO/SingleTests.cs b/X10D.Tests/src/IO/SingleTests.cs index 5f753c4..e7de74d 100644 --- a/X10D.Tests/src/IO/SingleTests.cs +++ b/X10D.Tests/src/IO/SingleTests.cs @@ -7,60 +7,60 @@ namespace X10D.Tests.IO; internal class SingleTests { [Test] - public void GetBytes_ReturnsCorrectValue() + public void GetBigEndianBytes_ReturnsCorrectValue() { const float value = 42.5f; - byte[] bytes = BitConverter.IsLittleEndian - ? new byte[] {0, 0, 0x2A, 0x42} - : new byte[] {0x42, 0x2A, 0, 0}; - CollectionAssert.AreEqual(bytes, value.GetBytes()); + + var expected = new byte[] { 0x42, 0x2A, 0, 0 }; + byte[] actual = value.GetBigEndianBytes(); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void GetBytes_ReturnsCorrectValue_WithEndianness() + public void GetLittleEndianBytes_ReturnsCorrectValue() { const float value = 42.5f; - byte[] littleEndian = {0, 0, 0x2A, 0x42}; - byte[] bigEndian = {0x42, 0x2A, 0, 0}; - CollectionAssert.AreEqual(littleEndian, value.GetBytes(Endianness.LittleEndian)); - CollectionAssert.AreEqual(bigEndian, value.GetBytes(Endianness.BigEndian)); + var expected = new byte[] { 0, 0, 0x2A, 0x42 }; + byte[] actual = value.GetLittleEndianBytes(); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() + public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly() { const float value = 42.5f; - byte[] bytes = BitConverter.IsLittleEndian - ? new byte[] {0, 0, 0x2A, 0x42} - : new byte[] {0x42, 0x2A, 0, 0}; - Span buffer = stackalloc byte[4]; - Assert.That(value.TryWriteBytes(buffer)); - CollectionAssert.AreEqual(bytes, buffer.ToArray()); + var expected = new byte[] { 0x42, 0x2A, 0, 0 }; + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteBigEndian(actual)); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan_WithEndianness() + public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly() { const float value = 42.5f; - byte[] littleEndian = {0, 0, 0x2A, 0x42}; - byte[] bigEndian = {0x42, 0x2A, 0, 0}; - Span buffer = stackalloc byte[4]; - - Assert.That(value.TryWriteBytes(buffer, Endianness.LittleEndian)); - CollectionAssert.AreEqual(littleEndian, buffer.ToArray()); - - Assert.That(value.TryWriteBytes(buffer, Endianness.BigEndian)); - CollectionAssert.AreEqual(bigEndian, buffer.ToArray()); + var expected = new byte[] { 0, 0, 0x2A, 0x42 }; + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteLittleEndian(actual)); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsFalse_GivenSmallSpan() + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() { const float value = 42.5f; Span buffer = stackalloc byte[0]; - Assert.That(value.TryWriteBytes(buffer), Is.False); + Assert.That(value.TryWriteBigEndian(buffer), Is.False); + } + + [Test] + public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan() + { + const float value = 42.5f; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteLittleEndian(buffer), Is.False); } } diff --git a/X10D.Tests/src/IO/StreamTests.ReadDecimal.cs b/X10D.Tests/src/IO/StreamTests.ReadDecimal.cs index 7f61b76..c7fcdb5 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadDecimal.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadDecimal.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,37 +7,37 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void ReadDecimal_ShouldThrowArgumentException_GivenNonReadableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.ReadDecimal()); - Assert.Throws(() => stream.ReadDecimal(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadDecimal(Endianness.BigEndian)); - } - - [Test] - public void ReadDecimal_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadDecimalBigEndian_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; - Assert.Throws(() => stream.ReadDecimal()); - Assert.Throws(() => stream.ReadDecimal(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadDecimal(Endianness.BigEndian)); + Assert.Throws(() => stream.ReadDecimalBigEndian()); } [Test] - public void ReadDecimal_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadDecimalLittleEndian_ShouldThrowArgumentNullException_GivenNullStream() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.ReadDecimal((Endianness)(-1))); + Stream stream = null!; + Assert.Throws(() => stream.ReadDecimalLittleEndian()); } [Test] - public void ReadDecimal_ShouldReadBigEndian_GivenBigEndian() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadDecimalBigEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadDecimalBigEndian()); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadDecimalLittleEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadDecimalLittleEndian()); + } + + [Test] + public void ReadDecimalBigEndian_ShouldReadBigEndian() { using var stream = new MemoryStream(); ReadOnlySpan bytes = stackalloc byte[] @@ -47,7 +48,7 @@ internal partial class StreamTests stream.Position = 0; const decimal expected = 420.0m; - decimal actual = stream.ReadDecimal(Endianness.BigEndian); + decimal actual = stream.ReadDecimalBigEndian(); Assert.Multiple(() => { @@ -57,7 +58,7 @@ internal partial class StreamTests } [Test] - public void ReadDecimal_ShouldWriteLittleEndian_GivenLittleEndian() + public void ReadDecimalLittleEndian_ShouldWriteLittleEndian() { using var stream = new MemoryStream(); ReadOnlySpan bytes = stackalloc byte[] @@ -68,7 +69,7 @@ internal partial class StreamTests stream.Position = 0; const decimal expected = 420.0m; - decimal actual = stream.ReadDecimal(Endianness.LittleEndian); + decimal actual = stream.ReadDecimalLittleEndian(); Assert.Multiple(() => { diff --git a/X10D.Tests/src/IO/StreamTests.ReadDouble.cs b/X10D.Tests/src/IO/StreamTests.ReadDouble.cs index b400ac1..02f7991 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadDouble.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadDouble.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,60 +7,60 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void ReadDouble_ShouldThrowArgumentException_GivenNonReadableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.ReadDouble()); - Assert.Throws(() => stream.ReadDouble(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadDouble(Endianness.BigEndian)); - } - - [Test] - public void ReadDouble_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadDoubleBigEndian_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; - Assert.Throws(() => stream.ReadDouble()); - Assert.Throws(() => stream.ReadDouble(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadDouble(Endianness.BigEndian)); + Assert.Throws(() => stream.ReadDoubleBigEndian()); } [Test] - public void ReadDouble_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadDoubleLittleEndian_ShouldThrowArgumentNullException_GivenNullStream() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.ReadDouble((Endianness)(-1))); + Stream stream = null!; + Assert.Throws(() => stream.ReadDoubleLittleEndian()); } [Test] - public void ReadDouble_ShouldReadBigEndian_GivenBigEndian() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadDoubleBigEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadDoubleBigEndian()); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadDoubleLittleEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadDoubleLittleEndian()); + } + + [Test] + public void ReadDoubleBigEndian_ShouldReadBigEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00}; + ReadOnlySpan bytes = stackalloc byte[] { 0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 }; stream.Write(bytes); stream.Position = 0; const double expected = 420.0; - double actual = stream.ReadDouble(Endianness.BigEndian); + double actual = stream.ReadDoubleBigEndian(); Assert.That(stream.Position, Is.EqualTo(8)); Assert.That(actual, Is.EqualTo(expected)); } [Test] - public void ReadDouble_ShouldWriteLittleEndian_GivenLittleEndian() + public void ReadDoubleLittleEndian_ShouldWriteLittleEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40}; + ReadOnlySpan bytes = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40 }; stream.Write(bytes); stream.Position = 0; const double expected = 420.0; - double actual = stream.ReadDouble(Endianness.LittleEndian); + double actual = stream.ReadDoubleLittleEndian(); Assert.That(stream.Position, Is.EqualTo(8)); Assert.That(actual, Is.EqualTo(expected)); diff --git a/X10D.Tests/src/IO/StreamTests.ReadInt16.cs b/X10D.Tests/src/IO/StreamTests.ReadInt16.cs index 950f368..a71d4bd 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadInt16.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,60 +7,60 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void ReadInt16_ShouldThrowArgumentException_GivenNonReadableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.ReadInt16()); - Assert.Throws(() => stream.ReadInt16(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadInt16(Endianness.BigEndian)); - } - - [Test] - public void ReadInt16_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadInt16BigEndian_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; - Assert.Throws(() => stream.ReadInt16()); - Assert.Throws(() => stream.ReadInt16(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadInt16(Endianness.BigEndian)); + Assert.Throws(() => stream.ReadInt16BigEndian()); } [Test] - public void ReadInt16_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadInt16LittleEndian_ShouldThrowArgumentNullException_GivenNullStream() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.ReadInt16((Endianness)(-1))); + Stream stream = null!; + Assert.Throws(() => stream.ReadInt16LittleEndian()); } [Test] - public void ReadInt16_ShouldReadBigEndian_GivenBigEndian() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadInt16BigEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadInt16BigEndian()); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadInt16LittleEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadInt16LittleEndian()); + } + + [Test] + public void ReadInt16BigEndian_ShouldReadBigEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0x01, 0xA4}; + ReadOnlySpan bytes = stackalloc byte[] { 0x01, 0xA4 }; stream.Write(bytes); stream.Position = 0; const short expected = 420; - short actual = stream.ReadInt16(Endianness.BigEndian); + short actual = stream.ReadInt16BigEndian(); Assert.That(stream.Position, Is.EqualTo(2)); Assert.That(actual, Is.EqualTo(expected)); } [Test] - public void ReadInt16_ShouldReadLittleEndian_GivenLittleEndian() + public void ReadInt16LittleEndian_ShouldReadLittleEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0xA4, 0x01}; + ReadOnlySpan bytes = stackalloc byte[] { 0xA4, 0x01 }; stream.Write(bytes); stream.Position = 0; const short expected = 420; - short actual = stream.ReadInt16(Endianness.LittleEndian); + short actual = stream.ReadInt16LittleEndian(); Assert.That(stream.Position, Is.EqualTo(2)); Assert.That(actual, Is.EqualTo(expected)); diff --git a/X10D.Tests/src/IO/StreamTests.ReadInt32.cs b/X10D.Tests/src/IO/StreamTests.ReadInt32.cs index 8b45594..e51ef95 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadInt32.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,60 +7,60 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void ReadInt32_ShouldThrowArgumentException_GivenNonReadableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.ReadInt32()); - Assert.Throws(() => stream.ReadInt32(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadInt32(Endianness.BigEndian)); - } - - [Test] - public void ReadInt32_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadInt32BigEndian_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; - Assert.Throws(() => stream.ReadInt32()); - Assert.Throws(() => stream.ReadInt32(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadInt32(Endianness.BigEndian)); + Assert.Throws(() => stream.ReadInt32BigEndian()); } [Test] - public void ReadInt32_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadInt32LittleEndian_ShouldThrowArgumentNullException_GivenNullStream() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.ReadInt32((Endianness)(-1))); + Stream stream = null!; + Assert.Throws(() => stream.ReadInt32LittleEndian()); } [Test] - public void ReadInt32_ShouldReadBigEndian_GivenBigEndian() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadInt32BigEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadInt32BigEndian()); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadInt32LittleEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadInt32LittleEndian()); + } + + [Test] + public void ReadInt32BigEndian_ShouldReadBigEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0x00, 0x00, 0x01, 0xA4}; + ReadOnlySpan bytes = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 }; stream.Write(bytes); stream.Position = 0; const int expected = 420; - int actual = stream.ReadInt32(Endianness.BigEndian); + int actual = stream.ReadInt32BigEndian(); Assert.That(stream.Position, Is.EqualTo(4)); Assert.That(actual, Is.EqualTo(expected)); } [Test] - public void ReadInt32_ShouldReadLittleEndian_GivenLittleEndian() + public void ReadInt32LittleEndian_ShouldReadLittleEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0xA4, 0x01, 0x00, 0x00}; + ReadOnlySpan bytes = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 }; stream.Write(bytes); stream.Position = 0; const int expected = 420; - int actual = stream.ReadInt32(Endianness.LittleEndian); + int actual = stream.ReadInt32LittleEndian(); Assert.That(stream.Position, Is.EqualTo(4)); Assert.That(actual, Is.EqualTo(expected)); diff --git a/X10D.Tests/src/IO/StreamTests.ReadInt64.cs b/X10D.Tests/src/IO/StreamTests.ReadInt64.cs index d094a56..faebfda 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadInt64.cs @@ -6,60 +6,58 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void ReadInt64_ShouldThrowArgumentException_GivenNonReadableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.ReadInt64()); - Assert.Throws(() => stream.ReadInt64(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadInt64(Endianness.BigEndian)); - } - - [Test] - public void ReadInt64_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadInt64BigEndian_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; - Assert.Throws(() => stream.ReadInt64()); - Assert.Throws(() => stream.ReadInt64(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadInt64(Endianness.BigEndian)); + Assert.Throws(() => stream.ReadInt64BigEndian()); } [Test] - public void ReadInt64_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadInt64LittleEndian_ShouldThrowArgumentNullException_GivenNullStream() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.ReadInt64((Endianness)(-1))); + Stream stream = null!; + Assert.Throws(() => stream.ReadInt64LittleEndian()); } [Test] - public void ReadInt64_ShouldReadBigEndian_GivenBigEndian() + public void ReadInt64BigEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadInt64BigEndian()); + } + + [Test] + public void ReadInt64LittleEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadInt64LittleEndian()); + } + + [Test] + public void ReadInt64BigEndian_ShouldReadBigEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4}; + ReadOnlySpan bytes = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 }; stream.Write(bytes); stream.Position = 0; const long expected = 420; - long actual = stream.ReadInt64(Endianness.BigEndian); + long actual = stream.ReadInt64BigEndian(); Assert.That(stream.Position, Is.EqualTo(8)); Assert.That(actual, Is.EqualTo(expected)); } [Test] - public void ReadInt64_ShouldWriteLittleEndian_GivenLittleEndian() + public void ReadInt64LittleEndian_ShouldWriteLittleEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + ReadOnlySpan bytes = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; stream.Write(bytes); stream.Position = 0; const long expected = 420; - long actual = stream.ReadInt64(Endianness.LittleEndian); + long actual = stream.ReadInt64LittleEndian(); Assert.That(stream.Position, Is.EqualTo(8)); Assert.That(actual, Is.EqualTo(expected)); diff --git a/X10D.Tests/src/IO/StreamTests.ReadSingle.cs b/X10D.Tests/src/IO/StreamTests.ReadSingle.cs index 7d5a396..ff2336b 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadSingle.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadSingle.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,60 +7,60 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void ReadSingle_ShouldThrowArgumentException_GivenNonReadableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.ReadSingle()); - Assert.Throws(() => stream.ReadSingle(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadSingle(Endianness.BigEndian)); - } - - [Test] - public void ReadSingle_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadSingleBigEndian_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; - Assert.Throws(() => stream.ReadSingle()); - Assert.Throws(() => stream.ReadSingle(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadSingle(Endianness.BigEndian)); + Assert.Throws(() => stream.ReadSingleBigEndian()); } [Test] - public void ReadSingle_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadSingleLittleEndian_ShouldThrowArgumentNullException_GivenNullStream() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.ReadSingle((Endianness)(-1))); + Stream stream = null!; + Assert.Throws(() => stream.ReadSingleLittleEndian()); } [Test] - public void ReadSingle_ShouldReadBigEndian_GivenBigEndian() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadSingleBigEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadSingleBigEndian()); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadSingleLittleEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadSingleLittleEndian()); + } + + [Test] + public void ReadSingleBigEndian_ShouldReadBigEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0x43, 0xD2, 0x00, 0x00}; + ReadOnlySpan bytes = stackalloc byte[] { 0x43, 0xD2, 0x00, 0x00 }; stream.Write(bytes); stream.Position = 0; const float expected = 420.0f; - float actual = stream.ReadSingle(Endianness.BigEndian); + float actual = stream.ReadSingleBigEndian(); Assert.That(stream.Position, Is.EqualTo(4)); Assert.That(actual, Is.EqualTo(expected)); } [Test] - public void ReadSingle_ShouldReadLittleEndian_GivenLittleEndian() + public void ReadSingleLittleEndian_ShouldReadLittleEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0x00, 0x00, 0xD2, 0x43}; + ReadOnlySpan bytes = stackalloc byte[] { 0x00, 0x00, 0xD2, 0x43 }; stream.Write(bytes); stream.Position = 0; const float expected = 420.0f; - float actual = stream.ReadSingle(Endianness.LittleEndian); + float actual = stream.ReadSingleLittleEndian(); Assert.That(stream.Position, Is.EqualTo(4)); Assert.That(actual, Is.EqualTo(expected)); diff --git a/X10D.Tests/src/IO/StreamTests.ReadUInt16.cs b/X10D.Tests/src/IO/StreamTests.ReadUInt16.cs index cd8d726..0cd249d 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadUInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadUInt16.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,60 +7,60 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void ReadUInt16_ShouldThrowArgumentException_GivenNonReadableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.ReadUInt16()); - Assert.Throws(() => stream.ReadUInt16(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadUInt16(Endianness.BigEndian)); - } - - [Test] - public void ReadUInt16_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadUInt16BigEndian_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; - Assert.Throws(() => stream.ReadUInt16()); - Assert.Throws(() => stream.ReadUInt16(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadUInt16(Endianness.BigEndian)); + Assert.Throws(() => stream.ReadUInt16BigEndian()); } [Test] - public void ReadUInt16_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadUInt16LittleEndian_ShouldThrowArgumentNullException_GivenNullStream() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.ReadUInt16((Endianness)(-1))); + Stream stream = null!; + Assert.Throws(() => stream.ReadUInt16LittleEndian()); } [Test] - public void ReadUInt16_ShouldReadBigEndian_GivenBigEndian() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadUInt16BigEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadUInt16BigEndian()); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadUInt16LittleEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadUInt16LittleEndian()); + } + + [Test] + public void ReadUInt16BigEndian_ShouldReadBigEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0x01, 0xA4}; + ReadOnlySpan bytes = stackalloc byte[] { 0x01, 0xA4 }; stream.Write(bytes); stream.Position = 0; const ushort expected = 420; - ushort actual = stream.ReadUInt16(Endianness.BigEndian); + ushort actual = stream.ReadUInt16BigEndian(); Assert.That(stream.Position, Is.EqualTo(2)); Assert.That(actual, Is.EqualTo(expected)); } [Test] - public void ReadUInt16_ShouldReadLittleEndian_GivenLittleEndian() + public void ReadUInt16LittleEndian_ShouldReadLittleEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0xA4, 0x01}; + ReadOnlySpan bytes = stackalloc byte[] { 0xA4, 0x01 }; stream.Write(bytes); stream.Position = 0; const ushort expected = 420; - ushort actual = stream.ReadUInt16(Endianness.LittleEndian); + ushort actual = stream.ReadUInt16LittleEndian(); Assert.That(stream.Position, Is.EqualTo(2)); Assert.That(actual, Is.EqualTo(expected)); diff --git a/X10D.Tests/src/IO/StreamTests.ReadUInt32.cs b/X10D.Tests/src/IO/StreamTests.ReadUInt32.cs index cc5c67d..3164afe 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadUInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadUInt32.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,60 +7,60 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void ReadUInt32_ShouldThrowArgumentException_GivenNonReadableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.ReadUInt32()); - Assert.Throws(() => stream.ReadUInt32(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadUInt32(Endianness.BigEndian)); - } - - [Test] - public void ReadUInt32_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadUInt32BigEndian_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; - Assert.Throws(() => stream.ReadUInt32()); - Assert.Throws(() => stream.ReadUInt32(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadUInt32(Endianness.BigEndian)); + Assert.Throws(() => stream.ReadUInt32BigEndian()); } [Test] - public void ReadUInt32_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadUInt32LittleEndian_ShouldThrowArgumentNullException_GivenNullStream() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.ReadUInt32((Endianness)(-1))); + Stream stream = null!; + Assert.Throws(() => stream.ReadUInt32LittleEndian()); } [Test] - public void ReadUInt32_ShouldReadBigEndian_GivenBigEndian() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadUInt32BigEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadUInt32BigEndian()); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadUInt32LittleEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadUInt32LittleEndian()); + } + + [Test] + public void ReadUInt32BigEndian_ShouldReadBigEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0x00, 0x00, 0x01, 0xA4}; + ReadOnlySpan bytes = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 }; stream.Write(bytes); stream.Position = 0; const uint expected = 420; - uint actual = stream.ReadUInt32(Endianness.BigEndian); + uint actual = stream.ReadUInt32BigEndian(); Assert.That(stream.Position, Is.EqualTo(4)); Assert.That(actual, Is.EqualTo(expected)); } [Test] - public void ReadUInt32_ShouldReadLittleEndian_GivenLittleEndian() + public void ReadUInt32LittleEndian_ShouldReadLittleEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0xA4, 0x01, 0x00, 0x00}; + ReadOnlySpan bytes = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 }; stream.Write(bytes); stream.Position = 0; const uint expected = 420; - uint actual = stream.ReadUInt32(Endianness.LittleEndian); + uint actual = stream.ReadUInt32LittleEndian(); Assert.That(stream.Position, Is.EqualTo(4)); Assert.That(actual, Is.EqualTo(expected)); diff --git a/X10D.Tests/src/IO/StreamTests.ReadUInt64.cs b/X10D.Tests/src/IO/StreamTests.ReadUInt64.cs index 0d916a7..ca33b01 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadUInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadUInt64.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,60 +7,60 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void ReadUInt64_ShouldThrowArgumentException_GivenNonReadableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.ReadUInt64()); - Assert.Throws(() => stream.ReadUInt64(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadUInt64(Endianness.BigEndian)); - } - - [Test] - public void ReadUInt64_ShouldThrowArgumentNullException_GivenNullStream() + public void ReadUInt64BigEndian_ShouldThrowArgumentNullException_GivenNullStream() { Stream stream = null!; - Assert.Throws(() => stream.ReadUInt64()); - Assert.Throws(() => stream.ReadUInt64(Endianness.LittleEndian)); - Assert.Throws(() => stream.ReadUInt64(Endianness.BigEndian)); + Assert.Throws(() => stream.ReadUInt64BigEndian()); } [Test] - public void ReadUInt64_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + public void ReadUInt64LittleEndian_ShouldThrowArgumentNullException_GivenNullStream() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.ReadUInt64((Endianness)(-1))); + Stream stream = null!; + Assert.Throws(() => stream.ReadUInt64LittleEndian()); } [Test] - public void ReadUInt64_ShouldReadBigEndian_GivenBigEndian() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadUInt64BigEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadUInt64BigEndian()); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void ReadUInt64LittleEndian_ShouldThrowArgumentException_GivenNonReadableStream() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.ReadUInt64LittleEndian()); + } + + [Test] + public void ReadUInt64BigEndian_ShouldReadBigEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4}; + ReadOnlySpan bytes = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 }; stream.Write(bytes); stream.Position = 0; const ulong expected = 420; - ulong actual = stream.ReadUInt64(Endianness.BigEndian); + ulong actual = stream.ReadUInt64BigEndian(); Assert.That(stream.Position, Is.EqualTo(8)); Assert.That(actual, Is.EqualTo(expected)); } [Test] - public void ReadUInt64_ShouldWriteLittleEndian_GivenLittleEndian() + public void ReadUInt64LittleEndian_ShouldWriteLittleEndian() { using var stream = new MemoryStream(); - ReadOnlySpan bytes = stackalloc byte[] {0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + ReadOnlySpan bytes = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; stream.Write(bytes); stream.Position = 0; const ulong expected = 420; - ulong actual = stream.ReadUInt64(Endianness.LittleEndian); + ulong actual = stream.ReadUInt64LittleEndian(); Assert.That(stream.Position, Is.EqualTo(8)); Assert.That(actual, Is.EqualTo(expected)); diff --git a/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs b/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs index 3aaa113..911dd5d 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using NUnit.Framework; using X10D.IO; @@ -7,46 +8,47 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void WriteDecimal_ShouldThrowArgumentException_GivenNonWriteableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.Write(420.0m, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420.0m, Endianness.BigEndian)); - } - - [Test] - public void WriteDecimal_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteBigEndian_ShouldThrowArgumentNullException_GivenNullStream_AndDecimalArgument() { Stream stream = null!; - Assert.Throws(() => stream.Write(420.0m, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420.0m, Endianness.BigEndian)); + Assert.Throws(() => stream.WriteBigEndian(420.0m)); } [Test] - public void WriteDecimal_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteBigEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndDecimalArgument() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.Write(420.0m, (Endianness)(-1))); - Assert.Throws(() => stream.Write(420.0m, (Endianness)(-1))); + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteBigEndian(420.0m)); } [Test] - public void WriteDecimal_ShouldWriteBigEndian_GivenBigEndian() + public void WriteLittleEndian_ShouldThrowArgumentNullException_GivenNullStream_AndDecimalArgument() + { + Stream stream = null!; + Assert.Throws(() => stream.WriteLittleEndian(420.0m)); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteLittleEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndDecimalArgument() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteLittleEndian(420.0m)); + } + + [Test] + public void WriteBigEndian_ShouldWriteBigEndian_GivenDecimalArgument() { using var stream = new MemoryStream(); - stream.Write(420.0m, Endianness.BigEndian); + stream.WriteBigEndian(420.0m); Assert.That(stream.Position, Is.EqualTo(16)); stream.Position = 0; Span actual = stackalloc byte[16]; ReadOnlySpan expected = stackalloc byte[] { - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x68 + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x10, 0x00, 0x00 }; int read = stream.Read(actual); @@ -55,10 +57,10 @@ internal partial class StreamTests } [Test] - public void WriteDecimal_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteLittleEndian_ShouldWriteLittleEndian_GivenDecimalArgument() { using var stream = new MemoryStream(); - stream.Write(420.0m, Endianness.LittleEndian); + stream.WriteLittleEndian(420.0m); Assert.That(stream.Position, Is.EqualTo(16)); stream.Position = 0; diff --git a/X10D.Tests/src/IO/StreamTests.WriteDouble.cs b/X10D.Tests/src/IO/StreamTests.WriteDouble.cs index e933858..8828325 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteDouble.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteDouble.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,44 +7,45 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void WriteDouble_ShouldThrowArgumentException_GivenNonWriteableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.Write(420.0, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420.0, Endianness.BigEndian)); - } - - [Test] - public void WriteDouble_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteBigEndian_ShouldThrowArgumentNullException_GivenNullStream_AndDoubleArgument() { Stream stream = null!; - Assert.Throws(() => stream.Write(420.0, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420.0, Endianness.BigEndian)); + Assert.Throws(() => stream.WriteBigEndian(420.0)); } [Test] - public void WriteDouble_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteBigEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndDoubleArgument() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.Write(420.0, (Endianness)(-1))); - Assert.Throws(() => stream.Write(420.0, (Endianness)(-1))); + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteBigEndian(420.0)); } [Test] - public void WriteDouble_ShouldWriteBigEndian_GivenBigEndian() + public void WriteLittleEndian_ShouldThrowArgumentNullException_GivenNullStream_AndDoubleArgument() + { + Stream stream = null!; + Assert.Throws(() => stream.WriteLittleEndian(420.0)); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteLittleEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndDoubleArgument() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteLittleEndian(420.0)); + } + + [Test] + public void WriteBigEndian_ShouldWriteBigEndian_GivenDoubleArgument() { using var stream = new MemoryStream(); - stream.Write(420.0, Endianness.BigEndian); + stream.WriteBigEndian(420.0); Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] {0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00}; + ReadOnlySpan expected = stackalloc byte[] { 0x40, 0x7A, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(8)); @@ -51,15 +53,15 @@ internal partial class StreamTests } [Test] - public void WriteDouble_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteLittleEndian_ShouldWriteLittleEndian_GivenDoubleArgument() { using var stream = new MemoryStream(); - stream.Write(420.0, Endianness.LittleEndian); + stream.WriteLittleEndian(420.0); Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40}; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x7A, 0x40 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(8)); diff --git a/X10D.Tests/src/IO/StreamTests.WriteInt16.cs b/X10D.Tests/src/IO/StreamTests.WriteInt16.cs index cc17549..bc38dd8 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt16.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,44 +7,45 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void WriteInt16_ShouldThrowArgumentException_GivenNonWriteableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.Write((short)420, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write((short)420, Endianness.BigEndian)); - } - - [Test] - public void WriteInt16_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteBigEndian_ShouldThrowArgumentNullException_GivenNullStream_AndInt16Argument() { Stream stream = null!; - Assert.Throws(() => stream.Write((short)420, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write((short)420, Endianness.BigEndian)); + Assert.Throws(() => stream.WriteBigEndian((short)420)); } [Test] - public void WriteInt16_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteBigEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndInt16Argument() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.Write((short)420, (Endianness)(-1))); - Assert.Throws(() => stream.Write((short)420, (Endianness)(-1))); + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteBigEndian((short)420)); } [Test] - public void WriteInt16_ShouldWriteBigEndian_GivenBigEndian() + public void WriteLittleEndian_ShouldThrowArgumentNullException_GivenNullStream_AndInt16Argument() + { + Stream stream = null!; + Assert.Throws(() => stream.WriteLittleEndian((short)420)); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteLittleEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndInt16Argument() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteLittleEndian((short)420)); + } + + [Test] + public void WriteBigEndian_ShouldWriteBigEndian_GivenInt16Argument() { using var stream = new MemoryStream(); - stream.Write((short)420, Endianness.BigEndian); + stream.WriteBigEndian((short)420); Assert.That(stream.Position, Is.EqualTo(2)); stream.Position = 0; Span actual = stackalloc byte[2]; - ReadOnlySpan expected = stackalloc byte[] {0x01, 0xA4}; + ReadOnlySpan expected = stackalloc byte[] { 0x01, 0xA4 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(2)); @@ -51,15 +53,15 @@ internal partial class StreamTests } [Test] - public void WriteInt16_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteLittleEndian_ShouldWriteLittleEndian_GivenInt16Argument() { using var stream = new MemoryStream(); - stream.Write((short)420, Endianness.LittleEndian); + stream.WriteLittleEndian((short)420); Assert.That(stream.Position, Is.EqualTo(2)); stream.Position = 0; Span actual = stackalloc byte[2]; - ReadOnlySpan expected = stackalloc byte[] {0xA4, 0x01}; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(2)); diff --git a/X10D.Tests/src/IO/StreamTests.WriteInt32.cs b/X10D.Tests/src/IO/StreamTests.WriteInt32.cs index 95f748e..75688f9 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt32.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,44 +7,45 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void WriteInt32_ShouldThrowArgumentException_GivenNonWriteableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.Write(420, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420, Endianness.BigEndian)); - } - - [Test] - public void WriteInt32_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteBigEndian_ShouldThrowArgumentNullException_GivenNullStream_AndInt32Argument() { Stream stream = null!; - Assert.Throws(() => stream.Write(420, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420, Endianness.BigEndian)); + Assert.Throws(() => stream.WriteBigEndian(420)); } [Test] - public void WriteInt32_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteBigEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndInt32Argument() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.Write(420, (Endianness)(-1))); - Assert.Throws(() => stream.Write(420, (Endianness)(-1))); + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteBigEndian(420)); } [Test] - public void WriteInt32_ShouldWriteBigEndian_GivenBigEndian() + public void WriteLittleEndian_ShouldThrowArgumentNullException_GivenNullStream_AndInt32Argument() + { + Stream stream = null!; + Assert.Throws(() => stream.WriteLittleEndian(420)); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteLittleEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndInt32Argument() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteLittleEndian(420)); + } + + [Test] + public void WriteBigEndian_ShouldWriteBigEndian_GivenInt32Argument() { using var stream = new MemoryStream(); - stream.Write(420, Endianness.BigEndian); + stream.WriteBigEndian(420); Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] {0x00, 0x00, 0x01, 0xA4}; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(4)); @@ -51,15 +53,15 @@ internal partial class StreamTests } [Test] - public void WriteInt32_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteLittleEndian_ShouldWriteLittleEndian_GivenInt32Argument() { using var stream = new MemoryStream(); - stream.Write(420, Endianness.LittleEndian); + stream.WriteLittleEndian(420); Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] {0xA4, 0x01, 0x00, 0x00}; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(4)); diff --git a/X10D.Tests/src/IO/StreamTests.WriteInt64.cs b/X10D.Tests/src/IO/StreamTests.WriteInt64.cs index adb8ce2..feeb677 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt64.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,44 +7,45 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void WriteInt64_ShouldThrowArgumentException_GivenNonWriteableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.Write(420L, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420L, Endianness.BigEndian)); - } - - [Test] - public void WriteInt64_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteBigEndian_ShouldThrowArgumentNullException_GivenNullStream_AndInt64Argument() { Stream stream = null!; - Assert.Throws(() => stream.Write(420L, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420L, Endianness.BigEndian)); + Assert.Throws(() => stream.WriteBigEndian(420L)); } [Test] - public void WriteInt64_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteBigEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndInt64Argument() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.Write(420L, (Endianness)(-1))); - Assert.Throws(() => stream.Write(420L, (Endianness)(-1))); + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteBigEndian(420L)); } [Test] - public void WriteInt64_ShouldWriteBigEndian_GivenBigEndian() + public void WriteLittleEndian_ShouldThrowArgumentNullException_GivenNullStream_AndInt64Argument() + { + Stream stream = null!; + Assert.Throws(() => stream.WriteLittleEndian(420L)); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteLittleEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndInt64Argument() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteLittleEndian(420L)); + } + + [Test] + public void WriteBigEndian_ShouldWriteBigEndian_GivenInt64Argument() { using var stream = new MemoryStream(); - stream.Write(420L, Endianness.BigEndian); + stream.WriteBigEndian(420L); Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4}; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(8)); @@ -51,15 +53,15 @@ internal partial class StreamTests } [Test] - public void WriteInt64_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteLittleEndian_ShouldWriteLittleEndian_GivenLittleEndian() { using var stream = new MemoryStream(); - stream.Write(420L, Endianness.LittleEndian); + stream.WriteLittleEndian(420L); Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] {0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(8)); diff --git a/X10D.Tests/src/IO/StreamTests.WriteSingle.cs b/X10D.Tests/src/IO/StreamTests.WriteSingle.cs index 4a7376e..7df8eb8 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteSingle.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteSingle.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,44 +7,45 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void WriteSingle_ShouldThrowArgumentException_GivenNonWriteableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.Write(420.0f, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420.0f, Endianness.BigEndian)); - } - - [Test] - public void WriteSingle_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteBigEndian_ShouldThrowArgumentNullException_GivenNullStream_AndSingleArgument() { Stream stream = null!; - Assert.Throws(() => stream.Write(420.0f, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420.0f, Endianness.BigEndian)); + Assert.Throws(() => stream.WriteBigEndian(420.0f)); } [Test] - public void WriteSingle_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteBigEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndSingleArgument() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.Write(420.0f, (Endianness)(-1))); - Assert.Throws(() => stream.Write(420.0f, (Endianness)(-1))); + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteBigEndian(420.0f)); } [Test] - public void WriteSingle_ShouldWriteBigEndian_GivenBigEndian() + public void WriteLittleEndian_ShouldThrowArgumentNullException_GivenNullStream_AndSingleArgument() + { + Stream stream = null!; + Assert.Throws(() => stream.WriteLittleEndian(420.0f)); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteLittleEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndSingleArgument() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteLittleEndian(420.0f)); + } + + [Test] + public void WriteBigEndian_ShouldWriteBigEndian_GivenSingleArgument() { using var stream = new MemoryStream(); - stream.Write(420.0f, Endianness.BigEndian); + stream.WriteBigEndian(420.0f); Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] {0x43, 0xD2, 0x00, 0x00}; + ReadOnlySpan expected = stackalloc byte[] { 0x43, 0xD2, 0x00, 0x00 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(4)); @@ -51,15 +53,15 @@ internal partial class StreamTests } [Test] - public void WriteSingle_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteLittleEndian_ShouldWriteLittleEndian_GivenSingleArgument() { using var stream = new MemoryStream(); - stream.Write(420.0f, Endianness.LittleEndian); + stream.WriteLittleEndian(420.0f); Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] {0x00, 0x00, 0xD2, 0x43}; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0xD2, 0x43 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(4)); diff --git a/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs b/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs index 89a620f..7fde9f2 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,44 +7,45 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void WriteUInt16_ShouldThrowArgumentException_GivenNonWriteableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.Write((ushort)420, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write((ushort)420, Endianness.BigEndian)); - } - - [Test] - public void WriteUInt16_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteBigEndian_ShouldThrowArgumentNullException_GivenNullStream_AndUInt16Argument() { Stream stream = null!; - Assert.Throws(() => stream.Write((ushort)420, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write((ushort)420, Endianness.BigEndian)); + Assert.Throws(() => stream.WriteBigEndian((ushort)420)); } [Test] - public void WriteUInt16_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteBigEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndUInt16Argument() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.Write((ushort)420, (Endianness)(-1))); - Assert.Throws(() => stream.Write((ushort)420, (Endianness)(-1))); + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteBigEndian((ushort)420)); } [Test] - public void WriteUInt16_ShouldWriteBigEndian_GivenBigEndian() + public void WriteLittleEndian_ShouldThrowArgumentNullException_GivenNullStream_AndUInt16Argument() + { + Stream stream = null!; + Assert.Throws(() => stream.WriteLittleEndian((ushort)420)); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteLittleEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndUInt16Argument() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteLittleEndian((ushort)420)); + } + + [Test] + public void WriteBigEndian_ShouldWriteBigEndian_GivenUInt16Endian() { using var stream = new MemoryStream(); - stream.Write((ushort)420, Endianness.BigEndian); + stream.WriteBigEndian((ushort)420); Assert.That(stream.Position, Is.EqualTo(2)); stream.Position = 0; Span actual = stackalloc byte[2]; - ReadOnlySpan expected = stackalloc byte[] {0x01, 0xA4}; + ReadOnlySpan expected = stackalloc byte[] { 0x01, 0xA4 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(2)); @@ -51,15 +53,15 @@ internal partial class StreamTests } [Test] - public void WriteUInt16_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteLittleEndian_ShouldWriteLittleEndian_GivenUInt16tleEndian() { using var stream = new MemoryStream(); - stream.Write((ushort)420, Endianness.LittleEndian); + stream.WriteLittleEndian((ushort)420); Assert.That(stream.Position, Is.EqualTo(2)); stream.Position = 0; Span actual = stackalloc byte[2]; - ReadOnlySpan expected = stackalloc byte[] {0xA4, 0x01}; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(2)); diff --git a/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs b/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs index a9c3bb9..e5eafb7 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,44 +7,45 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void WriteUInt32_ShouldThrowArgumentException_GivenNonWriteableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.Write(420U, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420U, Endianness.BigEndian)); - } - - [Test] - public void WriteUInt32_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteBigEndian_ShouldThrowArgumentNullException_GivenNullStream_AndUInt32Argument() { Stream stream = null!; - Assert.Throws(() => stream.Write(420U, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420U, Endianness.BigEndian)); + Assert.Throws(() => stream.WriteBigEndian(420U)); } [Test] - public void WriteUInt32_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteBigEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndUInt32Argument() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.Write(420U, (Endianness)(-1))); - Assert.Throws(() => stream.Write(420U, (Endianness)(-1))); + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteBigEndian(420U)); } [Test] - public void WriteUInt32_ShouldWriteBigEndian_GivenBigEndian() + public void WriteLittleEndian_ShouldThrowArgumentNullException_GivenNullStream_AndUInt32Argument() + { + Stream stream = null!; + Assert.Throws(() => stream.WriteLittleEndian(420U)); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteLittleEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndUInt32Argument() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteLittleEndian(420U)); + } + + [Test] + public void WriteBigEndian_ShouldWriteBigEndian_GivenUInt32Argument() { using var stream = new MemoryStream(); - stream.Write(420U, Endianness.BigEndian); + stream.WriteBigEndian(420U); Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] {0x00, 0x00, 0x01, 0xA4}; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x01, 0xA4 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(4)); @@ -51,15 +53,15 @@ internal partial class StreamTests } [Test] - public void WriteUInt32_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteLittleEndian_ShouldWriteLittleEndian_GivenUInt32Argument() { using var stream = new MemoryStream(); - stream.Write(420U, Endianness.LittleEndian); + stream.WriteLittleEndian(420U); Assert.That(stream.Position, Is.EqualTo(4)); stream.Position = 0; Span actual = stackalloc byte[4]; - ReadOnlySpan expected = stackalloc byte[] {0xA4, 0x01, 0x00, 0x00}; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(4)); diff --git a/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs b/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs index dad8cc4..1bf8464 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; @@ -6,44 +7,45 @@ namespace X10D.Tests.IO; internal partial class StreamTests { [Test] - public void WriteUInt64_ShouldThrowArgumentException_GivenNonWriteableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.Write(420UL, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420UL, Endianness.BigEndian)); - } - - [Test] - public void WriteUInt64_ShouldThrowArgumentNullException_GivenNullStream() + public void WriteBigEndian_ShouldThrowArgumentNullException_GivenNullStream_AndUInt64Argument() { Stream stream = null!; - Assert.Throws(() => stream.Write(420UL, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420UL, Endianness.BigEndian)); + Assert.Throws(() => stream.WriteBigEndian(420UL)); } [Test] - public void WriteUInt64_ShouldThrowArgumentOutOfRangeException_GivenInvalidEndiannessValue() + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteBigEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndUInt64Argument() { - // we don't need to enclose this stream in a using declaration, since disposing a - // null stream is meaningless. NullStream.Dispose actually does nothing, anyway. - // that - coupled with the fact that encapsulating the stream in a using declaration causes the - // analyser to trip up and think the stream is disposed by the time the local is captured in - // assertion lambda - means this line is fine as it is. please do not change. - Stream stream = Stream.Null; - Assert.Throws(() => stream.Write(420UL, (Endianness)(-1))); - Assert.Throws(() => stream.Write(420UL, (Endianness)(-1))); + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteBigEndian(420UL)); } [Test] - public void WriteUInt64_ShouldWriteBigEndian_GivenBigEndian() + public void WriteLittleEndian_ShouldThrowArgumentNullException_GivenNullStream_AndUInt64Argument() + { + Stream stream = null!; + Assert.Throws(() => stream.WriteLittleEndian(420UL)); + } + + [Test] + [SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope")] + public void WriteLittleEndian_ShouldThrowArgumentException_GivenNonWritableStream_AndUInt64Argument() + { + Stream stream = new DummyStream(); + Assert.Throws(() => stream.WriteLittleEndian(420UL)); + } + + [Test] + public void WriteBigEndian_ShouldWriteBigEndian_GivenUInt64Argument() { using var stream = new MemoryStream(); - stream.Write(420UL, Endianness.BigEndian); + stream.WriteBigEndian(420UL); Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4}; + ReadOnlySpan expected = stackalloc byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xA4 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(8)); @@ -51,15 +53,15 @@ internal partial class StreamTests } [Test] - public void WriteUInt64_ShouldWriteLittleEndian_GivenLittleEndian() + public void WriteLittleEndian_ShouldWriteLittleEndian_GivenUInt64Argument() { using var stream = new MemoryStream(); - stream.Write(420UL, Endianness.LittleEndian); + stream.WriteLittleEndian(420UL); Assert.That(stream.Position, Is.EqualTo(8)); stream.Position = 0; Span actual = stackalloc byte[8]; - ReadOnlySpan expected = stackalloc byte[] {0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + ReadOnlySpan expected = stackalloc byte[] { 0xA4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; int read = stream.Read(actual); Assert.That(read, Is.EqualTo(8)); diff --git a/X10D.Tests/src/IO/UInt16Tests.cs b/X10D.Tests/src/IO/UInt16Tests.cs index 6085358..4ce858d 100644 --- a/X10D.Tests/src/IO/UInt16Tests.cs +++ b/X10D.Tests/src/IO/UInt16Tests.cs @@ -7,56 +7,62 @@ namespace X10D.Tests.IO; internal class UInt16Tests { [Test] - public void GetBytes_ReturnsCorrectValue() + public void GetLittleEndianBytes_ReturnsCorrectValue_WithEndianness() { const ushort value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian ? new byte[] {0x0F, 0} : new byte[] {0, 0x0F}; - CollectionAssert.AreEqual(bytes, value.GetBytes()); + byte[] expected = { 0x0F, 0 }; + byte[] actual = value.GetLittleEndianBytes(); + + CollectionAssert.AreEqual(expected, actual); } [Test] - public void GetBytes_ReturnsCorrectValue_WithEndianness() + public void GetBigEndianBytes_ReturnsCorrectValue_WithEndianness() { const ushort value = 0x0F; - byte[] littleEndian = {0x0F, 0}; - byte[] bigEndian = {0, 0x0F}; + byte[] expected = { 0, 0x0F }; + byte[] actual = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(littleEndian, value.GetBytes(Endianness.LittleEndian)); - CollectionAssert.AreEqual(bigEndian, value.GetBytes(Endianness.BigEndian)); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() + public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() { const ushort value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian ? new byte[] {0x0F, 0} : new byte[] {0, 0x0F}; + byte[] expected = { 0x0F, 0 }; - Span buffer = stackalloc byte[2]; - Assert.That(value.TryWriteBytes(buffer)); - CollectionAssert.AreEqual(bytes, buffer.ToArray()); + Span actual = stackalloc byte[2]; + Assert.That(value.TryWriteLittleEndian(actual)); + + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan_WithEndianness() + public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() { const ushort value = 0x0F; - byte[] littleEndian = {0x0F, 0}; - byte[] bigEndian = {0, 0x0F}; + byte[] expected = { 0, 0x0F }; - Span buffer = stackalloc byte[2]; + Span actual = stackalloc byte[2]; + Assert.That(value.TryWriteBigEndian(actual)); - Assert.That(value.TryWriteBytes(buffer, Endianness.LittleEndian)); - CollectionAssert.AreEqual(littleEndian, buffer.ToArray()); - - Assert.That(value.TryWriteBytes(buffer, Endianness.BigEndian)); - CollectionAssert.AreEqual(bigEndian, buffer.ToArray()); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsFalse_GivenSmallSpan() + public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan() { const ushort value = 0x0F; Span buffer = stackalloc byte[0]; - Assert.That(value.TryWriteBytes(buffer), Is.False); + Assert.That(value.TryWriteLittleEndian(buffer), Is.False); + } + + [Test] + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() + { + const ushort value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteBigEndian(buffer), Is.False); } } diff --git a/X10D.Tests/src/IO/UInt32Tests.cs b/X10D.Tests/src/IO/UInt32Tests.cs index a04ea4b..eada9aa 100644 --- a/X10D.Tests/src/IO/UInt32Tests.cs +++ b/X10D.Tests/src/IO/UInt32Tests.cs @@ -7,56 +7,62 @@ namespace X10D.Tests.IO; internal class UInt32Tests { [Test] - public void GetBytes_ReturnsCorrectValue() + public void GetLittleEndianBytes_ReturnsCorrectValue_WithEndianness() { const uint value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian ? new byte[] {0x0F, 0, 0, 0} : new byte[] {0, 0, 0, 0x0F}; - CollectionAssert.AreEqual(bytes, value.GetBytes()); + byte[] expected = { 0x0F, 0, 0, 0 }; + byte[] actual = value.GetLittleEndianBytes(); + + CollectionAssert.AreEqual(expected, actual); } [Test] - public void GetBytes_ReturnsCorrectValue_WithEndianness() + public void GetBigEndianBytes_ReturnsCorrectValue_WithEndianness() { const uint value = 0x0F; - byte[] littleEndian = {0x0F, 0, 0, 0}; - byte[] bigEndian = {0, 0, 0, 0x0F}; + byte[] expected = { 0, 0, 0, 0x0F }; + byte[] actual = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(littleEndian, value.GetBytes(Endianness.LittleEndian)); - CollectionAssert.AreEqual(bigEndian, value.GetBytes(Endianness.BigEndian)); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() + public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() { const uint value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian ? new byte[] {0x0F, 0, 0, 0} : new byte[] {0, 0, 0, 0x0F}; + byte[] expected = { 0x0F, 0, 0, 0 }; - Span buffer = stackalloc byte[4]; - Assert.That(value.TryWriteBytes(buffer)); - CollectionAssert.AreEqual(bytes, buffer.ToArray()); + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteLittleEndian(actual)); + + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan_WithEndianness() + public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() { const uint value = 0x0F; - byte[] littleEndian = {0x0F, 0, 0, 0}; - byte[] bigEndian = {0, 0, 0, 0x0F}; + byte[] expected = { 0, 0, 0, 0x0F }; - Span buffer = stackalloc byte[4]; + Span actual = stackalloc byte[4]; + Assert.That(value.TryWriteBigEndian(actual)); - Assert.That(value.TryWriteBytes(buffer, Endianness.LittleEndian)); - CollectionAssert.AreEqual(littleEndian, buffer.ToArray()); - - Assert.That(value.TryWriteBytes(buffer, Endianness.BigEndian)); - CollectionAssert.AreEqual(bigEndian, buffer.ToArray()); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsFalse_GivenSmallSpan() + public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan() { const uint value = 0x0F; Span buffer = stackalloc byte[0]; - Assert.That(value.TryWriteBytes(buffer), Is.False); + Assert.That(value.TryWriteLittleEndian(buffer), Is.False); + } + + [Test] + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() + { + const uint value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteBigEndian(buffer), Is.False); } } diff --git a/X10D.Tests/src/IO/UInt64Tests.cs b/X10D.Tests/src/IO/UInt64Tests.cs index af5727d..6ed1be8 100644 --- a/X10D.Tests/src/IO/UInt64Tests.cs +++ b/X10D.Tests/src/IO/UInt64Tests.cs @@ -7,60 +7,62 @@ namespace X10D.Tests.IO; internal class UInt64Tests { [Test] - public void GetBytes_ReturnsCorrectValue() + public void GetLittleEndianBytes_ReturnsCorrectValue_WithEndianness() { const ulong value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian - ? new byte[] {0x0F, 0, 0, 0, 0, 0, 0, 0} - : new byte[] {0, 0, 0, 0, 0, 0, 0, 0x0F}; - CollectionAssert.AreEqual(bytes, value.GetBytes()); + byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 }; + byte[] actual = value.GetLittleEndianBytes(); + + CollectionAssert.AreEqual(expected, actual); } [Test] - public void GetBytes_ReturnsCorrectValue_WithEndianness() + public void GetBigEndianBytes_ReturnsCorrectValue_WithEndianness() { const ulong value = 0x0F; - byte[] littleEndian = {0x0F, 0, 0, 0, 0, 0, 0, 0}; - byte[] bigEndian = {0, 0, 0, 0, 0, 0, 0, 0x0F}; + byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F }; + byte[] actual = value.GetBigEndianBytes(); - CollectionAssert.AreEqual(littleEndian, value.GetBytes(Endianness.LittleEndian)); - CollectionAssert.AreEqual(bigEndian, value.GetBytes(Endianness.BigEndian)); + CollectionAssert.AreEqual(expected, actual); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() + public void TryWriteLittleEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() { const ulong value = 0x0F; - byte[] bytes = BitConverter.IsLittleEndian - ? new byte[] {0x0F, 0, 0, 0, 0, 0, 0, 0} - : new byte[] {0, 0, 0, 0, 0, 0, 0, 0x0F}; + byte[] expected = { 0x0F, 0, 0, 0, 0, 0, 0, 0 }; - Span buffer = stackalloc byte[8]; - Assert.That(value.TryWriteBytes(buffer)); - CollectionAssert.AreEqual(bytes, buffer.ToArray()); + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteLittleEndian(actual)); + + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan_WithEndianness() + public void TryWriteBigEndian_ReturnsTrue_FillsSpanCorrectly_GivenLargeEnoughSpan() { const ulong value = 0x0F; - byte[] littleEndian = {0x0F, 0, 0, 0, 0, 0, 0, 0}; - byte[] bigEndian = {0, 0, 0, 0, 0, 0, 0, 0x0F}; + byte[] expected = { 0, 0, 0, 0, 0, 0, 0, 0x0F }; - Span buffer = stackalloc byte[8]; + Span actual = stackalloc byte[8]; + Assert.That(value.TryWriteBigEndian(actual)); - Assert.That(value.TryWriteBytes(buffer, Endianness.LittleEndian)); - CollectionAssert.AreEqual(littleEndian, buffer.ToArray()); - - Assert.That(value.TryWriteBytes(buffer, Endianness.BigEndian)); - CollectionAssert.AreEqual(bigEndian, buffer.ToArray()); + CollectionAssert.AreEqual(expected, actual.ToArray()); } [Test] - public void TryWriteBytes_ReturnsFalse_GivenSmallSpan() + public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan() { const ulong value = 0x0F; Span buffer = stackalloc byte[0]; - Assert.That(value.TryWriteBytes(buffer), Is.False); + Assert.That(value.TryWriteLittleEndian(buffer), Is.False); + } + + [Test] + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() + { + const ulong value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteBigEndian(buffer), Is.False); } } diff --git a/X10D/src/Endianness.cs b/X10D/src/Endianness.cs deleted file mode 100644 index 3b23c07..0000000 --- a/X10D/src/Endianness.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.ComponentModel; - -namespace X10D; - -/// -/// Represents an enumeration of endianness values. -/// -public enum Endianness -{ - /// - /// The value should be read as though it uses little endian encoding. - /// - [Description("The value should be read as though it uses little endian encoding.")] LittleEndian, - - /// - /// The value should be read as though it uses big endian encoding. - /// - [Description("The value should be read as though it uses big endian encoding.")] BigEndian -} diff --git a/X10D/src/IO/DecimalExtensions.cs b/X10D/src/IO/DecimalExtensions.cs new file mode 100644 index 0000000..8058f70 --- /dev/null +++ b/X10D/src/IO/DecimalExtensions.cs @@ -0,0 +1,111 @@ +using System.Diagnostics.Contracts; +using System.Runtime.InteropServices; + +namespace X10D.IO; + +/// +/// IO-related extension methods for . +/// +public static class DecimalExtensions +{ + /// + /// Converts the current decimal number into an array of bytes, as little endian. + /// + /// The value. + /// An array of bytes with length 4. + [Pure] + public static byte[] GetBigEndianBytes(this decimal value) + { + Span buffer = stackalloc byte[4]; + value.TryWriteBigEndian(buffer); + return buffer.ToArray(); + } + + /// + /// Converts the current decimal number into an array of bytes, as little endian. + /// + /// The value. + /// An array of bytes with length 4. + [Pure] + public static byte[] GetLittleEndianBytes(this decimal value) + { + Span buffer = stackalloc byte[4]; + value.TryWriteLittleEndian(buffer); + return buffer.ToArray(); + } + + /// + /// Converts the current decimal number into a span of bytes, as big endian. + /// + /// The value. + /// The span of bytes where the value is to be written, as big endian. + /// if the conversion was successful; otherwise, . + public static bool TryWriteBigEndian(this decimal value, Span destination) + { + Span buffer = stackalloc int[4]; + GetBits(value, buffer); + + if (buffer[0].TryWriteBigEndian(destination[..4]) && + buffer[1].TryWriteBigEndian(destination[4..8]) && + buffer[2].TryWriteBigEndian(destination[8..12]) && + buffer[3].TryWriteBigEndian(destination[12..])) + { + if (BitConverter.IsLittleEndian) + { + destination.Reverse(); + } + + return true; + } + + destination.Clear(); + return false; + } + + /// + /// Converts the current decimal number into a span of bytes, as little endian. + /// + /// The value. + /// The span of bytes where the value is to be written, as little endian. + /// if the conversion was successful; otherwise, . + public static bool TryWriteLittleEndian(this decimal value, Span destination) + { + Span buffer = stackalloc int[4]; + GetBits(value, buffer); + + if (buffer[0].TryWriteLittleEndian(destination[..4]) && + buffer[1].TryWriteLittleEndian(destination[4..8]) && + buffer[2].TryWriteLittleEndian(destination[8..12]) && + buffer[3].TryWriteLittleEndian(destination[12..])) + { + if (!BitConverter.IsLittleEndian) + { + destination.Reverse(); + } + + return true; + } + + destination.Clear(); + return false; + } + + private static void GetBits(decimal value, Span destination) + { +#if NET5_0_OR_GREATER + decimal.GetBits(value, destination); +#else + Span buffer = stackalloc byte[16]; + MemoryMarshal.Write(buffer, ref value); + + var flags = MemoryMarshal.Read(buffer[..4]); + var hi = MemoryMarshal.Read(buffer[4..8]); + var lo = MemoryMarshal.Read(buffer[8..]); + + destination[0] = flags; + destination[1] = hi; + destination[2] = (int)(lo & 0xFFFFFFFF); + destination[3] = (int)(lo >> 32); +#endif + } +} diff --git a/X10D/src/IO/DoubleExtensions.cs b/X10D/src/IO/DoubleExtensions.cs index f71e4be..728cada 100644 --- a/X10D/src/IO/DoubleExtensions.cs +++ b/X10D/src/IO/DoubleExtensions.cs @@ -10,58 +10,70 @@ namespace X10D.IO; public static class DoubleExtensions { /// - /// Returns the current double-precision floating-point value as an array of bytes. + /// Converts the current double-precision floating-point number into an array of bytes, as little endian. /// - /// The number to convert. - /// An array of bytes with length 8. + /// The value. + /// An array of bytes with length 4. [Pure] - public static byte[] GetBytes(this double value) + public static byte[] GetBigEndianBytes(this double value) { - byte[] buffer = new byte[8]; - value.TryWriteBytes(buffer); - return buffer; + Span buffer = stackalloc byte[8]; + value.TryWriteBigEndian(buffer); + return buffer.ToArray(); } /// - /// Returns the current double-precision floating-point value as an array of bytes. + /// Converts the current double-precision floating-point number into an array of bytes, as little endian. /// - /// The number to convert. - /// The endianness with which to write the bytes. - /// An array of bytes with length 8. + /// The value. + /// An array of bytes with length 4. [Pure] - public static byte[] GetBytes(this double value, Endianness endianness) + public static byte[] GetLittleEndianBytes(this double value) { - byte[] buffer = new byte[8]; - value.TryWriteBytes(buffer, endianness); - return buffer; + Span buffer = stackalloc byte[8]; + value.TryWriteLittleEndian(buffer); + return buffer.ToArray(); } /// - /// Converts the current double-precision floating-point into a span of bytes. + /// Converts the current double-precision floating-point number into a span of bytes, as big endian. /// - /// The value. - /// When this method returns, the bytes representing the converted . + /// The value. + /// The span of bytes where the value is to be written, as big endian. /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this double value, Span destination) + public static bool TryWriteBigEndian(this double value, Span destination) { - return BitConverter.TryWriteBytes(destination, value); - } - - /// - /// Converts the current double-precision floating-point into a span of bytes. - /// - /// The value. - /// When this method returns, the bytes representing the converted . - /// The endianness with which to write the bytes. - /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this double value, Span destination, Endianness endianness) - { - if (BitConverter.IsLittleEndian == (endianness == Endianness.BigEndian)) +#if NET5_0_OR_GREATER + return BinaryPrimitives.TryWriteDoubleBigEndian(destination, value); +#else + if (BitConverter.IsLittleEndian) { - long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value)); - value = BitConverter.Int64BitsToDouble(tmp); + return MemoryMarshal.TryWrite(destination, ref value); } - return MemoryMarshal.TryWrite(destination, ref value); + long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value)); + return MemoryMarshal.TryWrite(destination, ref tmp); +#endif + } + + /// + /// Converts the current double-precision floating-point number into a span of bytes, as little endian. + /// + /// The value. + /// The span of bytes where the value is to be written, as little endian. + /// if the conversion was successful; otherwise, . + public static bool TryWriteLittleEndian(this double value, Span destination) + { +#if NET5_0_OR_GREATER + return BinaryPrimitives.TryWriteDoubleLittleEndian(destination, value); +#else + if (!BitConverter.IsLittleEndian) + { + return MemoryMarshal.TryWrite(destination, ref value); + } + + long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value)); + return MemoryMarshal.TryWrite(destination, ref tmp); +#endif } } diff --git a/X10D/src/IO/Int16Extensions.cs b/X10D/src/IO/Int16Extensions.cs index 60b0b87..6c0dcc4 100644 --- a/X10D/src/IO/Int16Extensions.cs +++ b/X10D/src/IO/Int16Extensions.cs @@ -9,54 +9,50 @@ namespace X10D.IO; public static class Int16Extensions { /// - /// Returns the current 16-bit signed integer value as an array of bytes. - /// - /// The number to convert. - /// An array of bytes with length 2. - [Pure] - public static byte[] GetBytes(this short value) - { - byte[] buffer = new byte[2]; - value.TryWriteBytes(buffer); - return buffer; - } - - /// - /// Returns the current 16-bit signed integer value as an array of bytes. - /// - /// The number to convert. - /// The endianness with which to write the bytes. - /// An array of bytes with length 2. - [Pure] - public static byte[] GetBytes(this short value, Endianness endianness) - { - byte[] buffer = new byte[2]; - value.TryWriteBytes(buffer, endianness); - return buffer; - } - - /// - /// Converts the current 16-bit signed integer into a span of bytes. + /// Converts the current 16-bit signed integer into an array of bytes, as big endian. /// /// The value. - /// When this method returns, the bytes representing the converted . - /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this short value, Span destination) + /// An array of bytes with length 8. + [Pure] + public static byte[] GetBigEndianBytes(this short value) { - return BitConverter.TryWriteBytes(destination, value); + Span buffer = stackalloc byte[2]; + value.TryWriteBigEndian(buffer); + return buffer.ToArray(); } /// - /// Converts the current 16-bit signed integer into a span of bytes. + /// Converts the current 16-bit signed integer into an array of bytes, as big endian. /// /// The value. - /// When this method returns, the bytes representing the converted . - /// The endianness with which to write the bytes. - /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this short value, Span destination, Endianness endianness) + /// An array of bytes with length 8. + [Pure] + public static byte[] GetLittleEndianBytes(this short value) { - return endianness == Endianness.BigEndian - ? BinaryPrimitives.TryWriteInt16BigEndian(destination, value) - : BinaryPrimitives.TryWriteInt16LittleEndian(destination, value); + Span buffer = stackalloc byte[2]; + value.TryWriteLittleEndian(buffer); + return buffer.ToArray(); + } + + /// + /// Writes the current 16-bit signed integer into a span of bytes, as big endian. + /// + /// The value. + /// The span of bytes where the value is to be written, as big endian. + /// if the conversion was successful; otherwise, . + public static bool TryWriteBigEndian(this short value, Span destination) + { + return BinaryPrimitives.TryWriteInt16BigEndian(destination, value); + } + + /// + /// Writes the current 16-bit signed integer into a span of bytes, as little endian. + /// + /// The value. + /// The span of bytes where the value is to be written, as little endian. + /// if the conversion was successful; otherwise, . + public static bool TryWriteLittleEndian(this short value, Span destination) + { + return BinaryPrimitives.TryWriteInt16LittleEndian(destination, value); } } diff --git a/X10D/src/IO/Int32Extensions.cs b/X10D/src/IO/Int32Extensions.cs index a349dec..7f9d6cb 100644 --- a/X10D/src/IO/Int32Extensions.cs +++ b/X10D/src/IO/Int32Extensions.cs @@ -9,54 +9,50 @@ namespace X10D.IO; public static class Int32Extensions { /// - /// Returns the current 32-bit signed integer value as an array of bytes. + /// Converts the current 32-bit signed integer into an array of bytes, as big endian. /// - /// The number to convert. - /// An array of bytes with length 4. + /// The value. + /// An array of bytes with length 8. [Pure] - public static byte[] GetBytes(this int value) + public static byte[] GetBigEndianBytes(this int value) { - byte[] buffer = new byte[4]; - value.TryWriteBytes(buffer); - return buffer; - } - - /// - /// Returns the current 32-bit signed integer value as an array of bytes. - /// - /// The number to convert. - /// The endianness with which to write the bytes. - /// An array of bytes with length 4. - [Pure] - public static byte[] GetBytes(this int value, Endianness endianness) - { - byte[] buffer = new byte[4]; - value.TryWriteBytes(buffer, endianness); + Span buffer = stackalloc byte[4]; + value.TryWriteBigEndian(buffer); return buffer.ToArray(); } /// - /// Converts the current 32-bit signed integer into a span of bytes. + /// Converts the current 32-bit signed integer into an array of bytes, as big endian. /// /// The value. - /// When this method returns, the bytes representing the converted . - /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this int value, Span destination) + /// An array of bytes with length 8. + [Pure] + public static byte[] GetLittleEndianBytes(this int value) { - return BitConverter.TryWriteBytes(destination, value); + Span buffer = stackalloc byte[4]; + value.TryWriteLittleEndian(buffer); + return buffer.ToArray(); } /// - /// Converts the current 32-bit signed integer into a span of bytes. + /// Writes the current 32-bit signed integer into a span of bytes, as big endian. /// /// The value. - /// When this method returns, the bytes representing the converted . - /// The endianness with which to write the bytes. + /// The span of bytes where the value is to be written, as big endian. /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this int value, Span destination, Endianness endianness) + public static bool TryWriteBigEndian(this int value, Span destination) { - return endianness == Endianness.BigEndian - ? BinaryPrimitives.TryWriteInt32BigEndian(destination, value) - : BinaryPrimitives.TryWriteInt32LittleEndian(destination, value); + return BinaryPrimitives.TryWriteInt32BigEndian(destination, value); + } + + /// + /// Writes the current 32-bit signed integer into a span of bytes, as little endian. + /// + /// The value. + /// The span of bytes where the value is to be written, as little endian. + /// if the conversion was successful; otherwise, . + public static bool TryWriteLittleEndian(this int value, Span destination) + { + return BinaryPrimitives.TryWriteInt32LittleEndian(destination, value); } } diff --git a/X10D/src/IO/Int64Extensions.cs b/X10D/src/IO/Int64Extensions.cs index 2fd7f05..118fc49 100644 --- a/X10D/src/IO/Int64Extensions.cs +++ b/X10D/src/IO/Int64Extensions.cs @@ -9,54 +9,50 @@ namespace X10D.IO; public static class Int64Extensions { /// - /// Returns the current 64-bit signed integer value as an array of bytes. + /// Converts the current 64-bit signed integer into an array of bytes, as big endian. /// - /// The number to convert. + /// The value. /// An array of bytes with length 8. [Pure] - public static byte[] GetBytes(this long value) + public static byte[] GetBigEndianBytes(this long value) { Span buffer = stackalloc byte[8]; - value.TryWriteBytes(buffer); + value.TryWriteBigEndian(buffer); return buffer.ToArray(); } /// - /// Returns the current 64-bit signed integer value as an array of bytes. + /// Converts the current 64-bit signed integer into an array of bytes, as big endian. /// - /// The number to convert. - /// The endianness with which to write the bytes. + /// The value. /// An array of bytes with length 8. [Pure] - public static byte[] GetBytes(this long value, Endianness endianness) + public static byte[] GetLittleEndianBytes(this long value) { Span buffer = stackalloc byte[8]; - value.TryWriteBytes(buffer, endianness); + value.TryWriteLittleEndian(buffer); return buffer.ToArray(); } /// - /// Converts the current 64-bit signed integer a span of bytes. + /// Writes the current 64-bit signed integer into a span of bytes, as big endian. /// /// The value. - /// When this method returns, the bytes representing the converted . + /// The span of bytes where the value is to be written, as big endian. /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this long value, Span destination) + public static bool TryWriteBigEndian(this long value, Span destination) { - return BitConverter.TryWriteBytes(destination, value); + return BinaryPrimitives.TryWriteInt64BigEndian(destination, value); } /// - /// Converts the current 64-bit signed integer a span of bytes. + /// Writes the current 64-bit signed integer into a span of bytes, as little endian. /// /// The value. - /// When this method returns, the bytes representing the converted . - /// The endianness with which to write the bytes. + /// The span of bytes where the value is to be written, as little endian. /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this long value, Span destination, Endianness endianness) + public static bool TryWriteLittleEndian(this long value, Span destination) { - return endianness == Endianness.BigEndian - ? BinaryPrimitives.TryWriteInt64BigEndian(destination, value) - : BinaryPrimitives.TryWriteInt64LittleEndian(destination, value); + return BinaryPrimitives.TryWriteInt64LittleEndian(destination, value); } } diff --git a/X10D/src/IO/SingleExtensions.cs b/X10D/src/IO/SingleExtensions.cs index 5db19f5..d799261 100644 --- a/X10D/src/IO/SingleExtensions.cs +++ b/X10D/src/IO/SingleExtensions.cs @@ -1,6 +1,8 @@ using System.Buffers.Binary; using System.Diagnostics.Contracts; +#if !NET5_0_OR_GREATER using System.Runtime.InteropServices; +#endif namespace X10D.IO; @@ -10,58 +12,70 @@ namespace X10D.IO; public static class SingleExtensions { /// - /// Returns the current single-precision floating-point value as an array of bytes. + /// Converts the current single-precision floating-point number into an array of bytes, as little endian. /// - /// The number to convert. + /// The value. /// An array of bytes with length 4. [Pure] - public static byte[] GetBytes(this float value) + public static byte[] GetBigEndianBytes(this float value) { Span buffer = stackalloc byte[4]; - value.TryWriteBytes(buffer); + value.TryWriteBigEndian(buffer); return buffer.ToArray(); } /// - /// Returns the current single-precision floating-point value as an array of bytes. + /// Converts the current single-precision floating-point number into an array of bytes, as little endian. /// - /// The number to convert. - /// The endianness with which to write the bytes. + /// The value. /// An array of bytes with length 4. [Pure] - public static byte[] GetBytes(this float value, Endianness endianness) + public static byte[] GetLittleEndianBytes(this float value) { Span buffer = stackalloc byte[4]; - value.TryWriteBytes(buffer, endianness); + value.TryWriteLittleEndian(buffer); return buffer.ToArray(); } /// - /// Converts the current single-precision floating-point into a span of bytes. + /// Converts the current single-precision floating-point number into a span of bytes, as big endian. /// /// The value. - /// When this method returns, the bytes representing the converted . + /// The span of bytes where the value is to be written, as big endian. /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this float value, Span destination) + public static bool TryWriteBigEndian(this float value, Span destination) { - return BitConverter.TryWriteBytes(destination, value); - } - - /// - /// Converts the current single-precision floating-point into a span of bytes. - /// - /// The value. - /// When this method returns, the bytes representing the converted . - /// The endianness with which to write the bytes. - /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this float value, Span destination, Endianness endianness) - { - if (BitConverter.IsLittleEndian == (endianness == Endianness.BigEndian)) +#if NET5_0_OR_GREATER + return BinaryPrimitives.TryWriteSingleBigEndian(destination, value); +#else + if (BitConverter.IsLittleEndian) { - int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value)); - value = BitConverter.Int32BitsToSingle(tmp); + return MemoryMarshal.TryWrite(destination, ref value); } - return MemoryMarshal.TryWrite(destination, ref value); + int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value)); + return MemoryMarshal.TryWrite(destination, ref tmp); +#endif + } + + /// + /// Converts the current single-precision floating-point number into a span of bytes, as little endian. + /// + /// The value. + /// The span of bytes where the value is to be written, as little endian. + /// if the conversion was successful; otherwise, . + public static bool TryWriteLittleEndian(this float value, Span destination) + { +#if NET5_0_OR_GREATER + return BinaryPrimitives.TryWriteSingleLittleEndian(destination, value); +#else + if (!BitConverter.IsLittleEndian) + { + return MemoryMarshal.TryWrite(destination, ref value); + } + + int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value)); + return MemoryMarshal.TryWrite(destination, ref tmp); +#endif } } diff --git a/X10D/src/IO/StreamExtensions.cs b/X10D/src/IO/StreamExtensions.cs index d1d44db..9bc7243 100644 --- a/X10D/src/IO/StreamExtensions.cs +++ b/X10D/src/IO/StreamExtensions.cs @@ -1,5 +1,4 @@ -using System.Buffers.Binary; -using System.Diagnostics.CodeAnalysis; +using System.Buffers.Binary; using System.Reflection; using System.Runtime.InteropServices; using System.Security.Cryptography; @@ -11,9 +10,6 @@ namespace X10D.IO; /// public static class StreamExtensions { - private static readonly Endianness DefaultEndianness = - BitConverter.IsLittleEndian ? Endianness.LittleEndian : Endianness.BigEndian; - /// /// Returns the hash of the current stream as an array of bytes using the specified hash algorithm. /// @@ -64,42 +60,20 @@ public static class StreamExtensions } /// - /// Reads a decimal value from the current stream using the system's default endian encoding, and advances the stream - /// position by sixteen bytes. - /// - /// The stream to read. - /// A sixteen-byte decimal value read from the stream. - public static decimal ReadDecimal(this Stream stream) - { - return stream.ReadDecimal(DefaultEndianness); - } - - /// - /// Reads a decimal value from the current stream using a specified endian encoding, and advances the stream position - /// by sixteen bytes. + /// Reads an from the current stream as big endian, and advances the stream position by sixteen + /// bytes. /// /// The stream from which the value should be read. - /// The endian encoding to use. - /// A decimal value read from the stream. - public static decimal ReadDecimal(this Stream stream, Endianness endianness) + /// The big endian value. + /// is + /// does not support reading. + public static decimal ReadDecimalBigEndian(this Stream stream) { if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - if (!stream.CanRead) { throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); @@ -109,436 +83,496 @@ public static class StreamExtensions const int int32Size = sizeof(int); const int partitionSize = decimalSize / int32Size; - var bits = new int[partitionSize]; + Span buffer = stackalloc int[partitionSize]; for (var index = 0; index < partitionSize; index++) { - bits[index] = stream.ReadInt32(endianness); + buffer[index] = stream.ReadInt32BigEndian(); } - if (endianness != DefaultEndianness) + if (BitConverter.IsLittleEndian) { - Array.Reverse(bits); + buffer.Reverse(); } - return new decimal(bits); +#if NET5_0_OR_GREATER + return new decimal(buffer); +#else + return new decimal(buffer.ToArray()); +#endif } /// - /// Reads a double-precision floating point value from the current stream using the system's default endian encoding, - /// and advances the stream position by eight bytes. + /// Reads an from the current stream as big endian, and advances the stream position by sixteen + /// bytes. /// /// The stream from which the value should be read. - /// A double-precision floating point value read from the stream. - public static double ReadDouble(this Stream stream) - { - return stream.ReadDouble(DefaultEndianness); - } - - /// - /// Reads a double-precision floating point value from the current stream using a specified endian encoding, and - /// advances the stream position by eight bytes. - /// - /// The stream from which the value should be read. - /// The endian encoding to use. - /// A double-precision floating point value read from the stream. - public static double ReadDouble(this Stream stream, Endianness endianness) + /// The big endian value. + /// is + /// does not support reading. + public static decimal ReadDecimalLittleEndian(this Stream stream) { if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - if (!stream.CanRead) { throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); } - Span buffer = stackalloc byte[sizeof(double)]; - stream.Read(buffer); + const int decimalSize = sizeof(decimal); + const int int32Size = sizeof(int); + const int partitionSize = decimalSize / int32Size; - var value = MemoryMarshal.Read(buffer); - - if (BitConverter.IsLittleEndian == (endianness == Endianness.BigEndian)) + Span buffer = stackalloc int[partitionSize]; + for (var index = 0; index < partitionSize; index++) { - long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value)); - value = BitConverter.Int64BitsToDouble(tmp); + buffer[index] = stream.ReadInt32LittleEndian(); } - return value; + if (!BitConverter.IsLittleEndian) + { + buffer.Reverse(); + } + +#if NET5_0_OR_GREATER + return new decimal(buffer); +#else + return new decimal(buffer.ToArray()); +#endif } /// - /// Reads a two-byte signed integer from the current stream using the system's default endian encoding, and advances - /// the stream position by two bytes. + /// Reads an from the current stream as big endian, and advances the stream position by eight bytes. /// /// The stream from which the value should be read. - /// An two-byte signed integer read from the stream. - public static short ReadInt16(this Stream stream) - { - return stream.ReadInt16(DefaultEndianness); - } - - /// - /// Reads a two-byte signed integer from the current stream using the specified endian encoding, and advances the - /// stream position by two bytes. - /// - /// The stream from which the value should be read. - /// The endian encoding to use. - /// An two-byte unsigned integer read from the stream. - public static short ReadInt16(this Stream stream, Endianness endianness) + /// The big endian value. + /// is + /// does not support reading. + public static double ReadDoubleBigEndian(this Stream stream) { if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - if (!stream.CanRead) { throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); } - Span buffer = stackalloc byte[sizeof(short)]; - stream.Read(buffer); + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); +#if NET5_0_OR_GREATER + return BinaryPrimitives.ReadDoubleBigEndian(buffer); +#else + if (BitConverter.IsLittleEndian) + { + buffer.Reverse(); + } - return endianness == Endianness.LittleEndian - ? BinaryPrimitives.ReadInt16LittleEndian(buffer) - : BinaryPrimitives.ReadInt16BigEndian(buffer); + return MemoryMarshal.Read(buffer); +#endif } /// - /// Reads a four-byte signed integer from the current stream using the system's default endian encoding, and advances - /// the stream position by four bytes. + /// Reads an from the current stream as little endian, and advances the stream position by eight + /// bytes. /// /// The stream from which the value should be read. - /// An four-byte signed integer read from the stream. - public static int ReadInt32(this Stream stream) - { - return stream.ReadInt32(DefaultEndianness); - } - - /// - /// Reads a four-byte signed integer from the current stream using the specified endian encoding, and advances the - /// stream position by four bytes. - /// - /// The stream from which the value should be read. - /// The endian encoding to use. - /// An four-byte unsigned integer read from the stream. - public static int ReadInt32(this Stream stream, Endianness endianness) + /// The little endian value. + /// is + /// does not support reading. + public static double ReadDoubleLittleEndian(this Stream stream) { if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - if (!stream.CanRead) { throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); } - Span buffer = stackalloc byte[sizeof(int)]; - stream.Read(buffer); + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); +#if NET5_0_OR_GREATER + return BinaryPrimitives.ReadDoubleLittleEndian(buffer); +#else + if (!BitConverter.IsLittleEndian) + { + buffer.Reverse(); + } - return endianness == Endianness.LittleEndian - ? BinaryPrimitives.ReadInt32LittleEndian(buffer) - : BinaryPrimitives.ReadInt32BigEndian(buffer); + return MemoryMarshal.Read(buffer); +#endif } /// - /// Reads an eight-byte signed integer from the current stream using the system's default endian encoding, and - /// advances the stream position by eight bytes. + /// Reads an from the current stream as big endian, and advances the stream position by two bytes. /// /// The stream from which the value should be read. - /// An eight-byte signed integer read from the stream. - public static long ReadInt64(this Stream stream) - { - return stream.ReadInt64(DefaultEndianness); - } - - /// - /// Reads an eight-byte signed integer from the current stream using the specified endian encoding, and advances the - /// stream position by eight bytes. - /// - /// The stream from which the value should be read. - /// The endian encoding to use. - /// An eight-byte unsigned integer read from the stream. - public static long ReadInt64(this Stream stream, Endianness endianness) + /// The big endian value. + /// is + /// does not support reading. + public static short ReadInt16BigEndian(this Stream stream) { if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - if (!stream.CanRead) { throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); } - Span buffer = stackalloc byte[sizeof(long)]; - stream.Read(buffer); - - return endianness == Endianness.LittleEndian - ? BinaryPrimitives.ReadInt64LittleEndian(buffer) - : BinaryPrimitives.ReadInt64BigEndian(buffer); + Span buffer = stackalloc byte[2]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt16BigEndian(buffer); } /// - /// Reads a single-precision floating point value from the current stream using the system's default endian encoding, - /// and advances the stream position by four bytes. + /// Reads an from the current stream as little endian, and advances the stream position by two bytes. /// /// The stream from which the value should be read. - /// A single-precision floating point value read from the stream. - public static double ReadSingle(this Stream stream) - { - return stream.ReadSingle(DefaultEndianness); - } - - /// - /// Reads a double-precision floating point value from the current stream using a specified endian encoding, and - /// advances the stream position by four bytes. - /// - /// The stream from which the value should be read. - /// The endian encoding to use. - /// A single-precision floating point value read from the stream. - public static float ReadSingle(this Stream stream, Endianness endianness) + /// The little endian value. + /// is + /// does not support reading. + public static short ReadInt16LittleEndian(this Stream stream) { if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) + if (!stream.CanRead) { - throw new ArgumentOutOfRangeException(nameof(endianness)); + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) + + Span buffer = stackalloc byte[2]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt16LittleEndian(buffer); + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by four bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + public static int ReadInt32BigEndian(this Stream stream) + { + if (stream is null) { - throw new ArgumentOutOfRangeException(nameof(endianness)); + throw new ArgumentNullException(nameof(stream)); } -#endif if (!stream.CanRead) { throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); } - Span buffer = stackalloc byte[sizeof(float)]; - stream.Read(buffer); - - var value = MemoryMarshal.Read(buffer); - - if (BitConverter.IsLittleEndian == (endianness == Endianness.BigEndian)) - { - int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value)); - value = BitConverter.Int32BitsToSingle(tmp); - } - - return value; + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt32BigEndian(buffer); } /// - /// Reads a two-byte unsigned integer from the current stream using the system's default endian encoding, and advances - /// the stream position by two bytes. + /// Reads an from the current stream as little endian, and advances the stream position by four bytes. /// /// The stream from which the value should be read. - /// An two-byte unsigned integer read from the stream. + /// The little endian value. + /// is + /// does not support reading. + public static int ReadInt32LittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt32LittleEndian(buffer); + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by eight bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + public static long ReadInt64BigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt64BigEndian(buffer); + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by eight + /// bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + public static long ReadInt64LittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt64LittleEndian(buffer); + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by four bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. [CLSCompliant(false)] - public static ushort ReadUInt16(this Stream stream) - { - return stream.ReadUInt16(DefaultEndianness); - } - - /// - /// Reads a two-byte unsigned integer from the current stream using the specified endian encoding, and advances the - /// stream position by two bytes. - /// - /// The stream from which the value should be read. - /// The endian encoding to use. - /// An two-byte unsigned integer read from the stream. - [CLSCompliant(false)] - public static ushort ReadUInt16(this Stream stream, Endianness endianness) + public static float ReadSingleBigEndian(this Stream stream) { if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - if (!stream.CanRead) { throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); } - Span buffer = stackalloc byte[sizeof(ushort)]; - stream.Read(buffer); + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); +#if NET5_0_OR_GREATER + return BinaryPrimitives.ReadSingleBigEndian(buffer); +#else + if (BitConverter.IsLittleEndian) + { + buffer.Reverse(); + } - return endianness == Endianness.LittleEndian - ? BinaryPrimitives.ReadUInt16LittleEndian(buffer) - : BinaryPrimitives.ReadUInt16BigEndian(buffer); + return MemoryMarshal.Read(buffer); +#endif } /// - /// Reads a four-byte unsigned integer from the current stream using the system's default endian encoding, and - /// advances the stream position by four bytes. + /// Reads an from the current stream as little endian, and advances the stream position by four + /// bytes. /// /// The stream from which the value should be read. - /// An four-byte unsigned integer read from the stream. + /// The little endian value. + /// is + /// does not support reading. [CLSCompliant(false)] - public static uint ReadUInt32(this Stream stream) - { - return stream.ReadUInt32(DefaultEndianness); - } - - /// - /// Reads a four-byte unsigned integer from the current stream using the specified endian encoding, and advances the - /// stream position by four bytes. - /// - /// The stream from which the value should be read. - /// The endian encoding to use. - /// An four-byte unsigned integer read from the stream. - [CLSCompliant(false)] - public static uint ReadUInt32(this Stream stream, Endianness endianness) + public static float ReadSingleLittleEndian(this Stream stream) { if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - if (!stream.CanRead) { throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); } - Span buffer = stackalloc byte[sizeof(uint)]; - stream.Read(buffer); + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); +#if NET5_0_OR_GREATER + return BinaryPrimitives.ReadSingleLittleEndian(buffer); +#else + if (!BitConverter.IsLittleEndian) + { + buffer.Reverse(); + } - return endianness == Endianness.LittleEndian - ? BinaryPrimitives.ReadUInt32LittleEndian(buffer) - : BinaryPrimitives.ReadUInt32BigEndian(buffer); + return MemoryMarshal.Read(buffer); +#endif } /// - /// Reads an eight-byte unsigned integer from the current stream using the system's default endian encoding, and - /// advances the stream position by eight bytes. + /// Reads an from the current stream as big endian, and advances the stream position by two bytes. /// /// The stream from which the value should be read. - /// An eight-byte unsigned integer read from the stream. + /// The big endian value. + /// is + /// does not support reading. [CLSCompliant(false)] - public static ulong ReadUInt64(this Stream stream) - { - return stream.ReadUInt64(DefaultEndianness); - } - - /// - /// Reads an eight-byte unsigned integer from the current stream using the specified endian encoding, and advances the - /// stream position by eight bytes. - /// - /// The stream from which the value should be read. - /// The endian encoding to use. - /// An eight-byte unsigned integer read from the stream. - [CLSCompliant(false)] - public static ulong ReadUInt64(this Stream stream, Endianness endianness) + public static ushort ReadUInt16BigEndian(this Stream stream) { if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) + if (!stream.CanRead) { - throw new ArgumentOutOfRangeException(nameof(endianness)); + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) + + Span buffer = stackalloc byte[2]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt16BigEndian(buffer); + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by two bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static ushort ReadUInt16LittleEndian(this Stream stream) + { + if (stream is null) { - throw new ArgumentOutOfRangeException(nameof(endianness)); + throw new ArgumentNullException(nameof(stream)); } -#endif if (!stream.CanRead) { throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); } - Span buffer = stackalloc byte[sizeof(ulong)]; - stream.Read(buffer); + Span buffer = stackalloc byte[2]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt16LittleEndian(buffer); + } - return endianness == Endianness.LittleEndian - ? BinaryPrimitives.ReadUInt64LittleEndian(buffer) - : BinaryPrimitives.ReadUInt64BigEndian(buffer); + /// + /// Reads an from the current stream as big endian, and advances the stream position by four bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static uint ReadUInt32BigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt32BigEndian(buffer); + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by four bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static uint ReadUInt32LittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt32LittleEndian(buffer); + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by eight bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static ulong ReadUInt64BigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt64BigEndian(buffer); + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by eight + /// bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static ulong ReadUInt64LittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt64LittleEndian(buffer); } /// @@ -605,582 +639,465 @@ public static class StreamExtensions } /// - /// Writes a two-byte signed integer to the current stream using the system's default endian encoding, and advances - /// the stream position by two bytes. + /// Writes a to the current stream as big endian, and advances the stream position by two bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, short value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[2]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as big endian, and advances the stream position by four bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, int value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[4]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as big endian, and advances the stream position by eight bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, long value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[8]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as big endian, and advances the stream position by two bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + [CLSCompliant(false)] + public static int WriteBigEndian(this Stream stream, ushort value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[2]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as big endian, and advances the stream position by four bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + [CLSCompliant(false)] + public static int WriteBigEndian(this Stream stream, uint value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[4]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as big endian, and advances the stream position by eight bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + [CLSCompliant(false)] + public static int WriteBigEndian(this Stream stream, ulong value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[8]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by four bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, float value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[4]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by eight + /// bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, double value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[8]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by sixteen + /// bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, decimal value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[16]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by two bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, short value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[2]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes an to the current stream as little endian, and advances the stream position by four bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, int value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[4]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by eight bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, long value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[8]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by four bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, float value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[4]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by eight + /// bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, double value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[8]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by sixteen + /// bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, decimal value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[16]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by two bytes. /// /// The stream to which the value should be written. /// The two-byte signed integer to write. /// The number of bytes written to the stream. - [ExcludeFromCodeCoverage] - public static int Write(this Stream stream, short value) + /// is . + /// does not support writing. + [CLSCompliant(false)] + public static int WriteLittleEndian(this Stream stream, ushort value) { - return stream.Write(value, DefaultEndianness); + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[2]; + BinaryPrimitives.WriteUInt16LittleEndian(buffer, value); + return stream.WriteInternal(buffer); } /// - /// Writes a two-byte signed integer to the current stream using the specified endian encoding, and advances the - /// stream position by two bytes. + /// Writes a to the current stream as little endian, and advances the stream position by four bytes. /// /// The stream to which the value should be written. /// The two-byte signed integer to write. - /// The endian encoding to use. - /// The number of bytes written to the stream. - public static int Write(this Stream stream, short value, Endianness endianness) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[sizeof(short)]; - - if (endianness == Endianness.LittleEndian) - { - BinaryPrimitives.WriteInt16LittleEndian(buffer, value); - } - else - { - BinaryPrimitives.WriteInt16BigEndian(buffer, value); - } - - return stream.WriteInternal(buffer); - } - - /// - /// Writes a four-byte signed integer to the current stream using the system's default endian encoding, and advances - /// the stream position by four bytes. - /// - /// The stream to which the value should be written. - /// The four-byte signed integer to write. - /// The number of bytes written to the stream. - [ExcludeFromCodeCoverage] - public static int Write(this Stream stream, int value) - { - return stream.Write(value, DefaultEndianness); - } - - /// - /// Writes a four-byte signed integer to the current stream using the specified endian encoding, and advances the - /// stream position by four bytes. - /// - /// The stream to which the value should be written. - /// The four-byte signed integer to write. - /// The endian encoding to use. - /// The number of bytes written to the stream. - /// is . - public static int Write(this Stream stream, int value, Endianness endianness) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[sizeof(int)]; - - if (endianness == Endianness.LittleEndian) - { - BinaryPrimitives.WriteInt32LittleEndian(buffer, value); - } - else - { - BinaryPrimitives.WriteInt32BigEndian(buffer, value); - } - - return stream.WriteInternal(buffer); - } - - /// - /// Writes an eight-byte signed integer to the current stream using the system's default endian encoding, and advances - /// the stream position by eight bytes. - /// - /// The stream to which the value should be written. - /// The eight-byte signed integer to write. - /// The number of bytes written to the stream. - /// is . - [ExcludeFromCodeCoverage] - public static int Write(this Stream stream, long value) - { - return stream.Write(value, DefaultEndianness); - } - - /// - /// Writes an eight-byte signed integer to the current stream using the specified endian encoding, and advances the - /// stream position by eight bytes. - /// - /// The stream to which the value should be written. - /// The eight-byte signed integer to write. - /// The endian encoding to use. - /// The number of bytes written to the stream. - /// is . - public static int Write(this Stream stream, long value, Endianness endianness) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[sizeof(long)]; - - if (endianness == Endianness.LittleEndian) - { - BinaryPrimitives.WriteInt64LittleEndian(buffer, value); - } - else - { - BinaryPrimitives.WriteInt64BigEndian(buffer, value); - } - - return stream.WriteInternal(buffer); - } - - /// - /// Writes a two-byte unsigned integer to the current stream using the system's default endian encoding, and advances - /// the stream position by two bytes. - /// - /// The stream to which the value should be written. - /// The two-byte unsigned integer to write. /// The number of bytes written to the stream. /// is . + /// does not support writing. [CLSCompliant(false)] - [ExcludeFromCodeCoverage] - public static int Write(this Stream stream, ushort value) - { - return stream.Write(value, DefaultEndianness); - } - - /// - /// Writes a two-byte unsigned integer to the current stream using the specified endian encoding, and advances the - /// stream position by two bytes. - /// - /// The stream to which the value should be written. - /// The two-byte unsigned integer to write. - /// The endian encoding to use. - /// The number of bytes written to the stream. - /// is . - [CLSCompliant(false)] - public static int Write(this Stream stream, ushort value, Endianness endianness) + public static int WriteLittleEndian(this Stream stream, uint value) { if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - if (!stream.CanWrite) { throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); } - Span buffer = stackalloc byte[sizeof(ushort)]; - - if (endianness == Endianness.LittleEndian) - { - BinaryPrimitives.WriteUInt16LittleEndian(buffer, value); - } - else - { - BinaryPrimitives.WriteUInt16BigEndian(buffer, value); - } - + Span buffer = stackalloc byte[4]; + BinaryPrimitives.WriteUInt32LittleEndian(buffer, value); return stream.WriteInternal(buffer); } /// - /// Writes a four-byte unsigned integer to the current stream using the system's default endian encoding, and advances - /// the stream position by four bytes. + /// Writes a to the current stream as little endian, and advances the stream position by eight bytes. /// /// The stream to which the value should be written. - /// The four-byte unsigned integer to write. + /// The two-byte signed integer to write. /// The number of bytes written to the stream. /// is . + /// does not support writing. [CLSCompliant(false)] - [ExcludeFromCodeCoverage] - public static int Write(this Stream stream, uint value) - { - return stream.Write(value, DefaultEndianness); - } - - /// - /// Writes a four-byte unsigned integer to the current stream using the specified endian encoding, and advances the - /// stream position by four bytes. - /// - /// The stream to which the value should be written. - /// The four-byte unsigned integer to write. - /// The endian encoding to use. - /// The number of bytes written to the stream. - /// is . - [CLSCompliant(false)] - public static int Write(this Stream stream, uint value, Endianness endianness) + public static int WriteLittleEndian(this Stream stream, ulong value) { if (stream is null) { throw new ArgumentNullException(nameof(stream)); } -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - if (!stream.CanWrite) { throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); } - Span buffer = stackalloc byte[sizeof(uint)]; - - if (endianness == Endianness.LittleEndian) - { - BinaryPrimitives.WriteUInt32LittleEndian(buffer, value); - } - else - { - BinaryPrimitives.WriteUInt32BigEndian(buffer, value); - } - + Span buffer = stackalloc byte[8]; + BinaryPrimitives.WriteUInt64LittleEndian(buffer, value); return stream.WriteInternal(buffer); } - /// - /// Writes an eight-byte unsigned integer to the current stream using the system's default endian encoding, and - /// advances the stream position by eight bytes. - /// - /// The stream to which the value should be written. - /// The eight-byte unsigned integer to write. - /// The number of bytes written to the stream. - /// is . - [CLSCompliant(false)] - [ExcludeFromCodeCoverage] - public static int Write(this Stream stream, ulong value) - { - return stream.Write(value, DefaultEndianness); - } - - /// - /// Writes an eight-byte signed integer to the current stream using the specified endian encoding, and advances the - /// stream position by eight bytes. - /// - /// The stream to which the value should be written. - /// The eight-byte signed integer to write. - /// The endian encoding to use. - /// The number of bytes written to the stream. - /// is . - [CLSCompliant(false)] - public static int Write(this Stream stream, ulong value, Endianness endianness) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[sizeof(ulong)]; - - if (endianness == Endianness.LittleEndian) - { - BinaryPrimitives.WriteUInt64LittleEndian(buffer, value); - } - else - { - BinaryPrimitives.WriteUInt64BigEndian(buffer, value); - } - - return stream.WriteInternal(buffer); - } - - /// - /// Writes a single-precision floating point value to the current stream using the specified endian encoding, and - /// advances the stream position by four bytes. - /// - /// The stream to which the value should be written. - /// The single-precision floating point value to write. - /// The endian encoding to use. - /// The number of bytes written to the stream. - /// is . - public static int Write(this Stream stream, float value, Endianness endianness) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[sizeof(float)]; - - if (endianness == Endianness.LittleEndian) - { -#if NET5_0_OR_GREATER - BinaryPrimitives.WriteSingleLittleEndian(buffer, value); -#else - if (BitConverter.IsLittleEndian) - { - MemoryMarshal.Write(buffer, ref value); - } - else - { - // dotcover disable - //NOSONAR - int temp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value)); - MemoryMarshal.Write(buffer, ref temp); - //NOSONAR - // dotcover enable - } -#endif - } - else - { -#if NET5_0_OR_GREATER - BinaryPrimitives.WriteSingleBigEndian(buffer, value); -#else - if (BitConverter.IsLittleEndian) - { - int temp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value)); - MemoryMarshal.Write(buffer, ref temp); - } - else - { - // dotcover disable - //NOSONAR - MemoryMarshal.Write(buffer, ref value); - //NOSONAR - // dotcover enable - } -#endif - } - - return stream.WriteInternal(buffer); - } - - /// - /// Writes a double-precision floating point value to the current stream using the specified endian encoding, and - /// advances the stream position by eight bytes. - /// - /// The stream to which the value should be written. - /// The double-precision floating point value to write. - /// The endian encoding to use. - /// The number of bytes written to the stream. - /// is . - public static int Write(this Stream stream, double value, Endianness endianness) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[sizeof(double)]; - - if (endianness == Endianness.LittleEndian) - { -#if NET5_0_OR_GREATER - BinaryPrimitives.WriteDoubleLittleEndian(buffer, value); -#else - if (BitConverter.IsLittleEndian) - { - MemoryMarshal.Write(buffer, ref value); - } - else - { - // dotcover disable - //NOSONAR - long temp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value)); - MemoryMarshal.Write(buffer, ref temp); - //NOSONAR - // dotcover enable - } -#endif - } - else - { -#if NET5_0_OR_GREATER - BinaryPrimitives.WriteDoubleBigEndian(buffer, value); -#else - if (BitConverter.IsLittleEndian) - { - long temp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value)); - MemoryMarshal.Write(buffer, ref temp); - } - else - { - // dotcover disable - //NOSONAR - MemoryMarshal.Write(buffer, ref value); - //NOSONAR - // dotcover enable - } -#endif - } - - return stream.WriteInternal(buffer); - } - - /// - /// Writes a decimal value to the current stream using the specified endian encoding, and advances the stream position - /// by sixteen bytes. - /// - /// The stream to which the value should be written. - /// The decimal value to write. - /// The endian encoding to use. - /// The number of bytes written to the stream. - /// is . - [ExcludeFromCodeCoverage] - public static int Write(this Stream stream, decimal value, Endianness endianness) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - -#if NET5_0_OR_GREATER - if (!Enum.IsDefined(endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#else - if (!Enum.IsDefined(typeof(Endianness), endianness)) - { - throw new ArgumentOutOfRangeException(nameof(endianness)); - } -#endif - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - int[] bits = decimal.GetBits(value); - long preWritePosition = stream.Position; - - if (endianness != DefaultEndianness) - { - Array.Reverse(bits); - } - - foreach (int section in bits) - { - stream.Write(section, endianness); - } - - return (int)(stream.Position - preWritePosition); - } - private static int WriteInternal(this Stream stream, ReadOnlySpan value) { long preWritePosition = stream.Position; diff --git a/X10D/src/IO/UInt16Extensions.cs b/X10D/src/IO/UInt16Extensions.cs index 5eb12ae..2cbc777 100644 --- a/X10D/src/IO/UInt16Extensions.cs +++ b/X10D/src/IO/UInt16Extensions.cs @@ -10,54 +10,50 @@ namespace X10D.IO; public static class UInt16Extensions { /// - /// Returns the current 16-bit unsigned integer value as an array of bytes. + /// Converts the current 16-bit unsigned integer into an array of bytes, as big endian. /// - /// The number to convert. - /// An array of bytes with length 2. + /// The value. + /// An array of bytes with length 8. [Pure] - public static byte[] GetBytes(this ushort value) + public static byte[] GetBigEndianBytes(this ushort value) { Span buffer = stackalloc byte[2]; - value.TryWriteBytes(buffer); + value.TryWriteBigEndian(buffer); return buffer.ToArray(); } /// - /// Returns the current 16-bit unsigned integer value as an array of bytes. + /// Converts the current 16-bit unsigned integer into an array of bytes, as big endian. /// - /// The number to convert. - /// The endianness with which to write the bytes. - /// An array of bytes with length 2. + /// The value. + /// An array of bytes with length 8. [Pure] - public static byte[] GetBytes(this ushort value, Endianness endianness) + public static byte[] GetLittleEndianBytes(this ushort value) { Span buffer = stackalloc byte[2]; - value.TryWriteBytes(buffer, endianness); + value.TryWriteLittleEndian(buffer); return buffer.ToArray(); } /// - /// Converts the current 16-bit unsigned integer into a span of bytes. + /// Writes the current 16-bit unsigned integer into a span of bytes, as big endian. /// /// The value. - /// When this method returns, the bytes representing the converted . + /// The span of bytes where the value is to be written, as big endian. /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this ushort value, Span destination) + public static bool TryWriteBigEndian(this ushort value, Span destination) { - return BitConverter.TryWriteBytes(destination, value); + return BinaryPrimitives.TryWriteUInt16BigEndian(destination, value); } /// - /// Converts the current 16-bit unsigned integer into a span of bytes. + /// Writes the current 16-bit unsigned integer into a span of bytes, as little endian. /// /// The value. - /// When this method returns, the bytes representing the converted . - /// The endianness with which to write the bytes. + /// The span of bytes where the value is to be written, as little endian. /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this ushort value, Span destination, Endianness endianness) + public static bool TryWriteLittleEndian(this ushort value, Span destination) { - return endianness == Endianness.BigEndian - ? BinaryPrimitives.TryWriteUInt16BigEndian(destination, value) - : BinaryPrimitives.TryWriteUInt16LittleEndian(destination, value); + return BinaryPrimitives.TryWriteUInt16LittleEndian(destination, value); } } diff --git a/X10D/src/IO/UInt32Extensions.cs b/X10D/src/IO/UInt32Extensions.cs index c4f3c30..12845ea 100644 --- a/X10D/src/IO/UInt32Extensions.cs +++ b/X10D/src/IO/UInt32Extensions.cs @@ -10,54 +10,50 @@ namespace X10D.IO; public static class UInt32Extensions { /// - /// Returns the current 32-bit unsigned integer value as an array of bytes. + /// Converts the current 32-bit unsigned integer into an array of bytes, as big endian. /// - /// The number to convert. - /// An array of bytes with length 4. + /// The value. + /// An array of bytes with length 8. [Pure] - public static byte[] GetBytes(this uint value) + public static byte[] GetBigEndianBytes(this uint value) { Span buffer = stackalloc byte[4]; - value.TryWriteBytes(buffer); + value.TryWriteBigEndian(buffer); return buffer.ToArray(); } /// - /// Returns the current 32-bit unsigned integer value as an array of bytes. + /// Converts the current 32-bit unsigned integer into an array of bytes, as big endian. /// - /// The number to convert. - /// The endianness with which to write the bytes. - /// An array of bytes with length 4. + /// The value. + /// An array of bytes with length 8. [Pure] - public static byte[] GetBytes(this uint value, Endianness endianness) + public static byte[] GetLittleEndianBytes(this uint value) { Span buffer = stackalloc byte[4]; - value.TryWriteBytes(buffer, endianness); + value.TryWriteLittleEndian(buffer); return buffer.ToArray(); } /// - /// Converts the current 32-bit unsigned integer into a span of bytes. + /// Writes the current 32-bit unsigned integer into a span of bytes, as big endian. /// /// The value. - /// When this method returns, the bytes representing the converted . + /// The span of bytes where the value is to be written, as big endian. /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this uint value, Span destination) + public static bool TryWriteBigEndian(this uint value, Span destination) { - return BitConverter.TryWriteBytes(destination, value); + return BinaryPrimitives.TryWriteUInt32BigEndian(destination, value); } /// - /// Converts the current 32-bit unsigned integer into a span of bytes. + /// Writes the current 32-bit unsigned integer into a span of bytes, as little endian. /// /// The value. - /// When this method returns, the bytes representing the converted . - /// The endianness with which to write the bytes. + /// The span of bytes where the value is to be written, as little endian. /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this uint value, Span destination, Endianness endianness) + public static bool TryWriteLittleEndian(this uint value, Span destination) { - return endianness == Endianness.BigEndian - ? BinaryPrimitives.TryWriteUInt32BigEndian(destination, value) - : BinaryPrimitives.TryWriteUInt32LittleEndian(destination, value); + return BinaryPrimitives.TryWriteUInt32LittleEndian(destination, value); } } diff --git a/X10D/src/IO/UInt64Extensions.cs b/X10D/src/IO/UInt64Extensions.cs index 1f48869..96f78c1 100644 --- a/X10D/src/IO/UInt64Extensions.cs +++ b/X10D/src/IO/UInt64Extensions.cs @@ -10,54 +10,50 @@ namespace X10D.IO; public static class UInt64Extensions { /// - /// Returns the current 64-bit unsigned integer value as an array of bytes. + /// Converts the current 64-bit unsigned integer into an array of bytes, as big endian. /// - /// The number to convert. + /// The value. /// An array of bytes with length 8. [Pure] - public static byte[] GetBytes(this ulong value) + public static byte[] GetBigEndianBytes(this ulong value) { Span buffer = stackalloc byte[8]; - value.TryWriteBytes(buffer); + value.TryWriteBigEndian(buffer); return buffer.ToArray(); } /// - /// Returns the current 64-bit unsigned integer value as an array of bytes. + /// Converts the current 64-bit unsigned integer into an array of bytes, as big endian. /// - /// The number to convert. - /// The endianness with which to write the bytes. + /// The value. /// An array of bytes with length 8. [Pure] - public static byte[] GetBytes(this ulong value, Endianness endianness) + public static byte[] GetLittleEndianBytes(this ulong value) { Span buffer = stackalloc byte[8]; - value.TryWriteBytes(buffer, endianness); + value.TryWriteLittleEndian(buffer); return buffer.ToArray(); } /// - /// Converts the current 64-bit unsigned integer into a span of bytes. + /// Writes the current 64-bit unsigned integer into a span of bytes, as big endian. /// /// The value. - /// When this method returns, the bytes representing the converted . + /// The span of bytes where the value is to be written, as big endian. /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this ulong value, Span destination) + public static bool TryWriteBigEndian(this ulong value, Span destination) { - return BitConverter.TryWriteBytes(destination, value); + return BinaryPrimitives.TryWriteUInt64BigEndian(destination, value); } /// - /// Converts the current 64-bit unsigned integer into a span of bytes. + /// Writes the current 64-bit unsigned integer into a span of bytes, as little endian. /// /// The value. - /// When this method returns, the bytes representing the converted . - /// The endianness with which to write the bytes. + /// The span of bytes where the value is to be written, as little endian. /// if the conversion was successful; otherwise, . - public static bool TryWriteBytes(this ulong value, Span destination, Endianness endianness) + public static bool TryWriteLittleEndian(this ulong value, Span destination) { - return endianness == Endianness.BigEndian - ? BinaryPrimitives.TryWriteUInt64BigEndian(destination, value) - : BinaryPrimitives.TryWriteUInt64LittleEndian(destination, value); + return BinaryPrimitives.TryWriteUInt64LittleEndian(destination, value); } } From 0bf89bb82a881dbb38c837e408d40ee46baace22 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 23 Aug 2023 14:17:42 +0100 Subject: [PATCH 22/46] refactor!: change exception thrown by GetHash and TryWriteHash The methods no longer throw TypeInitializationException, and instead now throw ArgumentException. --- CHANGELOG.md | 2 ++ X10D.Tests/src/IO/StreamTests.cs | 9 ++++----- X10D/src/IO/StreamExtensions.cs | 14 +++++--------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1957cf2..5f31c88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - X10D: DateTime.Age(DateTime) and DateTimeOffset.Age(DateTimeOffset) parameter renamed from asOf to referenceDate. - X10D: Methods which accepted the `Endianness` enum as an argument have been replaced with explicit BigEndian/LittleEndian methods. +- X10D: `Stream.GetHash<>` and `Stream.TryWriteHash<>` now throw ArgumentException in lieu of +TypeInitializationException. ### Removed diff --git a/X10D.Tests/src/IO/StreamTests.cs b/X10D.Tests/src/IO/StreamTests.cs index e240990..b522265 100644 --- a/X10D.Tests/src/IO/StreamTests.cs +++ b/X10D.Tests/src/IO/StreamTests.cs @@ -86,16 +86,15 @@ internal partial class StreamTests [Test] public void NullCreateMethodShouldThrow() { - Assert.Throws(() => Stream.Null.GetHash()); - Assert.Throws(() => - Stream.Null.TryWriteHash(Span.Empty, out _)); + Assert.Throws(() => Stream.Null.GetHash()); + Assert.Throws(() => Stream.Null.TryWriteHash(Span.Empty, out _)); } [Test] public void NoCreateMethodShouldThrow() { - Assert.Throws(() => Stream.Null.GetHash()); - Assert.Throws(() => + Assert.Throws(() => Stream.Null.GetHash()); + Assert.Throws(() => Stream.Null.TryWriteHash(Span.Empty, out _)); } diff --git a/X10D/src/IO/StreamExtensions.cs b/X10D/src/IO/StreamExtensions.cs index 9bc7243..ceb34c8 100644 --- a/X10D/src/IO/StreamExtensions.cs +++ b/X10D/src/IO/StreamExtensions.cs @@ -1,4 +1,4 @@ -using System.Buffers.Binary; +using System.Buffers.Binary; using System.Reflection; using System.Runtime.InteropServices; using System.Security.Cryptography; @@ -45,15 +45,13 @@ public static class StreamExtensions .FirstOrDefault(c => c.Name == "Create" && c.GetParameters().Length == 0); if (createMethod is null) { - throw new TypeInitializationException(type.FullName, - new ArgumentException(ExceptionMessages.HashAlgorithmNoCreateMethod)); + throw new ArgumentException(ExceptionMessages.HashAlgorithmNoCreateMethod); } using var crypt = createMethod.Invoke(null, null) as T; if (crypt is null) { - throw new TypeInitializationException(type.FullName, - new ArgumentException(ExceptionMessages.HashAlgorithmCreateReturnedNull)); + throw new ArgumentException(ExceptionMessages.HashAlgorithmCreateReturnedNull); } return crypt.ComputeHash(stream); @@ -617,15 +615,13 @@ public static class StreamExtensions .FirstOrDefault(c => c.Name == "Create" && c.GetParameters().Length == 0); if (createMethod is null) { - throw new TypeInitializationException(type.FullName, - new ArgumentException(ExceptionMessages.HashAlgorithmNoCreateMethod)); + throw new ArgumentException(ExceptionMessages.HashAlgorithmNoCreateMethod); } using var crypt = createMethod.Invoke(null, null) as T; if (crypt is null) { - throw new TypeInitializationException(type.FullName, - new ArgumentException(ExceptionMessages.HashAlgorithmCreateReturnedNull)); + throw new ArgumentException(ExceptionMessages.HashAlgorithmCreateReturnedNull); } if (stream.Length > int.MaxValue) From 28d7bee2623335a481a8a5d007156fe402a43be5 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 23 Aug 2023 14:18:04 +0100 Subject: [PATCH 23/46] fix(tests): add support for trace logging during tests --- X10D.Tests/src/SetUpTrace.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 X10D.Tests/src/SetUpTrace.cs diff --git a/X10D.Tests/src/SetUpTrace.cs b/X10D.Tests/src/SetUpTrace.cs new file mode 100644 index 0000000..4d22848 --- /dev/null +++ b/X10D.Tests/src/SetUpTrace.cs @@ -0,0 +1,20 @@ +using System.Diagnostics; +using NUnit.Framework; + +namespace X10D.Tests; + +[SetUpFixture] +internal sealed class SetupTrace +{ + [OneTimeSetUp] + public void StartTest() + { + Trace.Listeners.Add(new ConsoleTraceListener()); + } + + [OneTimeTearDown] + public void EndTest() + { + Trace.Flush(); + } +} From d90e949212d6668a1285e7dbbc559c8b1724cfd4 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 23 Aug 2023 16:14:56 +0100 Subject: [PATCH 24/46] fix(ci): build on subdir branch push --- .github/workflows/dotnet.yml | 2 ++ .github/workflows/unity.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 28a3441..7d3fc24 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -4,9 +4,11 @@ on: push: branches: - '*' + - '*/*' pull_request: branches: - '*' + - '*/*' jobs: build: diff --git a/.github/workflows/unity.yml b/.github/workflows/unity.yml index 61d7c51..2418e06 100644 --- a/.github/workflows/unity.yml +++ b/.github/workflows/unity.yml @@ -4,9 +4,11 @@ on: push: branches: - '*' + - '*/*' pull_request: branches: - '*' + - '*/*' jobs: build: From caa0070458d656e989008621e8ebd13b70ab25dd Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 23 Aug 2023 16:43:33 +0100 Subject: [PATCH 25/46] fix: fix incorrect endian swap --- X10D/src/IO/DoubleExtensions.cs | 8 ++++---- X10D/src/IO/SingleExtensions.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/X10D/src/IO/DoubleExtensions.cs b/X10D/src/IO/DoubleExtensions.cs index 728cada..c42a7ef 100644 --- a/X10D/src/IO/DoubleExtensions.cs +++ b/X10D/src/IO/DoubleExtensions.cs @@ -48,11 +48,11 @@ public static class DoubleExtensions #else if (BitConverter.IsLittleEndian) { - return MemoryMarshal.TryWrite(destination, ref value); + long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value)); + return MemoryMarshal.TryWrite(destination, ref tmp); } - long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value)); - return MemoryMarshal.TryWrite(destination, ref tmp); + return MemoryMarshal.TryWrite(destination, ref value); #endif } @@ -67,7 +67,7 @@ public static class DoubleExtensions #if NET5_0_OR_GREATER return BinaryPrimitives.TryWriteDoubleLittleEndian(destination, value); #else - if (!BitConverter.IsLittleEndian) + if (BitConverter.IsLittleEndian) { return MemoryMarshal.TryWrite(destination, ref value); } diff --git a/X10D/src/IO/SingleExtensions.cs b/X10D/src/IO/SingleExtensions.cs index d799261..539e919 100644 --- a/X10D/src/IO/SingleExtensions.cs +++ b/X10D/src/IO/SingleExtensions.cs @@ -50,11 +50,11 @@ public static class SingleExtensions #else if (BitConverter.IsLittleEndian) { - return MemoryMarshal.TryWrite(destination, ref value); + int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value)); + return MemoryMarshal.TryWrite(destination, ref tmp); } - int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value)); - return MemoryMarshal.TryWrite(destination, ref tmp); + return MemoryMarshal.TryWrite(destination, ref value); #endif } @@ -69,7 +69,7 @@ public static class SingleExtensions #if NET5_0_OR_GREATER return BinaryPrimitives.TryWriteSingleLittleEndian(destination, value); #else - if (!BitConverter.IsLittleEndian) + if (BitConverter.IsLittleEndian) { return MemoryMarshal.TryWrite(destination, ref value); } From 30b7a465a7c1ed9bb2cfb3f9bf1550f60d9d210a Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 23 Aug 2023 16:54:20 +0100 Subject: [PATCH 26/46] fix: fix marshal of decimal for netstandard 2.1 --- X10D/src/IO/DecimalExtensions.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/X10D/src/IO/DecimalExtensions.cs b/X10D/src/IO/DecimalExtensions.cs index 8058f70..5b82682 100644 --- a/X10D/src/IO/DecimalExtensions.cs +++ b/X10D/src/IO/DecimalExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; using System.Runtime.InteropServices; namespace X10D.IO; @@ -97,15 +97,22 @@ public static class DecimalExtensions #else Span buffer = stackalloc byte[16]; MemoryMarshal.Write(buffer, ref value); + WriteBits(destination, buffer); +#endif + } + private static void WriteBits(Span destination, Span buffer) + { var flags = MemoryMarshal.Read(buffer[..4]); var hi = MemoryMarshal.Read(buffer[4..8]); var lo = MemoryMarshal.Read(buffer[8..]); - destination[0] = flags; - destination[1] = hi; - destination[2] = (int)(lo & 0xFFFFFFFF); - destination[3] = (int)(lo >> 32); -#endif + var low = (uint)lo; + var mid = (uint)(lo >> 32); + + destination[0] = (int)low; + destination[1] = (int)mid; + destination[2] = hi; + destination[3] = flags; } } From 1157e36eff8beaa6f6a8aea0fbd18b0a868d4e96 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 23 Aug 2023 17:00:55 +0100 Subject: [PATCH 27/46] refactor: separate stream Read/Write methods to partials --- X10D/src/IO/StreamExtensions.Reading.cs | 523 +++++++++++++ X10D/src/IO/StreamExtensions.Writing.cs | 473 ++++++++++++ X10D/src/IO/StreamExtensions.cs | 989 +----------------------- 3 files changed, 998 insertions(+), 987 deletions(-) create mode 100644 X10D/src/IO/StreamExtensions.Reading.cs create mode 100644 X10D/src/IO/StreamExtensions.Writing.cs diff --git a/X10D/src/IO/StreamExtensions.Reading.cs b/X10D/src/IO/StreamExtensions.Reading.cs new file mode 100644 index 0000000..b3bc317 --- /dev/null +++ b/X10D/src/IO/StreamExtensions.Reading.cs @@ -0,0 +1,523 @@ +using System.Buffers.Binary; +using System.Runtime.InteropServices; + +namespace X10D.IO; + +public static partial class StreamExtensions +{ + /// + /// Reads an from the current stream as big endian, and advances the stream position by sixteen + /// bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + public static decimal ReadDecimalBigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + const int decimalSize = sizeof(decimal); + const int int32Size = sizeof(int); + const int partitionSize = decimalSize / int32Size; + + Span buffer = stackalloc int[partitionSize]; + for (var index = 0; index < partitionSize; index++) + { + buffer[index] = stream.ReadInt32BigEndian(); + } + + if (BitConverter.IsLittleEndian) + { + buffer.Reverse(); + } + +#if NET5_0_OR_GREATER + return new decimal(buffer); +#else + return new decimal(buffer.ToArray()); +#endif + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by sixteen + /// bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + public static decimal ReadDecimalLittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + const int decimalSize = sizeof(decimal); + const int int32Size = sizeof(int); + const int partitionSize = decimalSize / int32Size; + + Span buffer = stackalloc int[partitionSize]; + for (var index = 0; index < partitionSize; index++) + { + buffer[index] = stream.ReadInt32LittleEndian(); + } + + if (!BitConverter.IsLittleEndian) + { + buffer.Reverse(); + } + +#if NET5_0_OR_GREATER + return new decimal(buffer); +#else + return new decimal(buffer.ToArray()); +#endif + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by eight bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + public static double ReadDoubleBigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); +#if NET5_0_OR_GREATER + return BinaryPrimitives.ReadDoubleBigEndian(buffer); +#else + if (BitConverter.IsLittleEndian) + { + buffer.Reverse(); + } + + return MemoryMarshal.Read(buffer); +#endif + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by eight + /// bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + public static double ReadDoubleLittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); +#if NET5_0_OR_GREATER + return BinaryPrimitives.ReadDoubleLittleEndian(buffer); +#else + if (!BitConverter.IsLittleEndian) + { + buffer.Reverse(); + } + + return MemoryMarshal.Read(buffer); +#endif + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by two bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + public static short ReadInt16BigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[2]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt16BigEndian(buffer); + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by two bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + public static short ReadInt16LittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[2]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt16LittleEndian(buffer); + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by four bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + public static int ReadInt32BigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt32BigEndian(buffer); + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by four bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + public static int ReadInt32LittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt32LittleEndian(buffer); + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by eight bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + public static long ReadInt64BigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt64BigEndian(buffer); + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by eight + /// bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + public static long ReadInt64LittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadInt64LittleEndian(buffer); + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by four bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static float ReadSingleBigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); +#if NET5_0_OR_GREATER + return BinaryPrimitives.ReadSingleBigEndian(buffer); +#else + if (BitConverter.IsLittleEndian) + { + buffer.Reverse(); + } + + return MemoryMarshal.Read(buffer); +#endif + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by four + /// bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static float ReadSingleLittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); +#if NET5_0_OR_GREATER + return BinaryPrimitives.ReadSingleLittleEndian(buffer); +#else + if (!BitConverter.IsLittleEndian) + { + buffer.Reverse(); + } + + return MemoryMarshal.Read(buffer); +#endif + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by two bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static ushort ReadUInt16BigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[2]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt16BigEndian(buffer); + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by two bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static ushort ReadUInt16LittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[2]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt16LittleEndian(buffer); + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by four bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static uint ReadUInt32BigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt32BigEndian(buffer); + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by four bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static uint ReadUInt32LittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[4]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt32LittleEndian(buffer); + } + + /// + /// Reads an from the current stream as big endian, and advances the stream position by eight bytes. + /// + /// The stream from which the value should be read. + /// The big endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static ulong ReadUInt64BigEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt64BigEndian(buffer); + } + + /// + /// Reads an from the current stream as little endian, and advances the stream position by eight + /// bytes. + /// + /// The stream from which the value should be read. + /// The little endian value. + /// is + /// does not support reading. + [CLSCompliant(false)] + public static ulong ReadUInt64LittleEndian(this Stream stream) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanRead) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); + } + + Span buffer = stackalloc byte[8]; + _ = stream.Read(buffer); + return BinaryPrimitives.ReadUInt64LittleEndian(buffer); + } +} diff --git a/X10D/src/IO/StreamExtensions.Writing.cs b/X10D/src/IO/StreamExtensions.Writing.cs new file mode 100644 index 0000000..787108e --- /dev/null +++ b/X10D/src/IO/StreamExtensions.Writing.cs @@ -0,0 +1,473 @@ +using System.Buffers.Binary; + +namespace X10D.IO; + +public static partial class StreamExtensions +{ + /// + /// Writes a to the current stream as big endian, and advances the stream position by two bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, short value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[2]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as big endian, and advances the stream position by four bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, int value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[4]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as big endian, and advances the stream position by eight bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, long value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[8]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as big endian, and advances the stream position by two bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + [CLSCompliant(false)] + public static int WriteBigEndian(this Stream stream, ushort value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[2]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as big endian, and advances the stream position by four bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + [CLSCompliant(false)] + public static int WriteBigEndian(this Stream stream, uint value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[4]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as big endian, and advances the stream position by eight bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + [CLSCompliant(false)] + public static int WriteBigEndian(this Stream stream, ulong value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[8]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by four bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, float value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[4]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by eight + /// bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, double value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[8]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by sixteen + /// bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteBigEndian(this Stream stream, decimal value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[16]; + value.TryWriteBigEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by two bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, short value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[2]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes an to the current stream as little endian, and advances the stream position by four bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, int value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[4]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by eight bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, long value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[8]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by four bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, float value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[4]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by eight + /// bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, double value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[8]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by sixteen + /// bytes. + /// + /// The stream to which the value should be written. + /// The to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + public static int WriteLittleEndian(this Stream stream, decimal value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[16]; + value.TryWriteLittleEndian(buffer); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by two bytes. + /// + /// The stream to which the value should be written. + /// The two-byte signed integer to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + [CLSCompliant(false)] + public static int WriteLittleEndian(this Stream stream, ushort value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[2]; + BinaryPrimitives.WriteUInt16LittleEndian(buffer, value); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by four bytes. + /// + /// The stream to which the value should be written. + /// The two-byte signed integer to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + [CLSCompliant(false)] + public static int WriteLittleEndian(this Stream stream, uint value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[4]; + BinaryPrimitives.WriteUInt32LittleEndian(buffer, value); + return stream.WriteInternal(buffer); + } + + /// + /// Writes a to the current stream as little endian, and advances the stream position by eight bytes. + /// + /// The stream to which the value should be written. + /// The two-byte signed integer to write. + /// The number of bytes written to the stream. + /// is . + /// does not support writing. + [CLSCompliant(false)] + public static int WriteLittleEndian(this Stream stream, ulong value) + { + if (stream is null) + { + throw new ArgumentNullException(nameof(stream)); + } + + if (!stream.CanWrite) + { + throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); + } + + Span buffer = stackalloc byte[8]; + BinaryPrimitives.WriteUInt64LittleEndian(buffer, value); + return stream.WriteInternal(buffer); + } + + private static int WriteInternal(this Stream stream, ReadOnlySpan value) + { + long preWritePosition = stream.Position; + stream.Write(value); + return (int)(stream.Position - preWritePosition); + } +} diff --git a/X10D/src/IO/StreamExtensions.cs b/X10D/src/IO/StreamExtensions.cs index ceb34c8..15e50e0 100644 --- a/X10D/src/IO/StreamExtensions.cs +++ b/X10D/src/IO/StreamExtensions.cs @@ -1,6 +1,4 @@ -using System.Buffers.Binary; -using System.Reflection; -using System.Runtime.InteropServices; +using System.Reflection; using System.Security.Cryptography; namespace X10D.IO; @@ -8,7 +6,7 @@ namespace X10D.IO; /// /// IO-related extension methods for . /// -public static class StreamExtensions +public static partial class StreamExtensions { /// /// Returns the hash of the current stream as an array of bytes using the specified hash algorithm. @@ -57,522 +55,6 @@ public static class StreamExtensions return crypt.ComputeHash(stream); } - /// - /// Reads an from the current stream as big endian, and advances the stream position by sixteen - /// bytes. - /// - /// The stream from which the value should be read. - /// The big endian value. - /// is - /// does not support reading. - public static decimal ReadDecimalBigEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - const int decimalSize = sizeof(decimal); - const int int32Size = sizeof(int); - const int partitionSize = decimalSize / int32Size; - - Span buffer = stackalloc int[partitionSize]; - for (var index = 0; index < partitionSize; index++) - { - buffer[index] = stream.ReadInt32BigEndian(); - } - - if (BitConverter.IsLittleEndian) - { - buffer.Reverse(); - } - -#if NET5_0_OR_GREATER - return new decimal(buffer); -#else - return new decimal(buffer.ToArray()); -#endif - } - - /// - /// Reads an from the current stream as big endian, and advances the stream position by sixteen - /// bytes. - /// - /// The stream from which the value should be read. - /// The big endian value. - /// is - /// does not support reading. - public static decimal ReadDecimalLittleEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - const int decimalSize = sizeof(decimal); - const int int32Size = sizeof(int); - const int partitionSize = decimalSize / int32Size; - - Span buffer = stackalloc int[partitionSize]; - for (var index = 0; index < partitionSize; index++) - { - buffer[index] = stream.ReadInt32LittleEndian(); - } - - if (!BitConverter.IsLittleEndian) - { - buffer.Reverse(); - } - -#if NET5_0_OR_GREATER - return new decimal(buffer); -#else - return new decimal(buffer.ToArray()); -#endif - } - - /// - /// Reads an from the current stream as big endian, and advances the stream position by eight bytes. - /// - /// The stream from which the value should be read. - /// The big endian value. - /// is - /// does not support reading. - public static double ReadDoubleBigEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[8]; - _ = stream.Read(buffer); -#if NET5_0_OR_GREATER - return BinaryPrimitives.ReadDoubleBigEndian(buffer); -#else - if (BitConverter.IsLittleEndian) - { - buffer.Reverse(); - } - - return MemoryMarshal.Read(buffer); -#endif - } - - /// - /// Reads an from the current stream as little endian, and advances the stream position by eight - /// bytes. - /// - /// The stream from which the value should be read. - /// The little endian value. - /// is - /// does not support reading. - public static double ReadDoubleLittleEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[8]; - _ = stream.Read(buffer); -#if NET5_0_OR_GREATER - return BinaryPrimitives.ReadDoubleLittleEndian(buffer); -#else - if (!BitConverter.IsLittleEndian) - { - buffer.Reverse(); - } - - return MemoryMarshal.Read(buffer); -#endif - } - - /// - /// Reads an from the current stream as big endian, and advances the stream position by two bytes. - /// - /// The stream from which the value should be read. - /// The big endian value. - /// is - /// does not support reading. - public static short ReadInt16BigEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[2]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadInt16BigEndian(buffer); - } - - /// - /// Reads an from the current stream as little endian, and advances the stream position by two bytes. - /// - /// The stream from which the value should be read. - /// The little endian value. - /// is - /// does not support reading. - public static short ReadInt16LittleEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[2]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadInt16LittleEndian(buffer); - } - - /// - /// Reads an from the current stream as big endian, and advances the stream position by four bytes. - /// - /// The stream from which the value should be read. - /// The big endian value. - /// is - /// does not support reading. - public static int ReadInt32BigEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[4]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadInt32BigEndian(buffer); - } - - /// - /// Reads an from the current stream as little endian, and advances the stream position by four bytes. - /// - /// The stream from which the value should be read. - /// The little endian value. - /// is - /// does not support reading. - public static int ReadInt32LittleEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[4]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadInt32LittleEndian(buffer); - } - - /// - /// Reads an from the current stream as big endian, and advances the stream position by eight bytes. - /// - /// The stream from which the value should be read. - /// The big endian value. - /// is - /// does not support reading. - public static long ReadInt64BigEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[8]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadInt64BigEndian(buffer); - } - - /// - /// Reads an from the current stream as little endian, and advances the stream position by eight - /// bytes. - /// - /// The stream from which the value should be read. - /// The little endian value. - /// is - /// does not support reading. - public static long ReadInt64LittleEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[8]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadInt64LittleEndian(buffer); - } - - /// - /// Reads an from the current stream as big endian, and advances the stream position by four bytes. - /// - /// The stream from which the value should be read. - /// The big endian value. - /// is - /// does not support reading. - [CLSCompliant(false)] - public static float ReadSingleBigEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[4]; - _ = stream.Read(buffer); -#if NET5_0_OR_GREATER - return BinaryPrimitives.ReadSingleBigEndian(buffer); -#else - if (BitConverter.IsLittleEndian) - { - buffer.Reverse(); - } - - return MemoryMarshal.Read(buffer); -#endif - } - - /// - /// Reads an from the current stream as little endian, and advances the stream position by four - /// bytes. - /// - /// The stream from which the value should be read. - /// The little endian value. - /// is - /// does not support reading. - [CLSCompliant(false)] - public static float ReadSingleLittleEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[4]; - _ = stream.Read(buffer); -#if NET5_0_OR_GREATER - return BinaryPrimitives.ReadSingleLittleEndian(buffer); -#else - if (!BitConverter.IsLittleEndian) - { - buffer.Reverse(); - } - - return MemoryMarshal.Read(buffer); -#endif - } - - /// - /// Reads an from the current stream as big endian, and advances the stream position by two bytes. - /// - /// The stream from which the value should be read. - /// The big endian value. - /// is - /// does not support reading. - [CLSCompliant(false)] - public static ushort ReadUInt16BigEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[2]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadUInt16BigEndian(buffer); - } - - /// - /// Reads an from the current stream as little endian, and advances the stream position by two bytes. - /// - /// The stream from which the value should be read. - /// The little endian value. - /// is - /// does not support reading. - [CLSCompliant(false)] - public static ushort ReadUInt16LittleEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[2]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadUInt16LittleEndian(buffer); - } - - /// - /// Reads an from the current stream as big endian, and advances the stream position by four bytes. - /// - /// The stream from which the value should be read. - /// The big endian value. - /// is - /// does not support reading. - [CLSCompliant(false)] - public static uint ReadUInt32BigEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[4]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadUInt32BigEndian(buffer); - } - - /// - /// Reads an from the current stream as little endian, and advances the stream position by four bytes. - /// - /// The stream from which the value should be read. - /// The little endian value. - /// is - /// does not support reading. - [CLSCompliant(false)] - public static uint ReadUInt32LittleEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[4]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadUInt32LittleEndian(buffer); - } - - /// - /// Reads an from the current stream as big endian, and advances the stream position by eight bytes. - /// - /// The stream from which the value should be read. - /// The big endian value. - /// is - /// does not support reading. - [CLSCompliant(false)] - public static ulong ReadUInt64BigEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[8]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadUInt64BigEndian(buffer); - } - - /// - /// Reads an from the current stream as little endian, and advances the stream position by eight - /// bytes. - /// - /// The stream from which the value should be read. - /// The little endian value. - /// is - /// does not support reading. - [CLSCompliant(false)] - public static ulong ReadUInt64LittleEndian(this Stream stream) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanRead) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportReading); - } - - Span buffer = stackalloc byte[8]; - _ = stream.Read(buffer); - return BinaryPrimitives.ReadUInt64LittleEndian(buffer); - } - /// /// Returns the hash of the current stream as an array of bytes using the specified hash algorithm. /// @@ -633,471 +115,4 @@ public static class StreamExtensions _ = stream.Read(buffer); // we don't care about the number of bytes read. we can ignore MustUseReturnValue return crypt.TryComputeHash(buffer, destination, out bytesWritten); } - - /// - /// Writes a to the current stream as big endian, and advances the stream position by two bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteBigEndian(this Stream stream, short value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[2]; - value.TryWriteBigEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as big endian, and advances the stream position by four bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteBigEndian(this Stream stream, int value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[4]; - value.TryWriteBigEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as big endian, and advances the stream position by eight bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteBigEndian(this Stream stream, long value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[8]; - value.TryWriteBigEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as big endian, and advances the stream position by two bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - [CLSCompliant(false)] - public static int WriteBigEndian(this Stream stream, ushort value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[2]; - value.TryWriteBigEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as big endian, and advances the stream position by four bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - [CLSCompliant(false)] - public static int WriteBigEndian(this Stream stream, uint value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[4]; - value.TryWriteBigEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as big endian, and advances the stream position by eight bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - [CLSCompliant(false)] - public static int WriteBigEndian(this Stream stream, ulong value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[8]; - value.TryWriteBigEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as little endian, and advances the stream position by four bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteBigEndian(this Stream stream, float value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[4]; - value.TryWriteBigEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as little endian, and advances the stream position by eight - /// bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteBigEndian(this Stream stream, double value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[8]; - value.TryWriteBigEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as little endian, and advances the stream position by sixteen - /// bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteBigEndian(this Stream stream, decimal value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[16]; - value.TryWriteBigEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as little endian, and advances the stream position by two bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteLittleEndian(this Stream stream, short value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[2]; - value.TryWriteLittleEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes an to the current stream as little endian, and advances the stream position by four bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteLittleEndian(this Stream stream, int value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[4]; - value.TryWriteLittleEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as little endian, and advances the stream position by eight bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteLittleEndian(this Stream stream, long value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[8]; - value.TryWriteLittleEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as little endian, and advances the stream position by four bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteLittleEndian(this Stream stream, float value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[4]; - value.TryWriteLittleEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as little endian, and advances the stream position by eight - /// bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteLittleEndian(this Stream stream, double value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[8]; - value.TryWriteLittleEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as little endian, and advances the stream position by sixteen - /// bytes. - /// - /// The stream to which the value should be written. - /// The to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - public static int WriteLittleEndian(this Stream stream, decimal value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[16]; - value.TryWriteLittleEndian(buffer); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as little endian, and advances the stream position by two bytes. - /// - /// The stream to which the value should be written. - /// The two-byte signed integer to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - [CLSCompliant(false)] - public static int WriteLittleEndian(this Stream stream, ushort value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[2]; - BinaryPrimitives.WriteUInt16LittleEndian(buffer, value); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as little endian, and advances the stream position by four bytes. - /// - /// The stream to which the value should be written. - /// The two-byte signed integer to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - [CLSCompliant(false)] - public static int WriteLittleEndian(this Stream stream, uint value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[4]; - BinaryPrimitives.WriteUInt32LittleEndian(buffer, value); - return stream.WriteInternal(buffer); - } - - /// - /// Writes a to the current stream as little endian, and advances the stream position by eight bytes. - /// - /// The stream to which the value should be written. - /// The two-byte signed integer to write. - /// The number of bytes written to the stream. - /// is . - /// does not support writing. - [CLSCompliant(false)] - public static int WriteLittleEndian(this Stream stream, ulong value) - { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (!stream.CanWrite) - { - throw new ArgumentException(ExceptionMessages.StreamDoesNotSupportWriting); - } - - Span buffer = stackalloc byte[8]; - BinaryPrimitives.WriteUInt64LittleEndian(buffer, value); - return stream.WriteInternal(buffer); - } - - private static int WriteInternal(this Stream stream, ReadOnlySpan value) - { - long preWritePosition = stream.Position; - stream.Write(value); - return (int)(stream.Position - preWritePosition); - } } From 50d9cad2f3225d1155e2a91d9e7110aee6ac8006 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 23 Aug 2023 17:06:44 +0100 Subject: [PATCH 28/46] perf: optimise subsequent GetHash and TryWriteHash calls --- CHANGELOG.md | 1 + X10D/src/IO/StreamExtensions.cs | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f31c88..65394b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 BigEndian/LittleEndian methods. - X10D: `Stream.GetHash<>` and `Stream.TryWriteHash<>` now throw ArgumentException in lieu of TypeInitializationException. +- X10D: `Stream.GetHash<>` and `Stream.TryWriteHash<>` are now more efficient on second and subsequent calls. ### Removed diff --git a/X10D/src/IO/StreamExtensions.cs b/X10D/src/IO/StreamExtensions.cs index 15e50e0..4bf3df8 100644 --- a/X10D/src/IO/StreamExtensions.cs +++ b/X10D/src/IO/StreamExtensions.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using System.Collections.Concurrent; +using System.Reflection; using System.Security.Cryptography; namespace X10D.IO; @@ -8,6 +9,8 @@ namespace X10D.IO; /// public static partial class StreamExtensions { + private static readonly ConcurrentDictionary HashAlgorithmCache = new(); + /// /// Returns the hash of the current stream as an array of bytes using the specified hash algorithm. /// @@ -37,6 +40,11 @@ public static partial class StreamExtensions throw new IOException(ExceptionMessages.StreamDoesNotSupportReading); } + if (HashAlgorithmCache.TryGetValue(typeof(T), out HashAlgorithm? cachedHashAlgorithm)) + { + return cachedHashAlgorithm.ComputeHash(stream); + } + Type type = typeof(T); MethodInfo? createMethod = type.GetMethods(BindingFlags.Public | BindingFlags.Static) @@ -52,6 +60,7 @@ public static partial class StreamExtensions throw new ArgumentException(ExceptionMessages.HashAlgorithmCreateReturnedNull); } + HashAlgorithmCache.TryAdd(type, crypt); return crypt.ComputeHash(stream); } @@ -91,6 +100,13 @@ public static partial class StreamExtensions throw new IOException(ExceptionMessages.StreamDoesNotSupportReading); } + Span buffer = stackalloc byte[(int)stream.Length]; + if (HashAlgorithmCache.TryGetValue(typeof(T), out HashAlgorithm? cachedHashAlgorithm)) + { + _ = stream.Read(buffer); // we don't care about the number of bytes read. we can ignore MustUseReturnValue + return cachedHashAlgorithm.TryComputeHash(buffer, destination, out bytesWritten); + } + Type type = typeof(T); MethodInfo? createMethod = type.GetMethods(BindingFlags.Public | BindingFlags.Static) @@ -111,7 +127,7 @@ public static partial class StreamExtensions throw new ArgumentException(ExceptionMessages.StreamTooLarge); } - Span buffer = stackalloc byte[(int)stream.Length]; + HashAlgorithmCache.TryAdd(type, crypt); _ = stream.Read(buffer); // we don't care about the number of bytes read. we can ignore MustUseReturnValue return crypt.TryComputeHash(buffer, destination, out bytesWritten); } From 71b0bec85c286bdbee2bd33dac719ba97c1ebe78 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 24 Aug 2023 01:53:24 +0100 Subject: [PATCH 29/46] style(test): format span tests --- X10D.Tests/src/Linq/ReadOnlySpanTests.cs | 8 ++++---- X10D.Tests/src/Linq/SpanTests.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/X10D.Tests/src/Linq/ReadOnlySpanTests.cs b/X10D.Tests/src/Linq/ReadOnlySpanTests.cs index da74e71..942e646 100644 --- a/X10D.Tests/src/Linq/ReadOnlySpanTests.cs +++ b/X10D.Tests/src/Linq/ReadOnlySpanTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; @@ -16,7 +16,7 @@ internal class ReadOnlySpanTests [Test] public void AllShouldBeCorrect() { - var span = new ReadOnlySpan(new[] {2, 4, 6, 8, 10}); + var span = new ReadOnlySpan(new[] { 2, 4, 6, 8, 10 }); Assert.That(span.All(x => x % 2 == 0)); Assert.That(span.All(x => x % 2 == 1), Is.False); } @@ -31,7 +31,7 @@ internal class ReadOnlySpanTests [Test] public void AnyShouldBeCorrect() { - var span = new ReadOnlySpan(new[] {2, 4, 6, 8, 10}); + var span = new ReadOnlySpan(new[] { 2, 4, 6, 8, 10 }); Assert.That(span.Any(x => x % 2 == 0)); Assert.That(span.Any(x => x % 2 == 1), Is.False); } @@ -66,7 +66,7 @@ internal class ReadOnlySpanTests [Test] public void Count_ShouldReturn5_ForEvenNumbers_GivenNumbers1To10() { - var span = new ReadOnlySpan(new[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); + var span = new ReadOnlySpan(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); Assert.That(span.Count(i => i % 2 == 0), Is.EqualTo(5)); } diff --git a/X10D.Tests/src/Linq/SpanTests.cs b/X10D.Tests/src/Linq/SpanTests.cs index 05d60f5..313dea1 100644 --- a/X10D.Tests/src/Linq/SpanTests.cs +++ b/X10D.Tests/src/Linq/SpanTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; @@ -16,7 +16,7 @@ internal class SpanTests [Test] public void AllShouldBeCorrect() { - var span = new Span(new[] {2, 4, 6, 8, 10}); + var span = new Span(new[] { 2, 4, 6, 8, 10 }); Assert.That(span.All(x => x % 2 == 0)); Assert.That(span.All(x => x % 2 == 1), Is.False); } @@ -31,7 +31,7 @@ internal class SpanTests [Test] public void AnyShouldBeCorrect() { - var span = new Span(new[] {2, 4, 6, 8, 10}); + var span = new Span(new[] { 2, 4, 6, 8, 10 }); Assert.That(span.Any(x => x % 2 == 0)); Assert.That(span.Any(x => x % 2 == 1), Is.False); } @@ -66,7 +66,7 @@ internal class SpanTests [Test] public void Count_ShouldReturn5_ForEvenNumbers_GivenNumbers1To10() { - var span = new Span(new[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); + var span = new Span(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); Assert.That(span.Count(i => i % 2 == 0), Is.EqualTo(5)); } From 129cbfb51f1ff8e0bf2b052263442ed534d19098 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 24 Aug 2023 02:29:59 +0100 Subject: [PATCH 30/46] refactor: revert 50d9cad2f3225d1155e2a91d9e7110aee6ac8006 --- CHANGELOG.md | 1 - X10D/src/IO/StreamExtensions.cs | 20 ++------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65394b2..5f31c88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,7 +38,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 BigEndian/LittleEndian methods. - X10D: `Stream.GetHash<>` and `Stream.TryWriteHash<>` now throw ArgumentException in lieu of TypeInitializationException. -- X10D: `Stream.GetHash<>` and `Stream.TryWriteHash<>` are now more efficient on second and subsequent calls. ### Removed diff --git a/X10D/src/IO/StreamExtensions.cs b/X10D/src/IO/StreamExtensions.cs index 4bf3df8..15e50e0 100644 --- a/X10D/src/IO/StreamExtensions.cs +++ b/X10D/src/IO/StreamExtensions.cs @@ -1,5 +1,4 @@ -using System.Collections.Concurrent; -using System.Reflection; +using System.Reflection; using System.Security.Cryptography; namespace X10D.IO; @@ -9,8 +8,6 @@ namespace X10D.IO; /// public static partial class StreamExtensions { - private static readonly ConcurrentDictionary HashAlgorithmCache = new(); - /// /// Returns the hash of the current stream as an array of bytes using the specified hash algorithm. /// @@ -40,11 +37,6 @@ public static partial class StreamExtensions throw new IOException(ExceptionMessages.StreamDoesNotSupportReading); } - if (HashAlgorithmCache.TryGetValue(typeof(T), out HashAlgorithm? cachedHashAlgorithm)) - { - return cachedHashAlgorithm.ComputeHash(stream); - } - Type type = typeof(T); MethodInfo? createMethod = type.GetMethods(BindingFlags.Public | BindingFlags.Static) @@ -60,7 +52,6 @@ public static partial class StreamExtensions throw new ArgumentException(ExceptionMessages.HashAlgorithmCreateReturnedNull); } - HashAlgorithmCache.TryAdd(type, crypt); return crypt.ComputeHash(stream); } @@ -100,13 +91,6 @@ public static partial class StreamExtensions throw new IOException(ExceptionMessages.StreamDoesNotSupportReading); } - Span buffer = stackalloc byte[(int)stream.Length]; - if (HashAlgorithmCache.TryGetValue(typeof(T), out HashAlgorithm? cachedHashAlgorithm)) - { - _ = stream.Read(buffer); // we don't care about the number of bytes read. we can ignore MustUseReturnValue - return cachedHashAlgorithm.TryComputeHash(buffer, destination, out bytesWritten); - } - Type type = typeof(T); MethodInfo? createMethod = type.GetMethods(BindingFlags.Public | BindingFlags.Static) @@ -127,7 +111,7 @@ public static partial class StreamExtensions throw new ArgumentException(ExceptionMessages.StreamTooLarge); } - HashAlgorithmCache.TryAdd(type, crypt); + Span buffer = stackalloc byte[(int)stream.Length]; _ = stream.Read(buffer); // we don't care about the number of bytes read. we can ignore MustUseReturnValue return crypt.TryComputeHash(buffer, destination, out bytesWritten); } From 9caa0acb7b195c3d14f4d5e266b807c3dc3a552b Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sat, 26 Aug 2023 18:11:29 +0100 Subject: [PATCH 31/46] style: remove UTF8 BOM --- X10D.Hosting/src/Assembly.cs | 2 +- .../src/DependencyInjection/ServiceCollectionExtensions.cs | 2 +- X10D.Tests/1000primes.txt | 2 +- X10D.Tests/src/Collections/ArrayTests.AsReadOnly.cs | 2 +- X10D.Tests/src/Collections/ArrayTests.Clear.cs | 2 +- X10D.Tests/src/Collections/ArrayTests.cs | 2 +- X10D.Tests/src/Collections/BoolListTests.cs | 2 +- X10D.Tests/src/Collections/ByteTests.cs | 2 +- .../src/Collections/CollectionTests.ClearAndDisposeAll.cs | 2 +- .../src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs | 2 +- X10D.Tests/src/Collections/CollectionTests.cs | 2 +- X10D.Tests/src/Collections/DictionaryTests.cs | 2 +- X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs | 2 +- X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs | 2 +- X10D.Tests/src/Collections/EnumerableTests.cs | 2 +- X10D.Tests/src/Collections/Int16Tests.cs | 2 +- X10D.Tests/src/Collections/Int32Tests.cs | 2 +- X10D.Tests/src/Collections/Int64Tests.cs | 2 +- X10D.Tests/src/Collections/ListTests.cs | 2 +- X10D.Tests/src/Collections/SpanTest.cs | 2 +- X10D.Tests/src/Core/CoreTests.cs | 2 +- X10D.Tests/src/Core/EnumTests.cs | 2 +- X10D.Tests/src/Core/IntrinsicTests.cs | 2 +- X10D.Tests/src/Core/NullableTests.cs | 2 +- X10D.Tests/src/Core/RandomTests.cs | 2 +- X10D.Tests/src/Core/SpanTest.cs | 2 +- X10D.Tests/src/Drawing/CircleFTests.cs | 2 +- X10D.Tests/src/Drawing/CircleTests.cs | 2 +- X10D.Tests/src/Drawing/ColorTests.cs | 2 +- X10D.Tests/src/Drawing/CuboidTests.cs | 2 +- X10D.Tests/src/Drawing/EllipseFTests.cs | 2 +- X10D.Tests/src/Drawing/EllipseTests.cs | 2 +- X10D.Tests/src/Drawing/Line3DTests.cs | 2 +- X10D.Tests/src/Drawing/LineFTests.cs | 2 +- X10D.Tests/src/Drawing/LineTests.cs | 2 +- X10D.Tests/src/Drawing/PointFTests.cs | 2 +- X10D.Tests/src/Drawing/PointTests.cs | 2 +- X10D.Tests/src/Drawing/PolygonFTests.cs | 2 +- X10D.Tests/src/Drawing/PolygonTests.cs | 2 +- X10D.Tests/src/Drawing/PolyhedronTests.cs | 2 +- X10D.Tests/src/Drawing/RandomTests.cs | 2 +- X10D.Tests/src/Drawing/SizeTests.cs | 2 +- X10D.Tests/src/Drawing/SphereTests.cs | 2 +- X10D.Tests/src/Hosting/ServiceCollectionTests.cs | 2 +- X10D.Tests/src/IO/BooleanTests.cs | 2 +- X10D.Tests/src/IO/StreamTests.WriteUInt64.cs | 2 +- X10D.Tests/src/IO/TextReaderTests.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.Double.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.Int32.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.Int64.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.Single.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.UInt32.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.UInt64.cs | 2 +- X10D.Tests/src/IO/TextWriterTests.cs | 2 +- X10D.Tests/src/IO/UInt16Tests.cs | 2 +- X10D.Tests/src/IO/UInt32Tests.cs | 2 +- X10D.Tests/src/IO/UInt64Tests.cs | 2 +- X10D.Tests/src/Linq/ByteTests.cs | 2 +- X10D.Tests/src/Linq/DecimalTests.cs | 2 +- X10D.Tests/src/Linq/DoubleTests.cs | 2 +- X10D.Tests/src/Linq/EnumerableTests.cs | 2 +- X10D.Tests/src/Linq/Int16Tests.cs | 2 +- X10D.Tests/src/Linq/Int32Tests.cs | 2 +- X10D.Tests/src/Linq/Int64Tests.cs | 2 +- X10D.Tests/src/Linq/SByteTests.cs | 2 +- X10D.Tests/src/Linq/SingleTests.cs | 2 +- X10D.Tests/src/Linq/UInt16Tests.cs | 2 +- X10D.Tests/src/Linq/UInt32Tests.cs | 2 +- X10D.Tests/src/Linq/UInt64Tests.cs | 2 +- X10D.Tests/src/Math/BigIntegerTests.Wrap.cs | 2 +- X10D.Tests/src/Math/BigIntegerTests.cs | 2 +- X10D.Tests/src/Math/ByteTests.Wrap.cs | 2 +- X10D.Tests/src/Math/ByteTests.cs | 2 +- X10D.Tests/src/Math/ComparableTests.cs | 2 +- X10D.Tests/src/Math/DecimalTests.Wrap.cs | 2 +- X10D.Tests/src/Math/DecimalTests.cs | 2 +- X10D.Tests/src/Math/DoubleTests.Wrap.cs | 2 +- X10D.Tests/src/Math/DoubleTests.cs | 2 +- X10D.Tests/src/Math/Int16Tests.Wrap.cs | 2 +- X10D.Tests/src/Math/Int16Tests.cs | 2 +- X10D.Tests/src/Math/Int32Tests.Wrap.cs | 2 +- X10D.Tests/src/Math/Int32Tests.cs | 2 +- X10D.Tests/src/Math/Int64Tests.Wrap.cs | 2 +- X10D.Tests/src/Math/Int64Tests.cs | 2 +- X10D.Tests/src/Math/IsPrimeTests.cs | 2 +- X10D.Tests/src/Math/MathUtilityTests.cs | 2 +- X10D.Tests/src/Math/SByteTests.Wrap.cs | 2 +- X10D.Tests/src/Math/SByteTests.cs | 2 +- X10D.Tests/src/Math/SingleTests.Wrap.cs | 2 +- X10D.Tests/src/Math/SingleTests.cs | 2 +- X10D.Tests/src/Math/UInt16Tests.Wrap.cs | 2 +- X10D.Tests/src/Math/UInt16Tests.cs | 2 +- X10D.Tests/src/Math/UInt32Tests.Wrap.cs | 2 +- X10D.Tests/src/Math/UInt64Tests.Wrap.cs | 2 +- X10D.Tests/src/Net/EndPointTests.cs | 2 +- X10D.Tests/src/Net/IPAddressTests.cs | 2 +- X10D.Tests/src/Net/Int16Tests.cs | 2 +- X10D.Tests/src/Net/Int32Tests.cs | 2 +- X10D.Tests/src/Net/Int64Tests.cs | 2 +- X10D.Tests/src/Numerics/ByteTests.cs | 2 +- X10D.Tests/src/Numerics/Int16Tests.cs | 2 +- X10D.Tests/src/Numerics/Int32Tests.cs | 2 +- X10D.Tests/src/Numerics/Int64Tests.cs | 2 +- X10D.Tests/src/Numerics/QuaternionTests.cs | 2 +- X10D.Tests/src/Numerics/RandomTests.cs | 2 +- X10D.Tests/src/Numerics/SByteTests.cs | 2 +- X10D.Tests/src/Numerics/UInt16Tests.cs | 2 +- X10D.Tests/src/Numerics/UInt32Tests.cs | 2 +- X10D.Tests/src/Numerics/UInt64Tests.cs | 2 +- X10D.Tests/src/Numerics/Vector2Tests.cs | 2 +- X10D.Tests/src/Numerics/Vector3Tests.cs | 2 +- X10D.Tests/src/Numerics/Vector4Tests.cs | 2 +- X10D.Tests/src/Reactive/ProgressTests.cs | 2 +- X10D.Tests/src/Reflection/MemberInfoTests.cs | 2 +- X10D.Tests/src/Reflection/TypeTests.cs | 2 +- X10D.Tests/src/Text/CharSpanTests.cs | 2 +- X10D.Tests/src/Text/CharTests.cs | 2 +- X10D.Tests/src/Text/CoreTests.cs | 2 +- X10D.Tests/src/Text/EnumerableTests.cs | 2 +- X10D.Tests/src/Text/RuneTests.cs | 2 +- X10D.Tests/src/Text/StringBuilderReaderTests.cs | 2 +- X10D.Tests/src/Text/StringTests.cs | 2 +- X10D.Tests/src/Time/ByteTests.cs | 2 +- X10D.Tests/src/Time/CharSpanTests.cs | 2 +- X10D.Tests/src/Time/DecimalTests.cs | 2 +- X10D.Tests/src/Time/DoubleTests.cs | 2 +- X10D.Tests/src/Time/HalfTests.cs | 2 +- X10D.Tests/src/Time/Int16Tests.cs | 2 +- X10D.Tests/src/Time/Int32Tests.cs | 2 +- X10D.Tests/src/Time/Int64Tests.cs | 2 +- X10D.Tests/src/Time/SByteTests.cs | 2 +- X10D.Tests/src/Time/SingleTests.cs | 2 +- X10D.Tests/src/Time/StringTests.cs | 2 +- X10D.Tests/src/Time/TimeSpanParserTests.cs | 2 +- X10D.Tests/src/Time/TimeSpanTests.cs | 2 +- X10D.Tests/src/Time/UInt16Tests.cs | 2 +- X10D.Tests/src/Time/UInt32Tests.cs | 2 +- X10D.Tests/src/Time/UInt64Tests.cs | 2 +- X10D/src/Assembly.cs | 2 +- X10D/src/Collections/ArrayExtensions.cs | 2 +- X10D/src/Collections/ByteExtensions.cs | 2 +- X10D/src/Collections/CollectionExtensions.cs | 2 +- X10D/src/Collections/DictionaryExtensions.cs | 2 +- X10D/src/Collections/EnumerableExtensions.cs | 2 +- X10D/src/Collections/Int16Extensions.cs | 2 +- X10D/src/Collections/Int32Extensions.cs | 2 +- X10D/src/Collections/Int64Extensions.cs | 2 +- X10D/src/Collections/SpanExtensions.cs | 2 +- X10D/src/Collections/SpanSplitEnumerator.cs | 2 +- X10D/src/CompilerServices/CompilerResources.cs | 2 +- X10D/src/Core/EnumExtensions.cs | 2 +- X10D/src/Core/Extensions.cs | 2 +- X10D/src/Core/IntrinsicExtensions.cs | 2 +- X10D/src/Core/IntrinsicUtility.cs | 2 +- X10D/src/Core/NullableExtensions.cs | 2 +- X10D/src/Core/RandomExtensions.cs | 2 +- X10D/src/Core/SpanExtensions.cs | 2 +- X10D/src/Drawing/Circle.cs | 2 +- X10D/src/Drawing/CircleF.cs | 2 +- X10D/src/Drawing/ColorExtensions.cs | 2 +- X10D/src/Drawing/Cuboid.cs | 2 +- X10D/src/Drawing/Ellipse.cs | 2 +- X10D/src/Drawing/EllipseF.cs | 2 +- X10D/src/Drawing/Line.cs | 2 +- X10D/src/Drawing/Line3D.cs | 2 +- X10D/src/Drawing/LineF.cs | 2 +- X10D/src/Drawing/PointExtensions.cs | 2 +- X10D/src/Drawing/PointFExtensions.cs | 2 +- X10D/src/Drawing/Polygon.cs | 2 +- X10D/src/Drawing/PolygonF.cs | 2 +- X10D/src/Drawing/Polyhedron.cs | 2 +- X10D/src/Drawing/RandomExtensions.cs | 2 +- X10D/src/Drawing/SizeExtensions.cs | 2 +- X10D/src/Drawing/Sphere.cs | 2 +- X10D/src/ExceptionMessages.Designer.cs | 2 +- X10D/src/ExceptionMessages.resx | 2 +- X10D/src/IO/BooleanExtensions.cs | 2 +- X10D/src/IO/ByteExtensions.cs | 2 +- X10D/src/IO/DirectoryInfoExtensions.cs | 2 +- X10D/src/IO/DoubleExtensions.cs | 2 +- X10D/src/IO/FileInfoExtensions.cs | 2 +- X10D/src/IO/Int16Extensions.cs | 2 +- X10D/src/IO/Int32Extensions.cs | 2 +- X10D/src/IO/Int64Extensions.cs | 2 +- X10D/src/IO/ListOfByteExtensions.cs | 2 +- X10D/src/IO/SByteExtensions.cs | 2 +- X10D/src/IO/SingleExtensions.cs | 2 +- X10D/src/IO/StreamExtensions.Reading.cs | 2 +- X10D/src/IO/StreamExtensions.Writing.cs | 2 +- X10D/src/IO/StreamExtensions.cs | 2 +- X10D/src/IO/TextReaderExtensions.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Double.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Int32.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Int64.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.Single.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.UInt32.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteLineNoAlloc.UInt64.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Double.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Int32.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Int64.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteNoAlloc.Single.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteNoAlloc.UInt32.cs | 2 +- X10D/src/IO/TextWriterExtensions.WriteNoAlloc.UInt64.cs | 2 +- X10D/src/IO/TextWriterExtensions.cs | 2 +- X10D/src/IO/UInt16Extensions.cs | 2 +- X10D/src/IO/UInt32Extensions.cs | 2 +- X10D/src/IO/UInt64Extensions.cs | 2 +- X10D/src/Linq/ByteExtensions.cs | 2 +- X10D/src/Linq/DecimalExtensions.cs | 2 +- X10D/src/Linq/DoubleExtensions.cs | 2 +- X10D/src/Linq/EnumerableExtensions.cs | 2 +- X10D/src/Linq/Int16Extensions.cs | 2 +- X10D/src/Linq/Int32Extensions.cs | 2 +- X10D/src/Linq/Int64Extensions.cs | 2 +- X10D/src/Linq/ReadOnlySpanExtensions.cs | 2 +- X10D/src/Linq/SingleExtensions.cs | 2 +- X10D/src/Linq/SpanExtensions.cs | 2 +- X10D/src/Math/BigIntegerExtensions.cs | 2 +- X10D/src/Math/DecimalExtensions.cs | 2 +- X10D/src/Math/DoubleExtensions.cs | 2 +- X10D/src/Math/InclusiveOptions.cs | 2 +- X10D/src/Math/MathUtility.cs | 2 +- X10D/src/Math/SByteExtensions.cs | 2 +- X10D/src/Math/SingleExtensions.cs | 2 +- X10D/src/Math/UInt16Extensions.cs | 2 +- X10D/src/Math/UInt32Extensions.cs | 2 +- X10D/src/Math/UInt64Extensions.cs | 2 +- X10D/src/Net/EndPointExtensions.cs | 2 +- X10D/src/Net/IPAddressExtensions.cs | 2 +- X10D/src/Net/Int16Extensions.cs | 2 +- X10D/src/Net/Int32Extensions.cs | 2 +- X10D/src/Net/Int64Extensions.cs | 2 +- X10D/src/Numerics/ByteExtensions.cs | 2 +- X10D/src/Numerics/Int16Extensions.cs | 2 +- X10D/src/Numerics/Int32Extensions.cs | 2 +- X10D/src/Numerics/Int64Extensions.cs | 2 +- X10D/src/Numerics/QuaternionExtensions.cs | 2 +- X10D/src/Numerics/RandomExtensions.cs | 2 +- X10D/src/Numerics/SByteExtensions.cs | 2 +- X10D/src/Numerics/UInt16Extensions.cs | 2 +- X10D/src/Numerics/UInt32Extensions.cs | 2 +- X10D/src/Numerics/UInt64Extensions.cs | 2 +- X10D/src/Numerics/Vector2Extensions.cs | 2 +- X10D/src/Numerics/Vector3Extensions.cs | 2 +- X10D/src/Numerics/Vector4Extensions.cs | 2 +- X10D/src/Reactive/ProgressExtensions.cs | 2 +- X10D/src/Reflection/MemberInfoExtensions.cs | 2 +- X10D/src/Reflection/TypeExtensions.cs | 2 +- X10D/src/Text/CharExtensions.cs | 2 +- X10D/src/Text/CharSpanExtensions.cs | 2 +- X10D/src/Text/EnumerableExtensions.cs | 2 +- X10D/src/Text/Extensions.cs | 2 +- X10D/src/Text/RuneExtensions.cs | 2 +- X10D/src/Text/StringBuilderReader.cs | 2 +- X10D/src/Text/StringExtensions.cs | 2 +- X10D/src/Time/ByteExtensions.cs | 2 +- X10D/src/Time/CharSpanExtensions.cs | 2 +- X10D/src/Time/DateOnlyExtensions.cs | 2 +- X10D/src/Time/DecimalExtensions.cs | 2 +- X10D/src/Time/DoubleExtensions.cs | 2 +- X10D/src/Time/HalfExtensions.cs | 2 +- X10D/src/Time/Int16Extensions.cs | 2 +- X10D/src/Time/Int32Extensions.cs | 2 +- X10D/src/Time/Int64Extensions.cs | 2 +- X10D/src/Time/SByteExtensions.cs | 2 +- X10D/src/Time/SingleExtensions.cs | 2 +- X10D/src/Time/TimeSpanExtensions.cs | 2 +- X10D/src/Time/TimeSpanParser.cs | 2 +- X10D/src/Time/UInt16Extensions.cs | 2 +- X10D/src/Time/UInt32Extensions.cs | 2 +- X10D/src/Time/UInt64Extensions.cs | 2 +- tools/Benchmarks/Program.cs | 2 +- tools/Directory.Build.props | 2 +- tools/SourceGenerator/EmojiRegexGenerator.cs | 2 +- tools/SourceGenerator/MethodOverloadGenerator.cs | 2 +- tools/SourceGenerator/OverloadSyntaxReceiver.cs | 2 +- tools/SourceValidator/Program.cs | 2 +- tools/UpmPackageGenerator/Program.cs | 2 +- tools/X10D.MetaServices/Assembly.cs | 2 +- tools/X10D.MetaServices/AutoOverloadAttribute.cs | 2 +- tools/X10D.MetaServices/OverloadTypeAttribute.cs | 2 +- 281 files changed, 281 insertions(+), 281 deletions(-) diff --git a/X10D.Hosting/src/Assembly.cs b/X10D.Hosting/src/Assembly.cs index f547610..c0d560e 100644 --- a/X10D.Hosting/src/Assembly.cs +++ b/X10D.Hosting/src/Assembly.cs @@ -1 +1 @@ -[assembly: CLSCompliant(true)] +[assembly: CLSCompliant(true)] diff --git a/X10D.Hosting/src/DependencyInjection/ServiceCollectionExtensions.cs b/X10D.Hosting/src/DependencyInjection/ServiceCollectionExtensions.cs index ea0d3a4..70a05b7 100644 --- a/X10D.Hosting/src/DependencyInjection/ServiceCollectionExtensions.cs +++ b/X10D.Hosting/src/DependencyInjection/ServiceCollectionExtensions.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace X10D.Hosting.DependencyInjection; diff --git a/X10D.Tests/1000primes.txt b/X10D.Tests/1000primes.txt index 1d931b0..4dbadc3 100644 --- a/X10D.Tests/1000primes.txt +++ b/X10D.Tests/1000primes.txt @@ -1,4 +1,4 @@ -2 +2 3 5 7 diff --git a/X10D.Tests/src/Collections/ArrayTests.AsReadOnly.cs b/X10D.Tests/src/Collections/ArrayTests.AsReadOnly.cs index e1d010d..f7339d0 100644 --- a/X10D.Tests/src/Collections/ArrayTests.AsReadOnly.cs +++ b/X10D.Tests/src/Collections/ArrayTests.AsReadOnly.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Collections; namespace X10D.Tests.Collections; diff --git a/X10D.Tests/src/Collections/ArrayTests.Clear.cs b/X10D.Tests/src/Collections/ArrayTests.Clear.cs index 5608952..509785e 100644 --- a/X10D.Tests/src/Collections/ArrayTests.Clear.cs +++ b/X10D.Tests/src/Collections/ArrayTests.Clear.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Collections; namespace X10D.Tests.Collections; diff --git a/X10D.Tests/src/Collections/ArrayTests.cs b/X10D.Tests/src/Collections/ArrayTests.cs index 53c46f5..5469f75 100644 --- a/X10D.Tests/src/Collections/ArrayTests.cs +++ b/X10D.Tests/src/Collections/ArrayTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; namespace X10D.Tests.Collections; diff --git a/X10D.Tests/src/Collections/BoolListTests.cs b/X10D.Tests/src/Collections/BoolListTests.cs index c90bc16..de3a428 100644 --- a/X10D.Tests/src/Collections/BoolListTests.cs +++ b/X10D.Tests/src/Collections/BoolListTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Collections; namespace X10D.Tests.Collections; diff --git a/X10D.Tests/src/Collections/ByteTests.cs b/X10D.Tests/src/Collections/ByteTests.cs index 4f35f86..4891123 100644 --- a/X10D.Tests/src/Collections/ByteTests.cs +++ b/X10D.Tests/src/Collections/ByteTests.cs @@ -1,4 +1,4 @@ -using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics.X86; using NUnit.Framework; using X10D.Collections; diff --git a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs index 24c542f..226439f 100644 --- a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs +++ b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs @@ -1,4 +1,4 @@ -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using NSubstitute; using NUnit.Framework; using X10D.Collections; diff --git a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs index e176fa0..f08d639 100644 --- a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs +++ b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs @@ -1,4 +1,4 @@ -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using NSubstitute; using NUnit.Framework; using X10D.Collections; diff --git a/X10D.Tests/src/Collections/CollectionTests.cs b/X10D.Tests/src/Collections/CollectionTests.cs index 8452830..9a7b040 100644 --- a/X10D.Tests/src/Collections/CollectionTests.cs +++ b/X10D.Tests/src/Collections/CollectionTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; namespace X10D.Tests.Collections; diff --git a/X10D.Tests/src/Collections/DictionaryTests.cs b/X10D.Tests/src/Collections/DictionaryTests.cs index c420375..d21e826 100644 --- a/X10D.Tests/src/Collections/DictionaryTests.cs +++ b/X10D.Tests/src/Collections/DictionaryTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Collections; namespace X10D.Tests.Collections; diff --git a/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs b/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs index 6f8519b..fc5a4fb 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs @@ -1,4 +1,4 @@ -using NSubstitute; +using NSubstitute; using NUnit.Framework; using X10D.Collections; diff --git a/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs b/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs index 9cd238f..b785115 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs @@ -1,4 +1,4 @@ -using NSubstitute; +using NSubstitute; using NUnit.Framework; using X10D.Collections; diff --git a/X10D.Tests/src/Collections/EnumerableTests.cs b/X10D.Tests/src/Collections/EnumerableTests.cs index df6442c..a08c05f 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Collections; using X10D.Core; diff --git a/X10D.Tests/src/Collections/Int16Tests.cs b/X10D.Tests/src/Collections/Int16Tests.cs index 8672a0a..f7bfab3 100644 --- a/X10D.Tests/src/Collections/Int16Tests.cs +++ b/X10D.Tests/src/Collections/Int16Tests.cs @@ -1,4 +1,4 @@ -#if NET5_0_OR_GREATER +#if NET5_0_OR_GREATER using System.Runtime.Intrinsics.X86; #endif using NUnit.Framework; diff --git a/X10D.Tests/src/Collections/Int32Tests.cs b/X10D.Tests/src/Collections/Int32Tests.cs index 97485e1..39b1036 100644 --- a/X10D.Tests/src/Collections/Int32Tests.cs +++ b/X10D.Tests/src/Collections/Int32Tests.cs @@ -1,4 +1,4 @@ -#if NET5_0_OR_GREATER +#if NET5_0_OR_GREATER using System.Runtime.Intrinsics.X86; #endif using NUnit.Framework; diff --git a/X10D.Tests/src/Collections/Int64Tests.cs b/X10D.Tests/src/Collections/Int64Tests.cs index 1cfee79..9862ec8 100644 --- a/X10D.Tests/src/Collections/Int64Tests.cs +++ b/X10D.Tests/src/Collections/Int64Tests.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.Globalization; using NUnit.Framework; using X10D.Collections; diff --git a/X10D.Tests/src/Collections/ListTests.cs b/X10D.Tests/src/Collections/ListTests.cs index bd62f8c..599a58f 100644 --- a/X10D.Tests/src/Collections/ListTests.cs +++ b/X10D.Tests/src/Collections/ListTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Collections; namespace X10D.Tests.Collections; diff --git a/X10D.Tests/src/Collections/SpanTest.cs b/X10D.Tests/src/Collections/SpanTest.cs index 04f263a..fa7ac45 100644 --- a/X10D.Tests/src/Collections/SpanTest.cs +++ b/X10D.Tests/src/Collections/SpanTest.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Collections; namespace X10D.Tests.Collections; diff --git a/X10D.Tests/src/Core/CoreTests.cs b/X10D.Tests/src/Core/CoreTests.cs index fea360d..a5df6ac 100644 --- a/X10D.Tests/src/Core/CoreTests.cs +++ b/X10D.Tests/src/Core/CoreTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Core; namespace X10D.Tests.Core; diff --git a/X10D.Tests/src/Core/EnumTests.cs b/X10D.Tests/src/Core/EnumTests.cs index c335b9a..d4e9912 100644 --- a/X10D.Tests/src/Core/EnumTests.cs +++ b/X10D.Tests/src/Core/EnumTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Core; namespace X10D.Tests.Core; diff --git a/X10D.Tests/src/Core/IntrinsicTests.cs b/X10D.Tests/src/Core/IntrinsicTests.cs index da5fd8e..e45f236 100644 --- a/X10D.Tests/src/Core/IntrinsicTests.cs +++ b/X10D.Tests/src/Core/IntrinsicTests.cs @@ -1,4 +1,4 @@ -#if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; using NUnit.Framework; diff --git a/X10D.Tests/src/Core/NullableTests.cs b/X10D.Tests/src/Core/NullableTests.cs index db4c8ef..1dd08c1 100644 --- a/X10D.Tests/src/Core/NullableTests.cs +++ b/X10D.Tests/src/Core/NullableTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Core; namespace X10D.Tests.Core; diff --git a/X10D.Tests/src/Core/RandomTests.cs b/X10D.Tests/src/Core/RandomTests.cs index 5e1022d..72fe1e7 100644 --- a/X10D.Tests/src/Core/RandomTests.cs +++ b/X10D.Tests/src/Core/RandomTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Collections; using X10D.Core; diff --git a/X10D.Tests/src/Core/SpanTest.cs b/X10D.Tests/src/Core/SpanTest.cs index 85fb460..4755ff0 100644 --- a/X10D.Tests/src/Core/SpanTest.cs +++ b/X10D.Tests/src/Core/SpanTest.cs @@ -1,4 +1,4 @@ -#if NET5_0_OR_GREATER +#if NET5_0_OR_GREATER using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.X86; #endif diff --git a/X10D.Tests/src/Drawing/CircleFTests.cs b/X10D.Tests/src/Drawing/CircleFTests.cs index 06a4de8..9b05dec 100644 --- a/X10D.Tests/src/Drawing/CircleFTests.cs +++ b/X10D.Tests/src/Drawing/CircleFTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/CircleTests.cs b/X10D.Tests/src/Drawing/CircleTests.cs index e03fb0c..c98d367 100644 --- a/X10D.Tests/src/Drawing/CircleTests.cs +++ b/X10D.Tests/src/Drawing/CircleTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Drawing; namespace X10D.Tests.Drawing; diff --git a/X10D.Tests/src/Drawing/ColorTests.cs b/X10D.Tests/src/Drawing/ColorTests.cs index 7868484..cb5cc97 100644 --- a/X10D.Tests/src/Drawing/ColorTests.cs +++ b/X10D.Tests/src/Drawing/ColorTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/CuboidTests.cs b/X10D.Tests/src/Drawing/CuboidTests.cs index 37d006f..08203ea 100644 --- a/X10D.Tests/src/Drawing/CuboidTests.cs +++ b/X10D.Tests/src/Drawing/CuboidTests.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/EllipseFTests.cs b/X10D.Tests/src/Drawing/EllipseFTests.cs index aecdcdc..5c5d828 100644 --- a/X10D.Tests/src/Drawing/EllipseFTests.cs +++ b/X10D.Tests/src/Drawing/EllipseFTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using System.Numerics; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/EllipseTests.cs b/X10D.Tests/src/Drawing/EllipseTests.cs index 6f938cd..0ddf5b1 100644 --- a/X10D.Tests/src/Drawing/EllipseTests.cs +++ b/X10D.Tests/src/Drawing/EllipseTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/Line3DTests.cs b/X10D.Tests/src/Drawing/Line3DTests.cs index 1182a5b..36f88e4 100644 --- a/X10D.Tests/src/Drawing/Line3DTests.cs +++ b/X10D.Tests/src/Drawing/Line3DTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using System.Numerics; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/LineFTests.cs b/X10D.Tests/src/Drawing/LineFTests.cs index 412fff2..fa11b71 100644 --- a/X10D.Tests/src/Drawing/LineFTests.cs +++ b/X10D.Tests/src/Drawing/LineFTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/LineTests.cs b/X10D.Tests/src/Drawing/LineTests.cs index 24a985d..5ae1c30 100644 --- a/X10D.Tests/src/Drawing/LineTests.cs +++ b/X10D.Tests/src/Drawing/LineTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Drawing; namespace X10D.Tests.Drawing; diff --git a/X10D.Tests/src/Drawing/PointFTests.cs b/X10D.Tests/src/Drawing/PointFTests.cs index aace160..1bdd8c8 100644 --- a/X10D.Tests/src/Drawing/PointFTests.cs +++ b/X10D.Tests/src/Drawing/PointFTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; #if !NET6_0_OR_GREATER using X10D.Core; diff --git a/X10D.Tests/src/Drawing/PointTests.cs b/X10D.Tests/src/Drawing/PointTests.cs index ae07657..347d7a2 100644 --- a/X10D.Tests/src/Drawing/PointTests.cs +++ b/X10D.Tests/src/Drawing/PointTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/PolygonFTests.cs b/X10D.Tests/src/Drawing/PolygonFTests.cs index f6a09de..9052c98 100644 --- a/X10D.Tests/src/Drawing/PolygonFTests.cs +++ b/X10D.Tests/src/Drawing/PolygonFTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using System.Numerics; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/PolygonTests.cs b/X10D.Tests/src/Drawing/PolygonTests.cs index 4d73cd8..50fe6d8 100644 --- a/X10D.Tests/src/Drawing/PolygonTests.cs +++ b/X10D.Tests/src/Drawing/PolygonTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/PolyhedronTests.cs b/X10D.Tests/src/Drawing/PolyhedronTests.cs index 8e85423..30545e7 100644 --- a/X10D.Tests/src/Drawing/PolyhedronTests.cs +++ b/X10D.Tests/src/Drawing/PolyhedronTests.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/RandomTests.cs b/X10D.Tests/src/Drawing/RandomTests.cs index 349ca33..7559aca 100644 --- a/X10D.Tests/src/Drawing/RandomTests.cs +++ b/X10D.Tests/src/Drawing/RandomTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/SizeTests.cs b/X10D.Tests/src/Drawing/SizeTests.cs index 47a2a42..d89fa89 100644 --- a/X10D.Tests/src/Drawing/SizeTests.cs +++ b/X10D.Tests/src/Drawing/SizeTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; using X10D.Drawing; diff --git a/X10D.Tests/src/Drawing/SphereTests.cs b/X10D.Tests/src/Drawing/SphereTests.cs index dcbf8ce..75c29b4 100644 --- a/X10D.Tests/src/Drawing/SphereTests.cs +++ b/X10D.Tests/src/Drawing/SphereTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Drawing; namespace X10D.Tests.Drawing; diff --git a/X10D.Tests/src/Hosting/ServiceCollectionTests.cs b/X10D.Tests/src/Hosting/ServiceCollectionTests.cs index 0691914..d9a8351 100644 --- a/X10D.Tests/src/Hosting/ServiceCollectionTests.cs +++ b/X10D.Tests/src/Hosting/ServiceCollectionTests.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using NUnit.Framework; using X10D.Hosting.DependencyInjection; diff --git a/X10D.Tests/src/IO/BooleanTests.cs b/X10D.Tests/src/IO/BooleanTests.cs index 2994e03..87e2075 100644 --- a/X10D.Tests/src/IO/BooleanTests.cs +++ b/X10D.Tests/src/IO/BooleanTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; diff --git a/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs b/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs index 1bf8464..5d8edcf 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using NUnit.Framework; using X10D.IO; diff --git a/X10D.Tests/src/IO/TextReaderTests.cs b/X10D.Tests/src/IO/TextReaderTests.cs index a6ff77e..d6e7491 100644 --- a/X10D.Tests/src/IO/TextReaderTests.cs +++ b/X10D.Tests/src/IO/TextReaderTests.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; using NUnit.Framework; using X10D.IO; diff --git a/X10D.Tests/src/IO/TextWriterTests.Double.cs b/X10D.Tests/src/IO/TextWriterTests.Double.cs index 0eb9361..be9fa28 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Double.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Double.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; using X10D.IO; diff --git a/X10D.Tests/src/IO/TextWriterTests.Int32.cs b/X10D.Tests/src/IO/TextWriterTests.Int32.cs index 46d13b6..9d5b7a0 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Int32.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Int32.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; using X10D.IO; diff --git a/X10D.Tests/src/IO/TextWriterTests.Int64.cs b/X10D.Tests/src/IO/TextWriterTests.Int64.cs index f9b10b4..662e54a 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Int64.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Int64.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; using X10D.IO; diff --git a/X10D.Tests/src/IO/TextWriterTests.Single.cs b/X10D.Tests/src/IO/TextWriterTests.Single.cs index 35629b3..4ad055c 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Single.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Single.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; using X10D.IO; diff --git a/X10D.Tests/src/IO/TextWriterTests.UInt32.cs b/X10D.Tests/src/IO/TextWriterTests.UInt32.cs index 5b35c99..3ba143b 100644 --- a/X10D.Tests/src/IO/TextWriterTests.UInt32.cs +++ b/X10D.Tests/src/IO/TextWriterTests.UInt32.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; using X10D.IO; diff --git a/X10D.Tests/src/IO/TextWriterTests.UInt64.cs b/X10D.Tests/src/IO/TextWriterTests.UInt64.cs index a7b4551..5b41d38 100644 --- a/X10D.Tests/src/IO/TextWriterTests.UInt64.cs +++ b/X10D.Tests/src/IO/TextWriterTests.UInt64.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; using X10D.IO; diff --git a/X10D.Tests/src/IO/TextWriterTests.cs b/X10D.Tests/src/IO/TextWriterTests.cs index 6c0945b..0ae62b1 100644 --- a/X10D.Tests/src/IO/TextWriterTests.cs +++ b/X10D.Tests/src/IO/TextWriterTests.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Text; using NUnit.Framework; diff --git a/X10D.Tests/src/IO/UInt16Tests.cs b/X10D.Tests/src/IO/UInt16Tests.cs index 4ce858d..58307e4 100644 --- a/X10D.Tests/src/IO/UInt16Tests.cs +++ b/X10D.Tests/src/IO/UInt16Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; diff --git a/X10D.Tests/src/IO/UInt32Tests.cs b/X10D.Tests/src/IO/UInt32Tests.cs index eada9aa..cce312a 100644 --- a/X10D.Tests/src/IO/UInt32Tests.cs +++ b/X10D.Tests/src/IO/UInt32Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; diff --git a/X10D.Tests/src/IO/UInt64Tests.cs b/X10D.Tests/src/IO/UInt64Tests.cs index 6ed1be8..aeb589b 100644 --- a/X10D.Tests/src/IO/UInt64Tests.cs +++ b/X10D.Tests/src/IO/UInt64Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; diff --git a/X10D.Tests/src/Linq/ByteTests.cs b/X10D.Tests/src/Linq/ByteTests.cs index 0ece8b6..a3b79e2 100644 --- a/X10D.Tests/src/Linq/ByteTests.cs +++ b/X10D.Tests/src/Linq/ByteTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Linq/DecimalTests.cs b/X10D.Tests/src/Linq/DecimalTests.cs index db0e66b..909c478 100644 --- a/X10D.Tests/src/Linq/DecimalTests.cs +++ b/X10D.Tests/src/Linq/DecimalTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Linq/DoubleTests.cs b/X10D.Tests/src/Linq/DoubleTests.cs index 01399ea..3975e46 100644 --- a/X10D.Tests/src/Linq/DoubleTests.cs +++ b/X10D.Tests/src/Linq/DoubleTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Linq/EnumerableTests.cs b/X10D.Tests/src/Linq/EnumerableTests.cs index 253690a..84e0378 100644 --- a/X10D.Tests/src/Linq/EnumerableTests.cs +++ b/X10D.Tests/src/Linq/EnumerableTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Linq/Int16Tests.cs b/X10D.Tests/src/Linq/Int16Tests.cs index 76a6a48..1401d9e 100644 --- a/X10D.Tests/src/Linq/Int16Tests.cs +++ b/X10D.Tests/src/Linq/Int16Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Linq/Int32Tests.cs b/X10D.Tests/src/Linq/Int32Tests.cs index 5f8422a..783cbba 100644 --- a/X10D.Tests/src/Linq/Int32Tests.cs +++ b/X10D.Tests/src/Linq/Int32Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Linq/Int64Tests.cs b/X10D.Tests/src/Linq/Int64Tests.cs index aad0738..c55f74d 100644 --- a/X10D.Tests/src/Linq/Int64Tests.cs +++ b/X10D.Tests/src/Linq/Int64Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Linq/SByteTests.cs b/X10D.Tests/src/Linq/SByteTests.cs index a859279..9eaeb83 100644 --- a/X10D.Tests/src/Linq/SByteTests.cs +++ b/X10D.Tests/src/Linq/SByteTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Linq/SingleTests.cs b/X10D.Tests/src/Linq/SingleTests.cs index 0bac265..8486b8b 100644 --- a/X10D.Tests/src/Linq/SingleTests.cs +++ b/X10D.Tests/src/Linq/SingleTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Linq/UInt16Tests.cs b/X10D.Tests/src/Linq/UInt16Tests.cs index 8abfc97..60be62e 100644 --- a/X10D.Tests/src/Linq/UInt16Tests.cs +++ b/X10D.Tests/src/Linq/UInt16Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Linq/UInt32Tests.cs b/X10D.Tests/src/Linq/UInt32Tests.cs index 20d1217..8fde601 100644 --- a/X10D.Tests/src/Linq/UInt32Tests.cs +++ b/X10D.Tests/src/Linq/UInt32Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Linq/UInt64Tests.cs b/X10D.Tests/src/Linq/UInt64Tests.cs index 64710d3..1c8c889 100644 --- a/X10D.Tests/src/Linq/UInt64Tests.cs +++ b/X10D.Tests/src/Linq/UInt64Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; diff --git a/X10D.Tests/src/Math/BigIntegerTests.Wrap.cs b/X10D.Tests/src/Math/BigIntegerTests.Wrap.cs index ecff3df..601a6e2 100644 --- a/X10D.Tests/src/Math/BigIntegerTests.Wrap.cs +++ b/X10D.Tests/src/Math/BigIntegerTests.Wrap.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; using X10D.Math; diff --git a/X10D.Tests/src/Math/BigIntegerTests.cs b/X10D.Tests/src/Math/BigIntegerTests.cs index 80c0cec..2812a2b 100644 --- a/X10D.Tests/src/Math/BigIntegerTests.cs +++ b/X10D.Tests/src/Math/BigIntegerTests.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; using X10D.Math; diff --git a/X10D.Tests/src/Math/ByteTests.Wrap.cs b/X10D.Tests/src/Math/ByteTests.Wrap.cs index 91c214f..9785f58 100644 --- a/X10D.Tests/src/Math/ByteTests.Wrap.cs +++ b/X10D.Tests/src/Math/ByteTests.Wrap.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/ByteTests.cs b/X10D.Tests/src/Math/ByteTests.cs index 0d80790..6608222 100644 --- a/X10D.Tests/src/Math/ByteTests.cs +++ b/X10D.Tests/src/Math/ByteTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/ComparableTests.cs b/X10D.Tests/src/Math/ComparableTests.cs index cb90266..970d649 100644 --- a/X10D.Tests/src/Math/ComparableTests.cs +++ b/X10D.Tests/src/Math/ComparableTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/DecimalTests.Wrap.cs b/X10D.Tests/src/Math/DecimalTests.Wrap.cs index 1408043..5bed0f3 100644 --- a/X10D.Tests/src/Math/DecimalTests.Wrap.cs +++ b/X10D.Tests/src/Math/DecimalTests.Wrap.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/DecimalTests.cs b/X10D.Tests/src/Math/DecimalTests.cs index 8c4b31e..d84699b 100644 --- a/X10D.Tests/src/Math/DecimalTests.cs +++ b/X10D.Tests/src/Math/DecimalTests.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; using X10D.Math; diff --git a/X10D.Tests/src/Math/DoubleTests.Wrap.cs b/X10D.Tests/src/Math/DoubleTests.Wrap.cs index fdc5ada..138264d 100644 --- a/X10D.Tests/src/Math/DoubleTests.Wrap.cs +++ b/X10D.Tests/src/Math/DoubleTests.Wrap.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/DoubleTests.cs b/X10D.Tests/src/Math/DoubleTests.cs index 3929b24..7a23f98 100644 --- a/X10D.Tests/src/Math/DoubleTests.cs +++ b/X10D.Tests/src/Math/DoubleTests.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; using X10D.Math; diff --git a/X10D.Tests/src/Math/Int16Tests.Wrap.cs b/X10D.Tests/src/Math/Int16Tests.Wrap.cs index b5f20d7..0f9a5e5 100644 --- a/X10D.Tests/src/Math/Int16Tests.Wrap.cs +++ b/X10D.Tests/src/Math/Int16Tests.Wrap.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/Int16Tests.cs b/X10D.Tests/src/Math/Int16Tests.cs index 5612e4b..7ba50a2 100644 --- a/X10D.Tests/src/Math/Int16Tests.cs +++ b/X10D.Tests/src/Math/Int16Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/Int32Tests.Wrap.cs b/X10D.Tests/src/Math/Int32Tests.Wrap.cs index 754ae48..bf4e636 100644 --- a/X10D.Tests/src/Math/Int32Tests.Wrap.cs +++ b/X10D.Tests/src/Math/Int32Tests.Wrap.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/Int32Tests.cs b/X10D.Tests/src/Math/Int32Tests.cs index 0bfbf25..664e16f 100644 --- a/X10D.Tests/src/Math/Int32Tests.cs +++ b/X10D.Tests/src/Math/Int32Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/Int64Tests.Wrap.cs b/X10D.Tests/src/Math/Int64Tests.Wrap.cs index 6434295..fb7f7ba 100644 --- a/X10D.Tests/src/Math/Int64Tests.Wrap.cs +++ b/X10D.Tests/src/Math/Int64Tests.Wrap.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/Int64Tests.cs b/X10D.Tests/src/Math/Int64Tests.cs index bd5f524..8dd40a9 100644 --- a/X10D.Tests/src/Math/Int64Tests.cs +++ b/X10D.Tests/src/Math/Int64Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/IsPrimeTests.cs b/X10D.Tests/src/Math/IsPrimeTests.cs index 4d50e68..452a286 100644 --- a/X10D.Tests/src/Math/IsPrimeTests.cs +++ b/X10D.Tests/src/Math/IsPrimeTests.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using System.Reflection; using System.Text; using NUnit.Framework; diff --git a/X10D.Tests/src/Math/MathUtilityTests.cs b/X10D.Tests/src/Math/MathUtilityTests.cs index 01028a2..eff50c1 100644 --- a/X10D.Tests/src/Math/MathUtilityTests.cs +++ b/X10D.Tests/src/Math/MathUtilityTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; #if !NET6_0_OR_GREATER using X10D.Core; #endif diff --git a/X10D.Tests/src/Math/SByteTests.Wrap.cs b/X10D.Tests/src/Math/SByteTests.Wrap.cs index dd7b9b9..5727874 100644 --- a/X10D.Tests/src/Math/SByteTests.Wrap.cs +++ b/X10D.Tests/src/Math/SByteTests.Wrap.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/SByteTests.cs b/X10D.Tests/src/Math/SByteTests.cs index 9550cfb..3727af4 100644 --- a/X10D.Tests/src/Math/SByteTests.cs +++ b/X10D.Tests/src/Math/SByteTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/SingleTests.Wrap.cs b/X10D.Tests/src/Math/SingleTests.Wrap.cs index 596a40a..b95e29a 100644 --- a/X10D.Tests/src/Math/SingleTests.Wrap.cs +++ b/X10D.Tests/src/Math/SingleTests.Wrap.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/SingleTests.cs b/X10D.Tests/src/Math/SingleTests.cs index 5e50fe7..abf31ca 100644 --- a/X10D.Tests/src/Math/SingleTests.cs +++ b/X10D.Tests/src/Math/SingleTests.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; using X10D.Math; diff --git a/X10D.Tests/src/Math/UInt16Tests.Wrap.cs b/X10D.Tests/src/Math/UInt16Tests.Wrap.cs index e5be525..364515c 100644 --- a/X10D.Tests/src/Math/UInt16Tests.Wrap.cs +++ b/X10D.Tests/src/Math/UInt16Tests.Wrap.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/UInt16Tests.cs b/X10D.Tests/src/Math/UInt16Tests.cs index c6f38ad..d51f983 100644 --- a/X10D.Tests/src/Math/UInt16Tests.cs +++ b/X10D.Tests/src/Math/UInt16Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/UInt32Tests.Wrap.cs b/X10D.Tests/src/Math/UInt32Tests.Wrap.cs index 572f71c..9a967f0 100644 --- a/X10D.Tests/src/Math/UInt32Tests.Wrap.cs +++ b/X10D.Tests/src/Math/UInt32Tests.Wrap.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Math/UInt64Tests.Wrap.cs b/X10D.Tests/src/Math/UInt64Tests.Wrap.cs index 7307589..54b902e 100644 --- a/X10D.Tests/src/Math/UInt64Tests.Wrap.cs +++ b/X10D.Tests/src/Math/UInt64Tests.Wrap.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Math; namespace X10D.Tests.Math; diff --git a/X10D.Tests/src/Net/EndPointTests.cs b/X10D.Tests/src/Net/EndPointTests.cs index 7dca5cf..98dbe60 100644 --- a/X10D.Tests/src/Net/EndPointTests.cs +++ b/X10D.Tests/src/Net/EndPointTests.cs @@ -1,4 +1,4 @@ -using System.Net; +using System.Net; using NUnit.Framework; using X10D.Net; diff --git a/X10D.Tests/src/Net/IPAddressTests.cs b/X10D.Tests/src/Net/IPAddressTests.cs index ab48f24..8f916fb 100644 --- a/X10D.Tests/src/Net/IPAddressTests.cs +++ b/X10D.Tests/src/Net/IPAddressTests.cs @@ -1,4 +1,4 @@ -using System.Net; +using System.Net; using NUnit.Framework; using X10D.Net; diff --git a/X10D.Tests/src/Net/Int16Tests.cs b/X10D.Tests/src/Net/Int16Tests.cs index 310a183..8bfb3f8 100644 --- a/X10D.Tests/src/Net/Int16Tests.cs +++ b/X10D.Tests/src/Net/Int16Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Net; namespace X10D.Tests.Net; diff --git a/X10D.Tests/src/Net/Int32Tests.cs b/X10D.Tests/src/Net/Int32Tests.cs index 50b8899..3322b9a 100644 --- a/X10D.Tests/src/Net/Int32Tests.cs +++ b/X10D.Tests/src/Net/Int32Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Net; namespace X10D.Tests.Net; diff --git a/X10D.Tests/src/Net/Int64Tests.cs b/X10D.Tests/src/Net/Int64Tests.cs index a2150e1..845b0f9 100644 --- a/X10D.Tests/src/Net/Int64Tests.cs +++ b/X10D.Tests/src/Net/Int64Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Net; namespace X10D.Tests.Net; diff --git a/X10D.Tests/src/Numerics/ByteTests.cs b/X10D.Tests/src/Numerics/ByteTests.cs index 4a191b7..300a348 100644 --- a/X10D.Tests/src/Numerics/ByteTests.cs +++ b/X10D.Tests/src/Numerics/ByteTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Numerics; namespace X10D.Tests.Numerics; diff --git a/X10D.Tests/src/Numerics/Int16Tests.cs b/X10D.Tests/src/Numerics/Int16Tests.cs index 73a0025..ce7b273 100644 --- a/X10D.Tests/src/Numerics/Int16Tests.cs +++ b/X10D.Tests/src/Numerics/Int16Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Numerics; namespace X10D.Tests.Numerics; diff --git a/X10D.Tests/src/Numerics/Int32Tests.cs b/X10D.Tests/src/Numerics/Int32Tests.cs index 36b3c1d..33871d9 100644 --- a/X10D.Tests/src/Numerics/Int32Tests.cs +++ b/X10D.Tests/src/Numerics/Int32Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Numerics; namespace X10D.Tests.Numerics; diff --git a/X10D.Tests/src/Numerics/Int64Tests.cs b/X10D.Tests/src/Numerics/Int64Tests.cs index c4c7c7b..756c35d 100644 --- a/X10D.Tests/src/Numerics/Int64Tests.cs +++ b/X10D.Tests/src/Numerics/Int64Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Numerics; namespace X10D.Tests.Numerics; diff --git a/X10D.Tests/src/Numerics/QuaternionTests.cs b/X10D.Tests/src/Numerics/QuaternionTests.cs index ce33ad2..40a25cd 100644 --- a/X10D.Tests/src/Numerics/QuaternionTests.cs +++ b/X10D.Tests/src/Numerics/QuaternionTests.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; using X10D.Numerics; diff --git a/X10D.Tests/src/Numerics/RandomTests.cs b/X10D.Tests/src/Numerics/RandomTests.cs index 38b1716..434b217 100644 --- a/X10D.Tests/src/Numerics/RandomTests.cs +++ b/X10D.Tests/src/Numerics/RandomTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Numerics; namespace X10D.Tests.Numerics; diff --git a/X10D.Tests/src/Numerics/SByteTests.cs b/X10D.Tests/src/Numerics/SByteTests.cs index 72132bc..d36a352 100644 --- a/X10D.Tests/src/Numerics/SByteTests.cs +++ b/X10D.Tests/src/Numerics/SByteTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Numerics; namespace X10D.Tests.Numerics; diff --git a/X10D.Tests/src/Numerics/UInt16Tests.cs b/X10D.Tests/src/Numerics/UInt16Tests.cs index 585f479..ae5f090 100644 --- a/X10D.Tests/src/Numerics/UInt16Tests.cs +++ b/X10D.Tests/src/Numerics/UInt16Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Numerics; namespace X10D.Tests.Numerics; diff --git a/X10D.Tests/src/Numerics/UInt32Tests.cs b/X10D.Tests/src/Numerics/UInt32Tests.cs index da77d5b..5f71af4 100644 --- a/X10D.Tests/src/Numerics/UInt32Tests.cs +++ b/X10D.Tests/src/Numerics/UInt32Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Numerics; namespace X10D.Tests.Numerics; diff --git a/X10D.Tests/src/Numerics/UInt64Tests.cs b/X10D.Tests/src/Numerics/UInt64Tests.cs index d01bd39..ec9ff74 100644 --- a/X10D.Tests/src/Numerics/UInt64Tests.cs +++ b/X10D.Tests/src/Numerics/UInt64Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Numerics; namespace X10D.Tests.Numerics; diff --git a/X10D.Tests/src/Numerics/Vector2Tests.cs b/X10D.Tests/src/Numerics/Vector2Tests.cs index e18688e..7b119d0 100644 --- a/X10D.Tests/src/Numerics/Vector2Tests.cs +++ b/X10D.Tests/src/Numerics/Vector2Tests.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; #if !NET6_0_OR_GREATER using X10D.Core; diff --git a/X10D.Tests/src/Numerics/Vector3Tests.cs b/X10D.Tests/src/Numerics/Vector3Tests.cs index 23c1795..3eecf10 100644 --- a/X10D.Tests/src/Numerics/Vector3Tests.cs +++ b/X10D.Tests/src/Numerics/Vector3Tests.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; using X10D.Numerics; diff --git a/X10D.Tests/src/Numerics/Vector4Tests.cs b/X10D.Tests/src/Numerics/Vector4Tests.cs index 108fb47..7dd3e8a 100644 --- a/X10D.Tests/src/Numerics/Vector4Tests.cs +++ b/X10D.Tests/src/Numerics/Vector4Tests.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; using X10D.Numerics; diff --git a/X10D.Tests/src/Reactive/ProgressTests.cs b/X10D.Tests/src/Reactive/ProgressTests.cs index e18ed39..5b8f180 100644 --- a/X10D.Tests/src/Reactive/ProgressTests.cs +++ b/X10D.Tests/src/Reactive/ProgressTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Reactive; namespace X10D.Tests.Reactive; diff --git a/X10D.Tests/src/Reflection/MemberInfoTests.cs b/X10D.Tests/src/Reflection/MemberInfoTests.cs index bbb0952..8ce5774 100644 --- a/X10D.Tests/src/Reflection/MemberInfoTests.cs +++ b/X10D.Tests/src/Reflection/MemberInfoTests.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using NUnit.Framework; using X10D.Reflection; diff --git a/X10D.Tests/src/Reflection/TypeTests.cs b/X10D.Tests/src/Reflection/TypeTests.cs index f474b97..a7f927d 100644 --- a/X10D.Tests/src/Reflection/TypeTests.cs +++ b/X10D.Tests/src/Reflection/TypeTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Reflection; namespace X10D.Tests.Reflection; diff --git a/X10D.Tests/src/Text/CharSpanTests.cs b/X10D.Tests/src/Text/CharSpanTests.cs index 683f7c0..fa02e2f 100644 --- a/X10D.Tests/src/Text/CharSpanTests.cs +++ b/X10D.Tests/src/Text/CharSpanTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Text; namespace X10D.Tests.Text; diff --git a/X10D.Tests/src/Text/CharTests.cs b/X10D.Tests/src/Text/CharTests.cs index cf17cdf..5ac8840 100644 --- a/X10D.Tests/src/Text/CharTests.cs +++ b/X10D.Tests/src/Text/CharTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Text; namespace X10D.Tests.Text; diff --git a/X10D.Tests/src/Text/CoreTests.cs b/X10D.Tests/src/Text/CoreTests.cs index bbd114c..ca2f1dd 100644 --- a/X10D.Tests/src/Text/CoreTests.cs +++ b/X10D.Tests/src/Text/CoreTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Text; namespace X10D.Tests.Text; diff --git a/X10D.Tests/src/Text/EnumerableTests.cs b/X10D.Tests/src/Text/EnumerableTests.cs index 8e6ecd1..ab6bfd0 100644 --- a/X10D.Tests/src/Text/EnumerableTests.cs +++ b/X10D.Tests/src/Text/EnumerableTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Text; namespace X10D.Tests.Text; diff --git a/X10D.Tests/src/Text/RuneTests.cs b/X10D.Tests/src/Text/RuneTests.cs index 49c13e4..fc196c9 100644 --- a/X10D.Tests/src/Text/RuneTests.cs +++ b/X10D.Tests/src/Text/RuneTests.cs @@ -1,4 +1,4 @@ -#if NET5_0_OR_GREATER +#if NET5_0_OR_GREATER using System.Text; using NUnit.Framework; using X10D.Text; diff --git a/X10D.Tests/src/Text/StringBuilderReaderTests.cs b/X10D.Tests/src/Text/StringBuilderReaderTests.cs index 07e8849..8575511 100644 --- a/X10D.Tests/src/Text/StringBuilderReaderTests.cs +++ b/X10D.Tests/src/Text/StringBuilderReaderTests.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; using NUnit.Framework; using X10D.Text; diff --git a/X10D.Tests/src/Text/StringTests.cs b/X10D.Tests/src/Text/StringTests.cs index 336cafb..44422d1 100644 --- a/X10D.Tests/src/Text/StringTests.cs +++ b/X10D.Tests/src/Text/StringTests.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; #if NET5_0_OR_GREATER using System.Text.Json.Serialization; #endif diff --git a/X10D.Tests/src/Time/ByteTests.cs b/X10D.Tests/src/Time/ByteTests.cs index 7c3a3ed..9d4b59a 100644 --- a/X10D.Tests/src/Time/ByteTests.cs +++ b/X10D.Tests/src/Time/ByteTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/CharSpanTests.cs b/X10D.Tests/src/Time/CharSpanTests.cs index f420cf0..f06ab6c 100644 --- a/X10D.Tests/src/Time/CharSpanTests.cs +++ b/X10D.Tests/src/Time/CharSpanTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/DecimalTests.cs b/X10D.Tests/src/Time/DecimalTests.cs index f1a2b02..cba4370 100644 --- a/X10D.Tests/src/Time/DecimalTests.cs +++ b/X10D.Tests/src/Time/DecimalTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/DoubleTests.cs b/X10D.Tests/src/Time/DoubleTests.cs index 093e466..5247837 100644 --- a/X10D.Tests/src/Time/DoubleTests.cs +++ b/X10D.Tests/src/Time/DoubleTests.cs @@ -1,4 +1,4 @@ -#if NET5_0_OR_GREATER +#if NET5_0_OR_GREATER using NUnit.Framework; using X10D.Time; diff --git a/X10D.Tests/src/Time/HalfTests.cs b/X10D.Tests/src/Time/HalfTests.cs index b2f7faf..7f6ceab 100644 --- a/X10D.Tests/src/Time/HalfTests.cs +++ b/X10D.Tests/src/Time/HalfTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/Int16Tests.cs b/X10D.Tests/src/Time/Int16Tests.cs index f6c40ed..325aa84 100644 --- a/X10D.Tests/src/Time/Int16Tests.cs +++ b/X10D.Tests/src/Time/Int16Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/Int32Tests.cs b/X10D.Tests/src/Time/Int32Tests.cs index f0c258b..72edd02 100644 --- a/X10D.Tests/src/Time/Int32Tests.cs +++ b/X10D.Tests/src/Time/Int32Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/Int64Tests.cs b/X10D.Tests/src/Time/Int64Tests.cs index bf317e8..1e7a381 100644 --- a/X10D.Tests/src/Time/Int64Tests.cs +++ b/X10D.Tests/src/Time/Int64Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/SByteTests.cs b/X10D.Tests/src/Time/SByteTests.cs index 7a7de18..7518559 100644 --- a/X10D.Tests/src/Time/SByteTests.cs +++ b/X10D.Tests/src/Time/SByteTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/SingleTests.cs b/X10D.Tests/src/Time/SingleTests.cs index 52fbe24..37b94b2 100644 --- a/X10D.Tests/src/Time/SingleTests.cs +++ b/X10D.Tests/src/Time/SingleTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/StringTests.cs b/X10D.Tests/src/Time/StringTests.cs index c74658e..b176b41 100644 --- a/X10D.Tests/src/Time/StringTests.cs +++ b/X10D.Tests/src/Time/StringTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/TimeSpanParserTests.cs b/X10D.Tests/src/Time/TimeSpanParserTests.cs index a5a3aef..8a0e1ca 100644 --- a/X10D.Tests/src/Time/TimeSpanParserTests.cs +++ b/X10D.Tests/src/Time/TimeSpanParserTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/TimeSpanTests.cs b/X10D.Tests/src/Time/TimeSpanTests.cs index ca68da3..eb7cad4 100644 --- a/X10D.Tests/src/Time/TimeSpanTests.cs +++ b/X10D.Tests/src/Time/TimeSpanTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/UInt16Tests.cs b/X10D.Tests/src/Time/UInt16Tests.cs index d93f58a..fe54926 100644 --- a/X10D.Tests/src/Time/UInt16Tests.cs +++ b/X10D.Tests/src/Time/UInt16Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/UInt32Tests.cs b/X10D.Tests/src/Time/UInt32Tests.cs index 605110f..f6bc0f7 100644 --- a/X10D.Tests/src/Time/UInt32Tests.cs +++ b/X10D.Tests/src/Time/UInt32Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D.Tests/src/Time/UInt64Tests.cs b/X10D.Tests/src/Time/UInt64Tests.cs index dcd08cd..78e8681 100644 --- a/X10D.Tests/src/Time/UInt64Tests.cs +++ b/X10D.Tests/src/Time/UInt64Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; diff --git a/X10D/src/Assembly.cs b/X10D/src/Assembly.cs index a2c26c1..524d513 100644 --- a/X10D/src/Assembly.cs +++ b/X10D/src/Assembly.cs @@ -1,4 +1,4 @@ -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; [assembly: CLSCompliant(true)] [assembly: InternalsVisibleTo("X10D.Tests")] diff --git a/X10D/src/Collections/ArrayExtensions.cs b/X10D/src/Collections/ArrayExtensions.cs index 7dd5863..5c76705 100644 --- a/X10D/src/Collections/ArrayExtensions.cs +++ b/X10D/src/Collections/ArrayExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; namespace X10D.Collections; diff --git a/X10D/src/Collections/ByteExtensions.cs b/X10D/src/Collections/ByteExtensions.cs index 427afed..8563ae2 100644 --- a/X10D/src/Collections/ByteExtensions.cs +++ b/X10D/src/Collections/ByteExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; using X10D.CompilerServices; diff --git a/X10D/src/Collections/CollectionExtensions.cs b/X10D/src/Collections/CollectionExtensions.cs index e9b2c6e..f1f9486 100644 --- a/X10D/src/Collections/CollectionExtensions.cs +++ b/X10D/src/Collections/CollectionExtensions.cs @@ -1,4 +1,4 @@ -namespace X10D.Collections; +namespace X10D.Collections; /// /// Collection-related extension methods for . diff --git a/X10D/src/Collections/DictionaryExtensions.cs b/X10D/src/Collections/DictionaryExtensions.cs index 241efe9..387016e 100644 --- a/X10D/src/Collections/DictionaryExtensions.cs +++ b/X10D/src/Collections/DictionaryExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; #if NET6_0_OR_GREATER using System.Runtime.InteropServices; #endif diff --git a/X10D/src/Collections/EnumerableExtensions.cs b/X10D/src/Collections/EnumerableExtensions.cs index a183c2b..d6e1fcc 100644 --- a/X10D/src/Collections/EnumerableExtensions.cs +++ b/X10D/src/Collections/EnumerableExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; namespace X10D.Collections; diff --git a/X10D/src/Collections/Int16Extensions.cs b/X10D/src/Collections/Int16Extensions.cs index c53c0fb..9e6e16b 100644 --- a/X10D/src/Collections/Int16Extensions.cs +++ b/X10D/src/Collections/Int16Extensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; using X10D.CompilerServices; diff --git a/X10D/src/Collections/Int32Extensions.cs b/X10D/src/Collections/Int32Extensions.cs index 7e2ebaf..e5bdd7c 100644 --- a/X10D/src/Collections/Int32Extensions.cs +++ b/X10D/src/Collections/Int32Extensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; using X10D.CompilerServices; diff --git a/X10D/src/Collections/Int64Extensions.cs b/X10D/src/Collections/Int64Extensions.cs index 5b31a1d..505f3da 100644 --- a/X10D/src/Collections/Int64Extensions.cs +++ b/X10D/src/Collections/Int64Extensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; namespace X10D.Collections; diff --git a/X10D/src/Collections/SpanExtensions.cs b/X10D/src/Collections/SpanExtensions.cs index ac2fd2b..da54843 100644 --- a/X10D/src/Collections/SpanExtensions.cs +++ b/X10D/src/Collections/SpanExtensions.cs @@ -1,4 +1,4 @@ -namespace X10D.Collections; +namespace X10D.Collections; /// /// Extension methods for and diff --git a/X10D/src/Collections/SpanSplitEnumerator.cs b/X10D/src/Collections/SpanSplitEnumerator.cs index c99d9e7..1bd1c95 100644 --- a/X10D/src/Collections/SpanSplitEnumerator.cs +++ b/X10D/src/Collections/SpanSplitEnumerator.cs @@ -1,4 +1,4 @@ -namespace X10D.Collections; +namespace X10D.Collections; /// /// Enumerates the elements of a . diff --git a/X10D/src/CompilerServices/CompilerResources.cs b/X10D/src/CompilerServices/CompilerResources.cs index c06c585..a02ca99 100644 --- a/X10D/src/CompilerServices/CompilerResources.cs +++ b/X10D/src/CompilerServices/CompilerResources.cs @@ -1,4 +1,4 @@ -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; namespace X10D.CompilerServices; diff --git a/X10D/src/Core/EnumExtensions.cs b/X10D/src/Core/EnumExtensions.cs index 29b7649..2545f1e 100644 --- a/X10D/src/Core/EnumExtensions.cs +++ b/X10D/src/Core/EnumExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; namespace X10D.Core; diff --git a/X10D/src/Core/Extensions.cs b/X10D/src/Core/Extensions.cs index 8817ca0..df3969f 100644 --- a/X10D/src/Core/Extensions.cs +++ b/X10D/src/Core/Extensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; namespace X10D.Core; diff --git a/X10D/src/Core/IntrinsicExtensions.cs b/X10D/src/Core/IntrinsicExtensions.cs index c9f5380..7085c63 100644 --- a/X10D/src/Core/IntrinsicExtensions.cs +++ b/X10D/src/Core/IntrinsicExtensions.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_0_OR_GREATER +#if NETCOREAPP3_0_OR_GREATER using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; diff --git a/X10D/src/Core/IntrinsicUtility.cs b/X10D/src/Core/IntrinsicUtility.cs index ff573b8..44997cc 100644 --- a/X10D/src/Core/IntrinsicUtility.cs +++ b/X10D/src/Core/IntrinsicUtility.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_0_OR_GREATER +#if NETCOREAPP3_0_OR_GREATER using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; diff --git a/X10D/src/Core/NullableExtensions.cs b/X10D/src/Core/NullableExtensions.cs index 541fbd2..b90b4c5 100644 --- a/X10D/src/Core/NullableExtensions.cs +++ b/X10D/src/Core/NullableExtensions.cs @@ -1,4 +1,4 @@ -namespace X10D.Core; +namespace X10D.Core; /// /// Extension methods for diff --git a/X10D/src/Core/RandomExtensions.cs b/X10D/src/Core/RandomExtensions.cs index 49e8634..fa8d412 100644 --- a/X10D/src/Core/RandomExtensions.cs +++ b/X10D/src/Core/RandomExtensions.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; using System.Text; using X10D.Math; diff --git a/X10D/src/Core/SpanExtensions.cs b/X10D/src/Core/SpanExtensions.cs index 6c0b6c0..c75880c 100644 --- a/X10D/src/Core/SpanExtensions.cs +++ b/X10D/src/Core/SpanExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/X10D/src/Drawing/Circle.cs b/X10D/src/Drawing/Circle.cs index 75e3f23..5a64d7d 100644 --- a/X10D/src/Drawing/Circle.cs +++ b/X10D/src/Drawing/Circle.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; namespace X10D.Drawing; diff --git a/X10D/src/Drawing/CircleF.cs b/X10D/src/Drawing/CircleF.cs index 7832eb3..309fc50 100644 --- a/X10D/src/Drawing/CircleF.cs +++ b/X10D/src/Drawing/CircleF.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using System.Numerics; using X10D.Numerics; diff --git a/X10D/src/Drawing/ColorExtensions.cs b/X10D/src/Drawing/ColorExtensions.cs index 47ee9df..86f7615 100644 --- a/X10D/src/Drawing/ColorExtensions.cs +++ b/X10D/src/Drawing/ColorExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; using System.Drawing; using System.Runtime.CompilerServices; using X10D.CompilerServices; diff --git a/X10D/src/Drawing/Cuboid.cs b/X10D/src/Drawing/Cuboid.cs index cc2ebae..1e64a74 100644 --- a/X10D/src/Drawing/Cuboid.cs +++ b/X10D/src/Drawing/Cuboid.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using X10D.Numerics; namespace X10D.Drawing; diff --git a/X10D/src/Drawing/Ellipse.cs b/X10D/src/Drawing/Ellipse.cs index 736b3aa..ba8646a 100644 --- a/X10D/src/Drawing/Ellipse.cs +++ b/X10D/src/Drawing/Ellipse.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; namespace X10D.Drawing; diff --git a/X10D/src/Drawing/EllipseF.cs b/X10D/src/Drawing/EllipseF.cs index 310f17f..f4365fd 100644 --- a/X10D/src/Drawing/EllipseF.cs +++ b/X10D/src/Drawing/EllipseF.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using System.Numerics; using X10D.Numerics; diff --git a/X10D/src/Drawing/Line.cs b/X10D/src/Drawing/Line.cs index 4c24060..b6c7001 100644 --- a/X10D/src/Drawing/Line.cs +++ b/X10D/src/Drawing/Line.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using System.Numerics; namespace X10D.Drawing; diff --git a/X10D/src/Drawing/Line3D.cs b/X10D/src/Drawing/Line3D.cs index 9775c72..34d8bab 100644 --- a/X10D/src/Drawing/Line3D.cs +++ b/X10D/src/Drawing/Line3D.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using System.Numerics; namespace X10D.Drawing; diff --git a/X10D/src/Drawing/LineF.cs b/X10D/src/Drawing/LineF.cs index c4b31b2..1382b41 100644 --- a/X10D/src/Drawing/LineF.cs +++ b/X10D/src/Drawing/LineF.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using System.Numerics; using X10D.Numerics; diff --git a/X10D/src/Drawing/PointExtensions.cs b/X10D/src/Drawing/PointExtensions.cs index 4b36c64..6d0b7b7 100644 --- a/X10D/src/Drawing/PointExtensions.cs +++ b/X10D/src/Drawing/PointExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; using System.Drawing; using System.Numerics; using System.Runtime.CompilerServices; diff --git a/X10D/src/Drawing/PointFExtensions.cs b/X10D/src/Drawing/PointFExtensions.cs index 0b82643..4207440 100644 --- a/X10D/src/Drawing/PointFExtensions.cs +++ b/X10D/src/Drawing/PointFExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; using System.Drawing; using System.Numerics; using System.Runtime.CompilerServices; diff --git a/X10D/src/Drawing/Polygon.cs b/X10D/src/Drawing/Polygon.cs index 9f03b58..e3b6519 100644 --- a/X10D/src/Drawing/Polygon.cs +++ b/X10D/src/Drawing/Polygon.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Drawing; namespace X10D.Drawing; diff --git a/X10D/src/Drawing/PolygonF.cs b/X10D/src/Drawing/PolygonF.cs index 074edc3..7499db9 100644 --- a/X10D/src/Drawing/PolygonF.cs +++ b/X10D/src/Drawing/PolygonF.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Numerics; using X10D.Numerics; diff --git a/X10D/src/Drawing/Polyhedron.cs b/X10D/src/Drawing/Polyhedron.cs index 6be327e..f968cd9 100644 --- a/X10D/src/Drawing/Polyhedron.cs +++ b/X10D/src/Drawing/Polyhedron.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Numerics; diff --git a/X10D/src/Drawing/RandomExtensions.cs b/X10D/src/Drawing/RandomExtensions.cs index 880cd84..1836e52 100644 --- a/X10D/src/Drawing/RandomExtensions.cs +++ b/X10D/src/Drawing/RandomExtensions.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; #pragma warning disable CA5394 diff --git a/X10D/src/Drawing/SizeExtensions.cs b/X10D/src/Drawing/SizeExtensions.cs index d44fcce..5276c4b 100644 --- a/X10D/src/Drawing/SizeExtensions.cs +++ b/X10D/src/Drawing/SizeExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; using System.Drawing; using System.Numerics; using System.Runtime.CompilerServices; diff --git a/X10D/src/Drawing/Sphere.cs b/X10D/src/Drawing/Sphere.cs index 26d91d6..0d5a693 100644 --- a/X10D/src/Drawing/Sphere.cs +++ b/X10D/src/Drawing/Sphere.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; namespace X10D.Drawing; diff --git a/X10D/src/ExceptionMessages.Designer.cs b/X10D/src/ExceptionMessages.Designer.cs index ebabf39..8d6c6b6 100644 --- a/X10D/src/ExceptionMessages.Designer.cs +++ b/X10D/src/ExceptionMessages.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // diff --git a/X10D/src/ExceptionMessages.resx b/X10D/src/ExceptionMessages.resx index 9bc8b28..f9dcc1e 100644 --- a/X10D/src/ExceptionMessages.resx +++ b/X10D/src/ExceptionMessages.resx @@ -1,4 +1,4 @@ - +