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/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 7ee1360..356e513 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -1,50 +1,61 @@ -name: Build +name: SonarCloud on: push: branches: - main workflow_dispatch: pull_request: - types: [opened, synchronize, reopened] + types: [ opened, synchronize, reopened ] + jobs: - build: - name: Build + sonarcloud: + name: SonarCloud Analysis runs-on: windows-latest steps: - - name: Set up JDK 11 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: - java-version: 1.11 + java-version: 17 + distribution: 'zulu' + - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Cache SonarCloud packages - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~\sonar\cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar + - name: Cache SonarCloud scanner id: cache-sonar-scanner - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: .\.sonar\scanner key: ${{ runner.os }}-sonar-scanner restore-keys: ${{ runner.os }}-sonar-scanner + - name: Install SonarCloud scanner if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' shell: powershell run: | New-Item -Path .\.sonar\scanner -ItemType Directory dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner + + - name: Install dotCover + shell: powershell + run: | + dotnet tool install --global JetBrains.dotCover.GlobalTool + - name: Build and analyze env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} shell: powershell run: | - dotnet tool install JetBrains.dotCover.GlobalTool -g - .\.sonar\scanner\dotnet-sonarscanner begin /k:"oliverbooth_X10D" /o:"oliverbooth" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html + .\.sonar\scanner\dotnet-sonarscanner begin /k:"oliverbooth_X10D" /o:"oliverbooth" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" dotnet build --no-incremental dotnet dotcover test --dcReportType=HTML - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 034117e..b1b6ae2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,51 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 4.0.0 - [Unreleased] + +### Added + +- X10D: Added extension methods for `DateOnly`, for parity with `DateTime` and `DateTimeOffset`. +- X10D: Added math-related extension methods for `BigInteger`. +- X10D: Added `Span.Replace(T, T)`. +- X10D: Added `CountDigits` for integer types. +- X10D: Added `IEnumerable.Except(T)`. +- X10D: Added `Progress.OnProgressChanged([T])`. +- X10D: Added `TextWriter.WriteNoAlloc(int[, ReadOnlySpan[, IFormatProvider]])`. +- X10D: Added `TextWriter.WriteNoAlloc(uint[, ReadOnlySpan[, IFormatProvider]])`. +- X10D: Added `TextWriter.WriteNoAlloc(long[, ReadOnlySpan[, IFormatProvider]])`. +- X10D: Added `TextWriter.WriteNoAlloc(ulong[, ReadOnlySpan[, IFormatProvider]])`. +- X10D: Added `TextWriter.WriteLineNoAlloc(int[, ReadOnlySpan[, IFormatProvider]])`. +- 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: Added `string.MDBold`, `string.MDCode`, `string.MDCodeBlock([string])`, `string.MDHeading(int)`, +`string.MDItalic`, `string.MDLink`, `string.MDStrikeOut`, and `string.MDUnderline` for Markdown formatting. +- X10D: Added Span overloads which complement `char.Repeat` and `string.Repeat`. +- 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. +- 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. +- X10D: `char.IsEmoji` no longer allocates for .NET 7. +- X10D: `string.Repeat` is now more efficient. + +### 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 ### Fixed diff --git a/X10D.DSharpPlus/X10D.DSharpPlus.csproj b/Directory.Build.props similarity index 83% rename from X10D.DSharpPlus/X10D.DSharpPlus.csproj rename to Directory.Build.props index dfcf6f0..9f2994d 100644 --- a/X10D.DSharpPlus/X10D.DSharpPlus.csproj +++ b/Directory.Build.props @@ -1,11 +1,16 @@ - - + - net7.0;net6.0;netstandard2.1 11.0 true true + true + true + true + pdbonly + true + 4.0.0 Oliver Booth + enable en https://github.com/oliverbooth/X10D git @@ -14,16 +19,9 @@ branding_Icon.png dotnet extension-methods - $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) + README.md + See CHANGELOG.md for a full list of changes. true - 3.3.1 - enable - true - true - true - true - pdbonly - true @@ -48,10 +46,6 @@ $(VersionPrefix).0 - - - - True @@ -61,10 +55,13 @@ True + + True + + True - - + \ No newline at end of file diff --git a/README.md b/README.md index 183602b..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.3.1 +Install-Package X10D -Version 4.0.0 ``` ### Manual installation 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 2734af9..0000000 --- a/X10D.DSharpPlus/src/DiscordChannelExtensions.cs +++ /dev/null @@ -1,80 +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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(channel); -#else - if (channel is null) - { - throw new ArgumentNullException(nameof(channel)); - } -#endif - - 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(channel); - ArgumentNullException.ThrowIfNull(client); -#else - if (channel is null) - { - throw new ArgumentNullException(nameof(channel)); - } - - if (client is null) - { - 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 deleted file mode 100644 index f3d8964..0000000 --- a/X10D.DSharpPlus/src/DiscordClientExtensions.cs +++ /dev/null @@ -1,79 +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 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(); - - 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(client); -#else - if (client is null) - { - throw new ArgumentNullException(nameof(client)); - } -#endif - - 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 4a23a34..0000000 --- a/X10D.DSharpPlus/src/DiscordEmbedBuilderExtensions.cs +++ /dev/null @@ -1,239 +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 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); - } - - /// - /// 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(builder); -#else - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } -#endif - - 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(builder); - ArgumentNullException.ThrowIfNull(predicate); -#else - if (builder is null) - { - throw new ArgumentNullException(nameof(builder)); - } - - if (predicate is null) - { - throw new ArgumentNullException(nameof(predicate)); - } -#endif - - 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(builder); - ArgumentNullException.ThrowIfNull(predicate); - ArgumentNullException.ThrowIfNull(valueFactory); -#else - 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)); - } -#endif - - 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 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) - { - 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 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 deleted file mode 100644 index c03016b..0000000 --- a/X10D.DSharpPlus/src/DiscordGuildExtensions.cs +++ /dev/null @@ -1,97 +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 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); - } - - /// - /// 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(guild); -#else - if (guild is null) - { - throw new ArgumentNullException(nameof(guild)); - } -#endif - - 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(guild); - ArgumentNullException.ThrowIfNull(client); -#else - if (guild is null) - { - throw new ArgumentNullException(nameof(guild)); - } - - if (client is null) - { - 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 deleted file mode 100644 index 3fd2020..0000000 --- a/X10D.DSharpPlus/src/DiscordMemberExtensions.cs +++ /dev/null @@ -1,73 +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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(member); - ArgumentNullException.ThrowIfNull(role); -#else - if (member is null) - { - throw new ArgumentNullException(nameof(member)); - } - - if (role is null) - { - throw new ArgumentNullException(nameof(role)); - } -#endif - - 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(member); - ArgumentNullException.ThrowIfNull(client); -#else - if (member is null) - { - throw new ArgumentNullException(nameof(member)); - } - - if (client is null) - { - 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 deleted file mode 100644 index f8317c7..0000000 --- a/X10D.DSharpPlus/src/DiscordMessageExtensions.cs +++ /dev/null @@ -1,89 +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 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); - } - - /// - /// 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 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); - } - - /// - /// 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(message); - ArgumentNullException.ThrowIfNull(client); -#else - if (message is null) - { - throw new ArgumentNullException(nameof(message)); - } - - if (client is null) - { - 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 deleted file mode 100644 index 0cc9483..0000000 --- a/X10D.DSharpPlus/src/DiscordUserExtensions.cs +++ /dev/null @@ -1,164 +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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(user); - ArgumentNullException.ThrowIfNull(guild); -#else - if (user is null) - { - throw new ArgumentNullException(nameof(user)); - } - - if (guild is null) - { - throw new ArgumentNullException(nameof(guild)); - } -#endif - - 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(user); -#else - if (user is null) - { - throw new ArgumentNullException(nameof(user)); - } -#endif - - 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(user); - ArgumentNullException.ThrowIfNull(guild); -#else - if (user is null) - { - throw new ArgumentNullException(nameof(user)); - } - - if (guild is null) - { - throw new ArgumentNullException(nameof(guild)); - } -#endif - - 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 NET6_0_OR_GREATER - ArgumentNullException.ThrowIfNull(user); - ArgumentNullException.ThrowIfNull(client); -#else - if (user is null) - { - throw new ArgumentNullException(nameof(user)); - } - - if (client is null) - { - throw new ArgumentNullException(nameof(client)); - } -#endif - - 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.Hosting/X10D.Hosting.csproj b/X10D.Hosting/X10D.Hosting.csproj index 13a36d9..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 - 3.3.1 - 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.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/X10D.Tests.csproj b/X10D.Tests/X10D.Tests.csproj index aa5bbd2..39ddbe7 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 + true json,cobertura true + false 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..f7339d0 100644 --- a/X10D.Tests/src/Collections/ArrayTests.AsReadOnly.cs +++ b/X10D.Tests/src/Collections/ArrayTests.AsReadOnly.cs @@ -1,12 +1,12 @@ -using NUnit.Framework; +using NUnit.Framework; 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..509785e 100644 --- a/X10D.Tests/src/Collections/ArrayTests.Clear.cs +++ b/X10D.Tests/src/Collections/ArrayTests.Clear.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..5469f75 100644 --- a/X10D.Tests/src/Collections/ArrayTests.cs +++ b/X10D.Tests/src/Collections/ArrayTests.cs @@ -1,8 +1,8 @@ -using NUnit.Framework; +using NUnit.Framework; 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..de3a428 100644 --- a/X10D.Tests/src/Collections/BoolListTests.cs +++ b/X10D.Tests/src/Collections/BoolListTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..4891123 100644 --- a/X10D.Tests/src/Collections/ByteTests.cs +++ b/X10D.Tests/src/Collections/ByteTests.cs @@ -1,11 +1,11 @@ -using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics.X86; using NUnit.Framework; 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..226439f 100644 --- a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs +++ b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAll.cs @@ -1,11 +1,11 @@ -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using NSubstitute; using NUnit.Framework; 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..f08d639 100644 --- a/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs +++ b/X10D.Tests/src/Collections/CollectionTests.ClearAndDisposeAllAsync.cs @@ -1,11 +1,11 @@ -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using NSubstitute; using NUnit.Framework; 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..9a7b040 100644 --- a/X10D.Tests/src/Collections/CollectionTests.cs +++ b/X10D.Tests/src/Collections/CollectionTests.cs @@ -1,8 +1,8 @@ -using NUnit.Framework; +using NUnit.Framework; 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..d21e826 100644 --- a/X10D.Tests/src/Collections/DictionaryTests.cs +++ b/X10D.Tests/src/Collections/DictionaryTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..fc5a4fb 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.DisposeAll.cs @@ -1,10 +1,10 @@ -using NSubstitute; +using NSubstitute; using NUnit.Framework; 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..b785115 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.DisposeAllAsync.cs @@ -1,10 +1,10 @@ -using NSubstitute; +using NSubstitute; using NUnit.Framework; 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..a08c05f 100644 --- a/X10D.Tests/src/Collections/EnumerableTests.cs +++ b/X10D.Tests/src/Collections/EnumerableTests.cs @@ -1,11 +1,11 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Collections; 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..f7bfab3 100644 --- a/X10D.Tests/src/Collections/Int16Tests.cs +++ b/X10D.Tests/src/Collections/Int16Tests.cs @@ -1,11 +1,13 @@ -using System.Runtime.Intrinsics.X86; +#if NET5_0_OR_GREATER +using System.Runtime.Intrinsics.X86; +#endif using NUnit.Framework; 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..39b1036 100644 --- a/X10D.Tests/src/Collections/Int32Tests.cs +++ b/X10D.Tests/src/Collections/Int32Tests.cs @@ -1,11 +1,13 @@ -using System.Runtime.Intrinsics.X86; +#if NET5_0_OR_GREATER +using System.Runtime.Intrinsics.X86; +#endif using NUnit.Framework; 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..9862ec8 100644 --- a/X10D.Tests/src/Collections/Int64Tests.cs +++ b/X10D.Tests/src/Collections/Int64Tests.cs @@ -1,11 +1,12 @@ -using System.Diagnostics; +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..599a58f 100644 --- a/X10D.Tests/src/Collections/ListTests.cs +++ b/X10D.Tests/src/Collections/ListTests.cs @@ -1,13 +1,12 @@ -using NUnit.Framework; +using NUnit.Framework; 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..fa7ac45 100644 --- a/X10D.Tests/src/Collections/SpanTest.cs +++ b/X10D.Tests/src/Collections/SpanTest.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..a5df6ac 100644 --- a/X10D.Tests/src/Core/CoreTests.cs +++ b/X10D.Tests/src/Core/CoreTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..d4e9912 100644 --- a/X10D.Tests/src/Core/EnumTests.cs +++ b/X10D.Tests/src/Core/EnumTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..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; @@ -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..1dd08c1 100644 --- a/X10D.Tests/src/Core/NullableTests.cs +++ b/X10D.Tests/src/Core/NullableTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..72fe1e7 100644 --- a/X10D.Tests/src/Core/RandomTests.cs +++ b/X10D.Tests/src/Core/RandomTests.cs @@ -1,11 +1,11 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Collections; 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..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 @@ -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..9b05dec 100644 --- a/X10D.Tests/src/Drawing/CircleFTests.cs +++ b/X10D.Tests/src/Drawing/CircleFTests.cs @@ -1,11 +1,11 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; 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..c98d367 100644 --- a/X10D.Tests/src/Drawing/CircleTests.cs +++ b/X10D.Tests/src/Drawing/CircleTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..cb5cc97 100644 --- a/X10D.Tests/src/Drawing/ColorTests.cs +++ b/X10D.Tests/src/Drawing/ColorTests.cs @@ -1,11 +1,11 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; 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..08203ea 100644 --- a/X10D.Tests/src/Drawing/CuboidTests.cs +++ b/X10D.Tests/src/Drawing/CuboidTests.cs @@ -1,11 +1,11 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; 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..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; @@ -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..0ddf5b1 100644 --- a/X10D.Tests/src/Drawing/EllipseTests.cs +++ b/X10D.Tests/src/Drawing/EllipseTests.cs @@ -1,11 +1,11 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; 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..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; @@ -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..fa11b71 100644 --- a/X10D.Tests/src/Drawing/LineFTests.cs +++ b/X10D.Tests/src/Drawing/LineFTests.cs @@ -1,11 +1,11 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; 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..5ae1c30 100644 --- a/X10D.Tests/src/Drawing/LineTests.cs +++ b/X10D.Tests/src/Drawing/LineTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..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; @@ -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..347d7a2 100644 --- a/X10D.Tests/src/Drawing/PointTests.cs +++ b/X10D.Tests/src/Drawing/PointTests.cs @@ -1,11 +1,11 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; 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..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; @@ -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..50fe6d8 100644 --- a/X10D.Tests/src/Drawing/PolygonTests.cs +++ b/X10D.Tests/src/Drawing/PolygonTests.cs @@ -1,11 +1,11 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; 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..30545e7 100644 --- a/X10D.Tests/src/Drawing/PolyhedronTests.cs +++ b/X10D.Tests/src/Drawing/PolyhedronTests.cs @@ -1,11 +1,11 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; 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..7559aca 100644 --- a/X10D.Tests/src/Drawing/RandomTests.cs +++ b/X10D.Tests/src/Drawing/RandomTests.cs @@ -1,11 +1,11 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; 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..d89fa89 100644 --- a/X10D.Tests/src/Drawing/SizeTests.cs +++ b/X10D.Tests/src/Drawing/SizeTests.cs @@ -1,11 +1,11 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; 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..75c29b4 100644 --- a/X10D.Tests/src/Drawing/SphereTests.cs +++ b/X10D.Tests/src/Drawing/SphereTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..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; @@ -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..87e2075 100644 --- a/X10D.Tests/src/IO/BooleanTests.cs +++ b/X10D.Tests/src/IO/BooleanTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..9b8a43a 100644 --- a/X10D.Tests/src/IO/DoubleTests.cs +++ b/X10D.Tests/src/IO/DoubleTests.cs @@ -4,63 +4,63 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class DoubleTests +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/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..8d64f97 100644 --- a/X10D.Tests/src/IO/Int16Tests.cs +++ b/X10D.Tests/src/IO/Int16Tests.cs @@ -4,59 +4,63 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class Int16Tests +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 d69b2be..31898a0 100644 --- a/X10D.Tests/src/IO/Int32Tests.cs +++ b/X10D.Tests/src/IO/Int32Tests.cs @@ -4,59 +4,63 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class Int32Tests +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 ccd3673..393b9e0 100644 --- a/X10D.Tests/src/IO/Int64Tests.cs +++ b/X10D.Tests/src/IO/Int64Tests.cs @@ -4,63 +4,63 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class Int64Tests +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/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..e7de74d 100644 --- a/X10D.Tests/src/IO/SingleTests.cs +++ b/X10D.Tests/src/IO/SingleTests.cs @@ -4,63 +4,63 @@ using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -public class SingleTests +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 3209443..c7fcdb5 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadDecimal.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadDecimal.cs @@ -1,42 +1,43 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 @@ public 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 @@ public 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 @@ public 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 6084984..02f7991 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadDouble.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadDouble.cs @@ -1,65 +1,66 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 bdb045c..a71d4bd 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadInt16.cs @@ -1,65 +1,66 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 64f4c75..e51ef95 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadInt32.cs @@ -1,65 +1,66 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 d9f938e..faebfda 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadInt64.cs @@ -3,63 +3,61 @@ using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 2dc2292..ff2336b 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadSingle.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadSingle.cs @@ -1,65 +1,66 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 23508dc..0cd249d 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadUInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadUInt16.cs @@ -1,70 +1,66 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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 8bd57a3..3164afe 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadUInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadUInt32.cs @@ -1,70 +1,66 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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 f315b47..ca33b01 100644 --- a/X10D.Tests/src/IO/StreamTests.ReadUInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.ReadUInt64.cs @@ -1,70 +1,66 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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 e34a816..911dd5d 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteDecimal.cs @@ -1,52 +1,54 @@ using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 @@ public 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 b1b43e1..8828325 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteDouble.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteDouble.cs @@ -1,49 +1,51 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 @@ public 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 ce0bc8d..bc38dd8 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt16.cs @@ -1,49 +1,51 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 @@ public 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 bb8c982..75688f9 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt32.cs @@ -1,49 +1,51 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 @@ public 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 e0fda01..feeb677 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteInt64.cs @@ -1,49 +1,51 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 @@ public 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 69d491b..7df8eb8 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteSingle.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteSingle.cs @@ -1,49 +1,51 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +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 @@ public 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 9747ca8..7fde9f2 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt16.cs @@ -1,53 +1,51 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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)); @@ -55,16 +53,15 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - 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 41d77a9..e5eafb7 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt32.cs @@ -1,53 +1,51 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - public void WriteUInt32_ShouldThrowArgumentException_GivenNonWriteableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.Write(420U, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420U, Endianness.BigEndian)); - } - - [Test] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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)); @@ -55,16 +53,15 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - 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 51a44f5..5d8edcf 100644 --- a/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs +++ b/X10D.Tests/src/IO/StreamTests.WriteUInt64.cs @@ -1,53 +1,51 @@ -using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; -public partial class StreamTests +internal partial class StreamTests { [Test] - [CLSCompliant(false)] - public void WriteUInt64_ShouldThrowArgumentException_GivenNonWriteableStream() - { - Stream stream = new DummyStream(); - Assert.Throws(() => stream.Write(420UL, Endianness.LittleEndian)); - Assert.Throws(() => stream.Write(420UL, Endianness.BigEndian)); - } - - [Test] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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] - [CLSCompliant(false)] - 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)); @@ -55,16 +53,15 @@ public partial class StreamTests } [Test] - [CLSCompliant(false)] - 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/StreamTests.cs b/X10D.Tests/src/IO/StreamTests.cs index 01e4684..b522265 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() @@ -86,16 +86,15 @@ public 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.Tests/src/IO/TextReaderTests.cs b/X10D.Tests/src/IO/TextReaderTests.cs index a2bafbc..d6e7491 100644 --- a/X10D.Tests/src/IO/TextReaderTests.cs +++ b/X10D.Tests/src/IO/TextReaderTests.cs @@ -1,11 +1,11 @@ -using System.Text; +using System.Text; using NUnit.Framework; 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..be9fa28 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Double.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Double.cs @@ -1,11 +1,11 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; 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..9d5b7a0 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Int32.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Int32.cs @@ -1,11 +1,11 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; 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..662e54a 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Int64.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Int64.cs @@ -1,11 +1,11 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; 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..4ad055c 100644 --- a/X10D.Tests/src/IO/TextWriterTests.Single.cs +++ b/X10D.Tests/src/IO/TextWriterTests.Single.cs @@ -1,11 +1,11 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; 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..3ba143b 100644 --- a/X10D.Tests/src/IO/TextWriterTests.UInt32.cs +++ b/X10D.Tests/src/IO/TextWriterTests.UInt32.cs @@ -1,11 +1,11 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; 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..5b41d38 100644 --- a/X10D.Tests/src/IO/TextWriterTests.UInt64.cs +++ b/X10D.Tests/src/IO/TextWriterTests.UInt64.cs @@ -1,11 +1,11 @@ -using System.Globalization; +using System.Globalization; using System.Text; using NUnit.Framework; 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..0ae62b1 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; +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..58307e4 100644 --- a/X10D.Tests/src/IO/UInt16Tests.cs +++ b/X10D.Tests/src/IO/UInt16Tests.cs @@ -1,63 +1,68 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -[CLSCompliant(false)] -public class UInt16Tests +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 910aa50..cce312a 100644 --- a/X10D.Tests/src/IO/UInt32Tests.cs +++ b/X10D.Tests/src/IO/UInt32Tests.cs @@ -1,63 +1,68 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -[CLSCompliant(false)] -public class UInt32Tests +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 374444f..aeb589b 100644 --- a/X10D.Tests/src/IO/UInt64Tests.cs +++ b/X10D.Tests/src/IO/UInt64Tests.cs @@ -1,67 +1,68 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.IO; namespace X10D.Tests.IO; [TestFixture] -[CLSCompliant(false)] -public class UInt64Tests +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.Tests/src/Linq/ByteTests.cs b/X10D.Tests/src/Linq/ByteTests.cs index ccaf696..a3b79e2 100644 --- a/X10D.Tests/src/Linq/ByteTests.cs +++ b/X10D.Tests/src/Linq/ByteTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..909c478 100644 --- a/X10D.Tests/src/Linq/DecimalTests.cs +++ b/X10D.Tests/src/Linq/DecimalTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..3975e46 100644 --- a/X10D.Tests/src/Linq/DoubleTests.cs +++ b/X10D.Tests/src/Linq/DoubleTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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 c478578..84e0378 100644 --- a/X10D.Tests/src/Linq/EnumerableTests.cs +++ b/X10D.Tests/src/Linq/EnumerableTests.cs @@ -1,42 +1,11 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class EnumerableTests +internal 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() { diff --git a/X10D.Tests/src/Linq/Int16Tests.cs b/X10D.Tests/src/Linq/Int16Tests.cs index 2a8459d..1401d9e 100644 --- a/X10D.Tests/src/Linq/Int16Tests.cs +++ b/X10D.Tests/src/Linq/Int16Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..783cbba 100644 --- a/X10D.Tests/src/Linq/Int32Tests.cs +++ b/X10D.Tests/src/Linq/Int32Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..c55f74d 100644 --- a/X10D.Tests/src/Linq/Int64Tests.cs +++ b/X10D.Tests/src/Linq/Int64Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..942e646 100644 --- a/X10D.Tests/src/Linq/ReadOnlySpanTests.cs +++ b/X10D.Tests/src/Linq/ReadOnlySpanTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class ReadOnlySpanTests +internal class ReadOnlySpanTests { [Test] public void AllShouldReturnTrueForEmptySpan() @@ -16,7 +16,7 @@ public 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 @@ public 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 @@ public 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/SByteTests.cs b/X10D.Tests/src/Linq/SByteTests.cs index 5d5e0b8..9eaeb83 100644 --- a/X10D.Tests/src/Linq/SByteTests.cs +++ b/X10D.Tests/src/Linq/SByteTests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..8486b8b 100644 --- a/X10D.Tests/src/Linq/SingleTests.cs +++ b/X10D.Tests/src/Linq/SingleTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..313dea1 100644 --- a/X10D.Tests/src/Linq/SpanTests.cs +++ b/X10D.Tests/src/Linq/SpanTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Linq; namespace X10D.Tests.Linq; [TestFixture] -public class SpanTests +internal class SpanTests { [Test] public void AllShouldReturnTrueForEmptySpan() @@ -16,7 +16,7 @@ public 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 @@ public 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 @@ public 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)); } diff --git a/X10D.Tests/src/Linq/UInt16Tests.cs b/X10D.Tests/src/Linq/UInt16Tests.cs index 2742fc0..60be62e 100644 --- a/X10D.Tests/src/Linq/UInt16Tests.cs +++ b/X10D.Tests/src/Linq/UInt16Tests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..8fde601 100644 --- a/X10D.Tests/src/Linq/UInt32Tests.cs +++ b/X10D.Tests/src/Linq/UInt32Tests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..1c8c889 100644 --- a/X10D.Tests/src/Linq/UInt64Tests.cs +++ b/X10D.Tests/src/Linq/UInt64Tests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..601a6e2 100644 --- a/X10D.Tests/src/Math/BigIntegerTests.Wrap.cs +++ b/X10D.Tests/src/Math/BigIntegerTests.Wrap.cs @@ -1,10 +1,10 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; 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..2812a2b 100644 --- a/X10D.Tests/src/Math/BigIntegerTests.cs +++ b/X10D.Tests/src/Math/BigIntegerTests.cs @@ -1,11 +1,11 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; 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..9785f58 100644 --- a/X10D.Tests/src/Math/ByteTests.Wrap.cs +++ b/X10D.Tests/src/Math/ByteTests.Wrap.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..6608222 100644 --- a/X10D.Tests/src/Math/ByteTests.cs +++ b/X10D.Tests/src/Math/ByteTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..970d649 100644 --- a/X10D.Tests/src/Math/ComparableTests.cs +++ b/X10D.Tests/src/Math/ComparableTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..5bed0f3 100644 --- a/X10D.Tests/src/Math/DecimalTests.Wrap.cs +++ b/X10D.Tests/src/Math/DecimalTests.Wrap.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..d84699b 100644 --- a/X10D.Tests/src/Math/DecimalTests.cs +++ b/X10D.Tests/src/Math/DecimalTests.cs @@ -1,11 +1,11 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; 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..138264d 100644 --- a/X10D.Tests/src/Math/DoubleTests.Wrap.cs +++ b/X10D.Tests/src/Math/DoubleTests.Wrap.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..7a23f98 100644 --- a/X10D.Tests/src/Math/DoubleTests.cs +++ b/X10D.Tests/src/Math/DoubleTests.cs @@ -1,11 +1,11 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; 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..0f9a5e5 100644 --- a/X10D.Tests/src/Math/Int16Tests.Wrap.cs +++ b/X10D.Tests/src/Math/Int16Tests.Wrap.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..7ba50a2 100644 --- a/X10D.Tests/src/Math/Int16Tests.cs +++ b/X10D.Tests/src/Math/Int16Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..bf4e636 100644 --- a/X10D.Tests/src/Math/Int32Tests.Wrap.cs +++ b/X10D.Tests/src/Math/Int32Tests.Wrap.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..664e16f 100644 --- a/X10D.Tests/src/Math/Int32Tests.cs +++ b/X10D.Tests/src/Math/Int32Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..fb7f7ba 100644 --- a/X10D.Tests/src/Math/Int64Tests.Wrap.cs +++ b/X10D.Tests/src/Math/Int64Tests.Wrap.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..8dd40a9 100644 --- a/X10D.Tests/src/Math/Int64Tests.cs +++ b/X10D.Tests/src/Math/Int64Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..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; @@ -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..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 @@ -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..5727874 100644 --- a/X10D.Tests/src/Math/SByteTests.Wrap.cs +++ b/X10D.Tests/src/Math/SByteTests.Wrap.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..3727af4 100644 --- a/X10D.Tests/src/Math/SByteTests.cs +++ b/X10D.Tests/src/Math/SByteTests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..b95e29a 100644 --- a/X10D.Tests/src/Math/SingleTests.Wrap.cs +++ b/X10D.Tests/src/Math/SingleTests.Wrap.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..abf31ca 100644 --- a/X10D.Tests/src/Math/SingleTests.cs +++ b/X10D.Tests/src/Math/SingleTests.cs @@ -1,11 +1,11 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; 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..364515c 100644 --- a/X10D.Tests/src/Math/UInt16Tests.Wrap.cs +++ b/X10D.Tests/src/Math/UInt16Tests.Wrap.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..d51f983 100644 --- a/X10D.Tests/src/Math/UInt16Tests.cs +++ b/X10D.Tests/src/Math/UInt16Tests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..9a967f0 100644 --- a/X10D.Tests/src/Math/UInt32Tests.Wrap.cs +++ b/X10D.Tests/src/Math/UInt32Tests.Wrap.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..54b902e 100644 --- a/X10D.Tests/src/Math/UInt64Tests.Wrap.cs +++ b/X10D.Tests/src/Math/UInt64Tests.Wrap.cs @@ -1,9 +1,9 @@ -using NUnit.Framework; +using NUnit.Framework; 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..98dbe60 100644 --- a/X10D.Tests/src/Net/EndPointTests.cs +++ b/X10D.Tests/src/Net/EndPointTests.cs @@ -1,11 +1,11 @@ -using System.Net; +using System.Net; using NUnit.Framework; 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..8f916fb 100644 --- a/X10D.Tests/src/Net/IPAddressTests.cs +++ b/X10D.Tests/src/Net/IPAddressTests.cs @@ -1,11 +1,11 @@ -using System.Net; +using System.Net; using NUnit.Framework; 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..8bfb3f8 100644 --- a/X10D.Tests/src/Net/Int16Tests.cs +++ b/X10D.Tests/src/Net/Int16Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..3322b9a 100644 --- a/X10D.Tests/src/Net/Int32Tests.cs +++ b/X10D.Tests/src/Net/Int32Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..845b0f9 100644 --- a/X10D.Tests/src/Net/Int64Tests.cs +++ b/X10D.Tests/src/Net/Int64Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..300a348 100644 --- a/X10D.Tests/src/Numerics/ByteTests.cs +++ b/X10D.Tests/src/Numerics/ByteTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..ce7b273 100644 --- a/X10D.Tests/src/Numerics/Int16Tests.cs +++ b/X10D.Tests/src/Numerics/Int16Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..33871d9 100644 --- a/X10D.Tests/src/Numerics/Int32Tests.cs +++ b/X10D.Tests/src/Numerics/Int32Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..756c35d 100644 --- a/X10D.Tests/src/Numerics/Int64Tests.cs +++ b/X10D.Tests/src/Numerics/Int64Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..40a25cd 100644 --- a/X10D.Tests/src/Numerics/QuaternionTests.cs +++ b/X10D.Tests/src/Numerics/QuaternionTests.cs @@ -1,11 +1,11 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; 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..434b217 100644 --- a/X10D.Tests/src/Numerics/RandomTests.cs +++ b/X10D.Tests/src/Numerics/RandomTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..d36a352 100644 --- a/X10D.Tests/src/Numerics/SByteTests.cs +++ b/X10D.Tests/src/Numerics/SByteTests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..ae5f090 100644 --- a/X10D.Tests/src/Numerics/UInt16Tests.cs +++ b/X10D.Tests/src/Numerics/UInt16Tests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..5f71af4 100644 --- a/X10D.Tests/src/Numerics/UInt32Tests.cs +++ b/X10D.Tests/src/Numerics/UInt32Tests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..ec9ff74 100644 --- a/X10D.Tests/src/Numerics/UInt64Tests.cs +++ b/X10D.Tests/src/Numerics/UInt64Tests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..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; @@ -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..3eecf10 100644 --- a/X10D.Tests/src/Numerics/Vector3Tests.cs +++ b/X10D.Tests/src/Numerics/Vector3Tests.cs @@ -1,11 +1,11 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; 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..7dd3e8a 100644 --- a/X10D.Tests/src/Numerics/Vector4Tests.cs +++ b/X10D.Tests/src/Numerics/Vector4Tests.cs @@ -1,11 +1,11 @@ -using System.Numerics; +using System.Numerics; using NUnit.Framework; 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..5b8f180 100644 --- a/X10D.Tests/src/Reactive/ProgressTests.cs +++ b/X10D.Tests/src/Reactive/ProgressTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..8ce5774 100644 --- a/X10D.Tests/src/Reflection/MemberInfoTests.cs +++ b/X10D.Tests/src/Reflection/MemberInfoTests.cs @@ -1,11 +1,11 @@ -using System.Reflection; +using System.Reflection; using NUnit.Framework; 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..a7f927d 100644 --- a/X10D.Tests/src/Reflection/TypeTests.cs +++ b/X10D.Tests/src/Reflection/TypeTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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/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(); + } +} diff --git a/X10D.Tests/src/Text/CharSpanTests.cs b/X10D.Tests/src/Text/CharSpanTests.cs index 27d9dc5..2441a58 100644 --- a/X10D.Tests/src/Text/CharSpanTests.cs +++ b/X10D.Tests/src/Text/CharSpanTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class CharSpanTests +internal class CharSpanTests { [Test] public void CountSubstring_ShouldHonor_StringComparison() @@ -60,4 +60,60 @@ public class CharSpanTests Assert.That(string.Empty.AsSpan().CountSubstring('\0'), Is.Zero); Assert.That(string.Empty.AsSpan().CountSubstring(string.Empty.AsSpan(), StringComparison.OrdinalIgnoreCase), Is.Zero); } + + [Test] + public void Repeat_ShouldNotManipulateSpan_GivenCount0() + { + Span destination = new char[11]; + "Hello world".AsSpan().CopyTo(destination); + + "a".AsSpan().Repeat(0, destination); + Assert.That(destination.ToString(), Is.EqualTo("Hello world")); + } + + [Test] + public void Repeat_ShouldReturnItself_GivenCount1() + { + string repeated = "a".AsSpan().Repeat(1); + Assert.That(repeated, Has.Length.EqualTo(1)); + Assert.That(repeated, Is.EqualTo("a")); + } + + [Test] + public void Repeat_ShouldPopulateSpan_GivenValidSpan() + { + const string expected = "aaaaaaaaaa"; + Span destination = new char[10]; + "a".AsSpan().Repeat(10, destination); + + Assert.That(destination.ToString(), Is.EqualTo(expected)); + } + + [Test] + public void Repeat_ShouldReturnEmptyString_GivenCount0() + { + Assert.That("a".AsSpan().Repeat(0), Is.EqualTo(string.Empty)); + } + + [Test] + public void Repeat_ShouldReturnRepeatedString_GivenSpan() + { + const string expected = "aaaaaaaaaa"; + string actual = "a".AsSpan().Repeat(10); + + Assert.That(actual, Is.EqualTo(expected)); + } + + [Test] + public void Repeat_ShouldThrowArgumentException_GivenSmallSpan() + { + Assert.Throws(() => "a".AsSpan().Repeat(10, Span.Empty)); + } + + [Test] + public void Repeat_ShouldThrowArgumentOutOfRangeException_GivenNegativeCount() + { + Assert.Throws(() => _ = "a".AsSpan().Repeat(-1)); + Assert.Throws(() => "a".AsSpan().Repeat(-1, Span.Empty)); + } } diff --git a/X10D.Tests/src/Text/CharTests.cs b/X10D.Tests/src/Text/CharTests.cs index 602acba..e06d3b5 100644 --- a/X10D.Tests/src/Text/CharTests.cs +++ b/X10D.Tests/src/Text/CharTests.cs @@ -1,19 +1,22 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class CharTests +internal class CharTests { [Test] public void IsEmoji_ShouldReturnTrue_GivenBasicEmoji() { - Assert.That('✂'.IsEmoji()); - Assert.That('✅'.IsEmoji()); - Assert.That('❎'.IsEmoji()); - Assert.That('➕'.IsEmoji()); - Assert.That('➖'.IsEmoji()); + Assert.Multiple(() => + { + Assert.That('✂'.IsEmoji()); + Assert.That('✅'.IsEmoji()); + Assert.That('❎'.IsEmoji()); + Assert.That('➕'.IsEmoji()); + Assert.That('➖'.IsEmoji()); + }); } [Test] @@ -26,7 +29,26 @@ public class CharTests } [Test] - public void RepeatShouldBeCorrect() + public void Repeat_ShouldPopulateSpanWithRepeatedCharacter_GivenValidCount() + { + const string expected = "aaaaaaaaaa"; + Span destination = new char[10]; + 'a'.Repeat(10, destination); + + Assert.That(destination.ToString(), Is.EqualTo(expected)); + } + + [Test] + public void Repeat_ShouldOnlyWriteOneCharToSpan_GivenCount1() + { + Span destination = new char[10]; + 'a'.Repeat(1, destination); + + Assert.That(destination.ToString(), Is.EqualTo("a\0\0\0\0\0\0\0\0\0")); + } + + [Test] + public void Repeat_ShouldReturnRepeatedCharacter_GivenValidCount() { const string expected = "aaaaaaaaaa"; string actual = 'a'.Repeat(10); @@ -35,22 +57,47 @@ public class CharTests } [Test] - public void RepeatOneCountShouldBeLength1String() + public void Repeat_ShouldReturnSingleCharString_GivenCount1() { string repeated = 'a'.Repeat(1); - Assert.That(repeated.Length, Is.EqualTo(1)); + Assert.That(repeated, Has.Length.EqualTo(1)); Assert.That(repeated, Is.EqualTo("a")); } [Test] - public void RepeatZeroCountShouldBeEmpty() + public void Repeat_ShouldReturnEmptyString_GivenCount0() { Assert.That('a'.Repeat(0), Is.EqualTo(string.Empty)); } [Test] - public void RepeatNegativeCountShouldThrow() + public void Repeat_ShouldNotManipulateSpan_GivenCount0() { - Assert.Throws(() => 'a'.Repeat(-1)); + Span destination = new char[10]; + destination.Fill(' '); + 'a'.Repeat(0, destination); + + const string expected = " "; + Assert.That(destination.ToString(), Is.EqualTo(expected)); + } + + [Test] + public void Repeat_ShouldThrowArgumentOutOfRangeException_GivenNegativeCount() + { + Assert.Multiple(() => + { + Assert.Throws(() => _ = 'a'.Repeat(-1)); + Assert.Throws(() => 'a'.Repeat(-1, Span.Empty)); + }); + } + + [Test] + public void Repeat_ShouldThrowArgumentException_GivenSmallSpan() + { + Assert.Throws(() => + { + var destination = Span.Empty; + 'a'.Repeat(1, destination); + }); } } diff --git a/X10D.Tests/src/Text/CoreTests.cs b/X10D.Tests/src/Text/CoreTests.cs index 4ed8903..ca2f1dd 100644 --- a/X10D.Tests/src/Text/CoreTests.cs +++ b/X10D.Tests/src/Text/CoreTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..ab6bfd0 100644 --- a/X10D.Tests/src/Text/EnumerableTests.cs +++ b/X10D.Tests/src/Text/EnumerableTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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/MarkdownTests.cs b/X10D.Tests/src/Text/MarkdownTests.cs new file mode 100644 index 0000000..28bc5eb --- /dev/null +++ b/X10D.Tests/src/Text/MarkdownTests.cs @@ -0,0 +1,171 @@ +using NUnit.Framework; +using X10D.Text; + +namespace X10D.Tests.Text; + +[TestFixture] +internal class MarkdownTests +{ + [Test] + public void MDBold_ShouldThrowArgumentNullException_GivenNull() + { + Assert.Throws(() => ((string)null!).MDBold()); + } + + [Test] + public void MDBold_ShouldReturnBoldText_GivenText() + { + Assert.That("Hello, world!".MDBold(), Is.EqualTo("**Hello, world!**")); + } + + [Test] + public void MDCode_ShouldThrowArgumentNullException_GivenNull() + { + Assert.Throws(() => ((string)null!).MDCode()); + } + + [Test] + public void MDCode_ShouldReturnCodeText_GivenText() + { + Assert.That("Hello, world!".MDCode(), Is.EqualTo("`Hello, world!`")); + } + + [Test] + public void MDCodeBlock_ShouldThrowArgumentNullException_GivenNull() + { + Assert.Throws(() => ((string)null!).MDCodeBlock()); + } + + [Test] + public void MDCodeBlock_ShouldReturnCodeBlockText_GivenText() + { + var expected = $"```{Environment.NewLine}Hello, world!{Environment.NewLine}```"; + string actual = "Hello, world!".MDCodeBlock(); + + Assert.That(actual, Is.EqualTo(expected)); + } + + [Test] + public void MDCodeBlock_ShouldReturnCodeBlockText_GivenTextAndLanguage() + { + var expected = $"```csharp{Environment.NewLine}Hello, world!{Environment.NewLine}```"; + string actual = "Hello, world!".MDCodeBlock("csharp"); + + Assert.That(actual, Is.EqualTo(expected)); + } + + [Test] + public void MDHeading_ShouldThrowArgumentNullException_GivenNull() + { + Assert.Throws(() => ((string)null!).MDHeading(1)); + } + + [Test] + public void MDHeading_ShouldThrowArgumentOutOfRangeException_GivenInvalidHeading() + { + Assert.Throws(() => "Hello, world!".MDHeading(0)); + Assert.Throws(() => "Hello, world!".MDHeading(7)); + } + + [Test] + public void MDHeading_ShouldReturnHeadingText_GivenText() + { + Assert.Multiple(() => + { + Assert.That("Hello, world!".MDHeading(1), Is.EqualTo("# Hello, world!")); + Assert.That("Hello, world!".MDHeading(2), Is.EqualTo("## Hello, world!")); + Assert.That("Hello, world!".MDHeading(3), Is.EqualTo("### Hello, world!")); + Assert.That("Hello, world!".MDHeading(4), Is.EqualTo("#### Hello, world!")); + Assert.That("Hello, world!".MDHeading(5), Is.EqualTo("##### Hello, world!")); + Assert.That("Hello, world!".MDHeading(6), Is.EqualTo("###### Hello, world!")); + }); + } + + [Test] + public void MDItalic_ShouldThrowArgumentNullException_GivenNull() + { + Assert.Throws(() => ((string)null!).MDItalic()); + } + + [Test] + public void MDItalic_ShouldReturnItalicTextWithAsterisk_GivenText() + { + Assert.That("Hello, world!".MDItalic(), Is.EqualTo("*Hello, world!*")); + } + + [Test] + public void MDItalic_ShouldReturnItalicTextWithAsterisk_GivenText_AndFalseUnderscoreFlag() + { + Assert.That("Hello, world!".MDItalic(false), Is.EqualTo("*Hello, world!*")); + } + + [Test] + public void MDItalic_ShouldReturnItalicTextWithUnderscores_GivenText_AndTrueUnderscoreFlag() + { + Assert.That("Hello, world!".MDItalic(true), Is.EqualTo("_Hello, world!_")); + } + + [Test] + public void MDLink_ShouldThrowArgumentNullException_GivenNullUrl() + { + Assert.Multiple(() => + { + Assert.Throws(() => "".MDLink((string)null!)); + Assert.Throws(() => "".MDLink((Uri)null!)); + Assert.Throws(() => ((Uri)null!).MDLink("Hello, world!")); + }); + } + + [Test] + public void MDLink_ShouldReturnUrlOnly_GivenNullOrEmptyLabel() + { + const string url = "https://example.com/"; + Assert.Multiple(() => + { + Assert.That(((string)null!).MDLink(url), Is.EqualTo(url)); + Assert.That(string.Empty.MDLink(url), Is.EqualTo(url)); + + Assert.That(new Uri(url).MDLink(null), Is.EqualTo(url)); + Assert.That(new Uri(url).MDLink(string.Empty), Is.EqualTo(url)); + }); + } + + [Test] + public void MDLink_ShouldReturnFormattedLink_GivenValidLabelAndUrl() + { + const string url = "https://example.com/"; + const string label = "Hello, world!"; + + Assert.Multiple(() => + { + Assert.That(label.MDLink(url), Is.EqualTo($"[{label}]({url})")); + Assert.That(label.MDLink(new Uri(url)), Is.EqualTo($"[{label}]({url})")); + + Assert.That(new Uri(url).MDLink(label), Is.EqualTo($"[{label}]({url})")); + }); + } + + [Test] + public void MDStrikeOut_ShouldThrowArgumentNullException_GivenNull() + { + Assert.Throws(() => ((string)null!).MDStrikeOut()); + } + + [Test] + public void MDStrikeOut_ShouldReturnStrikeOutText_GivenText() + { + Assert.That("Hello, world!".MDStrikeOut(), Is.EqualTo("~~Hello, world!~~")); + } + + [Test] + public void MDUnderline_ShouldThrowArgumentNullException_GivenNull() + { + Assert.Throws(() => ((string)null!).MDUnderline()); + } + + [Test] + public void MDUnderline_ShouldReturnUnderlineText_GivenText() + { + Assert.That("Hello, world!".MDUnderline(), Is.EqualTo("__Hello, world!__")); + } +} diff --git a/X10D.Tests/src/Text/RuneTests.cs b/X10D.Tests/src/Text/RuneTests.cs index d5a6946..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; @@ -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..8575511 100644 --- a/X10D.Tests/src/Text/StringBuilderReaderTests.cs +++ b/X10D.Tests/src/Text/StringBuilderReaderTests.cs @@ -1,11 +1,11 @@ -using System.Text; +using System.Text; using NUnit.Framework; 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 99fca98..060a6f7 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 @@ -8,7 +8,7 @@ using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class StringTests +internal class StringTests { [Test] public void AsNullIfEmpty_ShouldBeCorrect() @@ -105,13 +105,68 @@ 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")); + 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")); + 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((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!)); + } + [Test] public void CountSubstring_ShouldHonor_StringComparison() { Assert.Multiple(() => { Assert.That("Hello World".CountSubstring('E'), Is.Zero); +#pragma warning disable CA1307 Assert.That("Hello World".CountSubstring("E"), Is.Zero); +#pragma warning restore CA1307 Assert.That("Hello World".CountSubstring("E", StringComparison.OrdinalIgnoreCase), Is.EqualTo(1)); }); } @@ -122,7 +177,9 @@ public class StringTests Assert.Multiple(() => { Assert.That("Hello World".CountSubstring('z'), Is.Zero); +#pragma warning disable CA1307 Assert.That("Hello World".CountSubstring("z"), Is.Zero); +#pragma warning restore CA1307 Assert.That("Hello World".CountSubstring("z", StringComparison.OrdinalIgnoreCase), Is.Zero); }); } @@ -133,7 +190,9 @@ public class StringTests Assert.Multiple(() => { Assert.That("Hello World".CountSubstring('e'), Is.EqualTo(1)); +#pragma warning disable CA1307 Assert.That("Hello World".CountSubstring("e"), Is.EqualTo(1)); +#pragma warning restore CA1307 Assert.That("Hello World".CountSubstring("e", StringComparison.OrdinalIgnoreCase), Is.EqualTo(1)); }); } @@ -144,7 +203,9 @@ public class StringTests Assert.Multiple(() => { Assert.That(string.Empty.CountSubstring('\0'), Is.Zero); +#pragma warning disable CA1307 Assert.That(string.Empty.CountSubstring(string.Empty), Is.Zero); +#pragma warning restore CA1307 Assert.That(string.Empty.CountSubstring(string.Empty, StringComparison.OrdinalIgnoreCase), Is.Zero); }); } @@ -154,7 +215,9 @@ public class StringTests { string value = null!; Assert.Throws(() => value.CountSubstring('\0')); +#pragma warning disable CA1307 Assert.Throws(() => value.CountSubstring(string.Empty)); +#pragma warning restore CA1307 Assert.Throws(() => value.CountSubstring(string.Empty, StringComparison.OrdinalIgnoreCase)); } @@ -164,7 +227,10 @@ public class StringTests const string value = "Hello Worl"; const char substring = 'd'; +#pragma warning disable CA1307 Assert.That(value.EnsureEndsWith(substring), Is.EqualTo("Hello World")); +#pragma warning restore CA1307 + Assert.That(value.EnsureEndsWith(substring, StringComparison.Ordinal), Is.EqualTo("Hello World")); } [Test] @@ -173,7 +239,10 @@ public class StringTests const string value = "A"; const char substring = 'A'; +#pragma warning disable CA1307 Assert.That(value.EnsureEndsWith(substring), Is.EqualTo(value)); +#pragma warning restore CA1307 + Assert.That(value.EnsureEndsWith(substring, StringComparison.Ordinal), Is.EqualTo(value)); } [Test] @@ -182,7 +251,10 @@ public class StringTests const string value = "B"; const char substring = 'A'; +#pragma warning disable CA1307 Assert.That(value.EnsureStartsWith(substring), Is.EqualTo("AB")); +#pragma warning restore CA1307 + Assert.That(value.EnsureStartsWith(substring, StringComparison.Ordinal), Is.EqualTo("AB")); } [Test] @@ -191,7 +263,10 @@ public class StringTests const string value = "A"; const char substring = 'A'; +#pragma warning disable CA1307 Assert.That(value.EnsureStartsWith(substring), Is.EqualTo(value)); +#pragma warning restore CA1307 + Assert.That(value.EnsureStartsWith(substring, StringComparison.Ordinal), Is.EqualTo(value)); } [Test] @@ -200,7 +275,10 @@ public class StringTests const string value = "Hello "; const string substring = "World"; +#pragma warning disable CA1307 Assert.That(value.EnsureEndsWith(substring), Is.EqualTo("Hello World")); +#pragma warning restore CA1307 + Assert.That(value.EnsureEndsWith(substring, StringComparison.Ordinal), Is.EqualTo("Hello World")); } [Test] @@ -208,7 +286,10 @@ public class StringTests { const string substring = "World"; +#pragma warning disable CA1307 Assert.That(substring.EnsureEndsWith(substring), Is.EqualTo(substring)); +#pragma warning restore CA1307 + Assert.That(substring.EnsureEndsWith(substring, StringComparison.Ordinal), Is.EqualTo(substring)); } [Test] @@ -216,7 +297,10 @@ public class StringTests { const string substring = "World"; +#pragma warning disable CA1307 Assert.That(string.Empty.EnsureEndsWith(substring), Is.EqualTo(substring)); +#pragma warning restore CA1307 + Assert.That(string.Empty.EnsureEndsWith(substring, StringComparison.Ordinal), Is.EqualTo(substring)); } [Test] @@ -224,7 +308,10 @@ public class StringTests { const string substring = "World"; +#pragma warning disable CA1307 Assert.That(substring.EnsureEndsWith(string.Empty), Is.EqualTo(substring)); +#pragma warning restore CA1307 + Assert.That(substring.EnsureEndsWith(string.Empty, StringComparison.Ordinal), Is.EqualTo(substring)); } [Test] @@ -233,7 +320,10 @@ public class StringTests const string value = "World"; const string substring = "Hello "; +#pragma warning disable CA1307 Assert.That(value.EnsureStartsWith(substring), Is.EqualTo("Hello World")); +#pragma warning restore CA1307 + Assert.That(value.EnsureStartsWith(substring, StringComparison.Ordinal), Is.EqualTo("Hello World")); } [Test] @@ -241,7 +331,10 @@ public class StringTests { const string substring = "World"; +#pragma warning disable CA1307 Assert.That(substring.EnsureStartsWith(substring), Is.EqualTo(substring)); +#pragma warning restore CA1307 + Assert.That(substring.EnsureStartsWith(substring, StringComparison.Ordinal), Is.EqualTo(substring)); } [Test] @@ -249,7 +342,10 @@ public class StringTests { const string substring = "World"; +#pragma warning disable CA1307 Assert.That(string.Empty.EnsureStartsWith(substring), Is.EqualTo(substring)); +#pragma warning restore CA1307 + Assert.That(string.Empty.EnsureStartsWith(substring, StringComparison.Ordinal), Is.EqualTo(substring)); } [Test] @@ -257,7 +353,10 @@ public class StringTests { const string substring = "World"; +#pragma warning disable CA1307 Assert.That(substring.EnsureStartsWith(string.Empty), Is.EqualTo(substring)); +#pragma warning restore CA1307 + Assert.That(substring.EnsureStartsWith(string.Empty, StringComparison.Ordinal), Is.EqualTo(substring)); } [Test] @@ -340,7 +439,7 @@ public class StringTests [Test] public void GetBytes_ShouldReturnUtf8Bytes_GivenHelloWorld() { - var expected = new byte[] {0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64}; + var expected = new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 }; byte[] actual = "Hello World".GetBytes(); CollectionAssert.AreEqual(expected, actual); @@ -349,7 +448,7 @@ public class StringTests [Test] public void GetBytes_ShouldReturnAsciiBytes_GivenHelloWorld() { - var expected = new byte[] {0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64}; + var expected = new byte[] { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 }; byte[] actual = "Hello World".GetBytes(Encoding.ASCII); CollectionAssert.AreEqual(expected, actual); @@ -391,14 +490,16 @@ public class StringTests public void IsEmoji_ShouldReturnTrue_GivenMultiByteEmoji() { string[] regionalIndicatorCodes = Enumerable.Range(0, 26) - .Select(i => Encoding.Unicode.GetString(new byte[] {0x3C, 0xD8, (byte)(0xE6 + i), 0xDD})) + .Select(i => Encoding.Unicode.GetString(new byte[] { 0x3C, 0xD8, (byte)(0xE6 + i), 0xDD })) .ToArray(); for (var i = 0; i < 26; i++) - for (var j = 0; j < 26; j++) { - string flag = (regionalIndicatorCodes[i] + regionalIndicatorCodes[j]); - Assert.That(flag.IsEmoji()); + for (var j = 0; j < 26; j++) + { + string flag = (regionalIndicatorCodes[i] + regionalIndicatorCodes[j]); + Assert.That(flag.IsEmoji()); + } } } @@ -643,7 +744,7 @@ public class StringTests [Test] public void Randomize_ShouldThrow_GivenNegativeLength() { - Assert.Throws(() => string.Empty.Randomize(-1)); + Assert.Throws(() => _ = string.Empty.Randomize(-1)); } [Test] @@ -661,25 +762,62 @@ public class StringTests Assert.That("a".Repeat(0), Is.EqualTo(string.Empty)); } + [Test] + public void Repeat_ShouldNotManipulateSpan_GivenCount0() + { + Span destination = new char[11]; + "Hello world".AsSpan().CopyTo(destination); + + "a".Repeat(0, destination); + Assert.That(destination.ToString(), Is.EqualTo("Hello world")); + } + [Test] public void Repeat_ShouldReturnItself_GivenCount1() { string repeated = "a".Repeat(1); - Assert.That(repeated.Length, Is.EqualTo(1)); + Assert.That(repeated, Has.Length.EqualTo(1)); Assert.That(repeated, Is.EqualTo("a")); } [Test] - public void Repeat_ShouldThrow_GivenNegativeCount() + public void Repeat_ShouldThrowArgumentException_GivenSmallSpan() { - Assert.Throws(() => _ = "a".Repeat(-1)); + Assert.Throws(() => "a".Repeat(10, Span.Empty)); } [Test] - public void Repeat_ShouldThrow_GivenNull() + public void Repeat_ShouldThrowArgumentOutOfRangeException_GivenNegativeCount() + { + Assert.Throws(() => _ = "a".Repeat(-1)); + Assert.Throws(() => "a".Repeat(-1, Span.Empty)); + } + + [Test] + public void Repeat_ShouldThrowArgumentNullException_GivenNull() { string value = null!; Assert.Throws(() => _ = value.Repeat(0)); + Assert.Throws(() => value.Repeat(0, Span.Empty)); + } + + [Test] + public void Repeat_ShouldPopulateSpanWithRepeatedCharacter_GivenValidCount() + { + const string expected = "aaaaaaaaaa"; + Span destination = new char[10]; + "a".Repeat(10, destination); + + Assert.That(destination.ToString(), Is.EqualTo(expected)); + } + + [Test] + public void Repeat_ShouldOnlyWriteOneCharToSpan_GivenCount1() + { + Span destination = new char[10]; + "a".Repeat(1, destination); + + Assert.That(destination.ToString(), Is.EqualTo("a\0\0\0\0\0\0\0\0\0")); } [Test] @@ -698,7 +836,7 @@ public class StringTests } [Test] - public void Reverse_ShouldThrow_GivenNull() + public void Reverse_ShouldThrowArgumentNullException_GivenNull() { string value = null!; Assert.Throws(() => _ = value.Reverse()); @@ -716,7 +854,7 @@ public class StringTests } [Test] - public void Shuffled_ShouldThrow_GivenNull() + public void Shuffled_ShouldThrowArgumentNullException_GivenNull() { string value = null!; Assert.Throws(() => _ = value.Shuffled()); @@ -750,7 +888,7 @@ public class StringTests } [Test] - public void Split_ShouldThrow_GivenNullString() + public void Split_ShouldThrowArgumentNullException_GivenNullString() { string value = null!; @@ -825,7 +963,7 @@ public class StringTests [Test] public void StartsWithAny_ShouldThrowArgumentNullException_GivenANullValue() { - var values = new[] {"Hello", null!, "World"}; + var values = new[] { "Hello", null!, "World" }; Assert.Throws(() => "Foobar".StartsWithAny(values)); Assert.Throws(() => "Foobar".StartsWithAny(StringComparison.Ordinal, values)); } diff --git a/X10D.Tests/src/Time/ByteTests.cs b/X10D.Tests/src/Time/ByteTests.cs index c046241..9d4b59a 100644 --- a/X10D.Tests/src/Time/ByteTests.cs +++ b/X10D.Tests/src/Time/ByteTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..f06ab6c 100644 --- a/X10D.Tests/src/Time/CharSpanTests.cs +++ b/X10D.Tests/src/Time/CharSpanTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..cba4370 100644 --- a/X10D.Tests/src/Time/DecimalTests.cs +++ b/X10D.Tests/src/Time/DecimalTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..5247837 100644 --- a/X10D.Tests/src/Time/DoubleTests.cs +++ b/X10D.Tests/src/Time/DoubleTests.cs @@ -1,11 +1,11 @@ -#if NET5_0_OR_GREATER +#if NET5_0_OR_GREATER using NUnit.Framework; 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..7f6ceab 100644 --- a/X10D.Tests/src/Time/HalfTests.cs +++ b/X10D.Tests/src/Time/HalfTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..325aa84 100644 --- a/X10D.Tests/src/Time/Int16Tests.cs +++ b/X10D.Tests/src/Time/Int16Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..72edd02 100644 --- a/X10D.Tests/src/Time/Int32Tests.cs +++ b/X10D.Tests/src/Time/Int32Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..1e7a381 100644 --- a/X10D.Tests/src/Time/Int64Tests.cs +++ b/X10D.Tests/src/Time/Int64Tests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..7518559 100644 --- a/X10D.Tests/src/Time/SByteTests.cs +++ b/X10D.Tests/src/Time/SByteTests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..37b94b2 100644 --- a/X10D.Tests/src/Time/SingleTests.cs +++ b/X10D.Tests/src/Time/SingleTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..b176b41 100644 --- a/X10D.Tests/src/Time/StringTests.cs +++ b/X10D.Tests/src/Time/StringTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..8a0e1ca 100644 --- a/X10D.Tests/src/Time/TimeSpanParserTests.cs +++ b/X10D.Tests/src/Time/TimeSpanParserTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..eb7cad4 100644 --- a/X10D.Tests/src/Time/TimeSpanTests.cs +++ b/X10D.Tests/src/Time/TimeSpanTests.cs @@ -1,10 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..fe54926 100644 --- a/X10D.Tests/src/Time/UInt16Tests.cs +++ b/X10D.Tests/src/Time/UInt16Tests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..f6bc0f7 100644 --- a/X10D.Tests/src/Time/UInt32Tests.cs +++ b/X10D.Tests/src/Time/UInt32Tests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; 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..78e8681 100644 --- a/X10D.Tests/src/Time/UInt64Tests.cs +++ b/X10D.Tests/src/Time/UInt64Tests.cs @@ -1,11 +1,10 @@ -using NUnit.Framework; +using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -[CLSCompliant(false)] -public class UInt64Tests +internal class UInt64Tests { [Test] public void FromUnixTimeMilliseconds_ShouldBeEpoch_GivenZero() diff --git a/X10D.Unity.Tests/Assets/.gitignore b/X10D.Unity.Tests/Assets/.gitignore new file mode 100644 index 0000000..987d457 --- /dev/null +++ b/X10D.Unity.Tests/Assets/.gitignore @@ -0,0 +1,2 @@ +Libraries/ +Libraries.meta diff --git a/X10D.Unity.Tests/Assets/Tests/DebugUtilityIntegrationTests.cs b/X10D.Unity.Tests/Assets/Tests/DebugUtilityIntegrationTests.cs index 157f6a9..4ba07e7 100644 --- a/X10D.Unity.Tests/Assets/Tests/DebugUtilityIntegrationTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/DebugUtilityIntegrationTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using UnityEngine; using X10D.Drawing; using X10D.Unity.Drawing; diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/Color32Tests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/Color32Tests.cs index eb2e7c2..738fb17 100644 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/Color32Tests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Drawing/Color32Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using NUnit.Framework; using UnityEngine; using X10D.Unity.Drawing; diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/ColorTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/ColorTests.cs index c9d9182..495c48f 100644 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/ColorTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Drawing/ColorTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using NUnit.Framework; using UnityEngine; using X10D.Unity.Drawing; diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs index 13d0b36..9af56fc 100644 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Drawing; using NUnit.Framework; using X10D.Core; diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs index ab8a428..dcbd30f 100644 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Drawing; using NUnit.Framework; using X10D.Unity.Drawing; diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RandomTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RandomTests.cs index 5f4e842..914a715 100644 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RandomTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Drawing/RandomTests.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable using System; using NUnit.Framework; diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectIntTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RectIntTests.cs index 2e5f759..8fbf5f6 100644 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectIntTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Drawing/RectIntTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using UnityEngine; using X10D.Unity.Drawing; using Random = System.Random; diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs index 9cc688e..791315c 100644 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using UnityEngine; using X10D.Core; using X10D.Unity.Drawing; diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs index fdcbaf6..19e0f17 100644 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; using X10D.Core; using X10D.Unity.Drawing; diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs index 3f0f051..884d312 100644 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using NUnit.Framework; using X10D.Unity.Drawing; using Random = System.Random; diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs index 6d871d6..689eb0d 100644 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Drawing; using NUnit.Framework; using X10D.Core; diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs index c9619c9..135534c 100644 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Drawing; using NUnit.Framework; using X10D.Unity.Drawing; diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/QuaternionTests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/QuaternionTests.cs index c5ec037..19735c4 100644 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/QuaternionTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Numerics/QuaternionTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using UnityEngine; using X10D.Core; using X10D.Unity.Numerics; diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/RandomTests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/RandomTests.cs index d93744a..5db434c 100644 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/RandomTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Numerics/RandomTests.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable using System; using NUnit.Framework; diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2IntTests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2IntTests.cs index 6ef0909..cc8de9b 100644 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2IntTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2IntTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using UnityEngine; using X10D.Unity.Numerics; using Random = System.Random; diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs index d6e5e0c..d1815a9 100644 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using UnityEngine; using X10D.Core; using X10D.Unity.Numerics; diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3IntTests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3IntTests.cs index acfac84..2fde749 100644 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3IntTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3IntTests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using UnityEngine; using X10D.Unity.Numerics; diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs index 9d7d64a..b74e563 100644 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using UnityEngine; using X10D.Core; using X10D.Unity.Numerics; diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs index 3848db7..51deff2 100644 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs +++ b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; using UnityEngine; using X10D.Core; using X10D.Unity.Numerics; diff --git a/X10D.Unity.Tests/Assets/Tests/SingletonTests.cs b/X10D.Unity.Tests/Assets/Tests/SingletonTests.cs index 9e77e11..e3033b6 100644 --- a/X10D.Unity.Tests/Assets/Tests/SingletonTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/SingletonTests.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; diff --git a/X10D.Unity.Tests/Assets/Tests/TestBehaviour.cs b/X10D.Unity.Tests/Assets/Tests/TestBehaviour.cs index a603e1d..9e9fb68 100644 --- a/X10D.Unity.Tests/Assets/Tests/TestBehaviour.cs +++ b/X10D.Unity.Tests/Assets/Tests/TestBehaviour.cs @@ -1,4 +1,4 @@ -namespace X10D.Unity.Tests +namespace X10D.Unity.Tests { internal sealed class TestBehaviour : Singleton { diff --git a/X10D.Unity.Tests/Assets/Tests/YieldInstructionIntegrationTests.cs b/X10D.Unity.Tests/Assets/Tests/YieldInstructionIntegrationTests.cs index 90dc18e..3ac73ea 100644 --- a/X10D.Unity.Tests/Assets/Tests/YieldInstructionIntegrationTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/YieldInstructionIntegrationTests.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System.Collections; using UnityEngine; namespace X10D.Unity.Tests diff --git a/X10D.Unity.Tests/Assets/Tests/YieldInstructionTests.cs b/X10D.Unity.Tests/Assets/Tests/YieldInstructionTests.cs index fd109f0..5ccc569 100644 --- a/X10D.Unity.Tests/Assets/Tests/YieldInstructionTests.cs +++ b/X10D.Unity.Tests/Assets/Tests/YieldInstructionTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using NUnit.Framework; using UnityEngine; diff --git a/X10D.Unity.Tests/Packages/manifest.json b/X10D.Unity.Tests/Packages/manifest.json index 97fb71f..2f770c2 100644 --- a/X10D.Unity.Tests/Packages/manifest.json +++ b/X10D.Unity.Tests/Packages/manifest.json @@ -1,13 +1,14 @@ { "dependencies": { - "com.unity.collab-proxy": "2.0.1", + "com.unity.collab-proxy": "2.0.5", "com.unity.feature.development": "1.0.1", - "com.unity.ide.rider": "3.0.18", - "com.unity.ide.visualstudio": "2.0.17", + "com.unity.ide.rider": "3.0.24", + "com.unity.ide.visualstudio": "2.0.18", "com.unity.ide.vscode": "1.2.5", - "com.unity.test-framework": "1.1.31", + "com.unity.test-framework": "1.1.33", "com.unity.textmeshpro": "3.0.6", - "com.unity.timeline": "1.6.4", + "com.unity.timeline": "1.6.5", + "com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.6", "com.unity.ugui": "1.0.0", "com.unity.visualscripting": "1.8.0", "com.unity.modules.ai": "1.0.0", diff --git a/X10D.Unity.Tests/Packages/packages-lock.json b/X10D.Unity.Tests/Packages/packages-lock.json index 3172caf..0fddeec 100644 --- a/X10D.Unity.Tests/Packages/packages-lock.json +++ b/X10D.Unity.Tests/Packages/packages-lock.json @@ -1,7 +1,7 @@ { "dependencies": { "com.unity.collab-proxy": { - "version": "2.0.1", + "version": "2.0.5", "depth": 0, "source": "registry", "dependencies": {}, @@ -26,17 +26,17 @@ "depth": 0, "source": "builtin", "dependencies": { - "com.unity.ide.visualstudio": "2.0.17", - "com.unity.ide.rider": "3.0.18", + "com.unity.ide.visualstudio": "2.0.18", + "com.unity.ide.rider": "3.0.24", "com.unity.ide.vscode": "1.2.5", "com.unity.editorcoroutines": "1.0.0", "com.unity.performance.profile-analyzer": "1.2.2", - "com.unity.test-framework": "1.1.31", - "com.unity.testtools.codecoverage": "1.2.2" + "com.unity.test-framework": "1.1.33", + "com.unity.testtools.codecoverage": "1.2.4" } }, "com.unity.ide.rider": { - "version": "3.0.18", + "version": "3.0.24", "depth": 0, "source": "registry", "dependencies": { @@ -45,7 +45,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.17", + "version": "2.0.18", "depth": 0, "source": "registry", "dependencies": { @@ -74,8 +74,24 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.sysroot": { + "version": "2.0.7", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.sysroot.linux-x86_64": { + "version": "2.0.6", + "depth": 1, + "source": "registry", + "dependencies": { + "com.unity.sysroot": "2.0.7" + }, + "url": "https://packages.unity.com" + }, "com.unity.test-framework": { - "version": "1.1.31", + "version": "1.1.33", "depth": 0, "source": "registry", "dependencies": { @@ -86,7 +102,7 @@ "url": "https://packages.unity.com" }, "com.unity.testtools.codecoverage": { - "version": "1.2.2", + "version": "1.2.4", "depth": 1, "source": "registry", "dependencies": { @@ -105,7 +121,7 @@ "url": "https://packages.unity.com" }, "com.unity.timeline": { - "version": "1.6.4", + "version": "1.6.5", "depth": 0, "source": "registry", "dependencies": { @@ -116,6 +132,16 @@ }, "url": "https://packages.unity.com" }, + "com.unity.toolchain.win-x86_64-linux-x86_64": { + "version": "2.0.6", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.sysroot": "2.0.7", + "com.unity.sysroot.linux-x86_64": "2.0.6" + }, + "url": "https://packages.unity.com" + }, "com.unity.ugui": { "version": "1.0.0", "depth": 0, diff --git a/X10D.Unity.Tests/ProjectSettings/ProjectVersion.txt b/X10D.Unity.Tests/ProjectSettings/ProjectVersion.txt index f8251a7..db3863a 100644 --- a/X10D.Unity.Tests/ProjectSettings/ProjectVersion.txt +++ b/X10D.Unity.Tests/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2021.3.22f1 -m_EditorVersionWithRevision: 2021.3.22f1 (b6c551784ba3) +m_EditorVersion: 2021.3.29f1 +m_EditorVersionWithRevision: 2021.3.29f1 (204d6dc9ae1c) diff --git a/X10D.Unity/X10D.Unity.csproj b/X10D.Unity/X10D.Unity.csproj index e68de2b..e1ac766 100644 --- a/X10D.Unity/X10D.Unity.csproj +++ b/X10D.Unity/X10D.Unity.csproj @@ -2,49 +2,7 @@ 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 - 3.3.1 - 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 + $(NoWarn);NU1701 @@ -55,21 +13,6 @@ - - - True - - - - True - - - - True - - - - ResXFileCodeGenerator diff --git a/X10D.sln b/X10D.sln index dd11b7d..d552642 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}" @@ -24,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}" @@ -44,6 +43,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 @@ -75,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 diff --git a/X10D/X10D.csproj b/X10D/X10D.csproj index c9ddcf1..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 - 3.3.1 - 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 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 c6ed75b..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; @@ -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/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 3554586..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 . @@ -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..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 @@ -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..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; @@ -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/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/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/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 32acc3b..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; @@ -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/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 d2e4177..34d8bab 100644 --- a/X10D/src/Drawing/Line3D.cs +++ b/X10D/src/Drawing/Line3D.cs @@ -1,10 +1,10 @@ -using System.Drawing; +using System.Drawing; 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 { 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 63abae8..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; @@ -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..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; @@ -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..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; @@ -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..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 @@ -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/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/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/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 @@ - +