diff --git a/.github/workflows/activate-unity.yml b/.github/workflows/activate-unity.yml deleted file mode 100644 index 0827bbd..0000000 --- a/.github/workflows/activate-unity.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Acquire activation file -on: - workflow_dispatch: {} -jobs: - activation: - name: Request manual activation file 🔑 - runs-on: ubuntu-latest - steps: - # Request manual activation file - - name: Request manual activation file - id: getManualLicenseFile - uses: game-ci/unity-request-activation-file@v2 - # Upload artifact (Unity_v20XX.X.XXXX.alf) - - name: Expose as artifact - uses: actions/upload-artifact@v2 - with: - name: ${{ steps.getManualLicenseFile.outputs.filePath }} - path: ${{ steps.getManualLicenseFile.outputs.filePath }} diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 7d3fc24..74520d4 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -23,9 +23,9 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: | - 3.1.x 6.0.x 7.0.x + 8.0.x - name: Add NuGet source run: dotnet nuget add source --username oliverbooth --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/oliverbooth/index.json" @@ -36,11 +36,11 @@ jobs: - name: Build run: dotnet build --no-restore --configuration Release - - name: Test .NET Core 3.1 - run: dotnet test --no-build --verbosity normal --configuration Release --framework netcoreapp3.1 - - name: Test .NET 6 run: dotnet test --no-build --verbosity normal --configuration Release --framework net6.0 - name: Test .NET 7 run: dotnet test --no-build --verbosity normal --configuration Release --framework net7.0 + + - name: Test .NET 8 + run: dotnet test --no-build --verbosity normal --configuration Release --framework net8.0 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index ca14ed1..05fd768 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -18,7 +18,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Add GitHub NuGet source run: dotnet nuget add source --username oliverbooth --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/oliverbooth/index.json" @@ -33,9 +33,7 @@ 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 }} - name: Push NuGet Package to GitHub run: dotnet nuget push "build/*" --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate @@ -48,42 +46,3 @@ jobs: with: name: build path: build/ - - - name: Checkout upm branch - uses: actions/checkout@v3 - with: - ref: upm - path: upm - - - name: Build package.json - run: | - dotnet run --project ./tools/UpmPackageGenerator/UpmPackageGenerator.csproj "./X10D/bin/Debug/netstandard2.1/X10D.dll" - cp package.json upm/package.json - - - name: Copy built artifacts to upm - run: | - cd upm - cp ../X10D/bin/Debug/netstandard2.1/X10D.dll ./X10D.dll - cp ../X10D/bin/Debug/netstandard2.1/X10D.xml ./X10D.xml - cp ../X10D.Unity/bin/Debug/netstandard2.1/X10D.Unity.dll ./X10D.Unity.dll - cp ../X10D.Unity/bin/Debug/netstandard2.1/X10D.Unity.xml ./X10D.Unity.xml - - - name: Check for changes - run: | - cd upm - git diff --quiet - continue-on-error: true - - - name: Commit update - if: ${{ success() }} - run: | - cd upm - git config user.name github-actions - git config user.email github-actions@github.com - git add X10D.dll - git add X10D.Unity.dll - git add X10D.xml - git add X10D.Unity.xml - git add package.json - git commit -m "Update upm branch ($GITHUB_SHA)" - git push diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index 7b9940b..d62576b 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Add GitHub NuGet source run: dotnet nuget add source --username oliverbooth --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/oliverbooth/index.json" @@ -32,9 +32,7 @@ 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 }} - name: Push NuGet Package to GitHub run: dotnet nuget push "build/*" --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate @@ -53,42 +51,3 @@ jobs: with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: true - - - name: Checkout upm branch - uses: actions/checkout@v3 - with: - ref: upm - path: upm - - - name: Build package.json - run: | - dotnet run --project ./tools/UpmPackageGenerator/UpmPackageGenerator.csproj "./X10D/bin/Release/netstandard2.1/X10D.dll" - cp package.json upm/package.json - - - name: Copy built artifacts to upm - run: | - cd upm - cp ../X10D/bin/Release/netstandard2.1/X10D.dll ./X10D.dll - cp ../X10D/bin/Release/netstandard2.1/X10D.xml ./X10D.xml - cp ../X10D.Unity/bin/Release/netstandard2.1/X10D.Unity.dll ./X10D.Unity.dll - cp ../X10D.Unity/bin/Release/netstandard2.1/X10D.Unity.xml ./X10D.Unity.xml - - - name: Check for changes - run: | - cd upm - git diff --quiet - continue-on-error: true - - - name: Commit update - if: ${{ success() }} - run: | - cd upm - git config user.name github-actions - git config user.email github-actions@github.com - git add X10D.dll - git add X10D.Unity.dll - git add X10D.xml - git add X10D.Unity.xml - git add package.json - git commit -m "Update upm branch ($GITHUB_SHA)" - git push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0bdbb14..374f271 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Add GitHub NuGet source run: dotnet nuget add source --username oliverbooth --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/oliverbooth/index.json" @@ -32,9 +32,7 @@ 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 - name: Push NuGet Package to GitHub run: dotnet nuget push "build/*" --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate @@ -53,42 +51,3 @@ jobs: with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false - - - name: Checkout upm branch - uses: actions/checkout@v3 - with: - ref: upm - path: upm - - - name: Build package.json - run: | - dotnet run --project ./tools/UpmPackageGenerator/UpmPackageGenerator.csproj "./X10D/bin/Release/netstandard2.1/X10D.dll" - cp package.json upm/package.json - - - name: Copy built artifacts to upm - run: | - cd upm - cp ../X10D/bin/Release/netstandard2.1/X10D.dll ./X10D.dll - cp ../X10D/bin/Release/netstandard2.1/X10D.xml ./X10D.xml - cp ../X10D.Unity/bin/Release/netstandard2.1/X10D.Unity.dll ./X10D.Unity.dll - cp ../X10D.Unity/bin/Release/netstandard2.1/X10D.Unity.xml ./X10D.Unity.xml - - - name: Check for changes - run: | - cd upm - git diff --quiet - continue-on-error: true - - - name: Commit update - if: ${{ success() }} - run: | - cd upm - git config user.name github-actions - git config user.email github-actions@github.com - git add X10D.dll - git add X10D.Unity.dll - git add X10D.xml - git add X10D.Unity.xml - git add package.json - git commit -m "Update upm branch ($GITHUB_SHA)" - git push 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/.github/workflows/source_validator.yml b/.github/workflows/source_validator.yml index aad570f..0d7fb93 100644 --- a/.github/workflows/source_validator.yml +++ b/.github/workflows/source_validator.yml @@ -19,7 +19,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Add GitHub NuGet source run: dotnet nuget add source --username oliverbooth --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/oliverbooth/index.json" @@ -31,4 +31,4 @@ jobs: run: dotnet build -c Debug - name: Run Source Validation - run: dotnet run --project ./tools/SourceValidator/SourceValidator.csproj ./X10D/src ./X10D.Unity/src + run: dotnet run --project ./tools/SourceValidator/SourceValidator.csproj ./X10D/src diff --git a/.github/workflows/unity.yml b/.github/workflows/unity.yml deleted file mode 100644 index 2418e06..0000000 --- a/.github/workflows/unity.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Unity Test Runner - -on: - push: - branches: - - '*' - - '*/*' - pull_request: - branches: - - '*' - - '*/*' - -jobs: - build: - name: "Unity Test Runner" - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 7.0.x - - - name: Add GitHub NuGet source - run: dotnet nuget add source --username oliverbooth --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/oliverbooth/index.json" - - - name: Restore dependencies - run: dotnet restore - - - name: Build - run: dotnet build -c Release - - - name: Copy artifacts to project - run: | - mkdir -p ./X10D.Unity.Tests/Assets/Libraries - cp -r ./X10D/bin/Release/netstandard2.1/X10D.dll ./X10D.Unity.Tests/Assets/Libraries/X10D.dll - cp -r ./X10D.Unity/bin/Release/netstandard2.1/X10D.Unity.dll ./X10D.Unity.Tests/Assets/Libraries/X10D.Unity.dll - - - name: Unity - Test runner - uses: game-ci/unity-test-runner@v2.1.0 - env: - UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} - UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} - UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} - with: - projectPath: X10D.Unity.Tests - githubToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 034117e..00ce823 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,53 @@ 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`. + +### 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: Removed `Span.Replace(T, T)` for .NET 8 target. +- X10D: Removed .NET Standard 2.1 target. +- X10D.Hosting: Removed .NET Standard 2.1 target. +- X10D.DSharpPlus: Complete sunset of library. This library will not be updated to support DSharpPlus v5.0.0 (#83). +- X10D.Unity: Complete sunset of library. This library will not be updated effective immediately (#86). + ## [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..8bd1047 100644 --- a/README.md +++ b/README.md @@ -9,29 +9,115 @@ MIT License

-### About +## About X10D (pronounced *extend*), is a .NET package that provides extension methods for numerous types. The purpose of this library is to simplify a codebase by reducing the need for repeated code when performing common operations. Simplify your codebase. Take advantage of .NET. Use extension methods. *(I'm also [dogfooding](https://www.pcmag.com/encyclopedia/term/dogfooding) this library, so there's that.)* +### What are extension methods? + +Extension methods are a clever .NET feature that augment existing types with new functionality. They are defined as +static methods in a static class, and are called as if they were instance methods on the type they are extending. Take, +for example, the following code: + +```csharp +public static class Program +{ + public static void Main() + { + string str = "Hello, world!"; + Console.WriteLine(str.Reverse()); + } +} + +public static class StringExtensions +{ + public static string Reverse(this string str) + { + char[] chars = str.ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } +} +``` + +This will print `!dlrow ,olleH` to the console. The `Reverse` method is defined in the `StringExtensions` class, yet is +called as if it were an instance method on the `str` variable, even though it's not. + +### Why use extension methods? + +Extension methods were introduced when LINQ was added to .NET. LINQ is a set of extension methods that provide a way to +query, filter, and transform data. If you were to access LINQ's methods statically, you would have to write code like +this: + +```csharp +public static class Program +{ + public static void Main() + { + int[] numbers = { 1, 2, 3, 4, 5 }; + IEnumerable evenNumbers = Enumerable.Where(numbers, x => x % 2 == 0); + IEnumerable doubledNumbers = Enumerable.Select(evenNumbers, x => x * 2); + int sum = Enumerable.Sum(doubledNumbers); + Console.WriteLine(sum); + } +} +``` + +And if you wanted to one-line this, you'd have to write this: + +```csharp +public static class Program +{ + public static void Main() + { + int[] numbers = { 1, 2, 3, 4, 5 }; + Console.WriteLine(Enumerable.Sum(Enumerable.Select(Enumerable.Where(numbers, x => x % 2 == 0), x => x * 2))); + } +} +``` + +This is a lot of code to write, and it's not very readable. The nested method calls make it incredibly difficult to +follow. However, because LINQ is implemented as extension methods, you can write the following code instead: + +```csharp +public static class Program +{ + public static void Main() + { + int[] numbers = { 1, 2, 3, 4, 5 }; + Console.WriteLine(numbers.Where(x => x % 2 == 0).Select(x => x * 2).Sum()); + } +} +``` + +Because the methods are called as if they were instance methods on `IEnumerable`, they can be chained together, +making the code much more readable. + +X10D aims to provide these same benefits as LINQ, but for dozens of other types and for countless other use cases. See +the [documentation](#documentation) for a complete breakdown of what's available. + ## Installation + ### NuGet installation + ```ps -Install-Package X10D -Version 3.3.1 +Install-Package X10D -Version 4.0.0 ``` ### Manual installation + Download the [latest release](https://github.com/oliverbooth/X10D/releases/latest) from this repository and adding a direct assembly reference for your chosen platform. -### Unity installation -For the Unity installation guide, refer to the [README.md in X10D.Unity](X10D.Unity/README.md). +## Documentation -## Features -I'm planning on writing complete and extensive documentation in the near future. As of this time, feel free to browse the source or the API using your favourite IDE. -For those familiar with the 2.6.0 API, please read [CHANGELOG.md](CHANGELOG.md) for a complete list of changes. **3.0.0 is a major release and introduces many breaking changes.** +Documentation and the API reference is available at https://oliverbooth.github.io/X10D/index.html. *I'm sorry this took +so long to get up and running. DocFX will be the death of me.* ## Contributing + Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md). ## License + X10D is released under the MIT License. See [here](https://github.com/oliverbooth/X10D/blob/main/LICENSE.md) for more details. 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..b54a518 100644 --- a/X10D.Hosting/X10D.Hosting.csproj +++ b/X10D.Hosting/X10D.Hosting.csproj @@ -1,69 +1,11 @@ - net7.0;net6.0;netstandard2.1 - 11.0 - true - true - Oliver Booth - en - https://github.com/oliverbooth/X10D - git - Extension methods on crack. - LICENSE.md - branding_Icon.png - - dotnet extension-methods - $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) - true - 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 + net8.0;net7.0;net6.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..ca37853 100644 --- a/X10D.Tests/X10D.Tests.csproj +++ b/X10D.Tests/X10D.Tests.csproj @@ -1,13 +1,12 @@ - net7.0;net6.0;netcoreapp3.1 - 11.0 + net8.0;net7.0;net6.0 false - enable - true + true json,cobertura true + false @@ -15,14 +14,14 @@ - - - - - - - - + + + + + + + + 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..304999a 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() @@ -47,7 +47,6 @@ public class ByteTests }); } -#if NET5_0_OR_GREATER [Test] public void UnpackInternal_Fallback_ShouldUnpackToSpanCorrectly() { @@ -92,7 +91,6 @@ public class ByteTests Assert.That(bits[7], Is.True); }); } -#endif [Test] public void Unpack_ShouldRepackEqually() 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..c01dbe4 100644 --- a/X10D.Tests/src/Collections/Int16Tests.cs +++ b/X10D.Tests/src/Collections/Int16Tests.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 Int16Tests +internal class Int16Tests { [Test] public void Unpack_ShouldUnpackToArrayCorrectly() @@ -82,7 +82,6 @@ public class Int16Tests }); } -#if NET5_0_OR_GREATER [Test] public void UnpackInternal_Ssse3_ShouldUnpackToSpanCorrectly() { @@ -113,7 +112,6 @@ public class Int16Tests } }); } -#endif [Test] public void Unpack_ShouldRepackEqually() diff --git a/X10D.Tests/src/Collections/Int32Tests.cs b/X10D.Tests/src/Collections/Int32Tests.cs index 9aee1e8..0a8ea19 100644 --- a/X10D.Tests/src/Collections/Int32Tests.cs +++ b/X10D.Tests/src/Collections/Int32Tests.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 Int32Tests +internal class Int32Tests { [Test] public void Unpack_ShouldUnpackToArrayCorrectly() @@ -83,7 +83,6 @@ public class Int32Tests }); } -#if NET5_0_OR_GREATER [Test] public void UnpackInternal_Ssse3_ShouldUnpackToSpanCorrectly() { @@ -143,7 +142,6 @@ public class Int32Tests } }); } -#endif [Test] public void Unpack_ShouldRepackEqually() 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..a37c99a 100644 --- a/X10D.Tests/src/Core/IntrinsicTests.cs +++ b/X10D.Tests/src/Core/IntrinsicTests.cs @@ -1,4 +1,3 @@ -#if NET6_0_OR_GREATER using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; using NUnit.Framework; @@ -7,7 +6,7 @@ using X10D.Core; namespace X10D.Tests.Core; [TestFixture] -public class IntrinsicTests +internal class IntrinsicTests { [Test] public void CorrectBoolean_ShouldReturnExpectedVector64Result_GivenInputVector() @@ -223,4 +222,3 @@ public class IntrinsicTests Assert.That(result, Is.EqualTo(expectedResult)); } } -#endif 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..743a55e 100644 --- a/X10D.Tests/src/Core/SpanTest.cs +++ b/X10D.Tests/src/Core/SpanTest.cs @@ -1,14 +1,12 @@ -#if NET5_0_OR_GREATER using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.X86; -#endif using NUnit.Framework; using X10D.Core; namespace X10D.Tests.Core; [TestFixture] -public class SpanTest +internal class SpanTest { [Test] public void Contains_ShouldReturnFalse_GivenReadOnlySpanWithNoMatchingElements_UsingByteEnum() @@ -209,7 +207,6 @@ public class SpanTest Assert.That(actual, Is.EqualTo(expected)); } -#if NET5_0_OR_GREATER [Test] public void PackByteInternal_Sse2_ShouldReturnCorrectByte_GivenReadOnlySpan_Using() { @@ -226,23 +223,6 @@ public class SpanTest Assert.That(actual, Is.EqualTo(expected)); } - [Test] - public void PackByteInternal_AdvSimd_ShouldReturnCorrectByte_GivenReadOnlySpan_Using() - { - if (!AdvSimd.IsSupported) - { - return; - } - - const byte expected = 0b00110011; - ReadOnlySpan span = stackalloc bool[8] {true, true, false, false, true, true, false, false}; - - byte actual = span.PackByteInternal_AdvSimd(); - - Assert.That(actual, Is.EqualTo(expected)); - } -#endif - [Test] public void PackInt16_ShouldReturnSameAsPackByte_WhenSpanHasLength8() { @@ -268,7 +248,6 @@ public class SpanTest Assert.That(actual, Is.EqualTo(expected)); } -#if NET5_0_OR_GREATER [Test] public void PackInt16Internal_Sse2_ShouldReturnCorrectInt16_GivenReadOnlySpan_Using() { @@ -287,7 +266,6 @@ public class SpanTest Assert.That(actual, Is.EqualTo(expected)); } -#endif [Test] public void PackInt32Internal_Fallback_ShouldReturnCorrectInt32_GivenReadOnlySpan() @@ -304,7 +282,6 @@ public class SpanTest Assert.That(actual, Is.EqualTo(expected)); } -#if NET5_0_OR_GREATER [Test] public void PackInt32Internal_Sse2_ShouldReturnCorrectInt32_GivenReadOnlySpan() { @@ -345,27 +322,6 @@ public class SpanTest Assert.That(actual, Is.EqualTo(expected)); } - [Test] - public void PackInt32Internal_AdvSimd_ShouldReturnCorrectInt32_GivenReadOnlySpan() - { - if (!AdvSimd.IsSupported) - { - return; - } - - const int expected = 0b01010101_10101010_01010101_10101010; - ReadOnlySpan span = stackalloc bool[32] - { - false, true, false, true, false, true, false, true, true, false, true, false, true, false, true, false, false, - true, false, true, false, true, false, true, true, false, true, false, true, false, true, false, - }; - - int actual = span.PackInt32Internal_AdvSimd(); - - Assert.That(actual, Is.EqualTo(expected)); - } -#endif - [Test] public void PackInt32_ShouldReturnSameAsPackByte_WhenSpanHasLength8_UsingReadOnlySpan() { 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..de95f14 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); @@ -207,9 +207,7 @@ public class ColorTests Assert.That(Color.Plum.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkGray)); Assert.That(Color.PowderBlue.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkGray)); Assert.That(Color.Purple.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkMagenta)); -#if NET6_0_OR_GREATER Assert.That(Color.RebeccaPurple.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkMagenta)); -#endif Assert.That(Color.Red.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Red)); Assert.That(Color.RosyBrown.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkGray)); Assert.That(Color.RoyalBlue.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.DarkCyan)); 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..66f15fe 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.TryWriteBigEndianBytes(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.TryWriteLittleEndianBytes(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.TryWriteBigEndianBytes(buffer), Is.False); + } + + [Test] + public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan() + { + const double value = 42.5; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteLittleEndianBytes(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..6b03d4a 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.TryWriteLittleEndianBytes(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.TryWriteBigEndianBytes(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.TryWriteLittleEndianBytes(buffer), Is.False); + } + + [Test] + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() + { + const short value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteBigEndianBytes(buffer), Is.False); } } diff --git a/X10D.Tests/src/IO/Int32Tests.cs b/X10D.Tests/src/IO/Int32Tests.cs index d69b2be..01c7990 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.TryWriteBigEndianBytes(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.TryWriteLittleEndianBytes(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.TryWriteBigEndianBytes(buffer), Is.False); + } + + [Test] + public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan() + { + const int value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteLittleEndianBytes(buffer), Is.False); } } diff --git a/X10D.Tests/src/IO/Int64Tests.cs b/X10D.Tests/src/IO/Int64Tests.cs index ccd3673..c331369 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.TryWriteLittleEndianBytes(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.TryWriteBigEndianBytes(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.TryWriteLittleEndianBytes(buffer), Is.False); + } + + [Test] + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() + { + const long value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteBigEndianBytes(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..984f8a4 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.TryWriteBigEndianBytes(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.TryWriteLittleEndianBytes(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.TryWriteBigEndianBytes(buffer), Is.False); + } + + [Test] + public void TryWriteLittleEndian_RReturnsFalse_GivenSmallSpan() + { + const float value = 42.5f; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteLittleEndianBytes(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..465a1e0 100644 --- a/X10D.Tests/src/IO/UInt16Tests.cs +++ b/X10D.Tests/src/IO/UInt16Tests.cs @@ -4,60 +4,65 @@ 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.TryWriteLittleEndianBytes(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.TryWriteBigEndianBytes(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.TryWriteLittleEndianBytes(buffer), Is.False); + } + + [Test] + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() + { + const ushort value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteBigEndianBytes(buffer), Is.False); } } diff --git a/X10D.Tests/src/IO/UInt32Tests.cs b/X10D.Tests/src/IO/UInt32Tests.cs index 910aa50..cb0f17b 100644 --- a/X10D.Tests/src/IO/UInt32Tests.cs +++ b/X10D.Tests/src/IO/UInt32Tests.cs @@ -4,60 +4,65 @@ 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.TryWriteLittleEndianBytes(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.TryWriteBigEndianBytes(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.TryWriteLittleEndianBytes(buffer), Is.False); + } + + [Test] + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() + { + const uint value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteBigEndianBytes(buffer), Is.False); } } diff --git a/X10D.Tests/src/IO/UInt64Tests.cs b/X10D.Tests/src/IO/UInt64Tests.cs index 374444f..dfaa621 100644 --- a/X10D.Tests/src/IO/UInt64Tests.cs +++ b/X10D.Tests/src/IO/UInt64Tests.cs @@ -4,64 +4,65 @@ 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.TryWriteLittleEndianBytes(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.TryWriteBigEndianBytes(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.TryWriteLittleEndianBytes(buffer), Is.False); + } + + [Test] + public void TryWriteBigEndian_ReturnsFalse_GivenSmallSpan() + { + const ulong value = 0x0F; + Span buffer = stackalloc byte[0]; + Assert.That(value.TryWriteBigEndianBytes(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..2b6ab5f 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)); } @@ -76,7 +76,7 @@ public class ReadOnlySpanTests Assert.Throws(() => { var span = new ReadOnlySpan(); - _ = span.Count(null!); + _ = span.Count((Predicate)null!); }); } } 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..186d0e8 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)); } @@ -76,7 +76,7 @@ public class SpanTests Assert.Throws(() => { var span = new Span(); - _ = span.Count(null!); + _ = span.Count((Predicate)null!); }); } } 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..684fa26 100644 --- a/X10D.Tests/src/Text/CoreTests.cs +++ b/X10D.Tests/src/Text/CoreTests.cs @@ -1,12 +1,11 @@ -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] public void ToJsonShouldNotBeEmpty() { @@ -24,5 +23,4 @@ public class CoreTests CollectionAssert.AreEqual(source, target); CollectionAssert.AreEquivalent(source, target); } -#endif } 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..0efb605 100644 --- a/X10D.Tests/src/Text/RuneTests.cs +++ b/X10D.Tests/src/Text/RuneTests.cs @@ -1,4 +1,3 @@ -#if NET5_0_OR_GREATER using System.Text; using NUnit.Framework; using X10D.Text; @@ -6,7 +5,7 @@ using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class RuneTests +internal class RuneTests { [Test] public void IsEmoji_ShouldReturnTrue_GivenBasicEmoji() @@ -90,4 +89,3 @@ public class RuneTests Assert.That(repeated, Is.EqualTo("𐀀𐀀𐀀𐀀𐀀𐀀")); } } -#endif 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..d658b72 100644 --- a/X10D.Tests/src/Text/StringTests.cs +++ b/X10D.Tests/src/Text/StringTests.cs @@ -1,14 +1,12 @@ -using System.Text; -#if NET5_0_OR_GREATER +using System.Text; using System.Text.Json.Serialization; -#endif using NUnit.Framework; using X10D.Text; namespace X10D.Tests.Text; [TestFixture] -public class StringTests +internal class StringTests { [Test] public void AsNullIfEmpty_ShouldBeCorrect() @@ -105,13 +103,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 +175,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 +188,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 +201,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 +213,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 +225,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 +237,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 +249,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 +261,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 +273,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 +284,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 +295,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 +306,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 +318,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 +329,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 +340,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 +351,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] @@ -319,7 +416,6 @@ public class StringTests Assert.Throws(() => _ = " ".EnumParse()); } -#if NET5_0_OR_GREATER [Test] public void FromJson_ShouldDeserializeCorrectly_GivenJsonString() { @@ -335,12 +431,11 @@ public class StringTests Assert.That(target.Values[2], Is.EqualTo(3)); }); } -#endif [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 +444,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 +486,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 +740,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 +758,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 +832,7 @@ public class StringTests } [Test] - public void Reverse_ShouldThrow_GivenNull() + public void Reverse_ShouldThrowArgumentNullException_GivenNull() { string value = null!; Assert.Throws(() => _ = value.Reverse()); @@ -716,7 +850,7 @@ public class StringTests } [Test] - public void Shuffled_ShouldThrow_GivenNull() + public void Shuffled_ShouldThrowArgumentNullException_GivenNull() { string value = null!; Assert.Throws(() => _ = value.Shuffled()); @@ -750,7 +884,7 @@ public class StringTests } [Test] - public void Split_ShouldThrow_GivenNullString() + public void Split_ShouldThrowArgumentNullException_GivenNullString() { string value = null!; @@ -825,7 +959,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)); } @@ -868,11 +1002,9 @@ public class StringTests }); } -#if NET5_0_OR_GREATER private struct SampleStructure { [JsonPropertyName("values")] public int[] Values { get; set; } } -#endif } 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..15b10ce 100644 --- a/X10D.Tests/src/Time/DateOnlyTests.cs +++ b/X10D.Tests/src/Time/DateOnlyTests.cs @@ -1,11 +1,10 @@ -#if NET6_0_OR_GREATER using NUnit.Framework; using X10D.Time; namespace X10D.Tests.Time; [TestFixture] -public class DateOnlyTests +internal class DateOnlyTests { [Test] public void Age_ShouldBe17_Given31December1991Birthday_And30December2017Date() @@ -230,4 +229,3 @@ public class DateOnlyTests Assert.That(date.ToUnixTimeSeconds(time), Is.EqualTo(946684800)); } } -#endif 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..18afb8f 100644 --- a/X10D.Tests/src/Time/DoubleTests.cs +++ b/X10D.Tests/src/Time/DoubleTests.cs @@ -1,11 +1,10 @@ -#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; @@ -52,4 +51,3 @@ public class DoubleTests Assert.That((_negativeOne).Weeks() < TimeSpan.Zero); } } -#endif 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/.gitignore b/X10D.Unity.Tests/.gitignore deleted file mode 100644 index 58cbc82..0000000 --- a/X10D.Unity.Tests/.gitignore +++ /dev/null @@ -1,72 +0,0 @@ -# This .gitignore file should be placed at the root of your Unity project directory -# -# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore -# -/[Ll]ibrary/ -/[Tt]emp/ -/[Oo]bj/ -/[Bb]uild/ -/[Bb]uilds/ -/[Ll]ogs/ -/[Uu]ser[Ss]ettings/ - -# MemoryCaptures can get excessive in size. -# They also could contain extremely sensitive data -/[Mm]emoryCaptures/ - -# Recordings can get excessive in size -/[Rr]ecordings/ - -# Uncomment this line if you wish to ignore the asset store tools plugin -# /[Aa]ssets/AssetStoreTools* - -# Autogenerated Jetbrains Rider plugin -/[Aa]ssets/Plugins/Editor/JetBrains* - -# Visual Studio cache directory -.vs/ - -# Gradle cache directory -.gradle/ - -# Autogenerated VS/MD/Consulo solution and project files -ExportedObj/ -.consulo/ -*.csproj -*.unityproj -*.sln -*.suo -*.tmp -*.user -*.userprefs -*.pidb -*.booproj -*.svd -*.pdb -*.mdb -*.opendb -*.VC.db - -# Unity3D generated meta files -*.pidb.meta -*.pdb.meta -*.mdb.meta - -# Unity3D generated file on crash reports -sysinfo.txt - -# Builds -*.apk -*.aab -*.unitypackage -*.app - -# Crashlytics generated file -crashlytics-build.properties - -# Packed Addressables -/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* - -# Temporary auto-generated Android Assets -/[Aa]ssets/[Ss]treamingAssets/aa.meta -/[Aa]ssets/[Ss]treamingAssets/aa/* diff --git a/X10D.Unity.Tests/Assets/Scenes.meta b/X10D.Unity.Tests/Assets/Scenes.meta deleted file mode 100644 index 83c741b..0000000 --- a/X10D.Unity.Tests/Assets/Scenes.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6ea315d0fd7389c41b19996891e99ae3 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/X10D.Unity.Tests/Assets/Scenes/DebugExIntegrationTests.unity b/X10D.Unity.Tests/Assets/Scenes/DebugExIntegrationTests.unity deleted file mode 100644 index c1a5fbe..0000000 --- a/X10D.Unity.Tests/Assets/Scenes/DebugExIntegrationTests.unity +++ /dev/null @@ -1,354 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!29 &1 -OcclusionCullingSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_OcclusionBakeSettings: - smallestOccluder: 5 - smallestHole: 0.25 - backfaceThreshold: 100 - m_SceneGUID: 00000000000000000000000000000000 - m_OcclusionCullingData: {fileID: 0} ---- !u!104 &2 -RenderSettings: - m_ObjectHideFlags: 0 - serializedVersion: 9 - m_Fog: 0 - m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - m_FogMode: 3 - m_FogDensity: 0.01 - m_LinearFogStart: 0 - m_LinearFogEnd: 300 - m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} - m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} - m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 1 - m_AmbientMode: 0 - m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} - m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} - m_HaloStrength: 0.5 - m_FlareStrength: 1 - m_FlareFadeSpeed: 3 - m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} - m_DefaultReflectionMode: 0 - m_DefaultReflectionResolution: 128 - m_ReflectionBounces: 1 - m_ReflectionIntensity: 1 - m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} - m_UseRadianceAmbientProbe: 0 ---- !u!157 &3 -LightmapSettings: - m_ObjectHideFlags: 0 - serializedVersion: 12 - m_GIWorkflowMode: 1 - m_GISettings: - serializedVersion: 2 - m_BounceScale: 1 - m_IndirectOutputScale: 1 - m_AlbedoBoost: 1 - m_EnvironmentLightingMode: 0 - m_EnableBakedLightmaps: 1 - m_EnableRealtimeLightmaps: 0 - m_LightmapEditorSettings: - serializedVersion: 12 - m_Resolution: 2 - m_BakeResolution: 40 - m_AtlasSize: 1024 - m_AO: 0 - m_AOMaxDistance: 1 - m_CompAOExponent: 1 - m_CompAOExponentDirect: 0 - m_ExtractAmbientOcclusion: 0 - m_Padding: 2 - m_LightmapParameters: {fileID: 0} - m_LightmapsBakeMode: 1 - m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherFiltering: 1 - m_FinalGatherRayCount: 256 - m_ReflectionCompression: 2 - m_MixedBakeMode: 2 - m_BakeBackend: 1 - m_PVRSampling: 1 - m_PVRDirectSampleCount: 32 - m_PVRSampleCount: 512 - m_PVRBounces: 2 - m_PVREnvironmentSampleCount: 256 - m_PVREnvironmentReferencePointCount: 2048 - m_PVRFilteringMode: 1 - m_PVRDenoiserTypeDirect: 1 - m_PVRDenoiserTypeIndirect: 1 - m_PVRDenoiserTypeAO: 1 - m_PVRFilterTypeDirect: 0 - m_PVRFilterTypeIndirect: 0 - m_PVRFilterTypeAO: 0 - m_PVREnvironmentMIS: 1 - m_PVRCulling: 1 - m_PVRFilteringGaussRadiusDirect: 1 - m_PVRFilteringGaussRadiusIndirect: 5 - m_PVRFilteringGaussRadiusAO: 2 - m_PVRFilteringAtrousPositionSigmaDirect: 0.5 - m_PVRFilteringAtrousPositionSigmaIndirect: 2 - m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ExportTrainingData: 0 - m_TrainingDataDestination: TrainingData - m_LightProbeSampleCountMultiplier: 4 - m_LightingDataAsset: {fileID: 0} - m_LightingSettings: {fileID: 0} ---- !u!196 &4 -NavMeshSettings: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_BuildSettings: - serializedVersion: 2 - agentTypeID: 0 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.4 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - minRegionArea: 2 - manualCellSize: 0 - cellSize: 0.16666667 - manualTileSize: 0 - tileSize: 256 - accuratePlacement: 0 - maxJobWorkers: 0 - preserveTilesOutsideBounds: 0 - debug: - m_Flags: 0 - m_NavMeshData: {fileID: 0} ---- !u!1 &192863441 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 192863443} - - component: {fileID: 192863442} - m_Layer: 0 - m_Name: GameObject - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &192863442 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 192863441} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0fac6b15ed0b420ba300fc1ac10ef01a, type: 3} - m_Name: - m_EditorClassIdentifier: - _hexagonPoints: - - {x: -0.5, y: 0.5} - - {x: -0.25, y: 1} - - {x: 0.25, y: 1} - - {x: 0.5, y: 0.5} - - {x: 0.25, y: 0} - - {x: -0.25, y: 0} ---- !u!4 &192863443 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 192863441} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &585803459 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 585803461} - - component: {fileID: 585803460} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!108 &585803460 -Light: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 585803459} - m_Enabled: 1 - serializedVersion: 10 - m_Type: 1 - m_Shape: 0 - m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} - m_Intensity: 1 - m_Range: 10 - m_SpotAngle: 30 - m_InnerSpotAngle: 21.80208 - m_CookieSize: 10 - m_Shadows: - m_Type: 2 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_CullingMatrixOverride: - e00: 1 - e01: 0 - e02: 0 - e03: 0 - e10: 0 - e11: 1 - e12: 0 - e13: 0 - e20: 0 - e21: 0 - e22: 1 - e23: 0 - e30: 0 - e31: 0 - e32: 0 - e33: 1 - m_UseCullingMatrixOverride: 0 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingLayerMask: 1 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} - m_UseBoundingSphereOverride: 0 - m_UseViewFrustumForShadowCasterCull: 1 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &585803461 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 585803459} - m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} ---- !u!1 &1189625736 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1189625739} - - component: {fileID: 1189625738} - - component: {fileID: 1189625737} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &1189625737 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1189625736} - m_Enabled: 1 ---- !u!20 &1189625738 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1189625736} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} - m_projectionMatrixMode: 1 - m_GateFitMode: 2 - m_FOVAxisMode: 0 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_FocalLength: 50 - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 0 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &1189625739 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1189625736} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/X10D.Unity.Tests/Assets/Scenes/DebugExIntegrationTests.unity.meta b/X10D.Unity.Tests/Assets/Scenes/DebugExIntegrationTests.unity.meta deleted file mode 100644 index 90ba21a..0000000 --- a/X10D.Unity.Tests/Assets/Scenes/DebugExIntegrationTests.unity.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: f2337eeeb085a25408461d996bb20a9c -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/X10D.Unity.Tests/Assets/Scenes/SampleScene.unity b/X10D.Unity.Tests/Assets/Scenes/SampleScene.unity deleted file mode 100644 index 2221b04..0000000 --- a/X10D.Unity.Tests/Assets/Scenes/SampleScene.unity +++ /dev/null @@ -1,267 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!29 &1 -OcclusionCullingSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_OcclusionBakeSettings: - smallestOccluder: 5 - smallestHole: 0.25 - backfaceThreshold: 100 - m_SceneGUID: 00000000000000000000000000000000 - m_OcclusionCullingData: {fileID: 0} ---- !u!104 &2 -RenderSettings: - m_ObjectHideFlags: 0 - serializedVersion: 9 - m_Fog: 0 - m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - m_FogMode: 3 - m_FogDensity: 0.01 - m_LinearFogStart: 0 - m_LinearFogEnd: 300 - m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} - m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} - m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 1 - m_AmbientMode: 0 - m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} - m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} - m_HaloStrength: 0.5 - m_FlareStrength: 1 - m_FlareFadeSpeed: 3 - m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} - m_DefaultReflectionMode: 0 - m_DefaultReflectionResolution: 128 - m_ReflectionBounces: 1 - m_ReflectionIntensity: 1 - m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 705507994} - m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} - m_UseRadianceAmbientProbe: 0 ---- !u!157 &3 -LightmapSettings: - m_ObjectHideFlags: 0 - serializedVersion: 12 - m_GIWorkflowMode: 1 - m_GISettings: - serializedVersion: 2 - m_BounceScale: 1 - m_IndirectOutputScale: 1 - m_AlbedoBoost: 1 - m_EnvironmentLightingMode: 0 - m_EnableBakedLightmaps: 1 - m_EnableRealtimeLightmaps: 0 - m_LightmapEditorSettings: - serializedVersion: 12 - m_Resolution: 2 - m_BakeResolution: 40 - m_AtlasSize: 1024 - m_AO: 0 - m_AOMaxDistance: 1 - m_CompAOExponent: 1 - m_CompAOExponentDirect: 0 - m_ExtractAmbientOcclusion: 0 - m_Padding: 2 - m_LightmapParameters: {fileID: 0} - m_LightmapsBakeMode: 1 - m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherFiltering: 1 - m_FinalGatherRayCount: 256 - m_ReflectionCompression: 2 - m_MixedBakeMode: 2 - m_BakeBackend: 1 - m_PVRSampling: 1 - m_PVRDirectSampleCount: 32 - m_PVRSampleCount: 500 - m_PVRBounces: 2 - m_PVREnvironmentSampleCount: 500 - m_PVREnvironmentReferencePointCount: 2048 - m_PVRFilteringMode: 2 - m_PVRDenoiserTypeDirect: 0 - m_PVRDenoiserTypeIndirect: 0 - m_PVRDenoiserTypeAO: 0 - m_PVRFilterTypeDirect: 0 - m_PVRFilterTypeIndirect: 0 - m_PVRFilterTypeAO: 0 - m_PVREnvironmentMIS: 0 - m_PVRCulling: 1 - m_PVRFilteringGaussRadiusDirect: 1 - m_PVRFilteringGaussRadiusIndirect: 5 - m_PVRFilteringGaussRadiusAO: 2 - m_PVRFilteringAtrousPositionSigmaDirect: 0.5 - m_PVRFilteringAtrousPositionSigmaIndirect: 2 - m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ExportTrainingData: 0 - m_TrainingDataDestination: TrainingData - m_LightProbeSampleCountMultiplier: 4 - m_LightingDataAsset: {fileID: 0} - m_LightingSettings: {fileID: 0} ---- !u!196 &4 -NavMeshSettings: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_BuildSettings: - serializedVersion: 2 - agentTypeID: 0 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.4 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - minRegionArea: 2 - manualCellSize: 0 - cellSize: 0.16666667 - manualTileSize: 0 - tileSize: 256 - accuratePlacement: 0 - debug: - m_Flags: 0 - m_NavMeshData: {fileID: 0} ---- !u!1 &705507993 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 705507995} - - component: {fileID: 705507994} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!108 &705507994 -Light: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 705507993} - m_Enabled: 1 - serializedVersion: 8 - m_Type: 1 - m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} - m_Intensity: 1 - m_Range: 10 - m_SpotAngle: 30 - m_CookieSize: 10 - m_Shadows: - m_Type: 2 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_Lightmapping: 1 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &705507995 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 705507993} - m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} ---- !u!1 &963194225 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 963194228} - - component: {fileID: 963194227} - - component: {fileID: 963194226} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &963194226 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 963194225} - m_Enabled: 1 ---- !u!20 &963194227 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 963194225} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} - m_projectionMatrixMode: 1 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_GateFitMode: 2 - m_FocalLength: 50 - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 0 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &963194228 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 963194225} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/X10D.Unity.Tests/Assets/Scenes/SampleScene.unity.meta b/X10D.Unity.Tests/Assets/Scenes/SampleScene.unity.meta deleted file mode 100644 index 952bd1e..0000000 --- a/X10D.Unity.Tests/Assets/Scenes/SampleScene.unity.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 9fc0d4010bbf28b4594072e72b8655ab -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/X10D.Unity.Tests/Assets/Scenes/YieldInstructionIntegrationTests.unity b/X10D.Unity.Tests/Assets/Scenes/YieldInstructionIntegrationTests.unity deleted file mode 100644 index ca0f32a..0000000 --- a/X10D.Unity.Tests/Assets/Scenes/YieldInstructionIntegrationTests.unity +++ /dev/null @@ -1,347 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!29 &1 -OcclusionCullingSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_OcclusionBakeSettings: - smallestOccluder: 5 - smallestHole: 0.25 - backfaceThreshold: 100 - m_SceneGUID: 00000000000000000000000000000000 - m_OcclusionCullingData: {fileID: 0} ---- !u!104 &2 -RenderSettings: - m_ObjectHideFlags: 0 - serializedVersion: 9 - m_Fog: 0 - m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - m_FogMode: 3 - m_FogDensity: 0.01 - m_LinearFogStart: 0 - m_LinearFogEnd: 300 - m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} - m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} - m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 1 - m_AmbientMode: 0 - m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} - m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} - m_HaloStrength: 0.5 - m_FlareStrength: 1 - m_FlareFadeSpeed: 3 - m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} - m_DefaultReflectionMode: 0 - m_DefaultReflectionResolution: 128 - m_ReflectionBounces: 1 - m_ReflectionIntensity: 1 - m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} - m_UseRadianceAmbientProbe: 0 ---- !u!157 &3 -LightmapSettings: - m_ObjectHideFlags: 0 - serializedVersion: 12 - m_GIWorkflowMode: 1 - m_GISettings: - serializedVersion: 2 - m_BounceScale: 1 - m_IndirectOutputScale: 1 - m_AlbedoBoost: 1 - m_EnvironmentLightingMode: 0 - m_EnableBakedLightmaps: 1 - m_EnableRealtimeLightmaps: 0 - m_LightmapEditorSettings: - serializedVersion: 12 - m_Resolution: 2 - m_BakeResolution: 40 - m_AtlasSize: 1024 - m_AO: 0 - m_AOMaxDistance: 1 - m_CompAOExponent: 1 - m_CompAOExponentDirect: 0 - m_ExtractAmbientOcclusion: 0 - m_Padding: 2 - m_LightmapParameters: {fileID: 0} - m_LightmapsBakeMode: 1 - m_TextureCompression: 1 - m_FinalGather: 0 - m_FinalGatherFiltering: 1 - m_FinalGatherRayCount: 256 - m_ReflectionCompression: 2 - m_MixedBakeMode: 2 - m_BakeBackend: 1 - m_PVRSampling: 1 - m_PVRDirectSampleCount: 32 - m_PVRSampleCount: 512 - m_PVRBounces: 2 - m_PVREnvironmentSampleCount: 256 - m_PVREnvironmentReferencePointCount: 2048 - m_PVRFilteringMode: 1 - m_PVRDenoiserTypeDirect: 1 - m_PVRDenoiserTypeIndirect: 1 - m_PVRDenoiserTypeAO: 1 - m_PVRFilterTypeDirect: 0 - m_PVRFilterTypeIndirect: 0 - m_PVRFilterTypeAO: 0 - m_PVREnvironmentMIS: 1 - m_PVRCulling: 1 - m_PVRFilteringGaussRadiusDirect: 1 - m_PVRFilteringGaussRadiusIndirect: 5 - m_PVRFilteringGaussRadiusAO: 2 - m_PVRFilteringAtrousPositionSigmaDirect: 0.5 - m_PVRFilteringAtrousPositionSigmaIndirect: 2 - m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ExportTrainingData: 0 - m_TrainingDataDestination: TrainingData - m_LightProbeSampleCountMultiplier: 4 - m_LightingDataAsset: {fileID: 0} - m_LightingSettings: {fileID: 0} ---- !u!196 &4 -NavMeshSettings: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_BuildSettings: - serializedVersion: 2 - agentTypeID: 0 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.4 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - minRegionArea: 2 - manualCellSize: 0 - cellSize: 0.16666667 - manualTileSize: 0 - tileSize: 256 - accuratePlacement: 0 - maxJobWorkers: 0 - preserveTilesOutsideBounds: 0 - debug: - m_Flags: 0 - m_NavMeshData: {fileID: 0} ---- !u!1 &736700400 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 736700402} - - component: {fileID: 736700401} - m_Layer: 0 - m_Name: GameObject - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &736700401 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 736700400} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 67d53e2f993d4a5ba0eb34431d1846cd, type: 3} - m_Name: - m_EditorClassIdentifier: ---- !u!4 &736700402 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 736700400} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1077233431 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1077233433} - - component: {fileID: 1077233432} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!108 &1077233432 -Light: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1077233431} - m_Enabled: 1 - serializedVersion: 10 - m_Type: 1 - m_Shape: 0 - m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} - m_Intensity: 1 - m_Range: 10 - m_SpotAngle: 30 - m_InnerSpotAngle: 21.80208 - m_CookieSize: 10 - m_Shadows: - m_Type: 2 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_CullingMatrixOverride: - e00: 1 - e01: 0 - e02: 0 - e03: 0 - e10: 0 - e11: 1 - e12: 0 - e13: 0 - e20: 0 - e21: 0 - e22: 1 - e23: 0 - e30: 0 - e31: 0 - e32: 0 - e33: 1 - m_UseCullingMatrixOverride: 0 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingLayerMask: 1 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} - m_UseBoundingSphereOverride: 0 - m_UseViewFrustumForShadowCasterCull: 1 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &1077233433 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1077233431} - m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} ---- !u!1 &1698122894 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1698122897} - - component: {fileID: 1698122896} - - component: {fileID: 1698122895} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &1698122895 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1698122894} - m_Enabled: 1 ---- !u!20 &1698122896 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1698122894} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} - m_projectionMatrixMode: 1 - m_GateFitMode: 2 - m_FOVAxisMode: 0 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_FocalLength: 50 - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 0 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &1698122897 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1698122894} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/X10D.Unity.Tests/Assets/Scenes/YieldInstructionIntegrationTests.unity.meta b/X10D.Unity.Tests/Assets/Scenes/YieldInstructionIntegrationTests.unity.meta deleted file mode 100644 index 3499fd2..0000000 --- a/X10D.Unity.Tests/Assets/Scenes/YieldInstructionIntegrationTests.unity.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: b95b5f3924bd65b4bb0b7703abdd4fe5 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/X10D.Unity.Tests/Assets/Tests.meta b/X10D.Unity.Tests/Assets/Tests.meta deleted file mode 100644 index 01f5869..0000000 --- a/X10D.Unity.Tests/Assets/Tests.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 478095eaef020f34ea189f98c9369aab -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/X10D.Unity.Tests/Assets/Tests/ComponentTests.cs b/X10D.Unity.Tests/Assets/Tests/ComponentTests.cs deleted file mode 100644 index 126e435..0000000 --- a/X10D.Unity.Tests/Assets/Tests/ComponentTests.cs +++ /dev/null @@ -1,31 +0,0 @@ -#nullable enable - -using System.Collections; -using NUnit.Framework; -using UnityEngine; -using UnityEngine.TestTools; -using Object = UnityEngine.Object; - -namespace X10D.Unity.Tests -{ - public class ComponentTests - { - [Test] - public void GetComponentsInChildrenOnly_ShouldIgnoreParent() - { - var parent = new GameObject(); - var rigidbody = parent.AddComponent(); - - var child = new GameObject(); - child.transform.SetParent(parent.transform); - child.AddComponent(); - - Rigidbody[] components = rigidbody.GetComponentsInChildrenOnly(); - Assert.That(components, Has.Length.EqualTo(1)); - Assert.That(child, Is.EqualTo(components[0].gameObject)); - - Object.Destroy(parent); - Object.Destroy(child); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/ComponentTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/ComponentTests.cs.meta deleted file mode 100644 index a5fe42b..0000000 --- a/X10D.Unity.Tests/Assets/Tests/ComponentTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0619dbb274114e4aa247ed8f4e7cff03 -timeCreated: 1652006240 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/DebugUtilityIntegrationTests.cs b/X10D.Unity.Tests/Assets/Tests/DebugUtilityIntegrationTests.cs deleted file mode 100644 index 157f6a9..0000000 --- a/X10D.Unity.Tests/Assets/Tests/DebugUtilityIntegrationTests.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using UnityEngine; -using X10D.Drawing; -using X10D.Unity.Drawing; -using Color = UnityEngine.Color; - -namespace X10D.Unity.Tests -{ - internal sealed class DebugUtilityIntegrationTests : MonoBehaviour - { - private void Update() - { - DebugUtility.DrawLine(Vector3.zero, Vector3.right, Color.red); - DebugUtility.DrawLine(Vector3.zero, Vector3.up, Color.green); - DebugUtility.DrawLine(Vector3.zero, Vector3.forward, Color.blue); - - DebugUtility.DrawWireCube(new Vector3(1.5f, 0.5f, 0), Vector3.one * 0.5f, Color.yellow); - DebugUtility.DrawRectangle(new Vector2(-1.5f, 0.5f), Vector2.one * -0.5f, Color.cyan); - - var circle = new CircleF(0.0f, 0.0f, 0.5f); - DebugUtility.DrawCircle(circle, 25, new Vector2(-3.0f, 0.5f), Color.magenta); - - var ellipse = new EllipseF(0.0f, 0.0f, 1.0f, 0.5f); - DebugUtility.DrawEllipse(ellipse, 25, new Vector2(0.0f, 1.5f), Color.white); - - var hexagon = new PolygonF(); - hexagon.AddVertex(new Vector2(-0.5f, 0.5f)); - hexagon.AddVertex(new Vector2(-0.25f, 1.0f)); - hexagon.AddVertex(new Vector2(0.25f, 1.0f)); - hexagon.AddVertex(new Vector2(0.5f, 0.5f)); - hexagon.AddVertex(new Vector2(0.25f, 0)); - hexagon.AddVertex(new Vector2(-0.25f, 0)); - DebugUtility.DrawPolygon(hexagon, new Vector2(3.0f, 0.0f), Color.white); - - var sphere = new Sphere(System.Numerics.Vector3.Zero, 0.5f); - DebugUtility.DrawSphere(sphere, 25, new Vector2(0.0f, -1.5f), Color.white); - - DebugUtility.DrawFunction(x => MathF.Sin(x + UnityEngine.Time.time % (2 * MathF.PI)), -10, 10, 0.1f, Vector3.up * 4, - Color.yellow, 0.0f, false); - - DebugUtility.Assert(true); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/DebugUtilityIntegrationTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/DebugUtilityIntegrationTests.cs.meta deleted file mode 100644 index 197dc9b..0000000 --- a/X10D.Unity.Tests/Assets/Tests/DebugUtilityIntegrationTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0fac6b15ed0b420ba300fc1ac10ef01a -timeCreated: 1654080788 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing.meta b/X10D.Unity.Tests/Assets/Tests/Drawing.meta deleted file mode 100644 index 43ccd4b..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 9674f5a2171d4c7d88cbfe9f1249bb27 -timeCreated: 1652006440 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/Color32Tests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/Color32Tests.cs deleted file mode 100644 index eb2e7c2..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/Color32Tests.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using NUnit.Framework; -using UnityEngine; -using X10D.Unity.Drawing; - -namespace X10D.Unity.Tests.Drawing -{ - public class Color32Tests - { - private static readonly Color32 Black = new(0, 0, 0, 255); - private static readonly Color32 White = new(255, 255, 255, 255); - private static readonly Color32 Red = new(255, 0, 0, 255); - private static readonly Color32 Green = new(0, 255, 0, 255); - private static readonly Color32 Blue = new(0, 0, 255, 255); - private static readonly Color32 Cyan = new(0, 255, 255, 255); - private static readonly Color32 Magenta = new(255, 0, 255, 255); - private static readonly Color32 Yellow = new(255, 255, 0, 255); - - [Test] - public void Deconstruct_ShouldDeconstruct_ToCorrectValues() - { - byte a, r, g, b; - - (r, g, b) = White; - Assert.That(r, Is.EqualTo(255)); - Assert.That(g, Is.EqualTo(255)); - Assert.That(b, Is.EqualTo(255)); - - (a, r, g, b) = Yellow; - Assert.That(a, Is.EqualTo(255)); - Assert.That(r, Is.EqualTo(255)); - Assert.That(g, Is.EqualTo(255)); - Assert.That(b, Is.EqualTo(0)); - } - - [Test] - public void GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor() - { - // I know it's just casting... but aim for 100% coverage babyyyy - - Assert.That(((Color32)Color.red).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Red)); - Assert.That(((Color32)Color.green).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Green)); - Assert.That(((Color32)Color.blue).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Blue)); - Assert.That(((Color32)Color.white).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.White)); - Assert.That(((Color32)Color.black).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Black)); - Assert.That(((Color32)Color.yellow).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Yellow)); - Assert.That(((Color32)Color.cyan).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Cyan)); - Assert.That(((Color32)Color.magenta).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Magenta)); - Assert.That(((Color32)Color.gray).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Gray)); - Assert.That(((Color32)Color.grey).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Gray)); - Assert.That(((Color32)Color.clear).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Black)); - } - - [Test] - public void Inverted_ShouldReturnInvertedColor() - { - Assert.That(Black.Inverted(), Is.EqualTo(White)); - Assert.That(White.Inverted(), Is.EqualTo(Black)); - Assert.That(Cyan.Inverted(), Is.EqualTo(Red)); - Assert.That(Red.Inverted(), Is.EqualTo(Cyan)); - Assert.That(Magenta.Inverted(), Is.EqualTo(Green)); - Assert.That(Green.Inverted(), Is.EqualTo(Magenta)); - Assert.That(Blue.Inverted(), Is.EqualTo(Yellow)); - Assert.That(Yellow.Inverted(), Is.EqualTo(Blue)); - } - - [Test] - public void Inverted_ShouldIgnoreAlpha() - { - var expected = new Color32(0, 0, 0, 255); - var actual = new Color32(255, 255, 255, 255).Inverted(); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void ToSystemDrawingColor_ShouldReturnEquivalentColor() - { - System.Drawing.Color expected = System.Drawing.Color.FromArgb(255, 255, 255); - System.Drawing.Color actual = White.ToSystemDrawingColor(); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void ToUnityColor32_ShouldReturnEquivalentColor() - { - Color32 expected = White; - Color32 actual = System.Drawing.Color.FromArgb(255, 255, 255).ToUnityColor32(); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void WithA0_ShouldReturnSameColor_GivenWhite() - { - var transparent = new Color32(255, 255, 255, 0); - Assert.That(White.WithA(0), Is.EqualTo(transparent)); - Assert.That(transparent.WithA(0), Is.EqualTo(transparent)); - } - - [Test] - public void WithB0_ShouldReturnYellow_GivenWhite() - { - Assert.That(White.WithB(0), Is.EqualTo(Yellow)); - Assert.That(Yellow.WithB(0), Is.EqualTo(Yellow)); - } - - [Test] - public void WithG0_ShouldReturnMagenta_GivenWhite() - { - Assert.That(White.WithG(0), Is.EqualTo(Magenta)); - Assert.That(Magenta.WithG(0), Is.EqualTo(Magenta)); - } - - [Test] - public void WithR0_ShouldReturnCyan_GivenWhite() - { - Assert.That(White.WithR(0), Is.EqualTo(Cyan)); - Assert.That(Cyan.WithR(0), Is.EqualTo(Cyan)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/Color32Tests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/Color32Tests.cs.meta deleted file mode 100644 index 6a819da..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/Color32Tests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 877c5a68b0dd44c68aae01463ae26b26 -timeCreated: 1652035626 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/ColorTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/ColorTests.cs deleted file mode 100644 index c9d9182..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/ColorTests.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using NUnit.Framework; -using UnityEngine; -using X10D.Unity.Drawing; - -namespace X10D.Unity.Tests.Drawing -{ - public class ColorTests - { - private static readonly Color Black = new(0, 0, 0); - private static readonly Color White = new(1, 1, 1); - private static readonly Color Red = new(1, 0, 0); - private static readonly Color Green = new(0, 1, 0); - private static readonly Color Blue = new(0, 0, 1); - private static readonly Color Cyan = new(0, 1, 1); - private static readonly Color Magenta = new(1, 0, 1); - private static readonly Color Yellow = new(1, 1, 0); - - [Test] - public void Deconstruct_ShouldDeconstruct_ToCorrectValues() - { - float a, r, g, b; - - (r, g, b) = White; - Assert.That(r, Is.EqualTo(1.0f)); - Assert.That(g, Is.EqualTo(1.0f)); - Assert.That(b, Is.EqualTo(1.0f)); - - (a, r, g, b) = Yellow; - Assert.That(a, Is.EqualTo(1.0f)); - Assert.That(r, Is.EqualTo(1.0f)); - Assert.That(g, Is.EqualTo(1.0f)); - Assert.That(b, Is.EqualTo(0.0f)); - } - - [Test] - public void GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor() - { - Assert.That(Color.red.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Red)); - Assert.That(Color.green.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Green)); - Assert.That(Color.blue.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Blue)); - Assert.That(Color.white.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.White)); - Assert.That(Color.black.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Black)); - Assert.That(Color.yellow.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Yellow)); - Assert.That(Color.cyan.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Cyan)); - Assert.That(Color.magenta.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Magenta)); - Assert.That(Color.gray.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Gray)); - Assert.That(Color.grey.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Gray)); - Assert.That(Color.clear.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Black)); - } - - [Test] - public void Inverted_ShouldReturnInvertedColor() - { - Assert.That(Black.Inverted(), Is.EqualTo(White)); - Assert.That(White.Inverted(), Is.EqualTo(Black)); - Assert.That(Cyan.Inverted(), Is.EqualTo(Red)); - Assert.That(Red.Inverted(), Is.EqualTo(Cyan)); - Assert.That(Magenta.Inverted(), Is.EqualTo(Green)); - Assert.That(Green.Inverted(), Is.EqualTo(Magenta)); - Assert.That(Blue.Inverted(), Is.EqualTo(Yellow)); - Assert.That(Yellow.Inverted(), Is.EqualTo(Blue)); - } - - [Test] - public void Inverted_ShouldIgnoreAlpha() - { - var expected = new Color(0, 0, 0, 1); - var actual = new Color(1, 1, 1, 1).Inverted(); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void ToSystemDrawingColor_ShouldReturnEquivalentColor() - { - System.Drawing.Color expected = System.Drawing.Color.FromArgb(255, 255, 255); - System.Drawing.Color actual = White.ToSystemDrawingColor(); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void ToUnityColor_ShouldReturnEquivalentColor() - { - Color expected = White; - Color actual = System.Drawing.Color.FromArgb(255, 255, 255).ToUnityColor(); - - Assert.That(actual, Is.EqualTo(expected)); - } - - [Test] - public void WithA0_ShouldReturnSameColor_GivenWhite() - { - var transparent = new Color(1, 1, 1, 0); - Assert.That(White.WithA(0), Is.EqualTo(transparent)); - Assert.That(transparent.WithA(0), Is.EqualTo(transparent)); - } - - [Test] - public void WithB0_ShouldReturnYellow_GivenWhite() - { - Assert.That(White.WithB(0), Is.EqualTo(Yellow)); - Assert.That(Yellow.WithB(0), Is.EqualTo(Yellow)); - } - - [Test] - public void WithG0_ShouldReturnMagenta_GivenWhite() - { - Assert.That(White.WithG(0), Is.EqualTo(Magenta)); - Assert.That(Magenta.WithG(0), Is.EqualTo(Magenta)); - } - - [Test] - public void WithR0_ShouldReturnCyan_GivenWhite() - { - Assert.That(White.WithR(0), Is.EqualTo(Cyan)); - Assert.That(Cyan.WithR(0), Is.EqualTo(Cyan)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/ColorTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/ColorTests.cs.meta deleted file mode 100644 index 8ab4670..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/ColorTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 61df0ae6778a4ab084e688f13adfc29c -timeCreated: 1652035747 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs deleted file mode 100644 index 13d0b36..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Drawing; -using NUnit.Framework; -using X10D.Core; -using X10D.Unity.Drawing; - -namespace X10D.Unity.Tests.Drawing -{ - public class PointFTests - { - [Test] - public void ToUnityVector2_ShouldReturnVector_WithEquivalentMembers() - { - var random = new Random(); - var point = new PointF(random.NextSingle(), random.NextSingle()); - var vector = point.ToUnityVector2(); - - Assert.That(vector.x, Is.EqualTo(point.X).Within(1e-6f)); - Assert.That(vector.y, Is.EqualTo(point.Y).Within(1e-6f)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs.meta deleted file mode 100644 index 751b242..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d90695756d1d4760aef2523486b1b41e -timeCreated: 1653743243 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs deleted file mode 100644 index ab8a428..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Drawing; -using NUnit.Framework; -using X10D.Unity.Drawing; - -namespace X10D.Unity.Tests.Drawing -{ - public class PointTests - { - [Test] - public void ToUnityVector2_ShouldReturnVector_WithEquivalentMembers() - { - var random = new Random(); - var point = new Point(random.Next(), random.Next()); - var vector = point.ToUnityVector2(); - - Assert.That(vector.x, Is.EqualTo(point.X)); - Assert.That(vector.y, Is.EqualTo(point.Y)); - } - - [Test] - public void ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers() - { - var random = new Random(); - var point = new Point(random.Next(), random.Next()); - var vector = point.ToUnityVector2Int(); - - Assert.That(vector.x, Is.EqualTo(point.X)); - Assert.That(vector.y, Is.EqualTo(point.Y)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs.meta deleted file mode 100644 index 8a5fdf4..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f465794fdc394d05a34229f34e5199e2 -timeCreated: 1653742987 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RandomTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RandomTests.cs deleted file mode 100644 index 5f4e842..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RandomTests.cs +++ /dev/null @@ -1,77 +0,0 @@ -#nullable enable - -using System; -using NUnit.Framework; -using UnityEngine; -using X10D.Unity.Drawing; -using Random = System.Random; - -namespace X10D.Unity.Tests.Drawing -{ - public class RandomTests - { - [Test] - public void NextColorArgb_ShouldReturn331515e5_GivenSeed1234() - { - var random = new Random(1234); - var color = random.NextColorArgb(); - Assert.That(color.r, Is.EqualTo(0.373868465f).Within(1e-6f)); - Assert.That(color.g, Is.EqualTo(0.391597569f).Within(1e-6f)); - Assert.That(color.b, Is.EqualTo(0.675019085f).Within(1e-6f)); - Assert.That(color.a, Is.EqualTo(0.234300315f).Within(1e-6f)); - } - - [Test] - public void NextColorArgb_ShouldThrow_GivenNull() - { - Random random = null!; - Assert.Throws(() => random.NextColorArgb()); - } - - [Test] - public void NextColor32Argb_ShouldReturn331515e5_GivenSeed1234() - { - var random = new Random(1234); - Assert.That(random.NextColor32Argb(), Is.EqualTo(new Color32(21, 21, 229, 51))); - } - - [Test] - public void NextColor32Argb_ShouldThrow_GivenNull() - { - Random random = null!; - Assert.Throws(() => random.NextColor32Argb()); - } - - [Test] - public void NextColorRgb_ShouldReturn1515e5_GivenSeed1234() - { - var random = new Random(1234); - var color = random.NextColorRgb(); - Assert.That(color.r, Is.EqualTo(0.234300315f).Within(1e-6f)); - Assert.That(color.g, Is.EqualTo(0.373868465f).Within(1e-6f)); - Assert.That(color.b, Is.EqualTo(0.391597569f).Within(1e-6f)); - Assert.That(color.a, Is.EqualTo(1).Within(1e-6f)); - } - - [Test] - public void NextColorRgb_ShouldThrow_GivenNull() - { - Random random = null!; - Assert.Throws(() => random.NextColorRgb()); - } - - [Test] - public void NextColor32Rgb_ShouldReturn1515e5_GivenSeed1234() - { - var random = new Random(1234); - Assert.That(random.NextColor32Rgb(), Is.EqualTo(new Color32(21, 21, 229, 255))); - } - - [Test] - public void NextColor32Rgb_ShouldThrow_GivenNull() - { - Random random = null!; - Assert.Throws(() => random.NextColor32Rgb()); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RandomTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/RandomTests.cs.meta deleted file mode 100644 index d190fdb..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RandomTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 28fa03c101834cd79774d8138b9d4adb -timeCreated: 1652006445 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectIntTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RectIntTests.cs deleted file mode 100644 index 2e5f759..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectIntTests.cs +++ /dev/null @@ -1,36 +0,0 @@ -using NUnit.Framework; -using UnityEngine; -using X10D.Unity.Drawing; -using Random = System.Random; - -namespace X10D.Unity.Tests.Drawing -{ - public class RectIntTests - { - [Test] - public void ToSystemRectangle_ShouldReturnRectangleF_WithEquivalentMembers() - { - var random = new Random(); - var rect = new RectInt(random.Next(), random.Next(), random.Next(), random.Next()); - var rectangle = rect.ToSystemRectangle(); - - Assert.That(rectangle.X, Is.EqualTo(rect.x)); - Assert.That(rectangle.Y, Is.EqualTo(rect.y)); - Assert.That(rectangle.Width, Is.EqualTo(rect.width)); - Assert.That(rectangle.Height, Is.EqualTo(rect.height)); - } - - [Test] - public void ToSystemRectangleF_ShouldReturnRectangleF_WithEquivalentMembers() - { - var random = new Random(); - var rect = new RectInt(random.Next(), random.Next(), random.Next(), random.Next()); - var rectangle = rect.ToSystemRectangleF(); - - Assert.That(rectangle.X, Is.EqualTo(rect.x)); - Assert.That(rectangle.Y, Is.EqualTo(rect.y)); - Assert.That(rectangle.Width, Is.EqualTo(rect.width)); - Assert.That(rectangle.Height, Is.EqualTo(rect.height)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectIntTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/RectIntTests.cs.meta deleted file mode 100644 index 462b6b5..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectIntTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 18f2e8fbc200475ca5fe7857a457a874 -timeCreated: 1654077768 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs deleted file mode 100644 index 9cc688e..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs +++ /dev/null @@ -1,24 +0,0 @@ -using NUnit.Framework; -using UnityEngine; -using X10D.Core; -using X10D.Unity.Drawing; -using Random = System.Random; - -namespace X10D.Unity.Tests.Drawing -{ - public class RectTests - { - [Test] - public void ToSystemRectangleF_ShouldReturnRectangleF_WithEquivalentMembers() - { - var random = new Random(); - var rect = new Rect(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle()); - var rectangle = rect.ToSystemRectangleF(); - - Assert.That(rectangle.X, Is.EqualTo(rect.x).Within(1e-6f)); - Assert.That(rectangle.Y, Is.EqualTo(rect.y).Within(1e-6f)); - Assert.That(rectangle.Width, Is.EqualTo(rect.width).Within(1e-6f)); - Assert.That(rectangle.Height, Is.EqualTo(rect.height).Within(1e-6f)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs.meta deleted file mode 100644 index ee14568..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: bb1ec5372c354f06b39e03649b9307db -timeCreated: 1653743583 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs deleted file mode 100644 index fdcbaf6..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Drawing; -using NUnit.Framework; -using X10D.Core; -using X10D.Unity.Drawing; -using Random = System.Random; - -namespace X10D.Unity.Tests.Drawing -{ - public class RectangleFTests - { - [Test] - public void ToUnityRect_ShouldReturnRect_WithEquivalentMembers() - { - var random = new Random(); - var rectangle = new RectangleF(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle()); - var rect = rectangle.ToUnityRect(); - - Assert.That(rect.x, Is.EqualTo(rectangle.X).Within(1e-6f)); - Assert.That(rect.y, Is.EqualTo(rectangle.Y).Within(1e-6f)); - Assert.That(rect.width, Is.EqualTo(rectangle.Width).Within(1e-6f)); - Assert.That(rect.height, Is.EqualTo(rectangle.Height).Within(1e-6f)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs.meta deleted file mode 100644 index 8cec772..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f38cbc892021405cad2b52de1f960a00 -timeCreated: 1653743640 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs deleted file mode 100644 index 3f0f051..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Drawing; -using NUnit.Framework; -using X10D.Unity.Drawing; -using Random = System.Random; - -namespace X10D.Unity.Tests.Drawing -{ - public class RectangleTests - { - [Test] - public void ToUnityRect_ShouldReturnRect_WithEquivalentMembers() - { - var random = new Random(); - var rectangle = new Rectangle(random.Next(), random.Next(), random.Next(), random.Next()); - var rect = rectangle.ToUnityRect(); - - Assert.That(rect.x, Is.EqualTo(rectangle.X)); - Assert.That(rect.y, Is.EqualTo(rectangle.Y)); - Assert.That(rect.width, Is.EqualTo(rectangle.Width)); - Assert.That(rect.height, Is.EqualTo(rectangle.Height)); - } - - [Test] - public void ToUnityRectInt_ShouldReturnRect_WithEquivalentMembers() - { - var random = new Random(); - var rectangle = new Rectangle(random.Next(), random.Next(), random.Next(), random.Next()); - var rect = rectangle.ToUnityRectInt(); - - Assert.That(rect.x, Is.EqualTo(rectangle.X)); - Assert.That(rect.y, Is.EqualTo(rectangle.Y)); - Assert.That(rect.width, Is.EqualTo(rectangle.Width)); - Assert.That(rect.height, Is.EqualTo(rectangle.Height)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs.meta deleted file mode 100644 index 2551e69..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 9c74177035d1452a8a7ca08c0a27124b -timeCreated: 1653743677 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs deleted file mode 100644 index 6d871d6..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Drawing; -using NUnit.Framework; -using X10D.Core; -using X10D.Unity.Drawing; - -namespace X10D.Unity.Tests.Drawing -{ - public class SizeFTests - { - [Test] - public void ToUnityVector2_ShouldReturnVector_WithEquivalentMembers() - { - var random = new Random(); - var size = new SizeF(random.NextSingle(), random.NextSingle()); - var vector = size.ToUnityVector2(); - - Assert.That(vector.x, Is.EqualTo(size.Width).Within(1e-6f)); - Assert.That(vector.y, Is.EqualTo(size.Height).Within(1e-6f)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs.meta deleted file mode 100644 index ac99418..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: b93fe56510de4ddcb9354bde7f10c362 -timeCreated: 1653743377 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs deleted file mode 100644 index c9619c9..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Drawing; -using NUnit.Framework; -using X10D.Unity.Drawing; - -namespace X10D.Unity.Tests.Drawing -{ - public class SizeTests - { - [Test] - public void ToUnityVector2_ShouldReturnVector_WithEquivalentMembers() - { - var random = new Random(); - var size = new Size(random.Next(), random.Next()); - var vector = size.ToUnityVector2(); - - Assert.That(vector.x, Is.EqualTo(size.Width)); - Assert.That(vector.y, Is.EqualTo(size.Height)); - } - - [Test] - public void ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers() - { - var random = new Random(); - var size = new Size(random.Next(), random.Next()); - var vector = size.ToUnityVector2Int(); - - Assert.That(vector.x, Is.EqualTo(size.Width)); - Assert.That(vector.y, Is.EqualTo(size.Height)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs.meta deleted file mode 100644 index 572e5f7..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: c748bfe02fce4b459df7ef2779c2a486 -timeCreated: 1653743400 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/GameObjectTests.cs b/X10D.Unity.Tests/Assets/Tests/GameObjectTests.cs deleted file mode 100644 index 565d455..0000000 --- a/X10D.Unity.Tests/Assets/Tests/GameObjectTests.cs +++ /dev/null @@ -1,116 +0,0 @@ -#nullable enable - -using System.Diagnostics.CodeAnalysis; -using NUnit.Framework; -using UnityEngine; -using Object = UnityEngine.Object; - -namespace X10D.Unity.Tests -{ - public class GameObjectTests - { - [Test] - public void GetComponentsInChildrenOnly_ShouldIgnoreParent() - { - var parent = new GameObject(); - parent.AddComponent(); - - var child = new GameObject(); - child.transform.SetParent(parent.transform); - child.AddComponent(); - - Rigidbody[] components = parent.GetComponentsInChildrenOnly(); - Assert.That(components, Has.Length.EqualTo(1)); - Assert.That(child, Is.EqualTo(components[0].gameObject)); - - Object.Destroy(parent); - Object.Destroy(child); - } - - [Test] - [SuppressMessage("ReSharper", "Unity.InefficientPropertyAccess", Justification = "False positive.")] - public void LookAt_ShouldRotateSameAsTransform() - { - var first = new GameObject {transform = {position = Vector3.zero, rotation = Quaternion.identity}}; - var second = new GameObject {transform = {position = Vector3.right, rotation = Quaternion.identity}}; - Transform firstTransform = first.transform; - Transform secondTransform = second.transform; - - Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity)); - Assert.That(secondTransform.rotation, Is.EqualTo(Quaternion.identity)); - - firstTransform.LookAt(secondTransform); - Quaternion expected = firstTransform.rotation; - - firstTransform.rotation = Quaternion.identity; - Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity)); - - first.LookAt(second); - Assert.That(firstTransform.rotation, Is.EqualTo(expected)); - - firstTransform.rotation = Quaternion.identity; - Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity)); - - first.LookAt(second.transform); - Assert.That(firstTransform.rotation, Is.EqualTo(expected)); - - firstTransform.rotation = Quaternion.identity; - Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity)); - - first.LookAt(Vector3.right); - Assert.That(firstTransform.rotation, Is.EqualTo(expected)); - - Object.Destroy(first); - Object.Destroy(second); - } - - [Test] - public void SetLayerRecursively_ShouldSetLayerRecursively() - { - var parent = new GameObject(); - var child = new GameObject(); - var grandChild = new GameObject(); - - child.transform.SetParent(parent.transform); - grandChild.transform.SetParent(child.transform); - - int layer = LayerMask.NameToLayer("UI"); - Assert.AreNotEqual(layer, parent.layer); - Assert.AreNotEqual(layer, child.layer); - Assert.AreNotEqual(layer, grandChild.layer); - - parent.SetLayerRecursively(layer); - - Assert.That(parent.layer, Is.EqualTo(layer)); - Assert.That(child.layer, Is.EqualTo(layer)); - Assert.That(grandChild.layer, Is.EqualTo(layer)); - - Object.Destroy(parent); - Object.Destroy(child); - Object.Destroy(grandChild); - } - - [Test] - [SuppressMessage("ReSharper", "Unity.InefficientPropertyAccess", Justification = "False positive.")] - public void SetParent_ShouldSetParent() - { - var first = new GameObject {transform = {position = Vector3.zero, rotation = Quaternion.identity}}; - var second = new GameObject {transform = {position = Vector3.right, rotation = Quaternion.identity}}; - - Assert.That(first.transform.parent, Is.EqualTo(null)); - Assert.That(second.transform.parent, Is.EqualTo(null)); - - first.SetParent(second); - Assert.That(first.transform.parent, Is.EqualTo(second.transform)); - - first.transform.SetParent(null!); - Assert.That(first.transform.parent, Is.EqualTo(null)); - - second.SetParent(first); - Assert.That(second.transform.parent, Is.EqualTo(first.transform)); - - Object.Destroy(first); - Object.Destroy(second); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/GameObjectTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/GameObjectTests.cs.meta deleted file mode 100644 index 7cad365..0000000 --- a/X10D.Unity.Tests/Assets/Tests/GameObjectTests.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1fde6c311eaec944abe1e4531a2980bc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics.meta b/X10D.Unity.Tests/Assets/Tests/Numerics.meta deleted file mode 100644 index 3410bae..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: c906e39e3c8d44c7a8dafe042fedf677 -timeCreated: 1652006420 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/QuaternionTests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/QuaternionTests.cs deleted file mode 100644 index c5ec037..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/QuaternionTests.cs +++ /dev/null @@ -1,47 +0,0 @@ -using NUnit.Framework; -using UnityEngine; -using X10D.Core; -using X10D.Unity.Numerics; -using Random = System.Random; - -namespace X10D.Unity.Tests.Numerics -{ - public class QuaternionTests - { - [Test] - public void ToSystemQuaternion_ShouldReturnQuaternion_WithEqualComponents() - { - var random = new Random(); - float x = random.NextSingle(); - float y = random.NextSingle(); - float z = random.NextSingle(); - float w = random.NextSingle(); - - var quaternion = new Quaternion(x, y, z, w); - var systemQuaternion = quaternion.ToSystemQuaternion(); - - Assert.That(systemQuaternion.X, Is.EqualTo(quaternion.x).Within(1e-6f)); - Assert.That(systemQuaternion.Y, Is.EqualTo(quaternion.y).Within(1e-6f)); - Assert.That(systemQuaternion.Z, Is.EqualTo(quaternion.z).Within(1e-6f)); - Assert.That(systemQuaternion.W, Is.EqualTo(quaternion.w).Within(1e-6f)); - } - - [Test] - public void ToUnityQuaternion_ShouldReturnQuaternion_WithEqualComponents() - { - var random = new Random(); - float x = random.NextSingle(); - float y = random.NextSingle(); - float z = random.NextSingle(); - float w = random.NextSingle(); - - var quaternion = new System.Numerics.Quaternion(x, y, z, w); - var unityQuaternion = quaternion.ToUnityQuaternion(); - - Assert.That(unityQuaternion.x, Is.EqualTo(quaternion.X).Within(1e-6f)); - Assert.That(unityQuaternion.y, Is.EqualTo(quaternion.Y).Within(1e-6f)); - Assert.That(unityQuaternion.z, Is.EqualTo(quaternion.Z).Within(1e-6f)); - Assert.That(unityQuaternion.w, Is.EqualTo(quaternion.W).Within(1e-6f)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/QuaternionTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Numerics/QuaternionTests.cs.meta deleted file mode 100644 index a8117be..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/QuaternionTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: a395fec41c5a4e9d9ffb05324e8159b0 -timeCreated: 1652124913 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/RandomTests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/RandomTests.cs deleted file mode 100644 index d93744a..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/RandomTests.cs +++ /dev/null @@ -1,55 +0,0 @@ -#nullable enable - -using System; -using NUnit.Framework; -using X10D.Unity.Numerics; - -namespace X10D.Unity.Tests.Numerics -{ - public class RandomTests - { - [Test] - public void NextUnitVector2_ShouldReturnVector_WithMagnitude1() - { - var random = new Random(); - var vector = random.NextUnitVector2(); - Assert.That(vector.magnitude, Is.EqualTo(1).Within(1e-6)); - } - - [Test] - public void NextUnitVector2_ShouldThrow_GivenNullRandom() - { - Random random = null!; - Assert.Throws(() => random.NextUnitVector2()); - } - - [Test] - public void NextUnitVector3_ShouldReturnVector_WithMagnitude1() - { - var random = new Random(); - var vector = random.NextUnitVector3(); - Assert.That(vector.magnitude, Is.EqualTo(1).Within(1e-6)); - } - - [Test] - public void NextUnitVector3_ShouldThrow_GivenNullRandom() - { - Random random = null!; - Assert.Throws(() => random.NextUnitVector3()); - } - - [Test] - public void NextRotation_ShouldThrow_GivenNullRandom() - { - Random random = null!; - Assert.Throws(() => random.NextRotation()); - } - - [Test] - public void NextRotationUniform_ShouldThrow_GivenNullRandom() - { - Random random = null!; - Assert.Throws(() => random.NextRotationUniform()); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/RandomTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Numerics/RandomTests.cs.meta deleted file mode 100644 index f143424..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/RandomTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 74577fe33f85446194c4ae2315caaace -timeCreated: 1652006301 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2IntTests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2IntTests.cs deleted file mode 100644 index 6ef0909..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2IntTests.cs +++ /dev/null @@ -1,76 +0,0 @@ -using NUnit.Framework; -using UnityEngine; -using X10D.Unity.Numerics; -using Random = System.Random; - -namespace X10D.Unity.Tests.Numerics -{ - public class Vector2IntTests - { - [Test] - public void Deconstruct_ShouldReturnCorrectValues() - { - var vector = new Vector2Int(1, 2); - (int x, int y) = vector; - - Assert.That(x, Is.EqualTo(1)); - Assert.That(y, Is.EqualTo(2)); - } - - [Test] - public void ToSystemPoint_ShouldReturnPoint_WithEquivalentMembers() - { - var random = new Random(); - int x = random.Next(); - int y = random.Next(); - - var vector = new Vector2Int(x, y); - var point = vector.ToSystemPoint(); - - Assert.That(point.X, Is.EqualTo(vector.x)); - Assert.That(point.Y, Is.EqualTo(vector.y)); - } - - [Test] - public void ToSystemSize_ShouldReturnSize_WithEquivalentMembers() - { - var random = new Random(); - int x = random.Next(); - int y = random.Next(); - - var vector = new Vector2Int(x, y); - var point = vector.ToSystemSize(); - - Assert.That(point.Width, Is.EqualTo(vector.x)); - Assert.That(point.Height, Is.EqualTo(vector.y)); - } - - [Test] - public void WithX_ShouldReturnVectorWithNewX_GivenVector() - { - Assert.That(Vector2Int.one.WithX(0), Is.EqualTo(Vector2Int.up)); - Assert.That(Vector2Int.zero.WithX(0), Is.EqualTo(Vector2Int.zero)); - Assert.That(Vector2Int.right.WithX(0), Is.EqualTo(Vector2Int.zero)); - Assert.That(Vector2Int.up.WithX(0), Is.EqualTo(Vector2Int.up)); - - Assert.That(Vector2Int.one.WithX(1), Is.EqualTo(Vector2Int.one)); - Assert.That(Vector2Int.zero.WithX(1), Is.EqualTo(Vector2Int.right)); - Assert.That(Vector2Int.right.WithX(1), Is.EqualTo(Vector2Int.right)); - Assert.That(Vector2Int.up.WithX(1), Is.EqualTo(Vector2Int.one)); - } - - [Test] - public void WithY_ShouldReturnVectorWithNewY_GivenVector() - { - Assert.That(Vector2Int.one.WithY(0), Is.EqualTo(Vector2Int.right)); - Assert.That(Vector2Int.zero.WithY(0), Is.EqualTo(Vector2Int.zero)); - Assert.That(Vector2Int.right.WithY(0), Is.EqualTo(Vector2Int.right)); - Assert.That(Vector2Int.up.WithY(0), Is.EqualTo(Vector2Int.zero)); - - Assert.That(Vector2Int.one.WithY(1), Is.EqualTo(Vector2Int.one)); - Assert.That(Vector2Int.zero.WithY(1), Is.EqualTo(Vector2Int.up)); - Assert.That(Vector2Int.right.WithY(1), Is.EqualTo(Vector2Int.one)); - Assert.That(Vector2Int.up.WithY(1), Is.EqualTo(Vector2Int.up)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2IntTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2IntTests.cs.meta deleted file mode 100644 index 7a62c97..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2IntTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ad987e96afa849e6b0626ba7d7720f7b -timeCreated: 1653993201 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs deleted file mode 100644 index d6e5e0c..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs +++ /dev/null @@ -1,127 +0,0 @@ -using NUnit.Framework; -using UnityEngine; -using X10D.Core; -using X10D.Unity.Numerics; -using Random = System.Random; - -namespace X10D.Unity.Tests.Numerics -{ - public class Vector2Tests - { - [Test] - public void Deconstruct_ShouldReturnCorrectValues() - { - var vector = new Vector2(1, 2); - (float x, float y) = vector; - - Assert.That(x, Is.EqualTo(1)); - Assert.That(y, Is.EqualTo(2)); - } - - [Test] - public void Round_ShouldRoundToNearestInteger_GivenNoParameters() - { - var vector = new Vector2(1.5f, 2.6f); - var rounded = vector.Round(); - - Assert.That(rounded.x, Is.EqualTo(2)); - Assert.That(rounded.y, Is.EqualTo(3)); - } - - [Test] - public void Round_ShouldRoundToNearest10_GivenPrecision10() - { - var vector = new Vector2(1.5f, 25.2f); - var rounded = vector.Round(10); - - Assert.That(rounded.x, Is.EqualTo(0)); - Assert.That(rounded.y, Is.EqualTo(30)); - } - - [Test] - public void ToSystemPointF_ShouldReturnPoint_WithEquivalentMembers() - { - var random = new Random(); - float x = random.NextSingle(); - float y = random.NextSingle(); - - var vector = new Vector2(x, y); - var point = vector.ToSystemPointF(); - - Assert.That(point.X, Is.EqualTo(vector.x).Within(1e-6f)); - Assert.That(point.Y, Is.EqualTo(vector.y).Within(1e-6f)); - } - - [Test] - public void ToSystemSizeF_ShouldReturnSize_WithEquivalentMembers() - { - var random = new Random(); - float x = random.NextSingle(); - float y = random.NextSingle(); - - var vector = new Vector2(x, y); - var point = vector.ToSystemSizeF(); - - Assert.That(point.Width, Is.EqualTo(vector.x).Within(1e-6f)); - Assert.That(point.Height, Is.EqualTo(vector.y).Within(1e-6f)); - } - - [Test] - public void ToSystemVector_ShouldReturnVector_WithEqualComponents() - { - var random = new Random(); - float x = random.NextSingle(); - float y = random.NextSingle(); - - var vector = new Vector2(x, y); - var systemVector = vector.ToSystemVector(); - - Assert.That(systemVector.Length(), Is.EqualTo(vector.magnitude).Within(1e-6f)); - Assert.That(systemVector.X, Is.EqualTo(vector.x).Within(1e-6f)); - Assert.That(systemVector.Y, Is.EqualTo(vector.y).Within(1e-6f)); - } - - [Test] - public void ToUnityVector_ShouldReturnVector_WithEqualComponents() - { - var random = new Random(); - float x = random.NextSingle(); - float y = random.NextSingle(); - - var vector = new System.Numerics.Vector2(x, y); - var unityVector = vector.ToUnityVector(); - - Assert.That(unityVector.magnitude, Is.EqualTo(vector.Length()).Within(1e-6f)); - Assert.That(unityVector.x, Is.EqualTo(vector.X).Within(1e-6f)); - Assert.That(unityVector.y, Is.EqualTo(vector.Y).Within(1e-6f)); - } - - [Test] - public void WithX_ShouldReturnVectorWithNewX_GivenVector() - { - Assert.That(Vector2.one.WithX(0), Is.EqualTo(Vector2.up)); - Assert.That(Vector2.zero.WithX(0), Is.EqualTo(Vector2.zero)); - Assert.That(Vector2.right.WithX(0), Is.EqualTo(Vector2.zero)); - Assert.That(Vector2.up.WithX(0), Is.EqualTo(Vector2.up)); - - Assert.That(Vector2.one.WithX(1), Is.EqualTo(Vector2.one)); - Assert.That(Vector2.zero.WithX(1), Is.EqualTo(Vector2.right)); - Assert.That(Vector2.right.WithX(1), Is.EqualTo(Vector2.right)); - Assert.That(Vector2.up.WithX(1), Is.EqualTo(Vector2.one)); - } - - [Test] - public void WithY_ShouldReturnVectorWithNewY_GivenVector() - { - Assert.That(Vector2.one.WithY(0), Is.EqualTo(Vector2.right)); - Assert.That(Vector2.zero.WithY(0), Is.EqualTo(Vector2.zero)); - Assert.That(Vector2.right.WithY(0), Is.EqualTo(Vector2.right)); - Assert.That(Vector2.up.WithY(0), Is.EqualTo(Vector2.zero)); - - Assert.That(Vector2.one.WithY(1), Is.EqualTo(Vector2.one)); - Assert.That(Vector2.zero.WithY(1), Is.EqualTo(Vector2.up)); - Assert.That(Vector2.right.WithY(1), Is.EqualTo(Vector2.one)); - Assert.That(Vector2.up.WithY(1), Is.EqualTo(Vector2.up)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs.meta deleted file mode 100644 index 54f9a75..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 83385270996049569380ae9769ff1381 -timeCreated: 1652088132 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3IntTests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3IntTests.cs deleted file mode 100644 index acfac84..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3IntTests.cs +++ /dev/null @@ -1,69 +0,0 @@ -using NUnit.Framework; -using UnityEngine; -using X10D.Unity.Numerics; - -namespace X10D.Unity.Tests.Numerics -{ - public class Vector3IntTests - { - [Test] - public void Deconstruct_ShouldReturnCorrectValues() - { - var vector = new Vector3Int(1, 2, 3); - (float x, float y, float z) = vector; - - Assert.That(x, Is.EqualTo(1)); - Assert.That(y, Is.EqualTo(2)); - Assert.That(z, Is.EqualTo(3)); - } - - [Test] - public void WithX_ShouldReturnVectorWithNewX_GivenVector() - { - Assert.That(Vector3Int.one.WithX(0), Is.EqualTo(new Vector3Int(0, 1, 1))); - Assert.That(Vector3Int.zero.WithX(0), Is.EqualTo(Vector3Int.zero)); - Assert.That(Vector3Int.right.WithX(0), Is.EqualTo(Vector3Int.zero)); - Assert.That(Vector3Int.up.WithX(0), Is.EqualTo(Vector3Int.up)); - Assert.That(Vector3Int.forward.WithX(0), Is.EqualTo(Vector3Int.forward)); - - Assert.That(Vector3Int.one.WithX(1), Is.EqualTo(Vector3Int.one)); - Assert.That(Vector3Int.zero.WithX(1), Is.EqualTo(Vector3Int.right)); - Assert.That(Vector3Int.right.WithX(1), Is.EqualTo(Vector3Int.right)); - Assert.That(Vector3Int.up.WithX(1), Is.EqualTo(new Vector3Int(1, 1, 0))); - Assert.That(Vector3Int.forward.WithX(1), Is.EqualTo(new Vector3Int(1, 0, 1))); - } - - [Test] - public void WithY_ShouldReturnVectorWithNewY_GivenVector() - { - Assert.That(Vector3Int.one.WithY(0), Is.EqualTo(new Vector3Int(1, 0, 1))); - Assert.That(Vector3Int.zero.WithY(0), Is.EqualTo(Vector3Int.zero)); - Assert.That(Vector3Int.right.WithY(0), Is.EqualTo(Vector3Int.right)); - Assert.That(Vector3Int.up.WithY(0), Is.EqualTo(Vector3Int.zero)); - Assert.That(Vector3Int.forward.WithY(0), Is.EqualTo(Vector3Int.forward)); - - Assert.That(Vector3Int.one.WithY(1), Is.EqualTo(Vector3Int.one)); - Assert.That(Vector3Int.zero.WithY(1), Is.EqualTo(Vector3Int.up)); - Assert.That(Vector3Int.right.WithY(1), Is.EqualTo(new Vector3Int(1, 1, 0))); - Assert.That(Vector3Int.up.WithY(1), Is.EqualTo(Vector3Int.up)); - Assert.That(Vector3Int.forward.WithY(1), Is.EqualTo(new Vector3Int(0, 1, 1))); - ; - } - - [Test] - public void WithZ_ShouldReturnVectorWithNewZ_GivenVector() - { - Assert.That(Vector3Int.one.WithZ(0), Is.EqualTo(new Vector3Int(1, 1, 0))); - Assert.That(Vector3Int.zero.WithZ(0), Is.EqualTo(Vector3Int.zero)); - Assert.That(Vector3Int.right.WithZ(0), Is.EqualTo(Vector3Int.right)); - Assert.That(Vector3Int.up.WithZ(0), Is.EqualTo(Vector3Int.up)); - Assert.That(Vector3Int.forward.WithZ(0), Is.EqualTo(Vector3Int.zero)); - - Assert.That(Vector3Int.one.WithZ(1), Is.EqualTo(Vector3Int.one)); - Assert.That(Vector3Int.zero.WithZ(1), Is.EqualTo(Vector3Int.forward)); - Assert.That(Vector3Int.right.WithZ(1), Is.EqualTo(new Vector3Int(1, 0, 1))); - Assert.That(Vector3Int.up.WithZ(1), Is.EqualTo(new Vector3Int(0, 1, 1))); - Assert.That(Vector3Int.forward.WithZ(1), Is.EqualTo(Vector3Int.forward)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3IntTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3IntTests.cs.meta deleted file mode 100644 index 1959799..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3IntTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: e474d98fd3ee48159980aaa88040cfb3 -timeCreated: 1653993371 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs deleted file mode 100644 index 9d7d64a..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs +++ /dev/null @@ -1,126 +0,0 @@ -using NUnit.Framework; -using UnityEngine; -using X10D.Core; -using X10D.Unity.Numerics; -using Random = System.Random; - -namespace X10D.Unity.Tests.Numerics -{ - public class Vector3Tests - { - [Test] - public void Deconstruct_ShouldReturnCorrectValues() - { - var vector = new Vector3(1, 2, 3); - (float x, float y, float z) = vector; - - Assert.That(x, Is.EqualTo(1)); - Assert.That(y, Is.EqualTo(2)); - Assert.That(z, Is.EqualTo(3)); - } - - [Test] - public void Round_ShouldRoundToNearestInteger_GivenNoParameters() - { - var vector = new Vector3(1.5f, 2.6f, -5.2f); - var rounded = vector.Round(); - - Assert.That(rounded.x, Is.EqualTo(2)); - Assert.That(rounded.y, Is.EqualTo(3)); - Assert.That(rounded.z, Is.EqualTo(-5)); - } - - [Test] - public void Round_ShouldRoundToNearest10_GivenPrecision10() - { - var vector = new Vector3(1.5f, 25.2f, -12.5f); - var rounded = vector.Round(10); - - Assert.That(rounded.x, Is.EqualTo(0)); - Assert.That(rounded.y, Is.EqualTo(30)); - Assert.That(rounded.z, Is.EqualTo(-10)); - } - - [Test] - public void ToSystemVector_ShouldReturnVector_WithEqualComponents() - { - var random = new Random(); - float x = random.NextSingle(); - float y = random.NextSingle(); - float z = random.NextSingle(); - - var vector = new Vector3(x, y, z); - var systemVector = vector.ToSystemVector(); - - Assert.That(systemVector.Length(), Is.EqualTo(vector.magnitude).Within(1e-6f)); - Assert.That(systemVector.X, Is.EqualTo(vector.x).Within(1e-6f)); - Assert.That(systemVector.Y, Is.EqualTo(vector.y).Within(1e-6f)); - Assert.That(systemVector.Z, Is.EqualTo(vector.z).Within(1e-6f)); - } - - [Test] - public void ToUnityVector_ShouldReturnVector_WithEqualComponents() - { - var random = new Random(); - float x = random.NextSingle(); - float y = random.NextSingle(); - float z = random.NextSingle(); - - var vector = new System.Numerics.Vector3(x, y, z); - var unityVector = vector.ToUnityVector(); - - Assert.That(unityVector.magnitude, Is.EqualTo(vector.Length()).Within(1e-6f)); - Assert.That(unityVector.x, Is.EqualTo(vector.X).Within(1e-6f)); - Assert.That(unityVector.y, Is.EqualTo(vector.Y).Within(1e-6f)); - Assert.That(unityVector.z, Is.EqualTo(vector.Z).Within(1e-6f)); - } - - [Test] - public void WithX_ShouldReturnVectorWithNewX_GivenVector() - { - Assert.That(Vector3.one.WithX(0), Is.EqualTo(new Vector3(0, 1, 1))); - Assert.That(Vector3.zero.WithX(0), Is.EqualTo(Vector3.zero)); - Assert.That(Vector3.right.WithX(0), Is.EqualTo(Vector3.zero)); - Assert.That(Vector3.up.WithX(0), Is.EqualTo(Vector3.up)); - Assert.That(Vector3.forward.WithX(0), Is.EqualTo(Vector3.forward)); - - Assert.That(Vector3.one.WithX(1), Is.EqualTo(Vector3.one)); - Assert.That(Vector3.zero.WithX(1), Is.EqualTo(Vector3.right)); - Assert.That(Vector3.right.WithX(1), Is.EqualTo(Vector3.right)); - Assert.That(Vector3.up.WithX(1), Is.EqualTo(new Vector3(1, 1, 0))); - Assert.That(Vector3.forward.WithX(1), Is.EqualTo(new Vector3(1, 0, 1))); - } - - [Test] - public void WithY_ShouldReturnVectorWithNewY_GivenVector() - { - Assert.That(Vector3.one.WithY(0), Is.EqualTo(new Vector3(1, 0, 1))); - Assert.That(Vector3.zero.WithY(0), Is.EqualTo(Vector3.zero)); - Assert.That(Vector3.right.WithY(0), Is.EqualTo(Vector3.right)); - Assert.That(Vector3.up.WithY(0), Is.EqualTo(Vector3.zero)); - Assert.That(Vector3.forward.WithY(0), Is.EqualTo(Vector3.forward)); - - Assert.That(Vector3.one.WithY(1), Is.EqualTo(Vector3.one)); - Assert.That(Vector3.zero.WithY(1), Is.EqualTo(Vector3.up)); - Assert.That(Vector3.right.WithY(1), Is.EqualTo(new Vector3(1, 1, 0))); - Assert.That(Vector3.up.WithY(1), Is.EqualTo(Vector3.up)); - Assert.That(Vector3.forward.WithY(1), Is.EqualTo(new Vector3(0, 1, 1))); - } - - [Test] - public void WithZ_ShouldReturnVectorWithNewZ_GivenVector() - { - Assert.That(Vector3.one.WithZ(0), Is.EqualTo(new Vector3(1, 1, 0))); - Assert.That(Vector3.zero.WithZ(0), Is.EqualTo(Vector3.zero)); - Assert.That(Vector3.right.WithZ(0), Is.EqualTo(Vector3.right)); - Assert.That(Vector3.up.WithZ(0), Is.EqualTo(Vector3.up)); - Assert.That(Vector3.forward.WithZ(0), Is.EqualTo(Vector3.zero)); - - Assert.That(Vector3.one.WithZ(1), Is.EqualTo(Vector3.one)); - Assert.That(Vector3.zero.WithZ(1), Is.EqualTo(Vector3.forward)); - Assert.That(Vector3.right.WithZ(1), Is.EqualTo(new Vector3(1, 0, 1))); - Assert.That(Vector3.up.WithZ(1), Is.EqualTo(new Vector3(0, 1, 1))); - Assert.That(Vector3.forward.WithZ(1), Is.EqualTo(Vector3.forward)); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs.meta deleted file mode 100644 index 6255e34..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector3Tests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: a00d613201bd497d91c9e98bca8dd6b1 -timeCreated: 1652088132 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs deleted file mode 100644 index 3848db7..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs +++ /dev/null @@ -1,157 +0,0 @@ -using NUnit.Framework; -using UnityEngine; -using X10D.Core; -using X10D.Unity.Numerics; -using Random = System.Random; - -namespace X10D.Unity.Tests.Numerics -{ - public class Vector4Tests - { - [Test] - public void Deconstruct_ShouldReturnCorrectValues() - { - var vector = new Vector4(1, 2, 3, 4); - (float x, float y, float z, float w) = vector; - - Assert.That(x, Is.EqualTo(1)); - Assert.That(y, Is.EqualTo(2)); - Assert.That(z, Is.EqualTo(3)); - Assert.That(w, Is.EqualTo(4)); - } - - [Test] - public void Round_ShouldRoundToNearestInteger_GivenNoParameters() - { - var vector = new Vector4(1.5f, 2.6f, -5.2f, 0.3f); - var rounded = vector.Round(); - - Assert.That(rounded.x, Is.EqualTo(2)); - Assert.That(rounded.y, Is.EqualTo(3)); - Assert.That(rounded.z, Is.EqualTo(-5)); - Assert.That(rounded.w, Is.EqualTo(0)); - } - - [Test] - public void Round_ShouldRoundToNearest10_GivenPrecision10() - { - var vector = new Vector4(1.5f, 25.2f, -12.5f, 101.2f); - var rounded = vector.Round(10); - - Assert.That(rounded.x, Is.EqualTo(0)); - Assert.That(rounded.y, Is.EqualTo(30)); - Assert.That(rounded.z, Is.EqualTo(-10)); - Assert.That(rounded.w, Is.EqualTo(100)); - } - - [Test] - public void ToSystemVector_ShouldReturnVector_WithEqualComponents() - { - var random = new Random(); - float x = random.NextSingle(); - float y = random.NextSingle(); - float z = random.NextSingle(); - float w = random.NextSingle(); - - var vector = new Vector4(x, y, z, w); - var systemVector = vector.ToSystemVector(); - - Assert.That(systemVector.Length(), Is.EqualTo(vector.magnitude).Within(1e-6f)); - Assert.That(systemVector.X, Is.EqualTo(vector.x).Within(1e-6f)); - Assert.That(systemVector.Y, Is.EqualTo(vector.y).Within(1e-6f)); - Assert.That(systemVector.Z, Is.EqualTo(vector.z).Within(1e-6f)); - Assert.That(systemVector.W, Is.EqualTo(vector.w).Within(1e-6f)); - } - - [Test] - public void ToUnityVector_ShouldReturnVector_WithEqualComponents() - { - var random = new Random(); - float x = random.NextSingle(); - float y = random.NextSingle(); - float z = random.NextSingle(); - float w = random.NextSingle(); - - var vector = new System.Numerics.Vector4(x, y, z, w); - var unityVector = vector.ToUnityVector(); - - Assert.That(unityVector.magnitude, Is.EqualTo(vector.Length()).Within(1e-6f)); - Assert.That(unityVector.x, Is.EqualTo(vector.X).Within(1e-6f)); - Assert.That(unityVector.y, Is.EqualTo(vector.Y).Within(1e-6f)); - Assert.That(unityVector.z, Is.EqualTo(vector.Z).Within(1e-6f)); - Assert.That(unityVector.w, Is.EqualTo(vector.W).Within(1e-6f)); - } - - [Test] - public void WithW_ShouldReturnVectorWithNewW_GivenVector() - { - Assert.That(Vector4.one.WithW(0), Is.EqualTo(new Vector4(1, 1, 1, 0))); - Assert.That(Vector4.zero.WithW(0), Is.EqualTo(Vector4.zero)); - Assert.That(new Vector4(0, 0, 0, 1).WithW(0), Is.EqualTo(Vector4.zero)); - Assert.That(new Vector4(1, 0, 0, 0).WithW(0), Is.EqualTo(new Vector4(1, 0, 0, 0))); - Assert.That(new Vector4(0, 1, 0, 0).WithW(0), Is.EqualTo(new Vector4(0, 1, 0, 0))); - Assert.That(new Vector4(0, 0, 1, 0).WithW(0), Is.EqualTo(new Vector4(0, 0, 1, 0))); - - Assert.That(Vector4.one.WithW(1), Is.EqualTo(Vector4.one)); - Assert.That(Vector4.zero.WithW(1), Is.EqualTo(new Vector4(0, 0, 0, 1))); - Assert.That(new Vector4(0, 0, 0, 1).WithW(1), Is.EqualTo(new Vector4(0, 0, 0, 1))); - Assert.That(new Vector4(1, 0, 0, 0).WithW(1), Is.EqualTo(new Vector4(1, 0, 0, 1))); - Assert.That(new Vector4(0, 1, 0, 0).WithW(1), Is.EqualTo(new Vector4(0, 1, 0, 1))); - Assert.That(new Vector4(0, 0, 1, 0).WithW(1), Is.EqualTo(new Vector4(0, 0, 1, 1))); - } - - [Test] - public void WithX_ShouldReturnVectorWithNewX_GivenVector() - { - Assert.That(Vector4.one.WithX(0), Is.EqualTo(new Vector4(0, 1, 1, 1))); - Assert.That(Vector4.zero.WithX(0), Is.EqualTo(Vector4.zero)); - Assert.That(new Vector4(0, 0, 0, 1).WithX(0), Is.EqualTo(new Vector4(0, 0, 0, 1))); - Assert.That(new Vector4(1, 0, 0, 0).WithX(0), Is.EqualTo(Vector4.zero)); - Assert.That(new Vector4(0, 1, 0, 0).WithX(0), Is.EqualTo(new Vector4(0, 1, 0, 0))); - Assert.That(new Vector4(0, 0, 1, 0).WithX(0), Is.EqualTo(new Vector4(0, 0, 1, 0))); - - Assert.That(Vector4.one.WithX(1), Is.EqualTo(Vector4.one)); - Assert.That(Vector4.zero.WithX(1), Is.EqualTo(new Vector4(1, 0, 0, 0))); - Assert.That(new Vector4(0, 0, 0, 1).WithX(1), Is.EqualTo(new Vector4(1, 0, 0, 1))); - Assert.That(new Vector4(1, 0, 0, 0).WithX(1), Is.EqualTo(new Vector4(1, 0, 0, 0))); - Assert.That(new Vector4(0, 1, 0, 0).WithX(1), Is.EqualTo(new Vector4(1, 1, 0, 0))); - Assert.That(new Vector4(0, 0, 1, 0).WithX(1), Is.EqualTo(new Vector4(1, 0, 1, 0))); - } - - [Test] - public void WithY_ShouldReturnVectorWithNewY_GivenVector() - { - Assert.That(Vector4.one.WithY(0), Is.EqualTo(new Vector4(1, 0, 1, 1))); - Assert.That(Vector4.zero.WithY(0), Is.EqualTo(Vector4.zero)); - Assert.That(new Vector4(0, 0, 0, 1).WithY(0), Is.EqualTo(new Vector4(0, 0, 0, 1))); - Assert.That(new Vector4(1, 0, 0, 0).WithY(0), Is.EqualTo(new Vector4(1, 0, 0, 0))); - Assert.That(new Vector4(0, 1, 0, 0).WithY(0), Is.EqualTo(Vector4.zero)); - Assert.That(new Vector4(0, 0, 1, 0).WithY(0), Is.EqualTo(new Vector4(0, 0, 1, 0))); - - Assert.That(Vector4.one.WithY(1), Is.EqualTo(Vector4.one)); - Assert.That(Vector4.zero.WithY(1), Is.EqualTo(new Vector4(0, 1, 0, 0))); - Assert.That(new Vector4(0, 0, 0, 1).WithY(1), Is.EqualTo(new Vector4(0, 1, 0, 1))); - Assert.That(new Vector4(1, 0, 0, 0).WithY(1), Is.EqualTo(new Vector4(1, 1, 0, 0))); - Assert.That(new Vector4(0, 1, 0, 0).WithY(1), Is.EqualTo(new Vector4(0, 1, 0, 0))); - Assert.That(new Vector4(0, 0, 1, 0).WithY(1), Is.EqualTo(new Vector4(0, 1, 1, 0))); - } - - [Test] - public void WithZ_ShouldReturnVectorWithNewZ_GivenVector() - { - Assert.That(Vector4.one.WithZ(0), Is.EqualTo(new Vector4(1, 1, 0, 1))); - Assert.That(Vector4.zero.WithZ(0), Is.EqualTo(Vector4.zero)); - Assert.That(new Vector4(0, 0, 0, 1).WithZ(0), Is.EqualTo(new Vector4(0, 0, 0, 1))); - Assert.That(new Vector4(1, 0, 0, 0).WithZ(0), Is.EqualTo(new Vector4(1, 0, 0, 0))); - Assert.That(new Vector4(0, 1, 0, 0).WithZ(0), Is.EqualTo(new Vector4(0, 1, 0, 0))); - Assert.That(new Vector4(0, 0, 1, 0).WithZ(0), Is.EqualTo(Vector4.zero)); - - Assert.That(Vector4.one.WithZ(1), Is.EqualTo(Vector4.one)); - Assert.That(Vector4.zero.WithZ(1), Is.EqualTo(new Vector4(0, 0, 1, 0))); - Assert.That(new Vector4(0, 0, 0, 1).WithZ(1), Is.EqualTo(new Vector4(0, 0, 1, 1))); - Assert.That(new Vector4(1, 0, 0, 0).WithZ(1), Is.EqualTo(new Vector4(1, 0, 1, 0))); - Assert.That(new Vector4(0, 1, 0, 0).WithZ(1), Is.EqualTo(new Vector4(0, 1, 1, 0))); - Assert.That(new Vector4(0, 0, 1, 0).WithZ(1), Is.EqualTo(new Vector4(0, 0, 1, 0))); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs.meta deleted file mode 100644 index 041ceb9..0000000 --- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector4Tests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0d487c2046a64354b199f4de01d57391 -timeCreated: 1652088132 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/SingletonTests.cs b/X10D.Unity.Tests/Assets/Tests/SingletonTests.cs deleted file mode 100644 index 9e77e11..0000000 --- a/X10D.Unity.Tests/Assets/Tests/SingletonTests.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Collections; -using NUnit.Framework; -using UnityEngine; -using UnityEngine.TestTools; - -namespace X10D.Unity.Tests -{ - public class SingletonTests - { - [Test] - public void Singleton_ShouldReturnNewInstance_WhenNoInstanceExists() - { - TestBehaviour instance = Singleton.Instance; - Assert.That(instance, Is.Not.Null); - Assert.That(instance.Flag); - } - - [Test] - public void Singleton_ShouldReturnSameInstance_WhenAccessedTwice() - { - TestBehaviour instance = Singleton.Instance; - Assert.That(instance, Is.Not.Null); - Assert.That(Singleton.Instance, Is.EqualTo(instance)); - } - - [UnityTest] - public IEnumerator Singleton_ShouldReturnNewInstance_WhenDestroyed() - { - TestBehaviour instance = Singleton.Instance; - Assert.That(instance, Is.Not.Null); - Object.Destroy(instance); - - yield return null; - - Assert.IsFalse(instance); - - // ReSharper disable once HeuristicUnreachableCode - instance = Singleton.Instance; - Assert.That(instance, Is.Not.Null); - Assert.IsTrue(instance.Flag); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/SingletonTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/SingletonTests.cs.meta deleted file mode 100644 index 3f086ce..0000000 --- a/X10D.Unity.Tests/Assets/Tests/SingletonTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 5c51198d124f40859bd9298d3241d5a6 -timeCreated: 1652428949 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/TestBehaviour.cs b/X10D.Unity.Tests/Assets/Tests/TestBehaviour.cs deleted file mode 100644 index a603e1d..0000000 --- a/X10D.Unity.Tests/Assets/Tests/TestBehaviour.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace X10D.Unity.Tests -{ - internal sealed class TestBehaviour : Singleton - { - public bool Flag - { - get => true; - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/TestBehaviour.cs.meta b/X10D.Unity.Tests/Assets/Tests/TestBehaviour.cs.meta deleted file mode 100644 index bc63104..0000000 --- a/X10D.Unity.Tests/Assets/Tests/TestBehaviour.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: df932718d20948ecbe9b0de8aa7bbaf4 -timeCreated: 1652428898 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/TransformTests.cs b/X10D.Unity.Tests/Assets/Tests/TransformTests.cs deleted file mode 100644 index 5d09176..0000000 --- a/X10D.Unity.Tests/Assets/Tests/TransformTests.cs +++ /dev/null @@ -1,59 +0,0 @@ -#nullable enable - -using System.Collections; -using NUnit.Framework; -using UnityEngine; -using UnityEngine.TestTools; - -namespace X10D.Unity.Tests -{ - public class TransformTests - { - [UnityTest] - public IEnumerator LookAt_ShouldRotateSameAsTransform() - { - var first = new GameObject {transform = {position = Vector3.zero, rotation = Quaternion.identity}}; - var second = new GameObject {transform = {position = Vector3.right, rotation = Quaternion.identity}}; - Transform firstTransform = first.transform; - Transform secondTransform = second.transform; - - Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity)); - Assert.That(secondTransform.rotation, Is.EqualTo(Quaternion.identity)); - - firstTransform.LookAt(secondTransform); - Quaternion expected = firstTransform.rotation; - - firstTransform.rotation = Quaternion.identity; - Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity)); - - firstTransform.LookAt(second); - Assert.That(firstTransform.rotation, Is.EqualTo(expected)); - - firstTransform.rotation = Quaternion.identity; - Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity)); - - yield break; - } - - [UnityTest] - public IEnumerator SetParent_ShouldSetParent() - { - var first = new GameObject {transform = {position = Vector3.zero, rotation = Quaternion.identity}}; - var second = new GameObject {transform = {position = Vector3.right, rotation = Quaternion.identity}}; - - Assert.That(first.transform.parent, Is.EqualTo(null)); - Assert.That(second.transform.parent, Is.EqualTo(null)); - - first.transform.SetParent(second); - Assert.That(first.transform.parent, Is.EqualTo(second.transform)); - - first.transform.SetParent(null!); - Assert.That(first.transform.parent, Is.EqualTo(null)); - - second.transform.SetParent(first); - Assert.That(second.transform.parent, Is.EqualTo(first.transform)); - - yield break; - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/TransformTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/TransformTests.cs.meta deleted file mode 100644 index 362c6cc..0000000 --- a/X10D.Unity.Tests/Assets/Tests/TransformTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 1f1518cdf51546288b7a16369297be5e -timeCreated: 1652005981 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/X10D.Unity.Tests.asmdef b/X10D.Unity.Tests/Assets/Tests/X10D.Unity.Tests.asmdef deleted file mode 100644 index 3798be8..0000000 --- a/X10D.Unity.Tests/Assets/Tests/X10D.Unity.Tests.asmdef +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "X10D.Unity.Tests", - "rootNamespace": "X10D.Unity", - "references": [ - "UnityEngine.TestRunner", - "UnityEditor.TestRunner" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": true, - "precompiledReferences": [ - "nunit.framework.dll", - "X10D.dll", - "X10D.Unity.dll" - ], - "autoReferenced": false, - "defineConstraints": [ - "UNITY_INCLUDE_TESTS" - ], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/X10D.Unity.Tests.asmdef.meta b/X10D.Unity.Tests/Assets/Tests/X10D.Unity.Tests.asmdef.meta deleted file mode 100644 index 5932295..0000000 --- a/X10D.Unity.Tests/Assets/Tests/X10D.Unity.Tests.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 34215b8a0b1faf64487ff72821603aad -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/X10D.Unity.Tests/Assets/Tests/YieldInstructionIntegrationTests.cs b/X10D.Unity.Tests/Assets/Tests/YieldInstructionIntegrationTests.cs deleted file mode 100644 index 90dc18e..0000000 --- a/X10D.Unity.Tests/Assets/Tests/YieldInstructionIntegrationTests.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Collections; -using UnityEngine; - -namespace X10D.Unity.Tests -{ - public class YieldInstructionIntegrationTests : MonoBehaviour - { - private void Start() - { - StartCoroutine(CO_WaitForAnyKeyDown()); - StartCoroutine(CO_WaitForSpaceKeyDown()); - StartCoroutine(CO_WaitForSpaceKeyUp()); - } - - private IEnumerator CO_WaitForAnyKeyDown() - { - Debug.Log("Waiting for any key to be pressed..."); - yield return new WaitForKeyDown(); - Debug.Log("Key was pressed!"); - } - - private IEnumerator CO_WaitForSpaceKeyDown() - { - Debug.Log("Waiting for Space key to be pressed..."); - yield return new WaitForKeyDown(KeyCode.Space); - Debug.Log("Space key was pressed!"); - } - - private IEnumerator CO_WaitForSpaceKeyUp() - { - Debug.Log("Waiting for Space key to be released..."); - yield return new WaitForKeyUp(KeyCode.Space); - Debug.Log("Space key was released!"); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/YieldInstructionIntegrationTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/YieldInstructionIntegrationTests.cs.meta deleted file mode 100644 index ae63f4d..0000000 --- a/X10D.Unity.Tests/Assets/Tests/YieldInstructionIntegrationTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 67d53e2f993d4a5ba0eb34431d1846cd -timeCreated: 1657791682 \ No newline at end of file diff --git a/X10D.Unity.Tests/Assets/Tests/YieldInstructionTests.cs b/X10D.Unity.Tests/Assets/Tests/YieldInstructionTests.cs deleted file mode 100644 index fd109f0..0000000 --- a/X10D.Unity.Tests/Assets/Tests/YieldInstructionTests.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections; -using NUnit.Framework; -using UnityEngine; -using UnityEngine.TestTools; -using UTime = UnityEngine.Time; - -namespace X10D.Unity.Tests -{ - public class YieldInstructionTests : MonoBehaviour - { - [UnityTest] - public IEnumerator WaitForFrames_ShouldYieldCorrectNumberOfFrames() - { - int frameCount = UTime.frameCount; - yield return new WaitForFrames(10); - Assert.That(UTime.frameCount, Is.EqualTo(frameCount + 10), $"{frameCount + 10} == {UTime.frameCount}"); - } - - [UnityTest] - public IEnumerator WaitForSecondsNoAlloc_ShouldYieldForCorrectTime() - { - float time = UTime.time; - yield return new WaitForSecondsNoAlloc(2); - Assert.That(UTime.time, Is.EqualTo(time + 2).Within(1e-2), $"{time + 2} == {UTime.time}"); - } - - [UnityTest] - public IEnumerator WaitForSecondsRealtimeNoAlloc_ShouldYieldForCorrectTime() - { - float time = UTime.time; - yield return new WaitForSecondsRealtimeNoAlloc(2); - Assert.That(UTime.time, Is.EqualTo(time + 2).Within(1e-2), $"{time + 2} == {UTime.time}"); - } - - [UnityTest] - public IEnumerator WaitForTimeSpan_ShouldYieldForCorrectTime() - { - float time = UTime.time; - yield return new WaitForTimeSpan(TimeSpan.FromSeconds(2.0)); - Assert.That(UTime.time, Is.GreaterThanOrEqualTo(time + 2.0f).Or.GreaterThanOrEqualTo(time + 1.5f)); - } - - [UnityTest] - public IEnumerator WaitForTimeSpanRealtime_ShouldYieldForCorrectTime() - { - float time = UTime.time; - yield return new WaitForTimeSpanRealtime(TimeSpan.FromSeconds(2.0)); - Assert.That(UTime.time, Is.EqualTo(time + 2).Within(1e-2), $"{time + 2} == {UTime.time}"); - } - } -} diff --git a/X10D.Unity.Tests/Assets/Tests/YieldInstructionTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/YieldInstructionTests.cs.meta deleted file mode 100644 index ae81ce1..0000000 --- a/X10D.Unity.Tests/Assets/Tests/YieldInstructionTests.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d7d35eefdf5b43278a6f6aa268a71091 -timeCreated: 1657795834 \ No newline at end of file diff --git a/X10D.Unity.Tests/Packages/manifest.json b/X10D.Unity.Tests/Packages/manifest.json deleted file mode 100644 index 97fb71f..0000000 --- a/X10D.Unity.Tests/Packages/manifest.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "dependencies": { - "com.unity.collab-proxy": "2.0.1", - "com.unity.feature.development": "1.0.1", - "com.unity.ide.rider": "3.0.18", - "com.unity.ide.visualstudio": "2.0.17", - "com.unity.ide.vscode": "1.2.5", - "com.unity.test-framework": "1.1.31", - "com.unity.textmeshpro": "3.0.6", - "com.unity.timeline": "1.6.4", - "com.unity.ugui": "1.0.0", - "com.unity.visualscripting": "1.8.0", - "com.unity.modules.ai": "1.0.0", - "com.unity.modules.androidjni": "1.0.0", - "com.unity.modules.animation": "1.0.0", - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.cloth": "1.0.0", - "com.unity.modules.director": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.particlesystem": "1.0.0", - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.physics2d": "1.0.0", - "com.unity.modules.screencapture": "1.0.0", - "com.unity.modules.terrain": "1.0.0", - "com.unity.modules.terrainphysics": "1.0.0", - "com.unity.modules.tilemap": "1.0.0", - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.uielements": "1.0.0", - "com.unity.modules.umbra": "1.0.0", - "com.unity.modules.unityanalytics": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.unitywebrequestassetbundle": "1.0.0", - "com.unity.modules.unitywebrequestaudio": "1.0.0", - "com.unity.modules.unitywebrequesttexture": "1.0.0", - "com.unity.modules.unitywebrequestwww": "1.0.0", - "com.unity.modules.vehicles": "1.0.0", - "com.unity.modules.video": "1.0.0", - "com.unity.modules.vr": "1.0.0", - "com.unity.modules.wind": "1.0.0", - "com.unity.modules.xr": "1.0.0" - } -} diff --git a/X10D.Unity.Tests/Packages/packages-lock.json b/X10D.Unity.Tests/Packages/packages-lock.json deleted file mode 100644 index 3172caf..0000000 --- a/X10D.Unity.Tests/Packages/packages-lock.json +++ /dev/null @@ -1,393 +0,0 @@ -{ - "dependencies": { - "com.unity.collab-proxy": { - "version": "2.0.1", - "depth": 0, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.editorcoroutines": { - "version": "1.0.0", - "depth": 1, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.ext.nunit": { - "version": "1.0.6", - "depth": 1, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.feature.development": { - "version": "1.0.1", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.ide.visualstudio": "2.0.17", - "com.unity.ide.rider": "3.0.18", - "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.ide.rider": { - "version": "3.0.18", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.ext.nunit": "1.0.6" - }, - "url": "https://packages.unity.com" - }, - "com.unity.ide.visualstudio": { - "version": "2.0.17", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.test-framework": "1.1.9" - }, - "url": "https://packages.unity.com" - }, - "com.unity.ide.vscode": { - "version": "1.2.5", - "depth": 0, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.performance.profile-analyzer": { - "version": "1.2.2", - "depth": 1, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.settings-manager": { - "version": "1.0.3", - "depth": 2, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.test-framework": { - "version": "1.1.31", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.ext.nunit": "1.0.6", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.testtools.codecoverage": { - "version": "1.2.2", - "depth": 1, - "source": "registry", - "dependencies": { - "com.unity.test-framework": "1.0.16", - "com.unity.settings-manager": "1.0.1" - }, - "url": "https://packages.unity.com" - }, - "com.unity.textmeshpro": { - "version": "3.0.6", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.ugui": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.timeline": { - "version": "1.6.4", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.modules.director": "1.0.0", - "com.unity.modules.animation": "1.0.0", - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.particlesystem": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.ugui": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.imgui": "1.0.0" - } - }, - "com.unity.visualscripting": { - "version": "1.8.0", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.ugui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.modules.ai": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.androidjni": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.animation": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.assetbundle": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.audio": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.cloth": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0" - } - }, - "com.unity.modules.director": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.animation": "1.0.0" - } - }, - "com.unity.modules.imageconversion": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.imgui": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.jsonserialize": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.particlesystem": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.physics": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.physics2d": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.screencapture": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.imageconversion": "1.0.0" - } - }, - "com.unity.modules.subsystems": { - "version": "1.0.0", - "depth": 1, - "source": "builtin", - "dependencies": { - "com.unity.modules.jsonserialize": "1.0.0" - } - }, - "com.unity.modules.terrain": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.terrainphysics": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.terrain": "1.0.0" - } - }, - "com.unity.modules.tilemap": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics2d": "1.0.0" - } - }, - "com.unity.modules.ui": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.uielements": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.uielementsnative": "1.0.0" - } - }, - "com.unity.modules.uielementsnative": { - "version": "1.0.0", - "depth": 1, - "source": "builtin", - "dependencies": { - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0" - } - }, - "com.unity.modules.umbra": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.unityanalytics": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0" - } - }, - "com.unity.modules.unitywebrequest": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.unitywebrequestassetbundle": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0" - } - }, - "com.unity.modules.unitywebrequestaudio": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.audio": "1.0.0" - } - }, - "com.unity.modules.unitywebrequesttexture": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0" - } - }, - "com.unity.modules.unitywebrequestwww": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.unitywebrequestassetbundle": "1.0.0", - "com.unity.modules.unitywebrequestaudio": "1.0.0", - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0" - } - }, - "com.unity.modules.vehicles": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0" - } - }, - "com.unity.modules.video": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0" - } - }, - "com.unity.modules.vr": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.xr": "1.0.0" - } - }, - "com.unity.modules.wind": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.xr": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.subsystems": "1.0.0" - } - } - } -} diff --git a/X10D.Unity.Tests/ProjectSettings/AudioManager.asset b/X10D.Unity.Tests/ProjectSettings/AudioManager.asset deleted file mode 100644 index 07ebfb0..0000000 --- a/X10D.Unity.Tests/ProjectSettings/AudioManager.asset +++ /dev/null @@ -1,19 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!11 &1 -AudioManager: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Volume: 1 - Rolloff Scale: 1 - Doppler Factor: 1 - Default Speaker Mode: 2 - m_SampleRate: 0 - m_DSPBufferSize: 1024 - m_VirtualVoiceCount: 512 - m_RealVoiceCount: 32 - m_SpatializerPlugin: - m_AmbisonicDecoderPlugin: - m_DisableAudio: 0 - m_VirtualizeEffects: 1 - m_RequestedDSPBufferSize: 1024 diff --git a/X10D.Unity.Tests/ProjectSettings/ClusterInputManager.asset b/X10D.Unity.Tests/ProjectSettings/ClusterInputManager.asset deleted file mode 100644 index e7886b2..0000000 --- a/X10D.Unity.Tests/ProjectSettings/ClusterInputManager.asset +++ /dev/null @@ -1,6 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!236 &1 -ClusterInputManager: - m_ObjectHideFlags: 0 - m_Inputs: [] diff --git a/X10D.Unity.Tests/ProjectSettings/DynamicsManager.asset b/X10D.Unity.Tests/ProjectSettings/DynamicsManager.asset deleted file mode 100644 index cdc1f3e..0000000 --- a/X10D.Unity.Tests/ProjectSettings/DynamicsManager.asset +++ /dev/null @@ -1,34 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!55 &1 -PhysicsManager: - m_ObjectHideFlags: 0 - serializedVersion: 11 - m_Gravity: {x: 0, y: -9.81, z: 0} - m_DefaultMaterial: {fileID: 0} - m_BounceThreshold: 2 - m_SleepThreshold: 0.005 - m_DefaultContactOffset: 0.01 - m_DefaultSolverIterations: 6 - m_DefaultSolverVelocityIterations: 1 - m_QueriesHitBackfaces: 0 - m_QueriesHitTriggers: 1 - m_EnableAdaptiveForce: 0 - m_ClothInterCollisionDistance: 0 - m_ClothInterCollisionStiffness: 0 - m_ContactsGeneration: 1 - m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff - m_AutoSimulation: 1 - m_AutoSyncTransforms: 0 - m_ReuseCollisionCallbacks: 1 - m_ClothInterCollisionSettingsToggle: 0 - m_ContactPairsMode: 0 - m_BroadphaseType: 0 - m_WorldBounds: - m_Center: {x: 0, y: 0, z: 0} - m_Extent: {x: 250, y: 250, z: 250} - m_WorldSubdivisions: 8 - m_FrictionType: 0 - m_EnableEnhancedDeterminism: 0 - m_EnableUnifiedHeightmaps: 1 - m_DefaultMaxAngluarSpeed: 7 diff --git a/X10D.Unity.Tests/ProjectSettings/EditorBuildSettings.asset b/X10D.Unity.Tests/ProjectSettings/EditorBuildSettings.asset deleted file mode 100644 index 0147887..0000000 --- a/X10D.Unity.Tests/ProjectSettings/EditorBuildSettings.asset +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1045 &1 -EditorBuildSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Scenes: [] - m_configObjects: {} diff --git a/X10D.Unity.Tests/ProjectSettings/EditorSettings.asset b/X10D.Unity.Tests/ProjectSettings/EditorSettings.asset deleted file mode 100644 index 1e44a0a..0000000 --- a/X10D.Unity.Tests/ProjectSettings/EditorSettings.asset +++ /dev/null @@ -1,30 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!159 &1 -EditorSettings: - m_ObjectHideFlags: 0 - serializedVersion: 11 - m_ExternalVersionControlSupport: Visible Meta Files - m_SerializationMode: 2 - m_LineEndingsForNewScripts: 0 - m_DefaultBehaviorMode: 0 - m_PrefabRegularEnvironment: {fileID: 0} - m_PrefabUIEnvironment: {fileID: 0} - m_SpritePackerMode: 0 - m_SpritePackerPaddingPower: 1 - m_EtcTextureCompressorBehavior: 1 - m_EtcTextureFastCompressor: 1 - m_EtcTextureNormalCompressor: 2 - m_EtcTextureBestCompressor: 4 - m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref - m_ProjectGenerationRootNamespace: - m_CollabEditorSettings: - inProgressEnabled: 1 - m_EnableTextureStreamingInEditMode: 1 - m_EnableTextureStreamingInPlayMode: 1 - m_AsyncShaderCompilation: 1 - m_EnterPlayModeOptionsEnabled: 0 - m_EnterPlayModeOptions: 3 - m_ShowLightmapResolutionOverlay: 1 - m_UseLegacyProbeSampleCount: 0 - m_SerializeInlineMappingsOnOneLine: 1 diff --git a/X10D.Unity.Tests/ProjectSettings/GraphicsSettings.asset b/X10D.Unity.Tests/ProjectSettings/GraphicsSettings.asset deleted file mode 100644 index 43369e3..0000000 --- a/X10D.Unity.Tests/ProjectSettings/GraphicsSettings.asset +++ /dev/null @@ -1,63 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!30 &1 -GraphicsSettings: - m_ObjectHideFlags: 0 - serializedVersion: 13 - m_Deferred: - m_Mode: 1 - m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} - m_DeferredReflections: - m_Mode: 1 - m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} - m_ScreenSpaceShadows: - m_Mode: 1 - m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} - m_LegacyDeferred: - m_Mode: 1 - m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} - m_DepthNormals: - m_Mode: 1 - m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} - m_MotionVectors: - m_Mode: 1 - m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} - m_LightHalo: - m_Mode: 1 - m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} - m_LensFlare: - m_Mode: 1 - m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} - m_AlwaysIncludedShaders: - - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} - - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} - m_PreloadedShaders: [] - m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, - type: 0} - m_CustomRenderPipeline: {fileID: 0} - m_TransparencySortMode: 0 - m_TransparencySortAxis: {x: 0, y: 0, z: 1} - m_DefaultRenderingPath: 1 - m_DefaultMobileRenderingPath: 1 - m_TierSettings: [] - m_LightmapStripping: 0 - m_FogStripping: 0 - m_InstancingStripping: 0 - m_LightmapKeepPlain: 1 - m_LightmapKeepDirCombined: 1 - m_LightmapKeepDynamicPlain: 1 - m_LightmapKeepDynamicDirCombined: 1 - m_LightmapKeepShadowMask: 1 - m_LightmapKeepSubtractive: 1 - m_FogKeepLinear: 1 - m_FogKeepExp: 1 - m_FogKeepExp2: 1 - m_AlbedoSwatchInfos: [] - m_LightsUseLinearIntensity: 0 - m_LightsUseColorTemperature: 0 - m_LogWhenShaderIsCompiled: 0 - m_AllowEnlightenSupportForUpgradedProject: 0 diff --git a/X10D.Unity.Tests/ProjectSettings/InputManager.asset b/X10D.Unity.Tests/ProjectSettings/InputManager.asset deleted file mode 100644 index 17c8f53..0000000 --- a/X10D.Unity.Tests/ProjectSettings/InputManager.asset +++ /dev/null @@ -1,295 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!13 &1 -InputManager: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Axes: - - serializedVersion: 3 - m_Name: Horizontal - descriptiveName: - descriptiveNegativeName: - negativeButton: left - positiveButton: right - altNegativeButton: a - altPositiveButton: d - gravity: 3 - dead: 0.001 - sensitivity: 3 - snap: 1 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Vertical - descriptiveName: - descriptiveNegativeName: - negativeButton: down - positiveButton: up - altNegativeButton: s - altPositiveButton: w - gravity: 3 - dead: 0.001 - sensitivity: 3 - snap: 1 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire1 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: left ctrl - altNegativeButton: - altPositiveButton: mouse 0 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire2 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: left alt - altNegativeButton: - altPositiveButton: mouse 1 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire3 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: left shift - altNegativeButton: - altPositiveButton: mouse 2 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Jump - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: space - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse X - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse Y - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 1 - joyNum: 0 - - serializedVersion: 3 - m_Name: Mouse ScrollWheel - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0 - sensitivity: 0.1 - snap: 0 - invert: 0 - type: 1 - axis: 2 - joyNum: 0 - - serializedVersion: 3 - m_Name: Horizontal - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 0 - type: 2 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Vertical - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: - altNegativeButton: - altPositiveButton: - gravity: 0 - dead: 0.19 - sensitivity: 1 - snap: 0 - invert: 1 - type: 2 - axis: 1 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire1 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 0 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire2 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 1 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Fire3 - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 2 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Jump - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: joystick button 3 - altNegativeButton: - altPositiveButton: - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Submit - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: return - altNegativeButton: - altPositiveButton: joystick button 0 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Submit - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: enter - altNegativeButton: - altPositiveButton: space - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 - - serializedVersion: 3 - m_Name: Cancel - descriptiveName: - descriptiveNegativeName: - negativeButton: - positiveButton: escape - altNegativeButton: - altPositiveButton: joystick button 1 - gravity: 1000 - dead: 0.001 - sensitivity: 1000 - snap: 0 - invert: 0 - type: 0 - axis: 0 - joyNum: 0 diff --git a/X10D.Unity.Tests/ProjectSettings/MemorySettings.asset b/X10D.Unity.Tests/ProjectSettings/MemorySettings.asset deleted file mode 100644 index 5b5face..0000000 --- a/X10D.Unity.Tests/ProjectSettings/MemorySettings.asset +++ /dev/null @@ -1,35 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!387306366 &1 -MemorySettings: - m_ObjectHideFlags: 0 - m_EditorMemorySettings: - m_MainAllocatorBlockSize: -1 - m_ThreadAllocatorBlockSize: -1 - m_MainGfxBlockSize: -1 - m_ThreadGfxBlockSize: -1 - m_CacheBlockSize: -1 - m_TypetreeBlockSize: -1 - m_ProfilerBlockSize: -1 - m_ProfilerEditorBlockSize: -1 - m_BucketAllocatorGranularity: -1 - m_BucketAllocatorBucketsCount: -1 - m_BucketAllocatorBlockSize: -1 - m_BucketAllocatorBlockCount: -1 - m_ProfilerBucketAllocatorGranularity: -1 - m_ProfilerBucketAllocatorBucketsCount: -1 - m_ProfilerBucketAllocatorBlockSize: -1 - m_ProfilerBucketAllocatorBlockCount: -1 - m_TempAllocatorSizeMain: -1 - m_JobTempAllocatorBlockSize: -1 - m_BackgroundJobTempAllocatorBlockSize: -1 - m_JobTempAllocatorReducedBlockSize: -1 - m_TempAllocatorSizeGIBakingWorker: -1 - m_TempAllocatorSizeNavMeshWorker: -1 - m_TempAllocatorSizeAudioWorker: -1 - m_TempAllocatorSizeCloudWorker: -1 - m_TempAllocatorSizeGfx: -1 - m_TempAllocatorSizeJobWorker: -1 - m_TempAllocatorSizeBackgroundWorker: -1 - m_TempAllocatorSizePreloadManager: -1 - m_PlatformMemorySettings: {} diff --git a/X10D.Unity.Tests/ProjectSettings/NavMeshAreas.asset b/X10D.Unity.Tests/ProjectSettings/NavMeshAreas.asset deleted file mode 100644 index 3b0b7c3..0000000 --- a/X10D.Unity.Tests/ProjectSettings/NavMeshAreas.asset +++ /dev/null @@ -1,91 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!126 &1 -NavMeshProjectSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - areas: - - name: Walkable - cost: 1 - - name: Not Walkable - cost: 1 - - name: Jump - cost: 2 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - - name: - cost: 1 - m_LastAgentTypeID: -887442657 - m_Settings: - - serializedVersion: 2 - agentTypeID: 0 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.75 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - minRegionArea: 2 - manualCellSize: 0 - cellSize: 0.16666667 - manualTileSize: 0 - tileSize: 256 - accuratePlacement: 0 - debug: - m_Flags: 0 - m_SettingNames: - - Humanoid diff --git a/X10D.Unity.Tests/ProjectSettings/PackageManagerSettings.asset b/X10D.Unity.Tests/ProjectSettings/PackageManagerSettings.asset deleted file mode 100644 index 112a053..0000000 --- a/X10D.Unity.Tests/ProjectSettings/PackageManagerSettings.asset +++ /dev/null @@ -1,35 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &1 -MonoBehaviour: - m_ObjectHideFlags: 61 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} - m_Name: - m_EditorClassIdentifier: - m_EnablePreReleasePackages: 0 - m_EnablePackageDependencies: 0 - m_AdvancedSettingsExpanded: 1 - m_ScopedRegistriesSettingsExpanded: 1 - m_SeeAllPackageVersions: 0 - oneTimeWarningShown: 0 - m_Registries: - - m_Id: main - m_Name: - m_Url: https://packages.unity.com - m_Scopes: [] - m_IsDefault: 1 - m_Capabilities: 7 - m_UserSelectedRegistryName: - m_UserAddingNewScopedRegistry: 0 - m_RegistryInfoDraft: - m_Modified: 0 - m_ErrorMessage: - m_UserModificationsInstanceId: -830 - m_OriginalInstanceId: -832 - m_LoadAssets: 0 diff --git a/X10D.Unity.Tests/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json b/X10D.Unity.Tests/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json deleted file mode 100644 index ad11087..0000000 --- a/X10D.Unity.Tests/ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "m_Name": "Settings", - "m_Path": "ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json", - "m_Dictionary": { - "m_DictionaryValues": [] - } -} \ No newline at end of file diff --git a/X10D.Unity.Tests/ProjectSettings/Physics2DSettings.asset b/X10D.Unity.Tests/ProjectSettings/Physics2DSettings.asset deleted file mode 100644 index 47880b1..0000000 --- a/X10D.Unity.Tests/ProjectSettings/Physics2DSettings.asset +++ /dev/null @@ -1,56 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!19 &1 -Physics2DSettings: - m_ObjectHideFlags: 0 - serializedVersion: 4 - m_Gravity: {x: 0, y: -9.81} - m_DefaultMaterial: {fileID: 0} - m_VelocityIterations: 8 - m_PositionIterations: 3 - m_VelocityThreshold: 1 - m_MaxLinearCorrection: 0.2 - m_MaxAngularCorrection: 8 - m_MaxTranslationSpeed: 100 - m_MaxRotationSpeed: 360 - m_BaumgarteScale: 0.2 - m_BaumgarteTimeOfImpactScale: 0.75 - m_TimeToSleep: 0.5 - m_LinearSleepTolerance: 0.01 - m_AngularSleepTolerance: 2 - m_DefaultContactOffset: 0.01 - m_JobOptions: - serializedVersion: 2 - useMultithreading: 0 - useConsistencySorting: 0 - m_InterpolationPosesPerJob: 100 - m_NewContactsPerJob: 30 - m_CollideContactsPerJob: 100 - m_ClearFlagsPerJob: 200 - m_ClearBodyForcesPerJob: 200 - m_SyncDiscreteFixturesPerJob: 50 - m_SyncContinuousFixturesPerJob: 50 - m_FindNearestContactsPerJob: 100 - m_UpdateTriggerContactsPerJob: 100 - m_IslandSolverCostThreshold: 100 - m_IslandSolverBodyCostScale: 1 - m_IslandSolverContactCostScale: 10 - m_IslandSolverJointCostScale: 10 - m_IslandSolverBodiesPerJob: 50 - m_IslandSolverContactsPerJob: 50 - m_AutoSimulation: 1 - m_QueriesHitTriggers: 1 - m_QueriesStartInColliders: 1 - m_CallbacksOnDisable: 1 - m_ReuseCollisionCallbacks: 1 - m_AutoSyncTransforms: 0 - m_AlwaysShowColliders: 0 - m_ShowColliderSleep: 1 - m_ShowColliderContacts: 0 - m_ShowColliderAABB: 0 - m_ContactArrowScale: 0.2 - m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} - m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} - m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} - m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} - m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/X10D.Unity.Tests/ProjectSettings/PresetManager.asset b/X10D.Unity.Tests/ProjectSettings/PresetManager.asset deleted file mode 100644 index 67a94da..0000000 --- a/X10D.Unity.Tests/ProjectSettings/PresetManager.asset +++ /dev/null @@ -1,7 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1386491679 &1 -PresetManager: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_DefaultPresets: {} diff --git a/X10D.Unity.Tests/ProjectSettings/ProjectSettings.asset b/X10D.Unity.Tests/ProjectSettings/ProjectSettings.asset deleted file mode 100644 index 67fd210..0000000 --- a/X10D.Unity.Tests/ProjectSettings/ProjectSettings.asset +++ /dev/null @@ -1,708 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!129 &1 -PlayerSettings: - m_ObjectHideFlags: 0 - serializedVersion: 23 - productGUID: a5313041f8a8e9240a746c81c45bc60b - AndroidProfiler: 0 - AndroidFilterTouchesWhenObscured: 0 - AndroidEnableSustainedPerformanceMode: 0 - defaultScreenOrientation: 4 - targetDevice: 2 - useOnDemandResources: 0 - accelerometerFrequency: 60 - companyName: DefaultCompany - productName: X10D.Unity.Tests - defaultCursor: {fileID: 0} - cursorHotspot: {x: 0, y: 0} - m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} - m_ShowUnitySplashScreen: 1 - m_ShowUnitySplashLogo: 1 - m_SplashScreenOverlayOpacity: 1 - m_SplashScreenAnimation: 1 - m_SplashScreenLogoStyle: 1 - m_SplashScreenDrawMode: 0 - m_SplashScreenBackgroundAnimationZoom: 1 - m_SplashScreenLogoAnimationZoom: 1 - m_SplashScreenBackgroundLandscapeAspect: 1 - m_SplashScreenBackgroundPortraitAspect: 1 - m_SplashScreenBackgroundLandscapeUvs: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - m_SplashScreenBackgroundPortraitUvs: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - m_SplashScreenLogos: [] - m_VirtualRealitySplashScreen: {fileID: 0} - m_HolographicTrackingLossScreen: {fileID: 0} - defaultScreenWidth: 1920 - defaultScreenHeight: 1080 - defaultScreenWidthWeb: 960 - defaultScreenHeightWeb: 600 - m_StereoRenderingPath: 0 - m_ActiveColorSpace: 0 - m_MTRendering: 1 - mipStripping: 0 - numberOfMipsStripped: 0 - m_StackTraceTypes: 010000000100000001000000010000000100000001000000 - iosShowActivityIndicatorOnLoading: -1 - androidShowActivityIndicatorOnLoading: -1 - iosUseCustomAppBackgroundBehavior: 0 - iosAllowHTTPDownload: 1 - allowedAutorotateToPortrait: 1 - allowedAutorotateToPortraitUpsideDown: 1 - allowedAutorotateToLandscapeRight: 1 - allowedAutorotateToLandscapeLeft: 1 - useOSAutorotation: 1 - use32BitDisplayBuffer: 1 - preserveFramebufferAlpha: 0 - disableDepthAndStencilBuffers: 0 - androidStartInFullscreen: 1 - androidRenderOutsideSafeArea: 1 - androidUseSwappy: 1 - androidBlitType: 0 - androidResizableWindow: 0 - androidDefaultWindowWidth: 1920 - androidDefaultWindowHeight: 1080 - androidMinimumWindowWidth: 400 - androidMinimumWindowHeight: 300 - androidFullscreenMode: 1 - defaultIsNativeResolution: 1 - macRetinaSupport: 1 - runInBackground: 1 - captureSingleScreen: 0 - muteOtherAudioSources: 0 - Prepare IOS For Recording: 0 - Force IOS Speakers When Recording: 0 - deferSystemGesturesMode: 0 - hideHomeButton: 0 - submitAnalytics: 1 - usePlayerLog: 1 - bakeCollisionMeshes: 0 - forceSingleInstance: 0 - useFlipModelSwapchain: 1 - resizableWindow: 0 - useMacAppStoreValidation: 0 - macAppStoreCategory: public.app-category.games - gpuSkinning: 1 - xboxPIXTextureCapture: 0 - xboxEnableAvatar: 0 - xboxEnableKinect: 0 - xboxEnableKinectAutoTracking: 0 - xboxEnableFitness: 0 - visibleInBackground: 1 - allowFullscreenSwitch: 1 - fullscreenMode: 1 - xboxSpeechDB: 0 - xboxEnableHeadOrientation: 0 - xboxEnableGuest: 0 - xboxEnablePIXSampling: 0 - metalFramebufferOnly: 0 - xboxOneResolution: 0 - xboxOneSResolution: 0 - xboxOneXResolution: 3 - xboxOneMonoLoggingLevel: 0 - xboxOneLoggingLevel: 1 - xboxOneDisableEsram: 0 - xboxOneEnableTypeOptimization: 0 - xboxOnePresentImmediateThreshold: 0 - switchQueueCommandMemory: 0 - switchQueueControlMemory: 16384 - switchQueueComputeMemory: 262144 - switchNVNShaderPoolsGranularity: 33554432 - switchNVNDefaultPoolsGranularity: 16777216 - switchNVNOtherPoolsGranularity: 16777216 - switchNVNMaxPublicTextureIDCount: 0 - switchNVNMaxPublicSamplerIDCount: 0 - stadiaPresentMode: 0 - stadiaTargetFramerate: 0 - vulkanNumSwapchainBuffers: 3 - vulkanEnableSetSRGBWrite: 0 - vulkanEnablePreTransform: 1 - vulkanEnableLateAcquireNextImage: 0 - vulkanEnableCommandBufferRecycling: 1 - m_SupportedAspectRatios: - 4:3: 1 - 5:4: 1 - 16:10: 1 - 16:9: 1 - Others: 1 - bundleVersion: 0.1 - preloadedAssets: [] - metroInputSource: 0 - wsaTransparentSwapchain: 0 - m_HolographicPauseOnTrackingLoss: 1 - xboxOneDisableKinectGpuReservation: 1 - xboxOneEnable7thCore: 1 - vrSettings: - enable360StereoCapture: 0 - isWsaHolographicRemotingEnabled: 0 - enableFrameTimingStats: 0 - useHDRDisplay: 0 - D3DHDRBitDepth: 0 - m_ColorGamuts: 00000000 - targetPixelDensity: 30 - resolutionScalingMode: 0 - androidSupportedAspectRatio: 1 - androidMaxAspectRatio: 2.1 - applicationIdentifier: {} - buildNumber: - Standalone: 0 - iPhone: 0 - tvOS: 0 - overrideDefaultApplicationIdentifier: 0 - AndroidBundleVersionCode: 1 - AndroidMinSdkVersion: 22 - AndroidTargetSdkVersion: 0 - AndroidPreferredInstallLocation: 1 - aotOptions: - stripEngineCode: 1 - iPhoneStrippingLevel: 0 - iPhoneScriptCallOptimization: 0 - ForceInternetPermission: 0 - ForceSDCardPermission: 0 - CreateWallpaper: 0 - APKExpansionFiles: 0 - keepLoadedShadersAlive: 0 - StripUnusedMeshComponents: 1 - VertexChannelCompressionMask: 4054 - iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 11.0 - tvOSSdkVersion: 0 - tvOSRequireExtendedGameController: 0 - tvOSTargetOSVersionString: 11.0 - uIPrerenderedIcon: 0 - uIRequiresPersistentWiFi: 0 - uIRequiresFullScreen: 1 - uIStatusBarHidden: 1 - uIExitOnSuspend: 0 - uIStatusBarStyle: 0 - appleTVSplashScreen: {fileID: 0} - appleTVSplashScreen2x: {fileID: 0} - tvOSSmallIconLayers: [] - tvOSSmallIconLayers2x: [] - tvOSLargeIconLayers: [] - tvOSLargeIconLayers2x: [] - tvOSTopShelfImageLayers: [] - tvOSTopShelfImageLayers2x: [] - tvOSTopShelfImageWideLayers: [] - tvOSTopShelfImageWideLayers2x: [] - iOSLaunchScreenType: 0 - iOSLaunchScreenPortrait: {fileID: 0} - iOSLaunchScreenLandscape: {fileID: 0} - iOSLaunchScreenBackgroundColor: - serializedVersion: 2 - rgba: 0 - iOSLaunchScreenFillPct: 100 - iOSLaunchScreenSize: 100 - iOSLaunchScreenCustomXibPath: - iOSLaunchScreeniPadType: 0 - iOSLaunchScreeniPadImage: {fileID: 0} - iOSLaunchScreeniPadBackgroundColor: - serializedVersion: 2 - rgba: 0 - iOSLaunchScreeniPadFillPct: 100 - iOSLaunchScreeniPadSize: 100 - iOSLaunchScreeniPadCustomXibPath: - iOSLaunchScreenCustomStoryboardPath: - iOSLaunchScreeniPadCustomStoryboardPath: - iOSDeviceRequirements: [] - iOSURLSchemes: [] - macOSURLSchemes: [] - iOSBackgroundModes: 0 - iOSMetalForceHardShadows: 0 - metalEditorSupport: 1 - metalAPIValidation: 1 - iOSRenderExtraFrameOnPause: 0 - iosCopyPluginsCodeInsteadOfSymlink: 0 - appleDeveloperTeamID: - iOSManualSigningProvisioningProfileID: - tvOSManualSigningProvisioningProfileID: - iOSManualSigningProvisioningProfileType: 0 - tvOSManualSigningProvisioningProfileType: 0 - appleEnableAutomaticSigning: 0 - iOSRequireARKit: 0 - iOSAutomaticallyDetectAndAddCapabilities: 1 - appleEnableProMotion: 0 - shaderPrecisionModel: 0 - clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea - templatePackageId: com.unity.template.3d@8.1.0 - templateDefaultScene: Assets/Scenes/SampleScene.unity - useCustomMainManifest: 0 - useCustomLauncherManifest: 0 - useCustomMainGradleTemplate: 0 - useCustomLauncherGradleManifest: 0 - useCustomBaseGradleTemplate: 0 - useCustomGradlePropertiesTemplate: 0 - useCustomProguardFile: 0 - AndroidTargetArchitectures: 1 - AndroidTargetDevices: 0 - AndroidSplashScreenScale: 0 - androidSplashScreen: {fileID: 0} - AndroidKeystoreName: - AndroidKeyaliasName: - AndroidBuildApkPerCpuArchitecture: 0 - AndroidTVCompatibility: 0 - AndroidIsGame: 1 - AndroidEnableTango: 0 - androidEnableBanner: 1 - androidUseLowAccuracyLocation: 0 - androidUseCustomKeystore: 0 - m_AndroidBanners: - - width: 320 - height: 180 - banner: {fileID: 0} - androidGamepadSupportLevel: 0 - chromeosInputEmulation: 1 - AndroidMinifyWithR8: 0 - AndroidMinifyRelease: 0 - AndroidMinifyDebug: 0 - AndroidValidateAppBundleSize: 1 - AndroidAppBundleSizeToValidate: 150 - m_BuildTargetIcons: [] - m_BuildTargetPlatformIcons: [] - m_BuildTargetBatching: - - m_BuildTarget: Standalone - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: tvOS - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: Android - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: iPhone - m_StaticBatching: 1 - m_DynamicBatching: 0 - - m_BuildTarget: WebGL - m_StaticBatching: 0 - m_DynamicBatching: 0 - m_BuildTargetGraphicsJobs: - - m_BuildTarget: MacStandaloneSupport - m_GraphicsJobs: 0 - - m_BuildTarget: Switch - m_GraphicsJobs: 1 - - m_BuildTarget: MetroSupport - m_GraphicsJobs: 1 - - m_BuildTarget: AppleTVSupport - m_GraphicsJobs: 0 - - m_BuildTarget: BJMSupport - m_GraphicsJobs: 1 - - m_BuildTarget: LinuxStandaloneSupport - m_GraphicsJobs: 1 - - m_BuildTarget: PS4Player - m_GraphicsJobs: 1 - - m_BuildTarget: iOSSupport - m_GraphicsJobs: 0 - - m_BuildTarget: WindowsStandaloneSupport - m_GraphicsJobs: 1 - - m_BuildTarget: XboxOnePlayer - m_GraphicsJobs: 1 - - m_BuildTarget: LuminSupport - m_GraphicsJobs: 0 - - m_BuildTarget: AndroidPlayer - m_GraphicsJobs: 0 - - m_BuildTarget: WebGLSupport - m_GraphicsJobs: 0 - m_BuildTargetGraphicsJobMode: - - m_BuildTarget: PS4Player - m_GraphicsJobMode: 0 - - m_BuildTarget: XboxOnePlayer - m_GraphicsJobMode: 0 - m_BuildTargetGraphicsAPIs: - - m_BuildTarget: AndroidPlayer - m_APIs: 150000000b000000 - m_Automatic: 1 - - m_BuildTarget: iOSSupport - m_APIs: 10000000 - m_Automatic: 1 - - m_BuildTarget: AppleTVSupport - m_APIs: 10000000 - m_Automatic: 1 - - m_BuildTarget: WebGLSupport - m_APIs: 0b000000 - m_Automatic: 1 - m_BuildTargetVRSettings: - - m_BuildTarget: Standalone - m_Enabled: 0 - m_Devices: - - Oculus - - OpenVR - openGLRequireES31: 0 - openGLRequireES31AEP: 0 - openGLRequireES32: 0 - m_TemplateCustomTags: {} - mobileMTRendering: - Android: 1 - iPhone: 1 - tvOS: 1 - m_BuildTargetGroupLightmapEncodingQuality: - - m_BuildTarget: Android - m_EncodingQuality: 1 - - m_BuildTarget: iPhone - m_EncodingQuality: 1 - - m_BuildTarget: tvOS - m_EncodingQuality: 1 - m_BuildTargetGroupLightmapSettings: [] - m_BuildTargetNormalMapEncoding: - - m_BuildTarget: Android - m_Encoding: 1 - - m_BuildTarget: iPhone - m_Encoding: 1 - - m_BuildTarget: tvOS - m_Encoding: 1 - m_BuildTargetDefaultTextureCompressionFormat: - - m_BuildTarget: Android - m_Format: 3 - playModeTestRunnerEnabled: 0 - runPlayModeTestAsEditModeTest: 0 - actionOnDotNetUnhandledException: 1 - enableInternalProfiler: 0 - logObjCUncaughtExceptions: 1 - enableCrashReportAPI: 0 - cameraUsageDescription: - locationUsageDescription: - microphoneUsageDescription: - bluetoothUsageDescription: - switchNMETAOverride: - switchNetLibKey: - switchSocketMemoryPoolSize: 6144 - switchSocketAllocatorPoolSize: 128 - switchSocketConcurrencyLimit: 14 - switchScreenResolutionBehavior: 2 - switchUseCPUProfiler: 0 - switchUseGOLDLinker: 0 - switchLTOSetting: 0 - switchApplicationID: 0x01004b9000490000 - switchNSODependencies: - switchTitleNames_0: - switchTitleNames_1: - switchTitleNames_2: - switchTitleNames_3: - switchTitleNames_4: - switchTitleNames_5: - switchTitleNames_6: - switchTitleNames_7: - switchTitleNames_8: - switchTitleNames_9: - switchTitleNames_10: - switchTitleNames_11: - switchTitleNames_12: - switchTitleNames_13: - switchTitleNames_14: - switchTitleNames_15: - switchPublisherNames_0: - switchPublisherNames_1: - switchPublisherNames_2: - switchPublisherNames_3: - switchPublisherNames_4: - switchPublisherNames_5: - switchPublisherNames_6: - switchPublisherNames_7: - switchPublisherNames_8: - switchPublisherNames_9: - switchPublisherNames_10: - switchPublisherNames_11: - switchPublisherNames_12: - switchPublisherNames_13: - switchPublisherNames_14: - switchPublisherNames_15: - switchIcons_0: {fileID: 0} - switchIcons_1: {fileID: 0} - switchIcons_2: {fileID: 0} - switchIcons_3: {fileID: 0} - switchIcons_4: {fileID: 0} - switchIcons_5: {fileID: 0} - switchIcons_6: {fileID: 0} - switchIcons_7: {fileID: 0} - switchIcons_8: {fileID: 0} - switchIcons_9: {fileID: 0} - switchIcons_10: {fileID: 0} - switchIcons_11: {fileID: 0} - switchIcons_12: {fileID: 0} - switchIcons_13: {fileID: 0} - switchIcons_14: {fileID: 0} - switchIcons_15: {fileID: 0} - switchSmallIcons_0: {fileID: 0} - switchSmallIcons_1: {fileID: 0} - switchSmallIcons_2: {fileID: 0} - switchSmallIcons_3: {fileID: 0} - switchSmallIcons_4: {fileID: 0} - switchSmallIcons_5: {fileID: 0} - switchSmallIcons_6: {fileID: 0} - switchSmallIcons_7: {fileID: 0} - switchSmallIcons_8: {fileID: 0} - switchSmallIcons_9: {fileID: 0} - switchSmallIcons_10: {fileID: 0} - switchSmallIcons_11: {fileID: 0} - switchSmallIcons_12: {fileID: 0} - switchSmallIcons_13: {fileID: 0} - switchSmallIcons_14: {fileID: 0} - switchSmallIcons_15: {fileID: 0} - switchManualHTML: - switchAccessibleURLs: - switchLegalInformation: - switchMainThreadStackSize: 1048576 - switchPresenceGroupId: - switchLogoHandling: 0 - switchReleaseVersion: 0 - switchDisplayVersion: 1.0.0 - switchStartupUserAccount: 0 - switchTouchScreenUsage: 0 - switchSupportedLanguagesMask: 0 - switchLogoType: 0 - switchApplicationErrorCodeCategory: - switchUserAccountSaveDataSize: 0 - switchUserAccountSaveDataJournalSize: 0 - switchApplicationAttribute: 0 - switchCardSpecSize: -1 - switchCardSpecClock: -1 - switchRatingsMask: 0 - switchRatingsInt_0: 0 - switchRatingsInt_1: 0 - switchRatingsInt_2: 0 - switchRatingsInt_3: 0 - switchRatingsInt_4: 0 - switchRatingsInt_5: 0 - switchRatingsInt_6: 0 - switchRatingsInt_7: 0 - switchRatingsInt_8: 0 - switchRatingsInt_9: 0 - switchRatingsInt_10: 0 - switchRatingsInt_11: 0 - switchRatingsInt_12: 0 - switchLocalCommunicationIds_0: - switchLocalCommunicationIds_1: - switchLocalCommunicationIds_2: - switchLocalCommunicationIds_3: - switchLocalCommunicationIds_4: - switchLocalCommunicationIds_5: - switchLocalCommunicationIds_6: - switchLocalCommunicationIds_7: - switchParentalControl: 0 - switchAllowsScreenshot: 1 - switchAllowsVideoCapturing: 1 - switchAllowsRuntimeAddOnContentInstall: 0 - switchDataLossConfirmation: 0 - switchUserAccountLockEnabled: 0 - switchSystemResourceMemory: 16777216 - switchSupportedNpadStyles: 22 - switchNativeFsCacheSize: 32 - switchIsHoldTypeHorizontal: 0 - switchSupportedNpadCount: 8 - switchSocketConfigEnabled: 0 - switchTcpInitialSendBufferSize: 32 - switchTcpInitialReceiveBufferSize: 64 - switchTcpAutoSendBufferSizeMax: 256 - switchTcpAutoReceiveBufferSizeMax: 256 - switchUdpSendBufferSize: 9 - switchUdpReceiveBufferSize: 42 - switchSocketBufferEfficiency: 4 - switchSocketInitializeEnabled: 1 - switchNetworkInterfaceManagerInitializeEnabled: 1 - switchPlayerConnectionEnabled: 1 - switchUseNewStyleFilepaths: 0 - switchUseMicroSleepForYield: 1 - switchEnableRamDiskSupport: 0 - switchMicroSleepForYieldTime: 25 - switchRamDiskSpaceSize: 12 - ps4NPAgeRating: 12 - ps4NPTitleSecret: - ps4NPTrophyPackPath: - ps4ParentalLevel: 11 - ps4ContentID: ED1633-NPXX51362_00-0000000000000000 - ps4Category: 0 - ps4MasterVersion: 01.00 - ps4AppVersion: 01.00 - ps4AppType: 0 - ps4ParamSfxPath: - ps4VideoOutPixelFormat: 0 - ps4VideoOutInitialWidth: 1920 - ps4VideoOutBaseModeInitialWidth: 1920 - ps4VideoOutReprojectionRate: 60 - ps4PronunciationXMLPath: - ps4PronunciationSIGPath: - ps4BackgroundImagePath: - ps4StartupImagePath: - ps4StartupImagesFolder: - ps4IconImagesFolder: - ps4SaveDataImagePath: - ps4SdkOverride: - ps4BGMPath: - ps4ShareFilePath: - ps4ShareOverlayImagePath: - ps4PrivacyGuardImagePath: - ps4ExtraSceSysFile: - ps4NPtitleDatPath: - ps4RemotePlayKeyAssignment: -1 - ps4RemotePlayKeyMappingDir: - ps4PlayTogetherPlayerCount: 0 - ps4EnterButtonAssignment: 1 - ps4ApplicationParam1: 0 - ps4ApplicationParam2: 0 - ps4ApplicationParam3: 0 - ps4ApplicationParam4: 0 - ps4DownloadDataSize: 0 - ps4GarlicHeapSize: 2048 - ps4ProGarlicHeapSize: 2560 - playerPrefsMaxSize: 32768 - ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ - ps4pnSessions: 1 - ps4pnPresence: 1 - ps4pnFriends: 1 - ps4pnGameCustomData: 1 - playerPrefsSupport: 0 - enableApplicationExit: 0 - resetTempFolder: 1 - restrictedAudioUsageRights: 0 - ps4UseResolutionFallback: 0 - ps4ReprojectionSupport: 0 - ps4UseAudio3dBackend: 0 - ps4UseLowGarlicFragmentationMode: 1 - ps4SocialScreenEnabled: 0 - ps4ScriptOptimizationLevel: 0 - ps4Audio3dVirtualSpeakerCount: 14 - ps4attribCpuUsage: 0 - ps4PatchPkgPath: - ps4PatchLatestPkgPath: - ps4PatchChangeinfoPath: - ps4PatchDayOne: 0 - ps4attribUserManagement: 0 - ps4attribMoveSupport: 0 - ps4attrib3DSupport: 0 - ps4attribShareSupport: 0 - ps4attribExclusiveVR: 0 - ps4disableAutoHideSplash: 0 - ps4videoRecordingFeaturesUsed: 0 - ps4contentSearchFeaturesUsed: 0 - ps4CompatibilityPS5: 0 - ps4GPU800MHz: 1 - ps4attribEyeToEyeDistanceSettingVR: 0 - ps4IncludedModules: [] - ps4attribVROutputEnabled: 0 - monoEnv: - splashScreenBackgroundSourceLandscape: {fileID: 0} - splashScreenBackgroundSourcePortrait: {fileID: 0} - blurSplashScreenBackground: 1 - spritePackerPolicy: - webGLMemorySize: 16 - webGLExceptionSupport: 1 - webGLNameFilesAsHashes: 0 - webGLDataCaching: 1 - webGLDebugSymbols: 0 - webGLEmscriptenArgs: - webGLModulesDirectory: - webGLTemplate: APPLICATION:Default - webGLAnalyzeBuildSize: 0 - webGLUseEmbeddedResources: 0 - webGLCompressionFormat: 1 - webGLWasmArithmeticExceptions: 0 - webGLLinkerTarget: 1 - webGLThreadsSupport: 0 - webGLDecompressionFallback: 0 - scriptingDefineSymbols: {} - additionalCompilerArguments: {} - platformArchitecture: {} - scriptingBackend: {} - il2cppCompilerConfiguration: {} - managedStrippingLevel: {} - incrementalIl2cppBuild: {} - suppressCommonWarnings: 1 - allowUnsafeCode: 0 - useDeterministicCompilation: 1 - enableRoslynAnalyzers: 1 - additionalIl2CppArgs: - scriptingRuntimeVersion: 1 - gcIncremental: 1 - assemblyVersionValidation: 1 - gcWBarrierValidation: 0 - apiCompatibilityLevelPerPlatform: {} - m_RenderingPath: 1 - m_MobileRenderingPath: 1 - metroPackageName: Template_3D - metroPackageVersion: - metroCertificatePath: - metroCertificatePassword: - metroCertificateSubject: - metroCertificateIssuer: - metroCertificateNotAfter: 0000000000000000 - metroApplicationDescription: Template_3D - wsaImages: {} - metroTileShortName: - metroTileShowName: 0 - metroMediumTileShowName: 0 - metroLargeTileShowName: 0 - metroWideTileShowName: 0 - metroSupportStreamingInstall: 0 - metroLastRequiredScene: 0 - metroDefaultTileSize: 1 - metroTileForegroundText: 2 - metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} - metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, a: 1} - metroSplashScreenUseBackgroundColor: 0 - platformCapabilities: {} - metroTargetDeviceFamilies: {} - metroFTAName: - metroFTAFileTypes: [] - metroProtocolName: - vcxProjDefaultLanguage: - XboxOneProductId: - XboxOneUpdateKey: - XboxOneSandboxId: - XboxOneContentId: - XboxOneTitleId: - XboxOneSCId: - XboxOneGameOsOverridePath: - XboxOnePackagingOverridePath: - XboxOneAppManifestOverridePath: - XboxOneVersion: 1.0.0.0 - XboxOnePackageEncryption: 0 - XboxOnePackageUpdateGranularity: 2 - XboxOneDescription: - XboxOneLanguage: - - enus - XboxOneCapability: [] - XboxOneGameRating: {} - XboxOneIsContentPackage: 0 - XboxOneEnhancedXboxCompatibilityMode: 0 - XboxOneEnableGPUVariability: 1 - XboxOneSockets: {} - XboxOneSplashScreen: {fileID: 0} - XboxOneAllowedProductIds: [] - XboxOnePersistentLocalStorageSize: 0 - XboxOneXTitleMemory: 8 - XboxOneOverrideIdentityName: - XboxOneOverrideIdentityPublisher: - vrEditorSettings: {} - cloudServicesEnabled: - UNet: 1 - luminIcon: - m_Name: - m_ModelFolderPath: - m_PortalFolderPath: - luminCert: - m_CertPath: - m_SignPackage: 1 - luminIsChannelApp: 0 - luminVersion: - m_VersionCode: 1 - m_VersionName: - apiCompatibilityLevel: 6 - activeInputHandler: 0 - cloudProjectId: - framebufferDepthMemorylessMode: 0 - qualitySettingsNames: [] - projectName: - organizationId: - cloudEnabled: 0 - legacyClampBlendShapeWeights: 0 - playerDataPath: - forceSRGBBlit: 1 - virtualTexturingSupportEnabled: 0 diff --git a/X10D.Unity.Tests/ProjectSettings/ProjectVersion.txt b/X10D.Unity.Tests/ProjectSettings/ProjectVersion.txt deleted file mode 100644 index f8251a7..0000000 --- a/X10D.Unity.Tests/ProjectSettings/ProjectVersion.txt +++ /dev/null @@ -1,2 +0,0 @@ -m_EditorVersion: 2021.3.22f1 -m_EditorVersionWithRevision: 2021.3.22f1 (b6c551784ba3) diff --git a/X10D.Unity.Tests/ProjectSettings/QualitySettings.asset b/X10D.Unity.Tests/ProjectSettings/QualitySettings.asset deleted file mode 100644 index 7b7658d..0000000 --- a/X10D.Unity.Tests/ProjectSettings/QualitySettings.asset +++ /dev/null @@ -1,232 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!47 &1 -QualitySettings: - m_ObjectHideFlags: 0 - serializedVersion: 5 - m_CurrentQuality: 5 - m_QualitySettings: - - serializedVersion: 2 - name: Very Low - pixelLightCount: 0 - shadows: 0 - shadowResolution: 0 - shadowProjection: 1 - shadowCascades: 1 - shadowDistance: 15 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 0 - blendWeights: 1 - textureQuality: 1 - anisotropicTextures: 0 - antiAliasing: 0 - softParticles: 0 - softVegetation: 0 - realtimeReflectionProbes: 0 - billboardsFaceCameraPosition: 0 - vSyncCount: 0 - lodBias: 0.3 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 4 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Low - pixelLightCount: 0 - shadows: 0 - shadowResolution: 0 - shadowProjection: 1 - shadowCascades: 1 - shadowDistance: 20 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 0 - blendWeights: 2 - textureQuality: 0 - anisotropicTextures: 0 - antiAliasing: 0 - softParticles: 0 - softVegetation: 0 - realtimeReflectionProbes: 0 - billboardsFaceCameraPosition: 0 - vSyncCount: 0 - lodBias: 0.4 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 16 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Medium - pixelLightCount: 1 - shadows: 1 - shadowResolution: 0 - shadowProjection: 1 - shadowCascades: 1 - shadowDistance: 20 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 0 - blendWeights: 2 - textureQuality: 0 - anisotropicTextures: 1 - antiAliasing: 0 - softParticles: 0 - softVegetation: 0 - realtimeReflectionProbes: 0 - billboardsFaceCameraPosition: 0 - vSyncCount: 1 - lodBias: 0.7 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 64 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: High - pixelLightCount: 2 - shadows: 2 - shadowResolution: 1 - shadowProjection: 1 - shadowCascades: 2 - shadowDistance: 40 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 1 - blendWeights: 2 - textureQuality: 0 - anisotropicTextures: 1 - antiAliasing: 0 - softParticles: 0 - softVegetation: 1 - realtimeReflectionProbes: 1 - billboardsFaceCameraPosition: 1 - vSyncCount: 1 - lodBias: 1 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 256 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Very High - pixelLightCount: 3 - shadows: 2 - shadowResolution: 2 - shadowProjection: 1 - shadowCascades: 2 - shadowDistance: 70 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 1 - blendWeights: 4 - textureQuality: 0 - anisotropicTextures: 2 - antiAliasing: 2 - softParticles: 1 - softVegetation: 1 - realtimeReflectionProbes: 1 - billboardsFaceCameraPosition: 1 - vSyncCount: 1 - lodBias: 1.5 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 1024 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - - serializedVersion: 2 - name: Ultra - pixelLightCount: 4 - shadows: 2 - shadowResolution: 2 - shadowProjection: 1 - shadowCascades: 4 - shadowDistance: 150 - shadowNearPlaneOffset: 3 - shadowCascade2Split: 0.33333334 - shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} - shadowmaskMode: 1 - blendWeights: 4 - textureQuality: 0 - anisotropicTextures: 2 - antiAliasing: 2 - softParticles: 1 - softVegetation: 1 - realtimeReflectionProbes: 1 - billboardsFaceCameraPosition: 1 - vSyncCount: 1 - lodBias: 2 - maximumLODLevel: 0 - streamingMipmapsActive: 0 - streamingMipmapsAddAllCameras: 1 - streamingMipmapsMemoryBudget: 512 - streamingMipmapsRenderersPerFrame: 512 - streamingMipmapsMaxLevelReduction: 2 - streamingMipmapsMaxFileIORequests: 1024 - particleRaycastBudget: 4096 - asyncUploadTimeSlice: 2 - asyncUploadBufferSize: 16 - asyncUploadPersistentBuffer: 1 - resolutionScalingFixedDPIFactor: 1 - excludedTargetPlatforms: [] - m_PerPlatformDefaultQuality: - Android: 2 - Lumin: 5 - Nintendo 3DS: 5 - Nintendo Switch: 5 - PS4: 5 - PSP2: 2 - Stadia: 5 - Standalone: 5 - WebGL: 3 - Windows Store Apps: 5 - XboxOne: 5 - iPhone: 2 - tvOS: 2 diff --git a/X10D.Unity.Tests/ProjectSettings/RiderScriptEditorPersistedState.asset b/X10D.Unity.Tests/ProjectSettings/RiderScriptEditorPersistedState.asset deleted file mode 100644 index 9f5ce87..0000000 --- a/X10D.Unity.Tests/ProjectSettings/RiderScriptEditorPersistedState.asset +++ /dev/null @@ -1,15 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &1 -MonoBehaviour: - m_ObjectHideFlags: 61 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 0} - m_Name: - m_EditorClassIdentifier: Unity.Rider.Editor:Packages.Rider.Editor:RiderScriptEditorPersistedState - lastWriteTicks: -8585496032972088364 diff --git a/X10D.Unity.Tests/ProjectSettings/SceneTemplateSettings.json b/X10D.Unity.Tests/ProjectSettings/SceneTemplateSettings.json deleted file mode 100644 index 6f3e60f..0000000 --- a/X10D.Unity.Tests/ProjectSettings/SceneTemplateSettings.json +++ /dev/null @@ -1,167 +0,0 @@ -{ - "templatePinStates": [], - "dependencyTypeInfos": [ - { - "userAdded": false, - "type": "UnityEngine.AnimationClip", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEditor.Animations.AnimatorController", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.AnimatorOverrideController", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEditor.Audio.AudioMixerController", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.ComputeShader", - "ignore": true, - "defaultInstantiationMode": 1, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.Cubemap", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.GameObject", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEditor.LightingDataAsset", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": false - }, - { - "userAdded": false, - "type": "UnityEngine.LightingSettings", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.Material", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEditor.MonoScript", - "ignore": true, - "defaultInstantiationMode": 1, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.PhysicMaterial", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.PhysicsMaterial2D", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.Rendering.VolumeProfile", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEditor.SceneAsset", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": false - }, - { - "userAdded": false, - "type": "UnityEngine.Shader", - "ignore": true, - "defaultInstantiationMode": 1, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.ShaderVariantCollection", - "ignore": true, - "defaultInstantiationMode": 1, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.Texture", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.Texture2D", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - }, - { - "userAdded": false, - "type": "UnityEngine.Timeline.TimelineAsset", - "ignore": false, - "defaultInstantiationMode": 0, - "supportsModification": true - } - ], - "defaultDependencyTypeInfo": { - "userAdded": false, - "type": "", - "ignore": false, - "defaultInstantiationMode": 1, - "supportsModification": true - }, - "newSceneOverride": 0 -} \ No newline at end of file diff --git a/X10D.Unity.Tests/ProjectSettings/TagManager.asset b/X10D.Unity.Tests/ProjectSettings/TagManager.asset deleted file mode 100644 index 1c92a78..0000000 --- a/X10D.Unity.Tests/ProjectSettings/TagManager.asset +++ /dev/null @@ -1,43 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!78 &1 -TagManager: - serializedVersion: 2 - tags: [] - layers: - - Default - - TransparentFX - - Ignore Raycast - - - - Water - - UI - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - m_SortingLayers: - - name: Default - uniqueID: 0 - locked: 0 diff --git a/X10D.Unity.Tests/ProjectSettings/TimeManager.asset b/X10D.Unity.Tests/ProjectSettings/TimeManager.asset deleted file mode 100644 index 558a017..0000000 --- a/X10D.Unity.Tests/ProjectSettings/TimeManager.asset +++ /dev/null @@ -1,9 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!5 &1 -TimeManager: - m_ObjectHideFlags: 0 - Fixed Timestep: 0.02 - Maximum Allowed Timestep: 0.33333334 - m_TimeScale: 1 - Maximum Particle Timestep: 0.03 diff --git a/X10D.Unity.Tests/ProjectSettings/UnityConnectSettings.asset b/X10D.Unity.Tests/ProjectSettings/UnityConnectSettings.asset deleted file mode 100644 index 6125b30..0000000 --- a/X10D.Unity.Tests/ProjectSettings/UnityConnectSettings.asset +++ /dev/null @@ -1,35 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!310 &1 -UnityConnectSettings: - m_ObjectHideFlags: 0 - serializedVersion: 1 - m_Enabled: 0 - m_TestMode: 0 - m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events - m_EventUrl: https://cdp.cloud.unity3d.com/v1/events - m_ConfigUrl: https://config.uca.cloud.unity3d.com - m_DashboardUrl: https://dashboard.unity3d.com - m_TestInitMode: 0 - CrashReportingSettings: - m_EventUrl: https://perf-events.cloud.unity3d.com - m_Enabled: 0 - m_LogBufferSize: 10 - m_CaptureEditorExceptions: 1 - UnityPurchasingSettings: - m_Enabled: 0 - m_TestMode: 0 - UnityAnalyticsSettings: - m_Enabled: 0 - m_TestMode: 0 - m_InitializeOnStartup: 1 - UnityAdsSettings: - m_Enabled: 0 - m_InitializeOnStartup: 1 - m_TestMode: 0 - m_IosGameId: - m_AndroidGameId: - m_GameIds: {} - m_GameId: - PerformanceReportingSettings: - m_Enabled: 0 diff --git a/X10D.Unity.Tests/ProjectSettings/VFXManager.asset b/X10D.Unity.Tests/ProjectSettings/VFXManager.asset deleted file mode 100644 index 3a95c98..0000000 --- a/X10D.Unity.Tests/ProjectSettings/VFXManager.asset +++ /dev/null @@ -1,12 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!937362698 &1 -VFXManager: - m_ObjectHideFlags: 0 - m_IndirectShader: {fileID: 0} - m_CopyBufferShader: {fileID: 0} - m_SortShader: {fileID: 0} - m_StripUpdateShader: {fileID: 0} - m_RenderPipeSettingsPath: - m_FixedTimeStep: 0.016666668 - m_MaxDeltaTime: 0.05 diff --git a/X10D.Unity.Tests/ProjectSettings/VersionControlSettings.asset b/X10D.Unity.Tests/ProjectSettings/VersionControlSettings.asset deleted file mode 100644 index dca2881..0000000 --- a/X10D.Unity.Tests/ProjectSettings/VersionControlSettings.asset +++ /dev/null @@ -1,8 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!890905787 &1 -VersionControlSettings: - m_ObjectHideFlags: 0 - m_Mode: Visible Meta Files - m_CollabEditorSettings: - inProgressEnabled: 1 diff --git a/X10D.Unity.Tests/ProjectSettings/XRSettings.asset b/X10D.Unity.Tests/ProjectSettings/XRSettings.asset deleted file mode 100644 index 482590c..0000000 --- a/X10D.Unity.Tests/ProjectSettings/XRSettings.asset +++ /dev/null @@ -1,10 +0,0 @@ -{ - "m_SettingKeys": [ - "VR Device Disabled", - "VR Device User Alert" - ], - "m_SettingValues": [ - "False", - "False" - ] -} \ No newline at end of file diff --git a/X10D.Unity.Tests/ProjectSettings/boot.config b/X10D.Unity.Tests/ProjectSettings/boot.config deleted file mode 100644 index e69de29..0000000 diff --git a/X10D.Unity/README.md b/X10D.Unity/README.md deleted file mode 100644 index 105de43..0000000 --- a/X10D.Unity/README.md +++ /dev/null @@ -1,36 +0,0 @@ -

-

-GitHub Workflow Status - -MIT License -

- -### About -X10D (pronounced *extend*), is a .NET package that provides extension methods for numerous types. The purpose of this library is to simplify a codebase by reducing the need for repeated code when performing common operations. Simplify your codebase. Take advantage of .NET. Use extension methods. - -*(I'm also [dogfooding](https://www.pcmag.com/encyclopedia/term/dogfooding) this library, so there's that.)* - - -### Preface -Parity with the main branch of X10D, and full .NET feature support, is planned. Unity plan to add CoreCLR and native NuGet support in the future, but no timeline is available. -For more information, see [this forum post](https://forum.unity.com/threads/unity-future-net-development-status.1092205/). - -## Installation -You must be using Unity 2021.3 LTS or later to add this package. -### Using the Unity Package Manager (UPM) -To install X10D in Unity, follow the steps blow: -1. Navigate to the [Package Manager window](https://docs.unity3d.com/Manual/upm-ui.html), under `Window > Package Manager` -2. Hit the `+` icon and select `Add package from git URL...` -3. Enter the following URL: https://github.com/oliverbooth/X10D.git#upm and hit the Add button -4. Profit! - -The [upm](https://github.com/oliverbooth/X10D/tree/upm) branch contains the latest nightly - that is the bleeding edge version of X10D. -If you'd like to remain on a stable release, specify a commit hash after the `#` instead of `upm`. -The latest current stable is 3.3.1, which is commit [0bb35bb565fff170a3848acdffbb5d53087de64b](https://github.com/oliverbooth/X10D/commit/0bb35bb565fff170a3848acdffbb5d53087de64b). -Keep in mind that referencing a specific commit rather than the `upm` branch will prevent the auto-updater in Unity from detecting new versions. - -## Contributing -Contributions are welcome. See [CONTRIBUTING.md](../CONTRIBUTING.md). - -## License -X10D is released under the MIT License. See [here](https://github.com/oliverbooth/X10D/blob/main/LICENSE.md) for more details. diff --git a/X10D.Unity/X10D.Unity.csproj b/X10D.Unity/X10D.Unity.csproj deleted file mode 100644 index e68de2b..0000000 --- a/X10D.Unity/X10D.Unity.csproj +++ /dev/null @@ -1,88 +0,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 - - - - - - - ResXFileCodeGenerator - ExceptionMessages.Designer.cs - - - - - - True - True - ExceptionMessages.resx - - - - diff --git a/X10D.Unity/X10D.Unity.csproj.DotSettings b/X10D.Unity/X10D.Unity.csproj.DotSettings deleted file mode 100644 index cc2d8d0..0000000 --- a/X10D.Unity/X10D.Unity.csproj.DotSettings +++ /dev/null @@ -1,2 +0,0 @@ - - True \ No newline at end of file diff --git a/X10D.Unity/branding_Unity.png b/X10D.Unity/branding_Unity.png deleted file mode 100644 index c46d202..0000000 Binary files a/X10D.Unity/branding_Unity.png and /dev/null differ diff --git a/X10D.Unity/src/Assembly.cs b/X10D.Unity/src/Assembly.cs deleted file mode 100644 index 4e11466..0000000 --- a/X10D.Unity/src/Assembly.cs +++ /dev/null @@ -1 +0,0 @@ -[assembly: CLSCompliant(false)] diff --git a/X10D.Unity/src/ComponentExtensions.cs b/X10D.Unity/src/ComponentExtensions.cs deleted file mode 100644 index 01d0a27..0000000 --- a/X10D.Unity/src/ComponentExtensions.cs +++ /dev/null @@ -1,27 +0,0 @@ -using UnityEngine; - -namespace X10D.Unity; - -/// -/// Extension methods for . -/// -public static class ComponentExtensions -{ - /// - /// Returns an array of components of the specified type, excluding components that live on the object to which this - /// component is attached. - /// - /// The component whose child components to retrieve. - /// The type of the components to retrieve. - /// An array representing the child components. - /// is . - public static T[] GetComponentsInChildrenOnly(this Component component) - { - if (component == null) - { - throw new ArgumentNullException(nameof(component)); - } - - return component.gameObject.GetComponentsInChildrenOnly(); - } -} diff --git a/X10D.Unity/src/DebugUtility/DebugUtility.Circle.cs b/X10D.Unity/src/DebugUtility/DebugUtility.Circle.cs deleted file mode 100644 index e5c6cb4..0000000 --- a/X10D.Unity/src/DebugUtility/DebugUtility.Circle.cs +++ /dev/null @@ -1,333 +0,0 @@ -using UnityEngine; -using X10D.Drawing; -using X10D.Numerics; -using X10D.Unity.Numerics; -using Quaternion = System.Numerics.Quaternion; - -namespace X10D.Unity; - -public static partial class DebugUtility -{ - /// - /// Draws a circle with the specified color. - /// - /// The center point of the circle. - /// The radius of the circle. - /// The number of segments to generate. - public static void DrawCircle(Vector2 center, float radius, int segments) - { - DrawCircle(center, radius, segments, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color. - /// - /// The center point of the circle. - /// The radius of the circle. - /// The number of segments to generate. - /// The color of the circle. - public static void DrawCircle(Vector2 center, float radius, int segments, in Color color) - { - DrawCircle(center, radius, segments, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color and duration. - /// - /// The center point of the circle. - /// The radius of the circle. - /// The number of segments to generate. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - public static void DrawCircle(Vector2 center, float radius, int segments, in Color color, float duration) - { - DrawCircle(center, radius, segments, Vector2.zero, color, duration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color and duration. - /// - /// The center point of the circle. - /// The radius of the circle. - /// The number of segments to generate. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the circle be obscured by objects closer to the camera. - /// - public static void DrawCircle(Vector2 center, float radius, int segments, in Color color, float duration, bool depthTest) - { - DrawCircle(center, radius, segments, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws a circle. - /// - /// The center point of the circle. - /// The radius of the circle. - /// The number of segments to generate. - /// The drawing offset of the circle. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the circle be obscured by objects closer to the camera. - /// - public static void DrawCircle(Vector2 center, float radius, int segments, in Vector3 offset, in Color color, float duration, - bool depthTest) - { - DrawCircle(new CircleF(center.ToSystemVector(), radius), segments, offset, color, duration, depthTest); - } - - /// - /// Draws a circle with the specified color. - /// - /// The circle to draw. - /// The number of segments to generate. - public static void DrawCircle(in Circle circle, int segments) - { - DrawCircle((CircleF)circle, segments, Vector2.zero, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The drawing offset of the circle. - public static void DrawCircle(in Circle circle, int segments, in Vector3 offset) - { - DrawCircle((CircleF)circle, segments, offset, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The color of the circle. - public static void DrawCircle(in Circle circle, int segments, in Color color) - { - DrawCircle((CircleF)circle, segments, Vector2.zero, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The drawing offset of the circle. - /// The color of the circle. - public static void DrawCircle(in Circle circle, int segments, in Vector3 offset, in Color color) - { - DrawCircle((CircleF)circle, segments, offset, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color and duration. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - public static void DrawCircle(in Circle circle, int segments, in Color color, float duration) - { - DrawCircle((CircleF)circle, segments, Vector2.zero, color, duration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color and duration. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The drawing offset of the circle. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - public static void DrawCircle(in Circle circle, int segments, in Vector3 offset, in Color color, float duration) - { - DrawCircle((CircleF)circle, segments, offset, color, duration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color and duration. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the circle be obscured by objects closer to the camera. - /// - public static void DrawCircle(in Circle circle, int segments, in Color color, float duration, bool depthTest) - { - DrawCircle((CircleF)circle, segments, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws a circle. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The drawing offset of the circle. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the circle be obscured by objects closer to the camera. - /// - public static void DrawCircle(in Circle circle, int segments, in Vector3 offset, in Color color, float duration, - bool depthTest) - { - DrawCircle((CircleF)circle, segments, offset, color, duration, depthTest); - } - - /// - /// Draws a circle with the specified color. - /// - /// The circle to draw. - /// The number of segments to generate. - public static void DrawCircle(in CircleF circle, int segments) - { - DrawCircle(circle, segments, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The drawing offset of the circle. - public static void DrawCircle(in CircleF circle, int segments, in Vector3 offset) - { - DrawCircle(circle, segments, offset, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The color of the circle. - public static void DrawCircle(in CircleF circle, int segments, in Color color) - { - DrawCircle(circle, segments, Vector2.zero, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The drawing offset of the circle. - /// The color of the circle. - public static void DrawCircle(in CircleF circle, int segments, in Vector3 offset, in Color color) - { - DrawCircle(circle, segments, offset, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color and duration. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - public static void DrawCircle(in CircleF circle, int segments, in Color color, float duration) - { - DrawCircle(circle, segments, Vector2.zero, color, duration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color and duration. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The drawing offset of the circle. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - public static void DrawCircle(in CircleF circle, int segments, in Vector3 offset, in Color color, float duration) - { - DrawCircle(circle, segments, offset, color, duration, DefaultDepthTest); - } - - /// - /// Draws a circle with the specified color and duration. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the circle be obscured by objects closer to the camera. - /// - public static void DrawCircle(in CircleF circle, int segments, in Color color, float duration, bool depthTest) - { - DrawCircle(circle, segments, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws a circle. - /// - /// The circle to draw. - /// The number of segments to generate. - /// The drawing offset of the circle. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the circle be obscured by objects closer to the camera. - /// - public static void DrawCircle(in CircleF circle, int segments, in Vector3 offset, in Color color, float duration, - bool depthTest) - { - DrawPolyhedron(CreateCircle(circle.Radius, segments, Vector3.zero), offset, color, duration, depthTest); - } - - private static Polyhedron CreateCircle(float radius, int segments, in Vector3 axis) - { - const float max = 2.0f * MathF.PI; - float step = max / segments; - - var points = new List(); - for (var theta = 0f; theta < max; theta += step) - { - float x = radius * MathF.Cos(theta); - float y = radius * MathF.Sin(theta); - var vector = new System.Numerics.Vector3(x, y, 0); - - if (axis != Vector3.zero) - { - vector = Quaternion.CreateFromAxisAngle(axis.ToSystemVector(), MathF.PI / 2.0f).Multiply(vector); - } - - points.Add(vector); - } - - return new Polyhedron(points); - } -} diff --git a/X10D.Unity/src/DebugUtility/DebugUtility.Ellipse.cs b/X10D.Unity/src/DebugUtility/DebugUtility.Ellipse.cs deleted file mode 100644 index a4994f6..0000000 --- a/X10D.Unity/src/DebugUtility/DebugUtility.Ellipse.cs +++ /dev/null @@ -1,406 +0,0 @@ -using UnityEngine; -using X10D.Drawing; - -namespace X10D.Unity; - -public static partial class DebugUtility -{ - /// - /// Draws an ellipse with the specified color. - /// - /// The center point of the ellipse. - /// The radius of the ellipse. - /// The number of segments to generate. - public static void DrawEllipse(Vector2 center, Vector2 radius, int segments) - { - DrawEllipse(center, radius.x, radius.y, segments, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color. - /// - /// The center point of the ellipse. - /// The radius of the ellipse. - /// The number of segments to generate. - /// The color of the ellipse. - public static void DrawEllipse(Vector2 center, Vector2 radius, int segments, in Color color) - { - DrawEllipse(center, radius.x, radius.y, segments, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color and duration. - /// - /// The center point of the ellipse. - /// The radius of the ellipse. - /// The number of segments to generate. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - public static void DrawEllipse(Vector2 center, Vector2 radius, int segments, in Color color, float duration) - { - DrawEllipse(center, radius.x, radius.y, segments, Vector2.zero, color, duration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color and duration. - /// - /// The center point of the ellipse. - /// The radius of the ellipse. - /// The number of segments to generate. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the ellipse be obscured by objects closer to the camera. - /// - public static void DrawEllipse(Vector2 center, Vector2 radius, int segments, in Color color, float duration, bool depthTest) - { - DrawEllipse(center, radius.x, radius.y, segments, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws an ellipse. - /// - /// The center point of the ellipse. - /// The radius of the ellipse. - /// The number of segments to generate. - /// The drawing offset of the ellipse. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the ellipse be obscured by objects closer to the camera. - /// - public static void DrawEllipse(Vector2 center, Vector2 radius, int segments, Vector2 offset, in Color color, float duration, - bool depthTest) - { - DrawEllipse(new EllipseF(center.x, center.y, radius.x, radius.y), segments, offset, color, duration, depthTest); - } - - /// - /// Draws an ellipse with the specified color. - /// - /// The center point of the ellipse. - /// The horizontal radius of the ellipse. - /// The vertical radius of the ellipse. - /// The number of segments to generate. - public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int segments) - { - DrawEllipse(center, radiusX, radiusY, segments, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color. - /// - /// The center point of the ellipse. - /// The horizontal radius of the ellipse. - /// The vertical radius of the ellipse. - /// The number of segments to generate. - /// The color of the ellipse. - public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int segments, in Color color) - { - DrawEllipse(center, radiusX, radiusY, segments, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color and duration. - /// - /// The center point of the ellipse. - /// The horizontal radius of the ellipse. - /// The vertical radius of the ellipse. - /// The number of segments to generate. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int segments, in Color color, float duration) - { - DrawEllipse(center, radiusX, radiusY, segments, Vector2.zero, color, duration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color and duration. - /// - /// The center point of the ellipse. - /// The horizontal radius of the ellipse. - /// The vertical radius of the ellipse. - /// The number of segments to generate. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the ellipse be obscured by objects closer to the camera. - /// - public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int segments, in Color color, float duration, - bool depthTest) - { - DrawEllipse(center, radiusX, radiusY, segments, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws an ellipse. - /// - /// The center point of the ellipse. - /// The horizontal radius of the ellipse. - /// The vertical radius of the ellipse. - /// The number of segments to generate. - /// The drawing offset of the ellipse. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the ellipse be obscured by objects closer to the camera. - /// - public static void DrawEllipse(Vector2 center, float radiusX, float radiusY, int segments, Vector2 offset, in Color color, - float duration, bool depthTest) - { - DrawEllipse(new EllipseF(center.x, center.y, radiusX, radiusY), segments, offset, color, duration, depthTest); - } - - /// - /// Draws an ellipse with the specified color. - /// - /// The ellipse to draw. - /// The number of segments to generate. - public static void DrawEllipse(Ellipse ellipse, int segments) - { - DrawEllipse((EllipseF)ellipse, segments, Vector2.zero, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The drawing offset of the ellipse. - public static void DrawEllipse(Ellipse ellipse, int segments, Vector2 offset) - { - DrawEllipse((EllipseF)ellipse, segments, offset, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The color of the ellipse. - public static void DrawEllipse(Ellipse ellipse, int segments, in Color color) - { - DrawEllipse((EllipseF)ellipse, segments, Vector2.zero, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The drawing offset of the ellipse. - /// The color of the ellipse. - public static void DrawEllipse(Ellipse ellipse, int segments, Vector2 offset, in Color color) - { - DrawEllipse((EllipseF)ellipse, segments, offset, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color and duration. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - public static void DrawEllipse(Ellipse ellipse, int segments, in Color color, float duration) - { - DrawEllipse((EllipseF)ellipse, segments, Vector2.zero, color, duration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color and duration. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The drawing offset of the ellipse. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - public static void DrawEllipse(Ellipse ellipse, int segments, Vector2 offset, in Color color, float duration) - { - DrawEllipse((EllipseF)ellipse, segments, offset, color, duration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color and duration. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the ellipse be obscured by objects closer to the camera. - /// - public static void DrawEllipse(Ellipse ellipse, int segments, in Color color, float duration, bool depthTest) - { - DrawEllipse((EllipseF)ellipse, segments, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws an ellipse. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The drawing offset of the ellipse. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the ellipse be obscured by objects closer to the camera. - /// - public static void DrawEllipse(Ellipse ellipse, int segments, Vector2 offset, in Color color, float duration, bool depthTest) - { - DrawEllipse((EllipseF)ellipse, segments, offset, color, duration, depthTest); - } - - /// - /// Draws an ellipse with the specified color. - /// - /// The ellipse to draw. - /// The number of segments to generate. - public static void DrawEllipse(EllipseF ellipse, int segments) - { - DrawEllipse(ellipse, segments, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The drawing offset of the ellipse. - public static void DrawEllipse(EllipseF ellipse, int segments, Vector2 offset) - { - DrawEllipse(ellipse, segments, offset, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The color of the ellipse. - public static void DrawEllipse(EllipseF ellipse, int segments, in Color color) - { - DrawEllipse(ellipse, segments, Vector2.zero, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The drawing offset of the ellipse. - /// The color of the ellipse. - public static void DrawEllipse(EllipseF ellipse, int segments, Vector2 offset, in Color color) - { - DrawEllipse(ellipse, segments, offset, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color and duration. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - public static void DrawEllipse(EllipseF ellipse, int segments, in Color color, float duration) - { - DrawEllipse(ellipse, segments, Vector2.zero, color, duration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color and duration. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The drawing offset of the ellipse. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - public static void DrawEllipse(EllipseF ellipse, int segments, Vector2 offset, in Color color, float duration) - { - DrawEllipse(ellipse, segments, offset, color, duration, DefaultDepthTest); - } - - /// - /// Draws an ellipse with the specified color and duration. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the ellipse be obscured by objects closer to the camera. - /// - public static void DrawEllipse(EllipseF ellipse, int segments, in Color color, float duration, bool depthTest) - { - DrawEllipse(ellipse, segments, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws an ellipse. - /// - /// The ellipse to draw. - /// The number of segments to generate. - /// The drawing offset of the ellipse. - /// The color of the ellipse. - /// - /// The duration of the ellipse's visibility, in seconds. If 0 is passed, the ellipse is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the ellipse be obscured by objects closer to the camera. - /// - public static void DrawEllipse(EllipseF ellipse, int segments, Vector2 offset, in Color color, float duration, bool depthTest) - { - DrawPolygon(CreateEllipse(ellipse.HorizontalRadius, ellipse.VerticalRadius, segments), offset, color, duration, - depthTest); - } - - private static PolygonF CreateEllipse(float radiusX, float radiusY, int segments) - { - const float max = 2.0f * MathF.PI; - float step = max / segments; - - var points = new List(); - for (var theta = 0f; theta < max; theta += step) - { - float x = radiusX * MathF.Cos(theta); - float y = radiusY * MathF.Sin(theta); - points.Add(new System.Numerics.Vector2(x, y)); - } - - return new PolygonF(points); - } -} diff --git a/X10D.Unity/src/DebugUtility/DebugUtility.Function.cs b/X10D.Unity/src/DebugUtility/DebugUtility.Function.cs deleted file mode 100644 index 4b7f33c..0000000 --- a/X10D.Unity/src/DebugUtility/DebugUtility.Function.cs +++ /dev/null @@ -1,69 +0,0 @@ -using UnityEngine; -using X10D.Drawing; -using X10D.Numerics; -using X10D.Unity.Numerics; -using Quaternion = System.Numerics.Quaternion; - -namespace X10D.Unity; - -public static partial class DebugUtility -{ - /// - /// Draws a function plot. - /// - /// The function to plot. - /// The minimum X value. - /// The maximum X value. - public static void DrawFunction(Func function, float xMin, float xMax) - { - DrawFunction(function, xMin, xMax, 0.1f, Vector3.zero, Color.white, 0.0f, false); - } - - /// - /// Draws a function plot. - /// - /// The function to plot. - /// The minimum X value. - /// The maximum X value. - /// The X increment. - /// The drawing offset of the circle. - /// The color of the circle. - /// - /// The duration of the circle's visibility, in seconds. If 0 is passed, the circle is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the circle be obscured by objects closer to the camera. - /// - /// is . - public static void DrawFunction(Func function, float xMin, float xMax, float step, in Vector3 offset, - in Color color, float duration, - bool depthTest) - { - if (function is null) - { - throw new ArgumentNullException(nameof(function)); - } - - DrawUnjoinedPolyhedron(CreateFunction(function, xMin, xMax, step, Vector3.zero), offset, color, duration, depthTest); - } - - private static Polyhedron CreateFunction(Func function, float xMin, float xMax, float step, in Vector3 axis) - { - var points = new List(); - for (float x = xMin; x < xMax; x += step) - { - float y = function(x); - var vector = new System.Numerics.Vector3(x, y, 0); - - if (axis != Vector3.zero) - { - vector = Quaternion.CreateFromAxisAngle(axis.ToSystemVector(), MathF.PI / 2.0f).Multiply(vector); - } - - points.Add(vector); - } - - return new Polyhedron(points); - } -} diff --git a/X10D.Unity/src/DebugUtility/DebugUtility.Line.cs b/X10D.Unity/src/DebugUtility/DebugUtility.Line.cs deleted file mode 100644 index 1439724..0000000 --- a/X10D.Unity/src/DebugUtility/DebugUtility.Line.cs +++ /dev/null @@ -1,209 +0,0 @@ -using UnityEngine; -using X10D.Drawing; -using X10D.Unity.Drawing; -using X10D.Unity.Numerics; - -namespace X10D.Unity; - -public static partial class DebugUtility -{ - /// - /// Draws a line between start and end points. - /// - /// The starting point. - /// The ending point. - public static void DrawLine(Vector3 start, Vector3 end) - { - DrawLine(start, end, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The starting point. - /// The ending point. - /// The color of the line. - public static void DrawLine(Vector3 start, Vector3 end, in Color color) - { - DrawLine(start, end, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The starting point. - /// The ending point. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - public static void DrawLine(Vector3 start, Vector3 end, in Color color, float duration) - { - DrawLine(start, end, color, duration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The starting point. - /// The ending point. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the line be obscured by objects closer to the camera. - /// - public static void DrawLine(Vector3 start, Vector3 end, in Color color, float duration, bool depthTest) - { - Debug.DrawLine(start, end, color, duration, depthTest); - } - - /// - /// Draws a line between start and end points. - /// - /// The line to draw. - public static void DrawLine(Line line) - { - DrawLine(line, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The line to draw. - /// The color of the line. - public static void DrawLine(Line line, in Color color) - { - DrawLine(line, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The line to draw. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - public static void DrawLine(Line line, in Color color, float duration) - { - DrawLine(line, color, duration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The line to draw. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the line be obscured by objects closer to the camera. - /// - public static void DrawLine(Line line, in Color color, float duration, bool depthTest) - { - Debug.DrawLine(line.Start.ToUnityVector2(), line.End.ToUnityVector2(), color, duration, depthTest); - } - - /// - /// Draws a line between start and end points. - /// - /// The line to draw. - public static void DrawLine(LineF line) - { - DrawLine(line, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The line to draw. - /// The color of the line. - public static void DrawLine(LineF line, in Color color) - { - DrawLine(line, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The line to draw. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - public static void DrawLine(LineF line, in Color color, float duration) - { - DrawLine(line, color, duration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The line to draw. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the line be obscured by objects closer to the camera. - /// - public static void DrawLine(LineF line, in Color color, float duration, bool depthTest) - { - Debug.DrawLine(line.Start.ToUnityVector2(), line.End.ToUnityVector2(), color, duration, depthTest); - } - - /// - /// Draws a line between start and end points. - /// - /// The line to draw. - public static void DrawLine(Line3D line) - { - DrawLine(line, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The line to draw. - /// The color of the line. - public static void DrawLine(Line3D line, in Color color) - { - DrawLine(line, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The line to draw. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - public static void DrawLine(Line3D line, in Color color, float duration) - { - DrawLine(line, color, duration, DefaultDepthTest); - } - - /// - /// Draws a line between start and end points, with the specified color. - /// - /// The line to draw. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the line be obscured by objects closer to the camera. - /// - public static void DrawLine(Line3D line, in Color color, float duration, bool depthTest) - { - Debug.DrawLine(line.Start.ToUnityVector(), line.End.ToUnityVector(), color, duration, depthTest); - } -} diff --git a/X10D.Unity/src/DebugUtility/DebugUtility.Polygon.cs b/X10D.Unity/src/DebugUtility/DebugUtility.Polygon.cs deleted file mode 100644 index 1e0fa9f..0000000 --- a/X10D.Unity/src/DebugUtility/DebugUtility.Polygon.cs +++ /dev/null @@ -1,232 +0,0 @@ -using UnityEngine; -using X10D.Drawing; -using X10D.Unity.Drawing; -using PointF = System.Drawing.PointF; - -namespace X10D.Unity; - -public static partial class DebugUtility -{ - /// - /// Draws a polygon. - /// - /// The polygon to draw. - public static void DrawPolygon(Polygon polygon) - { - DrawPolygon((PolygonF)polygon, Vector2.zero, Color.white, DefaultDrawDuration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The drawing offset of the polygon. - public static void DrawPolygon(Polygon polygon, in Vector3 offset) - { - DrawPolygon((PolygonF)polygon, offset, Color.white, DefaultDrawDuration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The color to use for drawing. - public static void DrawPolygon(Polygon polygon, in Color color) - { - DrawPolygon((PolygonF)polygon, Vector2.zero, color, DefaultDrawDuration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The drawing offset of the polygon. - /// The color to use for drawing. - public static void DrawPolygon(Polygon polygon, in Vector3 offset, in Color color) - { - DrawPolygon((PolygonF)polygon, offset, color, DefaultDrawDuration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The color to use for drawing. - /// - /// The duration of the polygon's visibility, in seconds. If 0 is passed, the polygon is visible for a single frame. - /// - public static void DrawPolygon(Polygon polygon, in Color color, float duration) - { - DrawPolygon((PolygonF)polygon, Vector2.zero, color, duration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The drawing offset of the polygon. - /// The color to use for drawing. - /// - /// The duration of the polygon's visibility, in seconds. If 0 is passed, the polygon is visible for a single frame. - /// - public static void DrawPolygon(Polygon polygon, in Vector3 offset, in Color color, float duration) - { - DrawPolygon((PolygonF)polygon, offset, color, duration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The color to use for drawing. - /// - /// The duration of the polygon's visibility, in seconds. If 0 is passed, the polygon is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawPolygon(Polygon polygon, in Color color, float duration, bool depthTest) - { - DrawPolygon((PolygonF)polygon, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The drawing offset of the polygon. - /// The color to use for drawing. - /// - /// The duration of the polygon's visibility, in seconds. If 0 is passed, the polygon is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawPolygon(Polygon polygon, in Vector3 offset, in Color color, float duration, bool depthTest) - { - DrawPolygon((PolygonF)polygon, offset, color, duration, depthTest); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - public static void DrawPolygon(PolygonF polygon) - { - DrawPolygon(polygon, Vector2.zero, Color.white, DefaultDrawDuration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The drawing offset of the polygon. - public static void DrawPolygon(PolygonF polygon, in Vector3 offset) - { - DrawPolygon(polygon, offset, Color.white, DefaultDrawDuration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The color to use for drawing. - public static void DrawPolygon(PolygonF polygon, in Color color) - { - DrawPolygon(polygon, Vector2.zero, color, DefaultDrawDuration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The drawing offset of the polygon. - /// The color to use for drawing. - public static void DrawPolygon(PolygonF polygon, in Vector3 offset, in Color color) - { - DrawPolygon(polygon, offset, color, DefaultDrawDuration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The color to use for drawing. - /// - /// The duration of the polygon's visibility, in seconds. If 0 is passed, the polygon is visible for a single frame. - /// - public static void DrawPolygon(PolygonF polygon, in Color color, float duration) - { - DrawPolygon(polygon, Vector2.zero, color, duration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The drawing offset of the polygon. - /// The color to use for drawing. - /// - /// The duration of the polygon's visibility, in seconds. If 0 is passed, the polygon is visible for a single frame. - /// - public static void DrawPolygon(PolygonF polygon, in Vector3 offset, in Color color, float duration) - { - DrawPolygon(polygon, offset, color, duration, true); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The color to use for drawing. - /// - /// The duration of the polygon's visibility, in seconds. If 0 is passed, the polygon is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawPolygon(PolygonF polygon, in Color color, float duration, bool depthTest) - { - DrawPolygon(polygon, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws a polygon. - /// - /// The polygon to draw. - /// The drawing offset of the polygon. - /// The color to use for drawing. - /// - /// The duration of the polygon's visibility, in seconds. If 0 is passed, the polygon is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - /// is . - public static void DrawPolygon(PolygonF polygon, in Vector3 offset, in Color color, float duration, bool depthTest) - { - if (polygon is null) - { - throw new ArgumentNullException(nameof(polygon)); - } - - IReadOnlyList points = polygon.Vertices; - if (points.Count < 2) - { - return; - } - - for (var i = 0; i < points.Count; i++) - { - int j = (i + 1) % points.Count; - Vector3 start = (Vector3)points[i].ToUnityVector2() + offset; - Vector3 end = (Vector3)points[j].ToUnityVector2() + offset; - - DrawLine(start, end, color, duration, depthTest); - } - } -} diff --git a/X10D.Unity/src/DebugUtility/DebugUtility.Polyhedron.cs b/X10D.Unity/src/DebugUtility/DebugUtility.Polyhedron.cs deleted file mode 100644 index 205dfff..0000000 --- a/X10D.Unity/src/DebugUtility/DebugUtility.Polyhedron.cs +++ /dev/null @@ -1,172 +0,0 @@ -using UnityEngine; -using X10D.Drawing; -using X10D.Unity.Numerics; - -namespace X10D.Unity; - -public static partial class DebugUtility -{ - /// - /// Draws a polyhedron. - /// - /// The polyhedron to draw. - public static void DrawPolyhedron(Polyhedron polyhedron) - { - DrawPolyhedron(polyhedron, Vector2.zero, Color.white, DefaultDrawDuration, true); - } - - /// - /// Draws a polyhedron. - /// - /// The polyhedron to draw. - /// The drawing offset of the polyhedron. - public static void DrawPolyhedron(Polyhedron polyhedron, in Vector3 offset) - { - DrawPolyhedron(polyhedron, offset, Color.white, DefaultDrawDuration, true); - } - - /// - /// Draws a polyhedron. - /// - /// The polyhedron to draw. - /// The color to use for drawing. - public static void DrawPolyhedron(Polyhedron polyhedron, in Color color) - { - DrawPolyhedron(polyhedron, Vector2.zero, color, DefaultDrawDuration, true); - } - - /// - /// Draws a polyhedron. - /// - /// The polyhedron to draw. - /// The drawing offset of the polyhedron. - /// The color to use for drawing. - public static void DrawPolyhedron(Polyhedron polyhedron, in Vector3 offset, in Color color) - { - DrawPolyhedron(polyhedron, offset, color, DefaultDrawDuration, true); - } - - /// - /// Draws a polyhedron. - /// - /// The polyhedron to draw. - /// The color to use for drawing. - /// - /// The duration of the polyhedron's visibility, in seconds. If 0 is passed, the polyhedron is visible for a single frame. - /// - public static void DrawPolyhedron(Polyhedron polyhedron, in Color color, float duration) - { - DrawPolyhedron(polyhedron, Vector2.zero, color, duration, true); - } - - /// - /// Draws a polyhedron. - /// - /// The polyhedron to draw. - /// The drawing offset of the polyhedron. - /// The color to use for drawing. - /// - /// The duration of the polyhedron's visibility, in seconds. If 0 is passed, the polyhedron is visible for a single frame. - /// - public static void DrawPolyhedron(Polyhedron polyhedron, in Vector3 offset, in Color color, float duration) - { - DrawPolyhedron(polyhedron, offset, color, duration, true); - } - - /// - /// Draws a polyhedron. - /// - /// The polyhedron to draw. - /// The color to use for drawing. - /// - /// The duration of the polyhedron's visibility, in seconds. If 0 is passed, the polyhedron is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawPolyhedron(Polyhedron polyhedron, in Color color, float duration, bool depthTest) - { - DrawPolyhedron(polyhedron, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws a polyhedron. - /// - /// The polyhedron to draw. - /// The drawing offset of the polyhedron. - /// The color to use for drawing. - /// - /// The duration of the polyhedron's visibility, in seconds. If 0 is passed, the polyhedron is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - /// is . - public static void DrawPolyhedron(Polyhedron polyhedron, in Vector3 offset, in Color color, float duration, bool depthTest) - { - if (polyhedron is null) - { - throw new ArgumentNullException(nameof(polyhedron)); - } - - IReadOnlyList points = polyhedron.Vertices; - if (points.Count < 2) - { - return; - } - - for (var i = 0; i < points.Count; i++) - { - int j = (i + 1) % points.Count; - Vector3 start = points[i].ToUnityVector() + offset; - Vector3 end = points[j].ToUnityVector() + offset; - - DrawLine(start, end, color, duration, depthTest); - } - } - - /// - /// Draws a polyhedron. - /// - /// The polyhedron to draw. - /// The drawing offset of the polyhedron. - /// The color to use for drawing. - /// - /// The duration of the polyhedron's visibility, in seconds. If 0 is passed, the polyhedron is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - /// is . - public static void DrawUnjoinedPolyhedron(Polyhedron polyhedron, in Vector3 offset, in Color color, float duration, - bool depthTest) - { - if (polyhedron is null) - { - throw new ArgumentNullException(nameof(polyhedron)); - } - - IReadOnlyList points = polyhedron.Vertices; - if (points.Count < 2) - { - return; - } - - for (var i = 0; i < points.Count; i++) - { - if (i >= points.Count - 2) - { - break; - } - - int j = i + 1; - Vector3 start = points[i].ToUnityVector() + offset; - Vector3 end = points[j].ToUnityVector() + offset; - - DrawLine(start, end, color, duration, depthTest); - } - } -} diff --git a/X10D.Unity/src/DebugUtility/DebugUtility.Ray.cs b/X10D.Unity/src/DebugUtility/DebugUtility.Ray.cs deleted file mode 100644 index 475a80c..0000000 --- a/X10D.Unity/src/DebugUtility/DebugUtility.Ray.cs +++ /dev/null @@ -1,108 +0,0 @@ -using UnityEngine; - -namespace X10D.Unity; - -public static partial class DebugUtility -{ - /// - /// Draws a ray. - /// - /// The ray to draw. - public static void DrawRay(Ray ray) - { - DrawRay(ray, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a ray. - /// - /// The ray to draw. - /// The color of the line. - public static void DrawRay(Ray ray, in Color color) - { - DrawRay(ray, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a ray. - /// - /// The ray to draw. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - public static void DrawRay(Ray ray, in Color color, float duration) - { - DrawRay(ray, color, duration, DefaultDepthTest); - } - - /// - /// Draws a ray. - /// - /// The ray to draw. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the line be obscured by objects closer to the camera. - /// - public static void DrawRay(Ray ray, in Color color, float duration, bool depthTest) - { - Debug.DrawRay(ray.origin, ray.direction, color, duration, depthTest); - } - - /// - /// Draws a ray. - /// - /// The starting point. - /// The direction. - public static void DrawRay(Vector3 start, Vector3 direction) - { - DrawRay(start, direction, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a ray. - /// - /// The starting point. - /// The direction. - /// The color of the line. - public static void DrawRay(Vector3 start, Vector3 direction, in Color color) - { - DrawRay(start, direction, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a ray. - /// - /// The starting point. - /// The direction. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - public static void DrawRay(Vector3 start, Vector3 direction, in Color color, float duration) - { - DrawRay(start, direction, color, duration, DefaultDepthTest); - } - - /// - /// Draws a ray. - /// - /// The starting point. - /// The direction. - /// The color of the line. - /// - /// The duration of the line's visibility, in seconds. If 0 is passed, the line is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the line be obscured by objects closer to the camera. - /// - public static void DrawRay(Vector3 start, Vector3 direction, in Color color, float duration, bool depthTest) - { - Debug.DrawRay(start, direction, color, duration, depthTest); - } -} diff --git a/X10D.Unity/src/DebugUtility/DebugUtility.Rectangle.cs b/X10D.Unity/src/DebugUtility/DebugUtility.Rectangle.cs deleted file mode 100644 index e8377d5..0000000 --- a/X10D.Unity/src/DebugUtility/DebugUtility.Rectangle.cs +++ /dev/null @@ -1,234 +0,0 @@ -using System.Drawing; -using UnityEngine; -using X10D.Unity.Drawing; -using Color = UnityEngine.Color; - -namespace X10D.Unity; - -public static partial class DebugUtility -{ - /// - /// Draws a rectangle. - /// - /// The center point. - /// The extents of the box. - public static void DrawRectangle(Vector2 center, Vector2 size) - { - DrawRectangle(center, size, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a rectangle with the specified color. - /// - /// The center point. - /// The extents of the box. - /// The color of the box. - public static void DrawRectangle(Vector2 center, Vector2 size, in Color color) - { - DrawRectangle(center, size, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a rectangle with the specified color and duration. - /// - /// The center point. - /// The extents of the box. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - public static void DrawRectangle(Vector2 center, Vector2 size, in Color color, float duration) - { - DrawRectangle(center, size, color, duration, DefaultDepthTest); - } - - /// - /// Draws a rectangle with the specified color and duration. - /// - /// The center point. - /// The extents of the box. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawRectangle(Vector2 center, Vector2 size, in Color color, float duration, bool depthTest) - { - DrawRectangle(new Rect(center, size), color, duration, depthTest); - } - - /// - /// Draws a rectangle with the specified color. - /// - /// The rectangle to draw. - /// The color of the box. - public static void DrawRectangle(Rect rect, in Color color) - { - DrawRectangle(rect, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a rectangle with the specified color and duration. - /// - /// The rectangle to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - public static void DrawRectangle(Rect rect, in Color color, float duration) - { - DrawRectangle(rect, color, duration, DefaultDepthTest); - } - - /// - /// Draws a rectangle with the specified color and duration. - /// - /// The rectangle to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawRectangle(Rect rect, in Color color, float duration, bool depthTest) - { - var topLeft = new Vector2(rect.xMin, rect.yMin); - var topRight = new Vector2(rect.xMax, rect.yMin); - var bottomLeft = new Vector2(rect.xMin, rect.yMax); - var bottomRight = new Vector2(rect.xMax, rect.yMax); - - DrawLine(topLeft, topRight, color, duration, depthTest); - DrawLine(topRight, bottomRight, color, duration, depthTest); - DrawLine(bottomRight, bottomLeft, color, duration, depthTest); - DrawLine(bottomLeft, topLeft, color, duration, depthTest); - } - - /// - /// Draws a rectangle with the specified color. - /// - /// The rectangle to draw. - /// The color of the box. - public static void DrawRectangle(RectInt rect, in Color color) - { - DrawRectangle(rect, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a rectangle with the specified color and duration. - /// - /// The rectangle to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - public static void DrawRectangle(RectInt rect, in Color color, float duration) - { - DrawRectangle(rect, color, duration, DefaultDepthTest); - } - - /// - /// Draws a rectangle with the specified color and duration. - /// - /// The rectangle to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawRectangle(RectInt rect, in Color color, float duration, bool depthTest) - { - DrawRectangle(new Rect(rect.center, rect.size), color, duration, depthTest); - } - - /// - /// Draws a rectangle with the specified color. - /// - /// The rectangle to draw. - /// The color of the box. - public static void DrawRectangle(Rectangle rectangle, in Color color) - { - DrawRectangle(rectangle, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a rectangle with the specified color and duration. - /// - /// The rectangle to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - public static void DrawRectangle(Rectangle rectangle, in Color color, float duration) - { - DrawRectangle(rectangle, color, duration, DefaultDepthTest); - } - - /// - /// Draws a rectangle with the specified color and duration. - /// - /// The rectangle to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawRectangle(Rectangle rectangle, in Color color, float duration, bool depthTest) - { - var origin = new Vector2(rectangle.X + rectangle.Width / 2.0f, rectangle.Y + rectangle.Height / 2.0f); - var rect = new Rect(origin, rectangle.Size.ToUnityVector2()); - DrawRectangle(rect, color, duration, depthTest); - } - - /// - /// Draws a rectangle with the specified color. - /// - /// The rectangle to draw. - /// The color of the box. - public static void DrawRectangle(RectangleF rectangle, in Color color) - { - DrawRectangle(rectangle, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a rectangle with the specified color and duration. - /// - /// The rectangle to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - public static void DrawRectangle(RectangleF rectangle, in Color color, float duration) - { - DrawRectangle(rectangle, color, duration, DefaultDepthTest); - } - - /// - /// Draws a rectangle with the specified color and duration. - /// - /// The rectangle to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawRectangle(RectangleF rectangle, in Color color, float duration, bool depthTest) - { - var origin = new Vector2(rectangle.X + rectangle.Width / 2.0f, rectangle.Y + rectangle.Height / 2.0f); - var rect = new Rect(origin, rectangle.Size.ToUnityVector2()); - DrawRectangle(rect, color, duration, depthTest); - } -} diff --git a/X10D.Unity/src/DebugUtility/DebugUtility.Sphere.cs b/X10D.Unity/src/DebugUtility/DebugUtility.Sphere.cs deleted file mode 100644 index 1f75c0e..0000000 --- a/X10D.Unity/src/DebugUtility/DebugUtility.Sphere.cs +++ /dev/null @@ -1,198 +0,0 @@ -using UnityEngine; -using X10D.Drawing; -using X10D.Unity.Numerics; - -namespace X10D.Unity; - -public static partial class DebugUtility -{ - /// - /// Draws a sphere with the specified color. - /// - /// The center point of the sphere. - /// The radius of the sphere. - /// The number of segments to generate. - public static void DrawSphere(Vector3 center, float radius, int segments) - { - DrawSphere(center, radius, segments, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a sphere with the specified color. - /// - /// The center point of the sphere. - /// The radius of the sphere. - /// The number of segments to generate. - /// The color of the sphere. - public static void DrawSphere(Vector3 center, float radius, int segments, in Color color) - { - DrawSphere(center, radius, segments, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a sphere with the specified color and duration. - /// - /// The center point of the sphere. - /// The radius of the sphere. - /// The number of segments to generate. - /// The color of the sphere. - /// - /// The duration of the sphere's visibility, in seconds. If 0 is passed, the sphere is visible for a single frame. - /// - public static void DrawSphere(Vector3 center, float radius, int segments, in Color color, float duration) - { - DrawSphere(center, radius, segments, Vector2.zero, color, duration, DefaultDepthTest); - } - - /// - /// Draws a sphere with the specified color and duration. - /// - /// The center point of the sphere. - /// The radius of the sphere. - /// The number of segments to generate. - /// The color of the sphere. - /// - /// The duration of the sphere's visibility, in seconds. If 0 is passed, the sphere is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the sphere be obscured by objects closer to the camera. - /// - public static void DrawSphere(Vector3 center, float radius, int segments, in Color color, float duration, bool depthTest) - { - DrawSphere(center, radius, segments, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws a sphere. - /// - /// The center point of the sphere. - /// The radius of the sphere. - /// The number of segments to generate. - /// The drawing offset of the sphere. - /// The color of the sphere. - /// - /// The duration of the sphere's visibility, in seconds. If 0 is passed, the sphere is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the sphere be obscured by objects closer to the camera. - /// - public static void DrawSphere(Vector3 center, float radius, int segments, Vector2 offset, in Color color, float duration, - bool depthTest) - { - DrawSphere(new Sphere(center.ToSystemVector(), radius), segments, offset, color, duration, depthTest); - } - - /// - /// Draws a sphere with the specified color. - /// - /// The sphere to draw. - /// The number of segments to generate. - public static void DrawSphere(Sphere sphere, int segments) - { - DrawSphere(sphere, segments, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a sphere with the specified color. - /// - /// The sphere to draw. - /// The number of segments to generate. - /// The drawing offset of the sphere. - public static void DrawSphere(Sphere sphere, int segments, Vector2 offset) - { - DrawSphere(sphere, segments, offset, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a sphere with the specified color. - /// - /// The sphere to draw. - /// The number of segments to generate. - /// The color of the sphere. - public static void DrawSphere(Sphere sphere, int segments, in Color color) - { - DrawSphere(sphere, segments, Vector2.zero, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a sphere with the specified color. - /// - /// The sphere to draw. - /// The number of segments to generate. - /// The drawing offset of the sphere. - /// The color of the sphere. - public static void DrawSphere(Sphere sphere, int segments, Vector2 offset, in Color color) - { - DrawSphere(sphere, segments, offset, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a sphere with the specified color and duration. - /// - /// The sphere to draw. - /// The number of segments to generate. - /// The color of the sphere. - /// - /// The duration of the sphere's visibility, in seconds. If 0 is passed, the sphere is visible for a single frame. - /// - public static void DrawSphere(Sphere sphere, int segments, in Color color, float duration) - { - DrawSphere(sphere, segments, Vector2.zero, color, duration, DefaultDepthTest); - } - - /// - /// Draws a sphere with the specified color and duration. - /// - /// The sphere to draw. - /// The number of segments to generate. - /// The drawing offset of the sphere. - /// The color of the sphere. - /// - /// The duration of the sphere's visibility, in seconds. If 0 is passed, the sphere is visible for a single frame. - /// - public static void DrawSphere(Sphere sphere, int segments, Vector2 offset, in Color color, float duration) - { - DrawSphere(sphere, segments, offset, color, duration, DefaultDepthTest); - } - - /// - /// Draws a sphere with the specified color and duration. - /// - /// The sphere to draw. - /// The number of segments to generate. - /// The color of the sphere. - /// - /// The duration of the sphere's visibility, in seconds. If 0 is passed, the sphere is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the sphere be obscured by objects closer to the camera. - /// - public static void DrawSphere(Sphere sphere, int segments, in Color color, float duration, bool depthTest) - { - DrawSphere(sphere, segments, Vector2.zero, color, duration, depthTest); - } - - /// - /// Draws a sphere. - /// - /// The sphere to draw. - /// The number of segments to generate. - /// The drawing offset of the sphere. - /// The color of the sphere. - /// - /// The duration of the sphere's visibility, in seconds. If 0 is passed, the sphere is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the sphere be obscured by objects closer to the camera. - /// - public static void DrawSphere(Sphere sphere, int segments, in Vector3 offset, in Color color, float duration, bool depthTest) - { - DrawPolyhedron(CreateCircle(sphere.Radius, segments, Vector3.zero), offset, color, duration, depthTest); - DrawPolyhedron(CreateCircle(sphere.Radius, segments, Vector3.left), offset, color, duration, depthTest); - DrawPolyhedron(CreateCircle(sphere.Radius, segments, Vector3.up), offset, color, duration, depthTest); - } -} diff --git a/X10D.Unity/src/DebugUtility/DebugUtility.WireCube.cs b/X10D.Unity/src/DebugUtility/DebugUtility.WireCube.cs deleted file mode 100644 index 1a550c2..0000000 --- a/X10D.Unity/src/DebugUtility/DebugUtility.WireCube.cs +++ /dev/null @@ -1,234 +0,0 @@ -using UnityEngine; -using X10D.Drawing; -using X10D.Unity.Numerics; - -namespace X10D.Unity; - -public static partial class DebugUtility -{ - /// - /// Draws an axis-aligned bounding box. - /// - /// The bounding box to draw. - public static void DrawWireCube(in Bounds bounds) - { - DrawWireCube(bounds.center, bounds.size, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an axis-aligned bounding box. - /// - /// The bounding box to draw. - /// The color of the box. - public static void DrawWireCube(in Bounds bounds, in Color color) - { - DrawWireCube(bounds.center, bounds.size, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws an axis-aligned bounding box. - /// - /// The bounding box to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - public static void DrawWireCube(in Bounds bounds, in Color color, float duration) - { - DrawWireCube(bounds.center, bounds.size, color, duration, DefaultDepthTest); - } - - /// - /// Draws an axis-aligned bounding box. - /// - /// The bounding box to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawWireCube(in Bounds bounds, in Color color, float duration, bool depthTest) - { - DrawWireCube(bounds.center, bounds.size, color, duration, depthTest); - } - - /// - /// Draws a wireframe cube with a center and a size. - /// - /// The center point. - /// The extents of the box. - public static void DrawWireCube(Vector3 center, Vector3 size) - { - DrawWireCube(center, size, Color.white, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a wireframe cube with the specified orientation. - /// - /// The center point. - /// The extents of the box. - /// The orientation of the box. - public static void DrawWireCube(Vector3 center, Vector3 size, Quaternion orientation) - { - DrawWireCube(new Cuboid(center.ToSystemVector(), size.ToSystemVector(), orientation.ToSystemQuaternion()), Color.white, - DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a wireframe cube with the specified color. - /// - /// The center point. - /// The extents of the box. - /// The color of the box. - public static void DrawWireCube(Vector3 center, Vector3 size, in Color color) - { - DrawWireCube(center, size, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a wireframe cube with the specified orientation and color. - /// - /// The center point. - /// The extents of the box. - /// The orientation of the box. - /// The color of the box. - public static void DrawWireCube(Vector3 center, Vector3 size, Quaternion orientation, in Color color) - { - DrawWireCube(new Cuboid(center.ToSystemVector(), size.ToSystemVector(), orientation.ToSystemQuaternion()), color, - DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a wireframe cube with the specified color and duration. - /// - /// The center point. - /// The extents of the box. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - public static void DrawWireCube(Vector3 center, Vector3 size, in Color color, float duration) - { - DrawWireCube(center, size, color, duration, DefaultDepthTest); - } - - /// - /// Draws a wireframe cube with the specified orientation, color, and duration. - /// - /// The center point. - /// The extents of the box. - /// The orientation of the box. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - public static void DrawWireCube(Vector3 center, Vector3 size, Quaternion orientation, in Color color, float duration) - { - DrawWireCube(new Cuboid(center.ToSystemVector(), size.ToSystemVector(), orientation.ToSystemQuaternion()), color, - duration, DefaultDepthTest); - } - - /// - /// Draws a wireframe cube with the specified color and duration. - /// - /// The center point. - /// The extents of the box. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawWireCube(Vector3 center, Vector3 size, in Color color, float duration, bool depthTest) - { - DrawWireCube(new Cuboid(center.ToSystemVector(), size.ToSystemVector()), color, duration, depthTest); - } - - /// - /// Draws a wireframe cube with the specified orientation, color, and duration. - /// - /// The center point. - /// The extents of the box. - /// The orientation of the box. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawWireCube(Vector3 center, Vector3 size, Quaternion orientation, in Color color, float duration, - bool depthTest) - { - DrawWireCube(new Cuboid(center.ToSystemVector(), size.ToSystemVector(), orientation.ToSystemQuaternion()), color, - duration, depthTest); - } - - /// - /// Draws a wireframe cube with the specified color. - /// - /// The cuboid to draw. - /// The color of the box. - public static void DrawWireCube(in Cuboid cuboid, in Color color) - { - DrawWireCube(cuboid, color, DefaultDrawDuration, DefaultDepthTest); - } - - /// - /// Draws a wireframe cube with the specified color and duration. - /// - /// The cuboid to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - public static void DrawWireCube(in Cuboid cuboid, in Color color, float duration) - { - DrawWireCube(cuboid, color, duration, DefaultDepthTest); - } - - /// - /// Draws a wireframe cube with the specified color and duration. - /// - /// The cuboid to draw. - /// The color of the box. - /// - /// The duration of the box's visibility, in seconds. If 0 is passed, the box is visible for a single frame. - /// - /// - /// if depth test should be applied; otherwise, . Passing - /// will have the box be obscured by objects closer to the camera. - /// - public static void DrawWireCube(in Cuboid cuboid, in Color color, float duration, bool depthTest) - { - Vector3 frontTopLeft = cuboid.FrontTopLeft.ToUnityVector(); - Vector3 frontTopRight = cuboid.FrontTopRight.ToUnityVector(); - Vector3 frontBottomRight = cuboid.FrontBottomRight.ToUnityVector(); - Vector3 frontBottomLeft = cuboid.FrontBottomLeft.ToUnityVector(); - Vector3 backTopLeft = cuboid.BackTopLeft.ToUnityVector(); - Vector3 backTopRight = cuboid.BackTopRight.ToUnityVector(); - Vector3 backBottomRight = cuboid.BackBottomRight.ToUnityVector(); - Vector3 backBottomLeft = cuboid.BackBottomLeft.ToUnityVector(); - - Debug.DrawLine(frontTopLeft, frontTopRight, color, duration, depthTest); - Debug.DrawLine(frontTopRight, frontBottomRight, color, duration, depthTest); - Debug.DrawLine(frontBottomRight, frontBottomLeft, color, duration, depthTest); - Debug.DrawLine(frontBottomLeft, frontTopLeft, color, duration, depthTest); - - Debug.DrawLine(backTopLeft, backTopRight, color, duration, depthTest); - Debug.DrawLine(backTopRight, backBottomRight, color, duration, depthTest); - Debug.DrawLine(backBottomRight, backBottomLeft, color, duration, depthTest); - Debug.DrawLine(backBottomLeft, backTopLeft, color, duration, depthTest); - - Debug.DrawLine(frontTopLeft, backTopLeft, color, duration, depthTest); - Debug.DrawLine(frontTopRight, backTopRight, color, duration, depthTest); - Debug.DrawLine(frontBottomRight, backBottomRight, color, duration, depthTest); - Debug.DrawLine(frontBottomLeft, backBottomLeft, color, duration, depthTest); - } -} diff --git a/X10D.Unity/src/DebugUtility/DebugUtility.cs b/X10D.Unity/src/DebugUtility/DebugUtility.cs deleted file mode 100644 index 0a2133c..0000000 --- a/X10D.Unity/src/DebugUtility/DebugUtility.cs +++ /dev/null @@ -1,417 +0,0 @@ -using System.Diagnostics; -using System.Runtime.CompilerServices; -using JetBrains.Annotations; -using UnityEngine; -using Debug = UnityEngine.Debug; -using Object = UnityEngine.Object; - -namespace X10D.Unity; - -/// -/// An extended version of Unity's utility class which offers support for drawing simple -/// primitives. -/// -public static partial class DebugUtility -{ - /// - /// The default value to use for the duration parameter. - /// - private const float DefaultDrawDuration = 0.0f; - - /// - /// The default value to use for the depthTest parameter. - /// - private const bool DefaultDepthTest = true; - - /// - /// Gets a value indicating whether this is a debug build. - /// - /// if this is a debug build; otherwise, . - // ReSharper disable once InconsistentNaming - public static bool isDebugBuild - { - get => Debug.isDebugBuild; - } - - /// - /// Gets a value indicating whether the developer console is visible. - /// - /// if the developer console is visible; otherwise, . - // ReSharper disable once InconsistentNaming - public static bool isDeveloperConsoleVisible - { - get => Debug.developerConsoleVisible; - } - - /// - /// Gets the default Unity debug logger. - /// - /// The Unity debug logger. - // ReSharper disable once InconsistentNaming - public static ILogger unityLogger - { - get => Debug.unityLogger; - } - - /// - /// Asserts a condition. - /// - /// The condition to assert. - [Conditional("UNITY_ASSERTIONS")] - [AssertionMethod] - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - public static void Assert(bool condition) - { - if (condition) - { - return; - } - - unityLogger.Log(LogType.Assert, "Assertion failed"); - } - - /// - /// Asserts a condition. - /// - /// The condition to assert. - /// The object to which the assertion applies. - [Conditional("UNITY_ASSERTIONS")] - [AssertionMethod] - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - public static void Assert(bool condition, Object context) - { - if (condition) - { - return; - } - - unityLogger.Log(LogType.Assert, (object)"Assertion failed", context); - } - - /// - /// Asserts a condition. - /// - /// The condition to assert. - /// The message to log. - [Conditional("UNITY_ASSERTIONS")] - [AssertionMethod] - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - public static void Assert(bool condition, string? message) - { - if (condition) - { - return; - } - - unityLogger.Log(LogType.Assert, message); - } - - /// - /// Asserts a condition. - /// - /// The condition to assert. - /// The message to log. - [Conditional("UNITY_ASSERTIONS")] - [AssertionMethod] - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - public static void Assert(bool condition, T? message) - { - if (condition) - { - return; - } - - unityLogger.Log(LogType.Assert, message?.ToString()); - } - - /// - /// Logs a message to the Unity Console. - /// - /// The condition to assert. - /// The message to log. - /// The object to which the assertion applies. - [Conditional("UNITY_ASSERTIONS")] - [AssertionMethod] - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - public static void Assert(bool condition, string? message, Object? context) - { - if (condition) - { - return; - } - - unityLogger.Log(LogType.Assert, (object?)message, context); - } - - /// - /// Logs a message to the Unity Console. - /// - /// The condition to assert. - /// The message to log. - /// The object to which the assertion applies. - [Conditional("UNITY_ASSERTIONS")] - [AssertionMethod] - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - public static void Assert(bool condition, T? message, Object? context) - { - if (condition) - { - return; - } - - unityLogger.Log(LogType.Assert, (object?)message?.ToString(), context); - } - - /// - /// Pauses the editor. - /// - public static void Break() - { - Debug.Break(); - } - - /// - /// Clears the developer console. - /// - public static void ClearDeveloperConsole() - { - Debug.ClearDeveloperConsole(); - } - - /// - /// Populate an unmanaged buffer with the current managed call stack as a sequence of UTF-8 bytes, without allocating GC - /// memory. - /// - /// The target buffer to receive the callstack text. - /// The maximum number of bytes to write. - /// The project folder path, to clean up path names. - /// The number of bytes written into the buffer. - [MustUseReturnValue("Fewer bytes may be returned than requested.")] - public static unsafe int ExtractStackTraceNoAlloc(byte* buffer, int bufferMax, string projectFolder) - { - return Debug.ExtractStackTraceNoAlloc(buffer, bufferMax, projectFolder); - } - - /// - /// Logs a message to the Unity Console. - /// - /// The message to log. - public static void Log(string? message) - { - Debug.Log(message); - } - - /// - /// Logs a message to the Unity Console. - /// - /// The message to log. - public static void Log(T message) - { - Log(message?.ToString()); - } - - /// - /// Logs a message to the Unity Console. - /// - /// The message to log. - /// The object to which the message applies. - public static void Log(string message, Object? context) - { - Debug.Log(message, context); - } - - /// - /// Logs a message to the Unity Console. - /// - /// The message to log. - /// The object to which the message applies. - public static void Log(T message, Object? context) - { - Debug.Log(message?.ToString(), context); - } - - /// - /// Logs an assertion message to the Unity Console. - /// - /// The message to log. - [Conditional("UNITY_ASSERTIONS")] - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - public static void LogAssertion(string? message) - { - unityLogger.Log(LogType.Assert, message); - } - - /// - /// Logs an assertion message to the Unity Console. - /// - /// The message to log. - [Conditional("UNITY_ASSERTIONS")] - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - public static void LogAssertion(T message) - { - unityLogger.Log(LogType.Assert, message?.ToString()); - } - - /// - /// Logs an assertion message to the Unity Console. - /// - /// The message to log. - /// The object to which the message applies. - [Conditional("UNITY_ASSERTIONS")] - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - public static void LogAssertion(string message, Object? context) - { - unityLogger.Log(LogType.Assert, (object?)message, context); - } - - /// - /// Logs an assertion message to the Unity Console. - /// - /// The message to log. - /// The object to which the message applies. - [Conditional("UNITY_ASSERTIONS")] - [MethodImpl(MethodImplOptions.NoOptimization | MethodImplOptions.NoInlining)] - public static void LogAssertion(T? message, Object? context) - { - unityLogger.Log(LogType.Assert, (object?)message?.ToString(), context); - } - - /// - /// Logs an error message to the Unity Console. - /// - /// The message to log. - public static void LogError(string? message) - { - Debug.LogError(message); - } - - /// - /// Logs an error message to the Unity Console. - /// - /// The message to log. - public static void LogError(T? message) - { - LogError(message?.ToString()); - } - - /// - /// Logs an error message to the Unity Console. - /// - /// The message to log. - /// The object to which the message applies. - public static void LogError(string message, Object? context) - { - Debug.LogError(message, context); - } - - /// - /// Logs an error message to the Unity Console. - /// - /// The message to log. - /// The object to which the message applies. - public static void LogError(T? message, Object? context) - { - Debug.LogError(message?.ToString(), context); - } - - /// - /// Logs a formatted error message to the Unity Console. - /// - /// The format string of the message to log. - /// The format arguments. - public static void LogErrorFormat(string? format, params object?[]? args) - { - Debug.LogErrorFormat(format, args); - } - - /// - /// Logs a formatted error message to the Unity Console. - /// - /// The object to which this message applies. - /// The format string of the message to log. - /// The format arguments. - public static void LogErrorFormat(Object context, string? format, params object?[]? args) - { - Debug.LogErrorFormat(context, format, args); - } - - /// - /// Logs a formatted message to the Unity Console. - /// - /// The format string of the message to log. - /// The format arguments. - public static void LogFormat(string? format, params object?[]? args) - { - Debug.LogFormat(format, args); - } - - /// - /// Logs a formatted message to the Unity Console. - /// - /// The object to which this message applies. - /// The format string of the message to log. - /// The format arguments. - public static void LogFormat(Object context, string? format, params object?[]? args) - { - Debug.LogFormat(context, format, args); - } - - /// - /// Logs a warning message to the Unity Console. - /// - /// The message to log. - public static void LogWarning(string? message) - { - Debug.LogWarning(message); - } - - /// - /// Logs a warning message to the Unity Console. - /// - /// The message to log. - public static void LogWarning(T? message) - { - LogWarning(message?.ToString()); - } - - /// - /// Logs a warning message to the Unity Console. - /// - /// The message to log. - /// The object to which the message applies. - public static void LogWarning(string message, Object? context) - { - Debug.LogWarning(message, context); - } - - /// - /// Logs a warning message to the Unity Console. - /// - /// The message to log. - /// The object to which the message applies. - public static void LogWarning(T? message, Object? context) - { - Debug.LogWarning(message?.ToString(), context); - } - - /// - /// Logs a formatted warning message to the Unity Console. - /// - /// The format string of the message to log. - /// The format arguments. - public static void LogWarningFormat(string? format, params object?[]? args) - { - Debug.LogWarningFormat(format, args); - } - - /// - /// Logs a formatted warning message to the Unity Console. - /// - /// The object to which this message applies. - /// The format string of the message to log. - /// The format arguments. - public static void LogWarningFormat(Object context, string? format, params object?[]? args) - { - Debug.LogWarningFormat(context, format, args); - } -} diff --git a/X10D.Unity/src/Drawing/Color32Extensions.cs b/X10D.Unity/src/Drawing/Color32Extensions.cs deleted file mode 100644 index 16dc327..0000000 --- a/X10D.Unity/src/Drawing/Color32Extensions.cs +++ /dev/null @@ -1,178 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Runtime.CompilerServices; -using UnityEngine; -using X10D.Drawing; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extensions for . -/// -public static class Color32Extensions -{ - /// - /// Deconstructs the current color into its RGB components. - /// - /// The source color. - /// - /// When this method returns, contains the component of . - /// - /// - /// When this method returns, contains the component of . - /// - /// - /// When this method returns, contains the component of . - /// - /// - /// When this method returns, contains the component of . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Deconstruct(this Color32 color, out byte a, out byte r, out byte g, out byte b) - { - a = color.a; - (r, g, b) = color; - } - - /// - /// Deconstructs the current color into its RGB components. - /// - /// The source color. - /// - /// When this method returns, contains the component of . - /// - /// - /// When this method returns, contains the component of . - /// - /// - /// When this method returns, contains the component of . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Deconstruct(this Color32 color, out byte r, out byte g, out byte b) - { - r = color.r; - g = color.g; - b = color.b; - } - - /// - /// Returns a which most closely resembles the current color. - /// - /// The source color. - /// The closest . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ConsoleColor GetClosestConsoleColor(this Color32 color) - { - return color.ToSystemDrawingColor().GetClosestConsoleColor(); - } - - /// - /// Returns a new with the red, green, and blue components inverted. Alpha is not affected. - /// - /// The color to invert. - /// The inverted color. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color32 Inverted(this Color32 color) - { - return new Color32((byte)(255 - color.r), (byte)(255 - color.g), (byte)(255 - color.b), color.a); - } - - /// - /// Converts the current color to a . - /// - /// The color to convert. - /// The converted color. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static System.Drawing.Color ToSystemDrawingColor(this Color32 color) - { - return System.Drawing.Color.FromArgb(color.a, color.r, color.g, color.b); - } - - /// - /// Converts the current color to a . - /// - /// The color to convert. - /// The converted color. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color32 ToUnityColor32(this System.Drawing.Color color) - { - return new Color32(color.R, color.G, color.B, color.A); - } - - /// - /// Returns a vector whose red, green, and blue components are the same as the specified color, and whose alpha component - /// is a new value. - /// - /// The color to copy. - /// The new alpha component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color32 WithA(this Color32 color, byte a) - { - return color with {a = a}; - } - - /// - /// Returns a vector whose red, green, and alpha components are the same as the specified color, and whose blue component - /// is a new value. - /// - /// The color to copy. - /// The new blue component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color32 WithB(this Color32 color, byte b) - { - return color with {b = b}; - } - - /// - /// Returns a vector whose red, blue, and alpha components are the same as the specified color, and whose green component - /// is a new value. - /// - /// The color to copy. - /// The new green component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color32 WithG(this Color32 color, byte g) - { - return color with {g = g}; - } - - /// - /// Returns a vector whose green, blue, and alpha components are the same as the specified color, and whose red component - /// is a new value. - /// - /// The color to copy. - /// The new red component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color32 WithR(this Color32 color, byte r) - { - return color with {r = r}; - } -} diff --git a/X10D.Unity/src/Drawing/ColorExtensions.cs b/X10D.Unity/src/Drawing/ColorExtensions.cs deleted file mode 100644 index 3fca7ec..0000000 --- a/X10D.Unity/src/Drawing/ColorExtensions.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Runtime.CompilerServices; -using UnityEngine; -using X10D.Drawing; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extensions for . -/// -public static class ColorExtensions -{ - /// - /// Deconstructs the current color into its ARGB components. - /// - /// The source color. - /// - /// When this method returns, contains the component of . - /// - /// - /// When this method returns, contains the component of . - /// - /// - /// When this method returns, contains the component of . - /// - /// - /// When this method returns, contains the component of . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Deconstruct(this Color color, out float a, out float r, out float g, out float b) - { - a = color.a; - (r, g, b) = color; - } - - /// - /// Deconstructs the current color into its RGB components. - /// - /// The source color. - /// - /// When this method returns, contains the component of . - /// - /// - /// When this method returns, contains the component of . - /// - /// - /// When this method returns, contains the component of . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Deconstruct(this Color color, out float r, out float g, out float b) - { - r = color.r; - g = color.g; - b = color.b; - } - - /// - /// Returns a which most closely resembles the current color. - /// - /// The source color. - /// The closest . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ConsoleColor GetClosestConsoleColor(this Color color) - { - return color.ToSystemDrawingColor().GetClosestConsoleColor(); - } - - /// - /// Returns a new with the red, green, and blue components inverted. Alpha is not affected. - /// - /// The color to invert. - /// The inverted color. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color Inverted(this Color color) - { - return new Color(1f - color.r, 1f - color.g, 1f - color.b, color.a); - } - - /// - /// Converts the current color to a . - /// - /// The color to convert. - /// The converted color. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static System.Drawing.Color ToSystemDrawingColor(this Color color) - { - return System.Drawing.Color.FromArgb( - (int)(color.a * 255f), - (int)(color.r * 255f), - (int)(color.g * 255f), - (int)(color.b * 255f) - ); - } - - /// - /// Converts the current color to a . - /// - /// The color to convert. - /// The converted color. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color ToUnityColor(this System.Drawing.Color color) - { - return new Color(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f); - } - - /// - /// Returns a vector whose red, green, and blue components are the same as the specified color, and whose alpha component - /// is a new value. - /// - /// The color to copy. - /// The new alpha component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color WithA(this Color color, float a) - { - return color with {a = a}; - } - - /// - /// Returns a vector whose red, green, and alpha components are the same as the specified color, and whose blue component - /// is a new value. - /// - /// The color to copy. - /// The new blue component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color WithB(this Color color, float b) - { - return color with {b = b}; - } - - /// - /// Returns a vector whose red, blue, and alpha components are the same as the specified color, and whose green component - /// is a new value. - /// - /// The color to copy. - /// The new green component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color WithG(this Color color, float g) - { - return color with {g = g}; - } - - /// - /// Returns a vector whose green, blue, and alpha components are the same as the specified color, and whose red component - /// is a new value. - /// - /// The color to copy. - /// The new red component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Color WithR(this Color color, float r) - { - return color with {r = r}; - } -} diff --git a/X10D.Unity/src/Drawing/PointExtensions.cs b/X10D.Unity/src/Drawing/PointExtensions.cs deleted file mode 100644 index 68f2a5f..0000000 --- a/X10D.Unity/src/Drawing/PointExtensions.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Drawing; -using System.Runtime.CompilerServices; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extension methods for . -/// -public static class PointExtensions -{ - /// - /// Converts the current to a . - /// - /// The point to convert. - /// The resulting . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 ToUnityVector2(this Point point) - { - return new Vector2(point.X, point.Y); - } - - /// - /// Converts the current to a . - /// - /// The point to convert. - /// The resulting . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2Int ToUnityVector2Int(this Point value) - { - return UnsafeUtility.As(ref value); - } -} diff --git a/X10D.Unity/src/Drawing/PointFExtensions.cs b/X10D.Unity/src/Drawing/PointFExtensions.cs deleted file mode 100644 index 7f58e51..0000000 --- a/X10D.Unity/src/Drawing/PointFExtensions.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Drawing; -using System.Runtime.CompilerServices; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; -using X10D.Drawing; -using X10D.Unity.Numerics; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extension methods for . -/// -public static class PointFExtensions -{ - /// - /// Determines if the current lies on the specified . - /// - /// The point to check. - /// The starting point of the line. - /// The ending point of the line. - /// - /// if lies on the line defined by and - /// ; otherwise . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsOnLine(this PointF point, Vector2 start, Vector2 end) - { - return point.IsOnLine(start.ToSystemVector(), end.ToSystemVector()); - } - - /// - /// Converts the current to a . - /// - /// The point to convert. - /// The resulting . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 ToUnityVector2(this PointF point) - { - return UnsafeUtility.As(ref point); - } -} diff --git a/X10D.Unity/src/Drawing/PolygonExtensions.cs b/X10D.Unity/src/Drawing/PolygonExtensions.cs deleted file mode 100644 index b1b962f..0000000 --- a/X10D.Unity/src/Drawing/PolygonExtensions.cs +++ /dev/null @@ -1,55 +0,0 @@ -using UnityEngine; -using X10D.Drawing; -using X10D.Unity.Numerics; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extension methods for . -/// -public static class PolygonExtensions -{ - /// - /// Adds a vertex to this polygon. - /// - /// The polygon whose points to update. - /// The point to add. - /// is . - public static void AddVertex(this Polygon polygon, Vector2Int point) - { - if (polygon is null) - { - throw new ArgumentNullException(nameof(polygon)); - } - - polygon.AddVertex(point.ToSystemPoint()); - } - - /// - /// Adds a collection of vertices to this polygon. - /// - /// The polygon whose vertices to update. - /// The vertices to add. - /// - /// is . - /// -or- - /// is . - /// - public static void AddVertices(this Polygon polygon, IEnumerable vertices) - { - if (polygon is null) - { - throw new ArgumentNullException(nameof(polygon)); - } - - if (vertices is null) - { - throw new ArgumentNullException(nameof(vertices)); - } - - foreach (Vector2Int vertex in vertices) - { - polygon.AddVertex(vertex); - } - } -} diff --git a/X10D.Unity/src/Drawing/PolygonFExtensions.cs b/X10D.Unity/src/Drawing/PolygonFExtensions.cs deleted file mode 100644 index 1b91d0c..0000000 --- a/X10D.Unity/src/Drawing/PolygonFExtensions.cs +++ /dev/null @@ -1,99 +0,0 @@ -using UnityEngine; -using X10D.Drawing; -using X10D.Unity.Numerics; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extension methods for . -/// -public static class PolygonFExtensions -{ - /// - /// Adds a point to this polygon. - /// - /// The polygon whose vertices to update. - /// The vertex to add. - /// is . - public static void AddVertex(this PolygonF polygon, Vector2Int vertex) - { - if (polygon is null) - { - throw new ArgumentNullException(nameof(polygon)); - } - - polygon.AddVertex(vertex.ToSystemPoint()); - } - - /// - /// Adds a point to this polygon. - /// - /// The polygon whose vertices to update. - /// The vertex to add. - /// is . - public static void AddVertex(this PolygonF polygon, Vector2 vertex) - { - if (polygon is null) - { - throw new ArgumentNullException(nameof(polygon)); - } - - polygon.AddVertex(vertex.ToSystemPointF()); - } - - /// - /// Adds a collection of vertices to this polygon. - /// - /// The polygon whose vertices to update. - /// The vertices to add. - /// - /// is . - /// -or- - /// is . - /// - public static void AddVertices(this PolygonF polygon, IEnumerable vertices) - { - if (polygon is null) - { - throw new ArgumentNullException(nameof(polygon)); - } - - if (vertices is null) - { - throw new ArgumentNullException(nameof(vertices)); - } - - foreach (Vector2Int vertex in vertices) - { - polygon.AddVertex(vertex); - } - } - - /// - /// Adds a collection of vertices to this polygon. - /// - /// The polygon whose vertices to update. - /// The vertices to add. - /// - /// is . - /// -or- - /// is . - /// - public static void AddVertices(this PolygonF polygon, IEnumerable vertices) - { - if (polygon is null) - { - throw new ArgumentNullException(nameof(polygon)); - } - - if (vertices is null) - { - throw new ArgumentNullException(nameof(vertices)); - } - - foreach (Vector2 vertex in vertices) - { - polygon.AddVertex(vertex); - } - } -} diff --git a/X10D.Unity/src/Drawing/PolyhedronExtensions.cs b/X10D.Unity/src/Drawing/PolyhedronExtensions.cs deleted file mode 100644 index 94cd4ed..0000000 --- a/X10D.Unity/src/Drawing/PolyhedronExtensions.cs +++ /dev/null @@ -1,99 +0,0 @@ -using UnityEngine; -using X10D.Drawing; -using X10D.Unity.Numerics; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extension methods for . -/// -public static class PolyhedronExtensions -{ - /// - /// Adds a vertex to this polyhedron. - /// - /// The polyhedron whose vertices to update. - /// The vertex to add. - /// is . - public static void AddVertex(this Polyhedron polyhedron, Vector3Int vertex) - { - if (polyhedron is null) - { - throw new ArgumentNullException(nameof(polyhedron)); - } - - polyhedron.AddVertex(vertex.ToSystemVector()); - } - - /// - /// Adds a vertex to this polyhedron. - /// - /// The polyhedron whose vertices to update. - /// The vertex to add. - /// is . - public static void AddVertex(this Polyhedron polyhedron, Vector3 vertex) - { - if (polyhedron is null) - { - throw new ArgumentNullException(nameof(polyhedron)); - } - - polyhedron.AddVertex(vertex.ToSystemVector()); - } - - /// - /// Adds a collection of vertices to this polyhedron. - /// - /// The polyhedron whose vertices to update. - /// The vertices to add. - /// - /// is . - /// -or- - /// is . - /// - public static void AddVertices(this Polyhedron polyhedron, IEnumerable vertices) - { - if (polyhedron is null) - { - throw new ArgumentNullException(nameof(polyhedron)); - } - - if (vertices is null) - { - throw new ArgumentNullException(nameof(vertices)); - } - - foreach (Vector3Int vertex in vertices) - { - polyhedron.AddVertex(vertex); - } - } - - /// - /// Adds a collection of vertices to this polyhedron. - /// - /// The polyhedron whose vertices to update. - /// The vertices to add. - /// - /// is . - /// -or- - /// is . - /// - public static void AddVertices(this Polyhedron polyhedron, IEnumerable vertices) - { - if (polyhedron is null) - { - throw new ArgumentNullException(nameof(polyhedron)); - } - - if (vertices is null) - { - throw new ArgumentNullException(nameof(vertices)); - } - - foreach (Vector3 vertex in vertices) - { - polyhedron.AddVertex(vertex); - } - } -} diff --git a/X10D.Unity/src/Drawing/RandomExtensions.cs b/X10D.Unity/src/Drawing/RandomExtensions.cs deleted file mode 100644 index c8b4bd7..0000000 --- a/X10D.Unity/src/Drawing/RandomExtensions.cs +++ /dev/null @@ -1,97 +0,0 @@ -using UnityEngine; -using X10D.Core; -using Random = System.Random; - -#pragma warning disable CA5394 - -namespace X10D.Unity.Drawing; - -/// -/// Extension methods for . -/// -public static class RandomExtensions -{ - /// - /// Returns an HDR color of random components for red, green, and blue. - /// - /// The instance. - /// A whose red, green, and blue components are all random, and whose alpha is 255 - /// is . - public static Color NextColorRgb(this Random random) - { - if (random is null) - { - throw new ArgumentNullException(nameof(random)); - } - - int seed = random.Next(); - var seededRandom = new Random(seed); - float r = seededRandom.NextSingle(); - float g = seededRandom.NextSingle(); - float b = seededRandom.NextSingle(); - return new Color(r, g, b, 1.0f); - } - - /// - /// Returns an HDR color composed of random components for apha, red, green, and blue. - /// - /// The instance. - /// A whose alpha, red, green, and blue components are all random. - /// is . - public static Color NextColorArgb(this Random random) - { - if (random is null) - { - throw new ArgumentNullException(nameof(random)); - } - - int seed = random.Next(); - var seededRandom = new Random(seed); - float a = seededRandom.NextSingle(); - float r = seededRandom.NextSingle(); - float g = seededRandom.NextSingle(); - float b = seededRandom.NextSingle(); - return new Color(r, g, b, a); - } - - /// - /// Returns a color of random components for red, green, and blue. - /// - /// The instance. - /// A whose red, green, and blue components are all random, and whose alpha is 255 - /// is . - public static Color32 NextColor32Rgb(this Random random) - { - if (random is null) - { - throw new ArgumentNullException(nameof(random)); - } - - int rgb = random.Next(); - var r = (byte)(rgb >> 16 & 0xFF); - var g = (byte)(rgb >> 8 & 0xFF); - var b = (byte)(rgb & 0xFF); - return new Color32(r, g, b, 0xFF); - } - - /// - /// Returns a color composed of random components for apha, red, green, and blue. - /// - /// The instance. - /// A whose alpha, red, green, and blue components are all random. - /// is . - public static Color32 NextColor32Argb(this Random random) - { - if (random is null) - { - throw new ArgumentNullException(nameof(random)); - } - - int argb = random.Next(); - var a = (byte)(argb >> 24 & 0xFF); - var r = (byte)(argb >> 16 & 0xFF); - var g = (byte)(argb >> 8 & 0xFF); - var b = (byte)(argb & 0xFF); - return new Color32(r, g, b, a); - } -} diff --git a/X10D.Unity/src/Drawing/RectExtensions.cs b/X10D.Unity/src/Drawing/RectExtensions.cs deleted file mode 100644 index 71db4d6..0000000 --- a/X10D.Unity/src/Drawing/RectExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Drawing; -using System.Runtime.CompilerServices; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extension methods for . -/// -public static class RectExtensions -{ - /// - /// Converts the current to a . - /// - /// The rectangle to convert. - /// The converted rectangle. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static RectangleF ToSystemRectangleF(this Rect rectangle) - { - return UnsafeUtility.As(ref rectangle); - } -} diff --git a/X10D.Unity/src/Drawing/RectIntExtensions.cs b/X10D.Unity/src/Drawing/RectIntExtensions.cs deleted file mode 100644 index 184bf74..0000000 --- a/X10D.Unity/src/Drawing/RectIntExtensions.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Drawing; -using System.Runtime.CompilerServices; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extension methods for . -/// -public static class RectIntExtensions -{ - /// - /// Converts the current to a . - /// - /// The rectangle to convert. - /// The converted rectangle. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rectangle ToSystemRectangle(this RectInt rectangle) - { - return UnsafeUtility.As(ref rectangle); - } - - /// - /// Converts the current to a . - /// - /// The rectangle to convert. - /// The converted rectangle. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static RectangleF ToSystemRectangleF(this RectInt rectangle) - { - // REMARKS: implicit conversion already exists, this method is largely pointless - return rectangle.ToSystemRectangle(); - } -} diff --git a/X10D.Unity/src/Drawing/RectangleExtensions.cs b/X10D.Unity/src/Drawing/RectangleExtensions.cs deleted file mode 100644 index 7326fdf..0000000 --- a/X10D.Unity/src/Drawing/RectangleExtensions.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Drawing; -using System.Runtime.CompilerServices; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extension methods for . -/// -public static class RectangleExtensions -{ - /// - /// Converts the current to a . - /// - /// The rectangle to convert. - /// The converted rectangle. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rect ToUnityRect(this Rectangle rectangle) - { - return new Rect(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); - } - - /// - /// Converts the current to a . - /// - /// The rectangle to convert. - /// The converted rectangle. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static RectInt ToUnityRectInt(this Rectangle rectangle) - { - return UnsafeUtility.As(ref rectangle); - } -} diff --git a/X10D.Unity/src/Drawing/RectangleFExtensions.cs b/X10D.Unity/src/Drawing/RectangleFExtensions.cs deleted file mode 100644 index 6eaf66c..0000000 --- a/X10D.Unity/src/Drawing/RectangleFExtensions.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Drawing; -using System.Runtime.CompilerServices; -using UnityEngine; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extension methods for . -/// -public static class RectangleFExtensions -{ - /// - /// Converts the current to a . - /// - /// The rectangle to convert. - /// The converted rectangle. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rect ToUnityRect(this RectangleF rectangle) - { - return new Rect(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); - } -} diff --git a/X10D.Unity/src/Drawing/SizeExtensions.cs b/X10D.Unity/src/Drawing/SizeExtensions.cs deleted file mode 100644 index bef5855..0000000 --- a/X10D.Unity/src/Drawing/SizeExtensions.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Drawing; -using System.Runtime.CompilerServices; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extension methods for . -/// -public static class SizeExtensions -{ - /// - /// Converts the current to a . - /// - /// The size to convert. - /// The resulting . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 ToUnityVector2(this Size size) - { - // REMARKS: implicit conversion already exists, this method is largely pointless - return size.ToUnityVector2Int(); - } - - /// - /// Converts the current to a . - /// - /// The size to convert. - /// The resulting . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2Int ToUnityVector2Int(this Size size) - { - return UnsafeUtility.As(ref size); - } -} diff --git a/X10D.Unity/src/Drawing/SizeFExtensions.cs b/X10D.Unity/src/Drawing/SizeFExtensions.cs deleted file mode 100644 index d9f1047..0000000 --- a/X10D.Unity/src/Drawing/SizeFExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Drawing; -using System.Runtime.CompilerServices; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; - -namespace X10D.Unity.Drawing; - -/// -/// Drawing-related extension methods for . -/// -public static class SizeFExtensions -{ - /// - /// Converts the current to a . - /// - /// The size to convert. - /// The resulting . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 ToUnityVector2(this SizeF size) - { - return UnsafeUtility.As(ref size); - } -} diff --git a/X10D.Unity/src/ExceptionMessages.Designer.cs b/X10D.Unity/src/ExceptionMessages.Designer.cs deleted file mode 100644 index 954a74a..0000000 --- a/X10D.Unity/src/ExceptionMessages.Designer.cs +++ /dev/null @@ -1,80 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace X10D.Unity { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class ExceptionMessages { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal ExceptionMessages() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("X10D.Unity.src.ExceptionMessages", typeof(ExceptionMessages).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to The game object {0} already has a component of type {1}.. - /// - internal static string ComponentAlreadyExists { - get { - return ResourceManager.GetString("ComponentAlreadyExists", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The game object {0} does not have a component of type {1}.. - /// - internal static string ComponentDoesNotExist { - get { - return ResourceManager.GetString("ComponentDoesNotExist", resourceCulture); - } - } - } -} diff --git a/X10D.Unity/src/ExceptionMessages.resx b/X10D.Unity/src/ExceptionMessages.resx deleted file mode 100644 index ec27743..0000000 --- a/X10D.Unity/src/ExceptionMessages.resx +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, - PublicKeyToken=b77a5c561934e089 - - - - - The game object {0} does not have a component of type {1}. - - - - The game object {0} already has a component of type {1}. - - \ No newline at end of file diff --git a/X10D.Unity/src/GameObjectExtensions.cs b/X10D.Unity/src/GameObjectExtensions.cs deleted file mode 100644 index 559ee39..0000000 --- a/X10D.Unity/src/GameObjectExtensions.cs +++ /dev/null @@ -1,324 +0,0 @@ -using UnityEngine; - -namespace X10D.Unity; - -/// -/// Extension methods for . -/// -public static class GameObjectExtensions -{ - /// - /// Returns an array of components of the specified type, excluding components that live on this game object. - /// - /// The game object whose child components to retrieve. - /// The type of the components to retrieve. - /// An array representing the child components. - /// is . - public static T[] GetComponentsInChildrenOnly(this GameObject gameObject) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - Transform rootTransform = gameObject.transform; - var components = new List(gameObject.GetComponentsInChildren()); - - for (var index = 0; index < components.Count; index++) - { - if (components[index] is not Component childComponent) - { - // this shouldn't happen, since you can't add a non-Component to a game object, - // but GetComponentsInChildren is not constrained, so this method shouldn't be either - continue; - } - - if (childComponent.transform == rootTransform) - { - components.RemoveAt(index); - index--; - } - } - - return components.ToArray(); - } - - /// - /// Rotates the transform component of this game object so the forward vector points at another game object. - /// - /// The game object whose rotation will be changed. - /// The game object to look at. - /// - /// is . - /// -or- - /// is . - /// - public static void LookAt(this GameObject gameObject, GameObject target) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - if (target == null) - { - throw new ArgumentNullException(nameof(target)); - } - - gameObject.transform.LookAt(target.transform); - } - - /// - /// Rotates the transform component of this game object so the forward vector points at . - /// - /// The game object whose rotation will be changed. - /// The point to look at. - /// is . - public static void LookAt(this GameObject gameObject, Vector3 target) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - gameObject.transform.LookAt(target); - } - - /// - /// Rotates the transform component of this game object so the forward vector points at a specified transform. - /// - /// The game object whose rotation will be changed. - /// The transform to look at. - /// - /// is . - /// -or- - /// is . - /// - public static void LookAt(this GameObject gameObject, Transform target) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - if (target == null) - { - throw new ArgumentNullException(nameof(target)); - } - - gameObject.transform.LookAt(target); - } - - /// - /// Rotates the transform component of this game object so the forward vector points at another game object. - /// - /// The game object whose rotation will be changed. - /// The game object to look at. - /// A vector specifying the upward direction. - /// - /// is . - /// -or- - /// is . - /// - public static void LookAt(this GameObject gameObject, GameObject target, Vector3 worldUp) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - if (target == null) - { - throw new ArgumentNullException(nameof(target)); - } - - gameObject.transform.LookAt(target.transform, worldUp); - } - - /// - /// Rotates the transform component of this game object so the forward vector points at . - /// - /// The game object whose rotation will be changed. - /// The point to look at. - /// A vector specifying the upward direction. - /// is . - public static void LookAt(this GameObject gameObject, Vector3 target, Vector3 worldUp) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - gameObject.transform.LookAt(target, worldUp); - } - - /// - /// Rotates the transform component of this game object so the forward vector points at a specified transform. - /// - /// The game object whose rotation will be changed. - /// The transform to look at. - /// A vector specifying the upward direction. - /// - /// is . - /// -or- - /// is . - /// - public static void LookAt(this GameObject gameObject, Transform target, Vector3 worldUp) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - if (target == null) - { - throw new ArgumentNullException(nameof(target)); - } - - gameObject.transform.LookAt(target, worldUp); - } - - /// - /// Sets the new layer of this game object and its children, recursively. - /// - /// The game object whose layer, and that of its children recursively, to change. - /// The new layer. - /// is . - public static void SetLayerRecursively(this GameObject gameObject, int layer) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - var children = new Stack(); - var transform = gameObject.transform; - children.Push(transform); - - while (children.Count > 0) - { - Transform child = children.Pop(); - int childCount = child.childCount; - - child.gameObject.layer = layer; - - if (childCount <= 0) - { - continue; - } - - for (var childIndex = 0; childIndex < childCount; childIndex++) - { - children.Push(child.GetChild(childIndex)); - } - } - } - - /// - /// Sets the parent of this game object. - /// - /// The game object whose parent to change. - /// The new parent. - /// - /// is . - /// -or- - /// is . - /// - public static void SetParent(this GameObject gameObject, GameObject parent) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - if (parent == null) - { - throw new ArgumentNullException(nameof(parent)); - } - - gameObject.transform.SetParent(parent.transform); - } - - /// - /// Sets the parent of this game object. - /// - /// The game object whose parent to change. - /// The new parent. - /// - /// is . - /// -or- - /// is . - /// - public static void SetParent(this GameObject gameObject, Transform parent) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - if (parent == null) - { - throw new ArgumentNullException(nameof(parent)); - } - - gameObject.transform.SetParent(parent); - } - - /// - /// Sets the parent of this game object. - /// - /// The game object whose parent to change. - /// The new parent. - /// - /// to modify the parent-relative position, scale and rotation such that the object keeps the same - /// world space position, rotation and scale as before; otherwise, . - /// - /// - /// is . - /// -or- - /// is . - /// - public static void SetParent(this GameObject gameObject, GameObject parent, bool worldPositionStays) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - if (parent == null) - { - throw new ArgumentNullException(nameof(parent)); - } - - gameObject.transform.SetParent(parent.transform, worldPositionStays); - } - - /// - /// Sets the parent of this game object. - /// - /// The game object whose parent to change. - /// The new parent. - /// - /// to modify the parent-relative position, scale and rotation such that the object keeps the same - /// world space position, rotation and scale as before; otherwise, . - /// - /// - /// is . - /// -or- - /// is . - /// - public static void SetParent(this GameObject gameObject, Transform parent, bool worldPositionStays) - { - if (gameObject == null) - { - throw new ArgumentNullException(nameof(gameObject)); - } - - if (parent == null) - { - throw new ArgumentNullException(nameof(parent)); - } - - gameObject.transform.SetParent(parent, worldPositionStays); - } -} diff --git a/X10D.Unity/src/Numerics/QuaternionExtensions.cs b/X10D.Unity/src/Numerics/QuaternionExtensions.cs deleted file mode 100644 index 5511bbc..0000000 --- a/X10D.Unity/src/Numerics/QuaternionExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Runtime.CompilerServices; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; - -namespace X10D.Unity.Numerics; - -/// -/// Numeric-extensions for . -/// -public static class QuaternionExtensions -{ - /// - /// Converts the current quaternion to a . - /// - /// The quaternion to convert. - /// The converted quaternion. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static System.Numerics.Quaternion ToSystemQuaternion(this Quaternion quaternion) - { - return UnsafeUtility.As(ref quaternion); - } - - /// - /// Converts the current quaternion to a . - /// - /// The quaternion to convert. - /// The converted quaternion. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Quaternion ToUnityQuaternion(this System.Numerics.Quaternion quaternion) - { - return UnsafeUtility.As(ref quaternion); - } -} diff --git a/X10D.Unity/src/Numerics/RandomExtensions.cs b/X10D.Unity/src/Numerics/RandomExtensions.cs deleted file mode 100644 index 07b54a2..0000000 --- a/X10D.Unity/src/Numerics/RandomExtensions.cs +++ /dev/null @@ -1,120 +0,0 @@ -using UnityEngine; -using X10D.Core; -using Random = System.Random; - -#pragma warning disable CA5394 - -namespace X10D.Unity.Numerics; - -/// -/// Extension methods for . -/// -public static class RandomExtensions -{ - /// - /// Returns a randomly generated rotation as represented by a . - /// - /// The instance. - /// - /// A constructed from 3 random single-precision floating point numbers representing the - /// yaw, pitch, and roll. - /// - /// is . - public static Quaternion NextRotation(this Random random) - { - if (random is null) - { - throw new ArgumentNullException(nameof(random)); - } - - int seed = random.Next(); - var seededRandom = new Random(seed); - - float x = seededRandom.NextSingle(0, 360); - float y = seededRandom.NextSingle(0, 360); - float z = seededRandom.NextSingle(0, 360); - - return Quaternion.Euler(x, y, z); - } - - /// - /// Returns a randomly generated rotation with uniform distribution. - /// - /// The instance. - /// A constructed with uniform distribution. - /// is . - public static Quaternion NextRotationUniform(this Random random) - { - if (random is null) - { - throw new ArgumentNullException(nameof(random)); - } - - int seed = random.Next(); - var seededRandom = new Random(seed); - float normal, w, x, y, z; - - do - { - w = seededRandom.NextSingle(-1f, 1f); - x = seededRandom.NextSingle(-1f, 1f); - y = seededRandom.NextSingle(-1f, 1f); - z = seededRandom.NextSingle(-1f, 1f); - normal = (w * w) + (x * x) + (y * y) + (z * z); - } while (normal is 0f or > 1f); - - normal = MathF.Sqrt(normal); - return new Quaternion(x / normal, y / normal, z / normal, w / normal); - } - - /// - /// Returns a with magnitude 1 whose components indicate a random point on the unit circle. - /// - /// The instance - /// - /// A whose returns 1, and whose components indicate a random - /// point on the unit circle. - /// - public static Vector2 NextUnitVector2(this Random random) - { - if (random is null) - { - throw new ArgumentNullException(nameof(random)); - } - - // no need to construct a seeded random here, since we only call Next once - - float angle = random.NextSingle(0, MathF.PI * 2.0f); - float x = MathF.Cos(angle); - float y = MathF.Sin(angle); - - return new Vector2(x, y); - } - - /// - /// Returns a with magnitude 1 whose components indicate a random point on the unit sphere. - /// - /// The instance - /// - /// A whose returns 1, and whose components indicate a random - /// point on the unit sphere. - /// - public static Vector3 NextUnitVector3(this Random random) - { - if (random is null) - { - throw new ArgumentNullException(nameof(random)); - } - - int seed = random.Next(); - var seededRandom = new Random(seed); - - float angle = seededRandom.NextSingle(0, MathF.PI * 2.0f); - float z = seededRandom.NextSingle(-1, 1); - float mp = MathF.Sqrt(1 - (z * z)); - float x = mp * MathF.Cos(angle); - float y = mp * MathF.Sin(angle); - - return new Vector3(x, y, z); - } -} diff --git a/X10D.Unity/src/Numerics/Vector2Extensions.cs b/X10D.Unity/src/Numerics/Vector2Extensions.cs deleted file mode 100644 index 6e608f8..0000000 --- a/X10D.Unity/src/Numerics/Vector2Extensions.cs +++ /dev/null @@ -1,185 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Drawing; -using System.Runtime.CompilerServices; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; -using X10D.Drawing; -using X10D.Math; -using X10D.Numerics; - -namespace X10D.Unity.Numerics; - -/// -/// Numeric-extensions for . -/// -public static class Vector2Extensions -{ - /// - /// Deconstructs the current into its components. - /// - /// The vector to deconstruct. - /// The X component value. - /// The Y component value. - public static void Deconstruct(this Vector2 vector, out float x, out float y) - { - x = vector.x; - y = vector.y; - } - - /// - /// Determines if the current lies on the specified . - /// - /// The point to check. - /// The line on which the point may lie. - /// - /// if lies on the line defined by ; otherwise - /// . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsOnLine(this Vector2 point, LineF line) - { - return point.ToSystemVector().IsOnLine(line); - } - - /// - /// Determines if the current lies on the specified line. - /// - /// The point to check. - /// The starting point of the line. - /// The ending point of the line. - /// - /// if lies on the line defined by and - /// ; otherwise . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsOnLine(this Vector2 point, PointF start, PointF end) - { - return point.IsOnLine(new LineF(start, end)); - } - - /// - /// Determines if the current lies on the specified line. - /// - /// The point to check. - /// The starting point of the line. - /// The ending point of the line. - /// - /// if lies on the line defined by and - /// ; otherwise . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsOnLine(this Vector2 point, Vector2 start, Vector2 end) - { - return point.ToSystemVector().IsOnLine(start.ToSystemVector(), end.ToSystemVector()); - } - - /// - /// Rounds the components in the current to the nearest integer. - /// - /// The vector whose components to round. - /// The rounded vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 Round(this Vector2 vector) - { - return vector.Round(1.0f); - } - - /// - /// Rounds the components in the current to the nearest multiple of a specified number. - /// - /// The vector whose components to round. - /// The nearest multiple to which the components should be rounded. - /// The rounded vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 Round(this Vector2 vector, float nearest) - { - float x = vector.x.Round(nearest); - float y = vector.y.Round(nearest); - return new Vector2(x, y); - } - - /// - /// Converts the current into a . - /// - /// The vector to convert. - /// The resulting . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static PointF ToSystemPointF(this Vector2 vector) - { - return UnsafeUtility.As(ref vector); - } - - /// - /// Converts the current into a . - /// - /// The vector to convert. - /// The resulting . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static SizeF ToSystemSizeF(this Vector2 vector) - { - return UnsafeUtility.As(ref vector); - } - - /// - /// Converts the current vector to a . - /// - /// The vector to convert. - /// The converted vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static System.Numerics.Vector2 ToSystemVector(this Vector2 vector) - { - return UnsafeUtility.As(ref vector); - } - - /// - /// Converts the current vector to a . - /// - /// The vector to convert. - /// The converted vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 ToUnityVector(this System.Numerics.Vector2 vector) - { - return UnsafeUtility.As(ref vector); - } - - /// - /// Returns a vector whose Y component is the same as the specified vector, and whose X component is a new value. - /// - /// The vector to copy. - /// The new X component value. - /// - /// A new instance of whose components is the same as that of - /// , and whose component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 WithX(this Vector2 vector, float x) - { - return vector with {x = x}; - } - - /// - /// Returns a vector whose X component is the same as the specified vector, and whose Y component is a new value. - /// - /// The vector to copy. - /// The new Y component value. - /// - /// A new instance of whose components is the same as that of - /// , and whose component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 WithY(this Vector2 vector, float y) - { - return vector with {y = y}; - } -} diff --git a/X10D.Unity/src/Numerics/Vector2IntExtensions.cs b/X10D.Unity/src/Numerics/Vector2IntExtensions.cs deleted file mode 100644 index babf2d9..0000000 --- a/X10D.Unity/src/Numerics/Vector2IntExtensions.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Drawing; -using System.Runtime.CompilerServices; -using UnityEngine; -using X10D.Drawing; - -namespace X10D.Unity.Numerics; - -/// -/// Numeric-extensions for . -/// -public static class Vector2IntExtensions -{ - /// - /// Deconstructs the current into its components. - /// - /// The vector to deconstruct. - /// The X component value. - /// The Y component value. - public static void Deconstruct(this Vector2Int vector, out int x, out int y) - { - x = vector.x; - y = vector.y; - } - - /// - /// Determines if the current lies on the specified . - /// - /// The point to check. - /// The line on which the point may lie. - /// - /// if lies on the line defined by ; otherwise - /// . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsOnLine(this Vector2Int point, LineF line) - { - return point.ToSystemPoint().IsOnLine(line); - } - - /// - /// Determines if the current lies on the specified line. - /// - /// The point to check. - /// The starting point of the line. - /// The ending point of the line. - /// - /// if lies on the line defined by and - /// ; otherwise . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsOnLine(this Vector2Int point, PointF start, PointF end) - { - return point.IsOnLine(new LineF(start, end)); - } - - /// - /// Determines if the current lies on the specified line. - /// - /// The point to check. - /// The starting point of the line. - /// The ending point of the line. - /// - /// if lies on the line defined by and - /// ; otherwise . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsOnLine(this Vector2Int point, Vector2Int start, Vector2Int end) - { - return point.ToSystemPoint().IsOnLine(new LineF(start.ToSystemVector(), end.ToSystemVector())); - } - - /// - /// Determines if the current lies on the specified line. - /// - /// The point to check. - /// The starting point of the line. - /// The ending point of the line. - /// - /// if lies on the line defined by and - /// ; otherwise . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsOnLine(this Vector2Int point, Vector2 start, Vector2 end) - { - return point.ToSystemPoint().IsOnLine(new LineF(start.ToSystemVector(), end.ToSystemVector())); - } - - /// - /// Converts the current into a . - /// - /// The vector to convert. - /// The resulting . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point ToSystemPoint(this Vector2Int vector) - { - return new Point(vector.x, vector.y); - } - - /// - /// Converts the current into a . - /// - /// The vector to convert. - /// The resulting . - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size ToSystemSize(this Vector2Int vector) - { - return new Size(vector.x, vector.y); - } - - /// - /// Converts the current vector to a . - /// - /// The vector to convert. - /// The converted vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static System.Numerics.Vector2 ToSystemVector(this Vector2Int vector) - { - return new System.Numerics.Vector2(vector.x, vector.y); - } - - /// - /// Returns a vector whose Y component is the same as the specified vector, and whose X component is a new value. - /// - /// The vector to copy. - /// The new X component value. - /// - /// A new instance of whose components is the same as that of - /// , and whose component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2Int WithX(this Vector2Int vector, int x) - { - return vector with {x = x}; - } - - /// - /// Returns a vector whose X component is the same as the specified vector, and whose Y component is a new value. - /// - /// The vector to copy. - /// The new Y component value. - /// - /// A new instance of whose components is the same as that of - /// , and whose component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2Int WithY(this Vector2Int vector, int y) - { - return vector with {y = y}; - } -} diff --git a/X10D.Unity/src/Numerics/Vector3Extensions.cs b/X10D.Unity/src/Numerics/Vector3Extensions.cs deleted file mode 100644 index 64dc0e1..0000000 --- a/X10D.Unity/src/Numerics/Vector3Extensions.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Runtime.CompilerServices; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; -using X10D.Math; - -namespace X10D.Unity.Numerics; - -/// -/// Numeric-extensions for . -/// -public static class Vector3Extensions -{ - /// - /// Deconstructs the current into its components. - /// - /// The vector to deconstruct. - /// The X component value. - /// The Y component value. - /// The Z component value. - public static void Deconstruct(this Vector3 vector, out float x, out float y, out float z) - { - x = vector.x; - y = vector.y; - z = vector.z; - } - - /// - /// Rounds the components in the current to the nearest integer. - /// - /// The vector whose components to round. - /// The rounded vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 Round(this Vector3 vector) - { - return vector.Round(1.0f); - } - - /// - /// Rounds the components in the current to the nearest multiple of a specified number. - /// - /// The vector whose components to round. - /// The nearest multiple to which the components should be rounded. - /// The rounded vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 Round(this Vector3 vector, float nearest) - { - float x = vector.x.Round(nearest); - float y = vector.y.Round(nearest); - float z = vector.z.Round(nearest); - return new Vector3(x, y, z); - } - - /// - /// Converts the current vector to a . - /// - /// The vector to convert. - /// The converted vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static System.Numerics.Vector3 ToSystemVector(this Vector3 vector) - { - return UnsafeUtility.As(ref vector); - } - - /// - /// Converts the current vector to a . - /// - /// The vector to convert. - /// The converted vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 ToUnityVector(this System.Numerics.Vector3 vector) - { - return UnsafeUtility.As(ref vector); - } - - /// - /// Returns a vector whose Y and Z components are the same as the specified vector, and whose X component is a new value. - /// - /// The vector to copy. - /// The new X component value. - /// - /// A new instance of whose and components are - /// the same as that of , and whose component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 WithX(this Vector3 vector, float x) - { - return vector with {x = x}; - } - - /// - /// Returns a vector whose X and Z components are the same as the specified vector, and whose Y component is a new value. - /// - /// The vector to copy. - /// The new Y component value. - /// - /// A new instance of whose and components are - /// the same as that of , and whose component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 WithY(this Vector3 vector, float y) - { - return vector with {y = y}; - } - - /// - /// Returns a vector whose X and Y components are the same as the specified vector, and whose Z component is a new value. - /// - /// The vector to copy. - /// The new Z component value. - /// - /// A new instance of whose and components are - /// the same as that of , and whose component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 WithZ(this Vector3 vector, float z) - { - return vector with {z = z}; - } -} diff --git a/X10D.Unity/src/Numerics/Vector3IntExtensions.cs b/X10D.Unity/src/Numerics/Vector3IntExtensions.cs deleted file mode 100644 index 16b2e4d..0000000 --- a/X10D.Unity/src/Numerics/Vector3IntExtensions.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Runtime.CompilerServices; -using UnityEngine; - -namespace X10D.Unity.Numerics; - -/// -/// Numeric-extensions for . -/// -public static class Vector3IntExtensions -{ - /// - /// Deconstructs the current into its components. - /// - /// The vector to deconstruct. - /// The X component value. - /// The Y component value. - /// The Z component value. - public static void Deconstruct(this Vector3Int vector, out int x, out int y, out int z) - { - x = vector.x; - y = vector.y; - z = vector.z; - } - - /// - /// Converts the current vector to a . - /// - /// The vector to convert. - /// The converted vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static System.Numerics.Vector3 ToSystemVector(this Vector3Int vector) - { - return new System.Numerics.Vector3(vector.x, vector.y, vector.z); - } - - /// - /// Returns a vector whose Y and Z components are the same as the specified vector, and whose X component is a new value. - /// - /// The vector to copy. - /// The new X component value. - /// - /// A new instance of whose and - /// components are the same as that of , and whose component is - /// . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3Int WithX(this Vector3Int vector, int x) - { - return vector with {x = x}; - } - - /// - /// Returns a vector whose X and Z components are the same as the specified vector, and whose Y component is a new value. - /// - /// The vector to copy. - /// The new Y component value. - /// - /// A new instance of whose and - /// components are the same as that of , and whose component is - /// . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3Int WithY(this Vector3Int vector, int y) - { - return vector with {y = y}; - } - - /// - /// Returns a vector whose X and Y components are the same as the specified vector, and whose Z component is a new value. - /// - /// The vector to copy. - /// The new Z component value. - /// - /// A new instance of whose and - /// components are the same as that of , and whose component is - /// . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3Int WithZ(this Vector3Int vector, int z) - { - return vector with {z = z}; - } -} diff --git a/X10D.Unity/src/Numerics/Vector4Extensions.cs b/X10D.Unity/src/Numerics/Vector4Extensions.cs deleted file mode 100644 index e17ba25..0000000 --- a/X10D.Unity/src/Numerics/Vector4Extensions.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Runtime.CompilerServices; -using Unity.Collections.LowLevel.Unsafe; -using UnityEngine; -using X10D.Math; - -namespace X10D.Unity.Numerics; - -/// -/// Numeric-extensions for . -/// -public static class Vector4Extensions -{ - /// - /// Deconstructs the current into its components. - /// - /// The vector to deconstruct. - /// The X component value. - /// The Y component value. - /// The Z component value. - /// The W component value. - public static void Deconstruct(this Vector4 vector, out float x, out float y, out float z, out float w) - { - x = vector.x; - y = vector.y; - z = vector.z; - w = vector.w; - } - - /// - /// Rounds the components in the current to the nearest integer. - /// - /// The vector whose components to round. - /// The rounded vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Round(this Vector4 vector) - { - return vector.Round(1.0f); - } - - /// - /// Rounds the components in the current to the nearest multiple of a specified number. - /// - /// The vector whose components to round. - /// The nearest multiple to which the components should be rounded. - /// The rounded vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 Round(this Vector4 vector, float nearest) - { - float x = vector.x.Round(nearest); - float y = vector.y.Round(nearest); - float z = vector.z.Round(nearest); - float w = vector.w.Round(nearest); - return new Vector4(x, y, z, w); - } - - /// - /// Converts the current vector to a . - /// - /// The vector to convert. - /// The converted vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static System.Numerics.Vector4 ToSystemVector(this Vector4 vector) - { - return UnsafeUtility.As(ref vector); - } - - /// - /// Converts the current vector to a . - /// - /// The vector to convert. - /// The converted vector. - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 ToUnityVector(this System.Numerics.Vector4 vector) - { - return UnsafeUtility.As(ref vector); - } - - /// - /// Returns a vector whose Y, Z, and W components are the same as the specified vector, and whose X component is a new - /// value. - /// - /// The vector to copy. - /// The new X component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 WithX(this Vector4 vector, float x) - { - return vector with {x = x}; - } - - /// - /// Returns a vector whose X, Z, and W components are the same as the specified vector, and whose Y component is a new - /// value. - /// - /// The vector to copy. - /// The new Y component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 WithY(this Vector4 vector, float y) - { - return vector with {y = y}; - } - - /// - /// Returns a vector whose X, Y, and W components are the same as the specified vector, and whose Z component is a new - /// value. - /// - /// The vector to copy. - /// The new Z component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 WithZ(this Vector4 vector, float z) - { - return vector with {z = z}; - } - - /// - /// Returns a vector whose X, Y, and Z components are the same as the specified vector, and whose W component is a new - /// value. - /// - /// The vector to copy. - /// The new W component value. - /// - /// A new instance of whose , , and - /// components are the same as that of , and whose - /// component is . - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 WithW(this Vector4 vector, float w) - { - return vector with {w = w}; - } -} diff --git a/X10D.Unity/src/RaycastHitExtensions.cs b/X10D.Unity/src/RaycastHitExtensions.cs deleted file mode 100644 index 5e44dca..0000000 --- a/X10D.Unity/src/RaycastHitExtensions.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using UnityEngine; - -namespace X10D.Unity; - -/// -/// Extension methods for . -/// -public static class RaycastHitExtensions -{ - /// - /// Gets the component of the specified type from the object that was hit by the raycast. - /// - /// The raycast hit. - /// The type of the component to retrieve. - /// - /// The component of the specified type from the object that was hit by the raycast, or if no - /// component of the specified type was found. - /// - public static T? GetComponent(this RaycastHit hit) - { - if (hit.transform == null) - { - return default; - } - - return hit.transform.GetComponent(); - } - - /// - /// Gets the component of the specified type from the object that was hit by the raycast. - /// - /// The raycast hit. - /// The type of the component to retrieve. - /// - /// The component of the specified type from the object that was hit by the raycast, or if no - /// component of the specified type was found. - /// - /// is . - public static Component? GetComponent(this RaycastHit hit, Type componentType) - { - if (componentType is null) - { - throw new ArgumentNullException(nameof(componentType)); - } - - if (hit.transform == null) - { - return default; - } - - return hit.transform.GetComponent(componentType); - } - - - /// - /// Attempts to get the component of the specified type from the object that was hit by the raycast, and returns a value - /// that indicates whether the operation succeeded. - /// - /// The raycast hit. - /// - /// When this method returns, contains the component of the specified type from the object that was hit by the raycast, or - /// if no component of the specified type was found. - /// - /// The type of the component to retrieve. - /// - /// if the component of the specified type was found; otherwise, . - /// - public static bool TryGetComponent(this RaycastHit hit, [NotNullWhen(true)] out T? component) - { - if (hit.transform == null) - { - component = default; - return false; - } - - return hit.transform.TryGetComponent(out component); - } - - /// - /// Attempts to get the component of the specified type from the object that was hit by the raycast, and returns a value - /// that indicates whether the operation succeeded. - /// - /// The raycast hit. - /// The type of the component to retrieve. - /// - /// When this method returns, contains the component of the specified type from the object that was hit by the raycast, or - /// if no component of the specified type was found. - /// - /// - /// if the component of the specified type was found; otherwise, . - /// - /// is . - public static bool TryGetComponent(this RaycastHit hit, Type componentType, [NotNullWhen(true)] out Component? component) - { - if (componentType is null) - { - throw new ArgumentNullException(nameof(componentType)); - } - - if (hit.transform == null) - { - component = default; - return false; - } - - return hit.transform.TryGetComponent(componentType, out component); - } -} diff --git a/X10D.Unity/src/Singleton.cs b/X10D.Unity/src/Singleton.cs deleted file mode 100644 index 6d75df7..0000000 --- a/X10D.Unity/src/Singleton.cs +++ /dev/null @@ -1,60 +0,0 @@ -using UnityEngine; - -namespace X10D.Unity; - -/// -/// Represents a class which implements the singleton pattern for a specific . This class is not -/// thread-safe. -/// -/// The type of the singleton. -public abstract class Singleton : MonoBehaviour - where T : Singleton -{ - private static Lazy s_instanceLazy = new(CreateLazyInstanceInternal, false); - private static T? s_instance; - - /// - /// Gets the instance of the singleton. - /// - /// The singleton instance. -#pragma warning disable CA1000 - public static T Instance -#pragma warning restore CA1000 - { - get => s_instance ? s_instance! : s_instanceLazy.Value; - } - - /// - /// Called when the script instance is being loaded. - /// - protected virtual void Awake() - { - s_instance = (T?)this; - } - - /// - /// Called when the object is destroyed. - /// - protected virtual void OnDestroy() - { - s_instance = null; - s_instanceLazy = new Lazy(CreateLazyInstanceInternal, false); - } - - private static T CreateLazyInstanceInternal() - { - if (s_instance) - { - return s_instance!; - } - - if (FindObjectOfType() is { } instance) - { - s_instance = instance; - return instance; - } - - var gameObject = new GameObject {name = typeof(T).Name}; - return s_instance = gameObject.AddComponent(); - } -} diff --git a/X10D.Unity/src/TransformExtensions.cs b/X10D.Unity/src/TransformExtensions.cs deleted file mode 100644 index 922ed5c..0000000 --- a/X10D.Unity/src/TransformExtensions.cs +++ /dev/null @@ -1,114 +0,0 @@ -using UnityEngine; - -namespace X10D.Unity; - -/// -/// Extension methods for . -/// -public static class TransformExtensions -{ - /// - /// Rotates this transform so the forward vector points at another game object. - /// - /// The transform whose rotation will be changed. - /// The game object to look at. - /// - /// is . - /// -or- - /// is . - /// - public static void LookAt(this Transform transform, GameObject target) - { - if (transform == null) - { - throw new ArgumentNullException(nameof(transform)); - } - - if (target == null) - { - throw new ArgumentNullException(nameof(target)); - } - - transform.LookAt(target.transform); - } - - /// - /// Rotates this transform so the forward vector points at another game object. - /// - /// The transform whose rotation will be changed. - /// The game object to look at. - /// A vector specifying the upward direction. - /// - /// is . - /// -or- - /// is . - /// - public static void LookAt(this Transform transform, GameObject target, Vector3 worldUp) - { - if (transform == null) - { - throw new ArgumentNullException(nameof(transform)); - } - - if (target == null) - { - throw new ArgumentNullException(nameof(target)); - } - - transform.LookAt(target.transform, worldUp); - } - - /// - /// Sets the parent of this transform. - /// - /// The transform whose parent to change. - /// The new parent. - /// - /// is . - /// -or- - /// is . - /// - public static void SetParent(this Transform transform, GameObject parent) - { - if (transform == null) - { - throw new ArgumentNullException(nameof(transform)); - } - - if (parent == null) - { - throw new ArgumentNullException(nameof(parent)); - } - - transform.transform.SetParent(parent.transform); - } - - /// - /// Sets the parent of this transform. - /// - /// The transform whose parent to change. - /// The new parent. - /// - /// to modify the parent-relative position, scale and rotation such that the object keeps the same - /// world space position, rotation and scale as before; otherwise, . - /// - /// - /// is . - /// -or- - /// is . - /// - public static void SetParent(this Transform transform, GameObject parent, bool worldPositionStays) - { - if (transform == null) - { - throw new ArgumentNullException(nameof(transform)); - } - - if (parent == null) - { - throw new ArgumentNullException(nameof(parent)); - } - - transform.SetParent(parent.transform, worldPositionStays); - } -} diff --git a/X10D.Unity/src/WaitForFrames.cs b/X10D.Unity/src/WaitForFrames.cs deleted file mode 100644 index d6d69a8..0000000 --- a/X10D.Unity/src/WaitForFrames.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections; - -namespace X10D.Unity; - -/// -/// Represents a yield instruction that waits for a specific number of frames. -/// -public struct WaitForFrames : IEnumerator -{ - private readonly int _frameCount; - private int _frameIndex; - - /// - /// Initializes a new instance of the struct. - /// - /// The frame count. - public WaitForFrames(int frameCount) - { - _frameCount = frameCount; - _frameIndex = 0; - } - - /// - public object Current - { - get => _frameCount; - } - - /// - public bool MoveNext() - { - return ++_frameIndex <= _frameCount; - } - - /// - public void Reset() - { - _frameIndex = 0; - } -} diff --git a/X10D.Unity/src/WaitForKeyDown.cs b/X10D.Unity/src/WaitForKeyDown.cs deleted file mode 100644 index 0ffaaf4..0000000 --- a/X10D.Unity/src/WaitForKeyDown.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections; -using UnityEngine; - -namespace X10D.Unity; - -/// -/// Represents a yield instruction that waits for a key to be pressed. -/// -public readonly struct WaitForKeyDown : IEnumerator -{ - private readonly KeyCode _keyCode; - - /// - /// Initializes a new instance of the struct. - /// - /// The key to wait for. - public WaitForKeyDown(KeyCode keyCode) - { - _keyCode = keyCode; - } - - /// - public object Current - { - get => _keyCode == KeyCode.None ? Input.anyKeyDown : Input.GetKeyDown(_keyCode); - } - - /// - public bool MoveNext() - { - return !(_keyCode == KeyCode.None ? Input.anyKeyDown : Input.GetKeyDown(_keyCode)); - } - - /// - public void Reset() - { - } -} diff --git a/X10D.Unity/src/WaitForKeyUp.cs b/X10D.Unity/src/WaitForKeyUp.cs deleted file mode 100644 index 9cea34d..0000000 --- a/X10D.Unity/src/WaitForKeyUp.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections; -using UnityEngine; - -namespace X10D.Unity; - -/// -/// Represents a yield instruction that waits for a key to be released. -/// -public readonly struct WaitForKeyUp : IEnumerator -{ - private readonly KeyCode _keyCode; - - /// - /// Initializes a new instance of the struct. - /// - /// The key to wait for. - public WaitForKeyUp(KeyCode keyCode) - { - _keyCode = keyCode; - } - - /// - public object Current - { - get => _keyCode == KeyCode.None || Input.GetKeyUp(_keyCode); - } - - /// - public bool MoveNext() - { - return !(_keyCode == KeyCode.None || Input.GetKeyUp(_keyCode)); - } - - /// - public void Reset() - { - } -} diff --git a/X10D.Unity/src/WaitForSecondsNoAlloc.cs b/X10D.Unity/src/WaitForSecondsNoAlloc.cs deleted file mode 100644 index c10b751..0000000 --- a/X10D.Unity/src/WaitForSecondsNoAlloc.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Collections; - -namespace X10D.Unity; - -/// -/// Represents a yield instruction which waits for a specified amount of seconds. -/// -/// This struct exists as an allocation-free alternative to . -public struct WaitForSecondsNoAlloc : IEnumerator -{ - private readonly float _duration; - private float _delta; - - /// - /// Initializes a new instance of the struct. - /// - /// The duration of the pause, in seconds. - public WaitForSecondsNoAlloc(float duration) - { - _duration = duration; - _delta = 0f; - } - - /// - public object Current - { - get => _delta; - } - - /// - public bool MoveNext() - { - _delta += UnityEngine.Time.deltaTime; - return _delta < _duration; - } - - /// - public void Reset() - { - } -} diff --git a/X10D.Unity/src/WaitForSecondsRealtimeNoAlloc.cs b/X10D.Unity/src/WaitForSecondsRealtimeNoAlloc.cs deleted file mode 100644 index 3335336..0000000 --- a/X10D.Unity/src/WaitForSecondsRealtimeNoAlloc.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections; - -namespace X10D.Unity; - -/// -/// Represents a yield instruction which waits for a given amount of time, as provided by a . -/// -/// This struct exists as an allocation-free alternative to . -public readonly struct WaitForSecondsRealtimeNoAlloc : IEnumerator -{ - private readonly DateTime _expectedEnd; - - /// - /// Initializes a new instance of the struct. - /// - /// The duration of the pause, in seconds. - public WaitForSecondsRealtimeNoAlloc(float duration) - { - _expectedEnd = DateTime.Now + TimeSpan.FromSeconds(duration); - } - - /// - public object Current - { - get => DateTime.Now; - } - - /// - public bool MoveNext() - { - return DateTime.Now < _expectedEnd; - } - - /// - public void Reset() - { - } -} diff --git a/X10D.Unity/src/WaitForTimeSpan.cs b/X10D.Unity/src/WaitForTimeSpan.cs deleted file mode 100644 index 11b83c1..0000000 --- a/X10D.Unity/src/WaitForTimeSpan.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Collections; - -namespace X10D.Unity; - -/// -/// Represents a yield instruction which waits for a given amount of time, as provided by a . -/// -public struct WaitForTimeSpan : IEnumerator -{ - private readonly TimeSpan _duration; - private readonly DateTime _start; - private DateTime _current; - - /// - /// Initializes a new instance of the struct. - /// - /// The duration of the pause. - public WaitForTimeSpan(TimeSpan duration) - { - _duration = duration; - _start = DateTime.Now; - _current = _start; - } - - /// - public object Current - { - get => _current; - } - - /// - public bool MoveNext() - { - _current += TimeSpan.FromSeconds(UnityEngine.Time.deltaTime); - return _current < _start + _duration; - } - - /// - public void Reset() - { - } -} diff --git a/X10D.Unity/src/WaitForTimeSpanRealtime.cs b/X10D.Unity/src/WaitForTimeSpanRealtime.cs deleted file mode 100644 index 28ed33f..0000000 --- a/X10D.Unity/src/WaitForTimeSpanRealtime.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections; - -namespace X10D.Unity; - -/// -/// Represents a yield instruction which waits for a given amount of time, as provided by a . -/// -public readonly struct WaitForTimeSpanRealtime : IEnumerator -{ - private readonly DateTime _expectedEnd; - - /// - /// Initializes a new instance of the struct. - /// - /// The duration of the pause. - public WaitForTimeSpanRealtime(TimeSpan duration) - { - _expectedEnd = DateTime.Now + duration; - } - - /// - public object Current - { - get => DateTime.Now; - } - - /// - public bool MoveNext() - { - return DateTime.Now < _expectedEnd; - } - - /// - public void Reset() - { - } -} diff --git a/X10D.sln b/X10D.sln index dd11b7d..1596572 100644 --- a/X10D.sln +++ b/X10D.sln @@ -16,21 +16,18 @@ 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 + global.json = global.json EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceValidator", "tools\SourceValidator\SourceValidator.csproj", "{84750149-9068-4780-AFDE-CDA1AC57007D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X10D.Unity", "X10D.Unity\X10D.Unity.csproj", "{7EAB3F09-A9FD-4334-B4DB-0394DD0C6568}" -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}" ProjectSection(SolutionItems) = preProject - .github\workflows\activate-unity.yml = .github\workflows\activate-unity.yml .github\workflows\docfx.yml = .github\workflows\docfx.yml .github\workflows\dotnet.yml = .github\workflows\dotnet.yml .github\workflows\nightly.yml = .github\workflows\nightly.yml @@ -38,12 +35,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{ .github\workflows\release.yml = .github\workflows\release.yml .github\workflows\sonarcloud.yml = .github\workflows\sonarcloud.yml .github\workflows\source_validator.yml = .github\workflows\source_validator.yml - .github\workflows\unity.yml = .github\workflows\unity.yml EndProjectSection 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 @@ -67,26 +64,14 @@ Global {84750149-9068-4780-AFDE-CDA1AC57007D}.Debug|Any CPU.Build.0 = Debug|Any CPU {84750149-9068-4780-AFDE-CDA1AC57007D}.Release|Any CPU.ActiveCfg = Release|Any CPU {84750149-9068-4780-AFDE-CDA1AC57007D}.Release|Any CPU.Build.0 = Release|Any CPU - {7EAB3F09-A9FD-4334-B4DB-0394DD0C6568}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7EAB3F09-A9FD-4334-B4DB-0394DD0C6568}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7EAB3F09-A9FD-4334-B4DB-0394DD0C6568}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7EAB3F09-A9FD-4334-B4DB-0394DD0C6568}.Release|Any CPU.Build.0 = Release|Any CPU {077A5D33-AD55-4C55-8A67-972CEBC32C7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {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 {B04AF429-30CF-4B69-81BA-38F560CA9126}.Release|Any CPU.Build.0 = Release|Any CPU - {CCBF047D-1B01-45EC-8D89-B00B4AC482CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CCBF047D-1B01-45EC-8D89-B00B4AC482CA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CCBF047D-1B01-45EC-8D89-B00B4AC482CA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CCBF047D-1B01-45EC-8D89-B00B4AC482CA}.Release|Any CPU.Build.0 = Release|Any CPU {259450A0-9964-403A-91E1-E9111B92C293}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {259450A0-9964-403A-91E1-E9111B92C293}.Debug|Any CPU.Build.0 = Debug|Any CPU {259450A0-9964-403A-91E1-E9111B92C293}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -104,7 +89,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {84750149-9068-4780-AFDE-CDA1AC57007D} = {4B8969E6-27D2-4357-964E-9979FF7CC805} - {CCBF047D-1B01-45EC-8D89-B00B4AC482CA} = {4B8969E6-27D2-4357-964E-9979FF7CC805} {259450A0-9964-403A-91E1-E9111B92C293} = {4B8969E6-27D2-4357-964E-9979FF7CC805} {077A5D33-AD55-4C55-8A67-972CEBC32C7A} = {4B8969E6-27D2-4357-964E-9979FF7CC805} {F57376C4-3591-43AF-BBED-447A1DE2B1FE} = {4B8969E6-27D2-4357-964E-9979FF7CC805} diff --git a/X10D/X10D.csproj b/X10D/X10D.csproj index c9ddcf1..8f36b52 100644 --- a/X10D/X10D.csproj +++ b/X10D/X10D.csproj @@ -1,72 +1,9 @@ - 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 + net8.0;net7.0;net6.0 - - 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..5207b26 100644 --- a/X10D/src/Collections/ByteExtensions.cs +++ b/X10D/src/Collections/ByteExtensions.cs @@ -1,12 +1,9 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; -using X10D.CompilerServices; - -#if NETCOREAPP3_0_OR_GREATER using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -#endif +using X10D.CompilerServices; namespace X10D.Collections; @@ -23,7 +20,7 @@ public static class ByteExtensions /// The value to unpack. /// An array of with length 8. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static bool[] Unpack(this byte value) { var buffer = new bool[Size]; @@ -38,7 +35,7 @@ public static class ByteExtensions /// When this method returns, contains the unpacked booleans from . /// is not large enough to contain the result. [ExcludeFromCodeCoverage] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static void Unpack(this byte value, Span destination) { if (destination.Length < Size) @@ -46,18 +43,16 @@ public static class ByteExtensions throw new ArgumentException(ExceptionMessages.DestinationSpanLengthTooShort, nameof(destination)); } -#if NETCOREAPP3_0_OR_GREATER if (Sse3.IsSupported) { UnpackInternal_Ssse3(value, destination); return; } -#endif UnpackInternal_Fallback(value, destination); } - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static void UnpackInternal_Fallback(this byte value, Span destination) { for (var index = 0; index < Size; index++) @@ -66,8 +61,7 @@ public static class ByteExtensions } } -#if NETCOREAPP3_0_OR_GREATER - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal unsafe static void UnpackInternal_Ssse3(this byte value, Span destination) { fixed (bool* pDestination = destination) @@ -87,5 +81,4 @@ public static class ByteExtensions Sse2.StoreScalar((long*)pDestination, correctness.AsInt64()); } } -#endif } 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..6138a62 100644 --- a/X10D/src/Collections/DictionaryExtensions.cs +++ b/X10D/src/Collections/DictionaryExtensions.cs @@ -1,7 +1,5 @@ -using System.Diagnostics.Contracts; -#if NET6_0_OR_GREATER +using System.Diagnostics.Contracts; using System.Runtime.InteropServices; -#endif using System.Web; namespace X10D.Collections; @@ -37,10 +35,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,25 +44,11 @@ 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); // DO NOT CHANGE. reassigning value is necessary to mutate the dictionary, due to ref return above. // mutation of the dictionary is INTENDED BEHAVIOUR. this is not a mistake. return value = exists ? updateValueFactory(key, value!) : addValue; -#else - if (dictionary.TryGetValue(key, out TValue? old)) - { - TValue updated = updateValueFactory(key, old); - dictionary[key] = updated; - - return updated; - } - - dictionary.Add(key, addValue); - return addValue; -#endif } /// @@ -97,10 +77,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 +86,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(updateValueFactory)); } -#endif if (dictionary.TryGetValue(key, out TValue? old)) { @@ -152,11 +127,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,27 +141,11 @@ 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); // DO NOT CHANGE. reassigning value is necessary to mutate the dictionary, due to ref return above. // mutation of the dictionary is INTENDED BEHAVIOUR. this is not a mistake. return value = exists ? updateValueFactory(key, value!) : addValueFactory(key); -#else - if (dictionary.TryGetValue(key, out TValue? old)) - { - TValue updated = updateValueFactory(key, old); - dictionary[key] = updated; - - return updated; - } - - TValue add = addValueFactory(key); - dictionary.Add(key, add); - - return add; -#endif } /// @@ -222,11 +176,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 +190,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(updateValueFactory)); } -#endif if (dictionary.TryGetValue(key, out TValue? old)) { @@ -291,11 +239,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,27 +253,11 @@ 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); // DO NOT CHANGE. reassigning value is necessary to mutate the dictionary, due to ref return above. // mutation of the dictionary is INTENDED BEHAVIOUR. this is not a mistake. return value = exists ? updateValueFactory(key, value!, factoryArgument) : addValueFactory(key, factoryArgument); -#else - if (dictionary.TryGetValue(key, out TValue? old)) - { - TValue updated = updateValueFactory(key, old, factoryArgument); - dictionary[key] = updated; - - return updated; - } - - TValue add = addValueFactory(key, factoryArgument); - dictionary.Add(key, add); - - return add; -#endif } /// @@ -367,11 +294,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 +308,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(updateValueFactory)); } -#endif if (dictionary.TryGetValue(key, out TValue? old)) { @@ -414,14 +335,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 +378,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 +387,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(selector)); } -#endif static string SanitizeValue(string? value) { @@ -520,11 +432,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 +446,6 @@ public static class DictionaryExtensions { throw new ArgumentNullException(nameof(valueSelector)); } -#endif static string SanitizeValue(string? value) { @@ -571,14 +477,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 +512,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 +521,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 +558,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 +572,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..fb722b9 100644 --- a/X10D/src/Collections/Int16Extensions.cs +++ b/X10D/src/Collections/Int16Extensions.cs @@ -1,12 +1,9 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; -using X10D.CompilerServices; - -#if NETCOREAPP3_0_OR_GREATER using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -#endif +using X10D.CompilerServices; namespace X10D.Collections; @@ -23,7 +20,7 @@ public static class Int16Extensions /// The value to unpack. /// An array of with length 16. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static bool[] Unpack(this short value) { var ret = new bool[Size]; @@ -38,7 +35,7 @@ public static class Int16Extensions /// When this method returns, contains the unpacked booleans from . /// is not large enough to contain the result. [ExcludeFromCodeCoverage] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static void Unpack(this short value, Span destination) { if (destination.Length < Size) @@ -46,18 +43,16 @@ public static class Int16Extensions throw new ArgumentException(ExceptionMessages.DestinationSpanLengthTooShort, nameof(destination)); } -#if NETCOREAPP3_0_OR_GREATER if (Sse3.IsSupported) { UnpackInternal_Ssse3(value, destination); return; } -#endif UnpackInternal_Fallback(value, destination); } - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static void UnpackInternal_Fallback(this short value, Span destination) { for (var index = 0; index < Size; index++) @@ -66,8 +61,7 @@ public static class Int16Extensions } } -#if NETCOREAPP3_0_OR_GREATER - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal unsafe static void UnpackInternal_Ssse3(this short value, Span destination) { fixed (bool* pDestination = destination) @@ -89,5 +83,4 @@ public static class Int16Extensions Sse2.Store((byte*)pDestination, correctness); } } -#endif } diff --git a/X10D/src/Collections/Int32Extensions.cs b/X10D/src/Collections/Int32Extensions.cs index 7e2ebaf..19dbe7e 100644 --- a/X10D/src/Collections/Int32Extensions.cs +++ b/X10D/src/Collections/Int32Extensions.cs @@ -1,12 +1,9 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; -using X10D.CompilerServices; - -#if NETCOREAPP3_0_OR_GREATER using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -#endif +using X10D.CompilerServices; namespace X10D.Collections; @@ -23,7 +20,7 @@ public static class Int32Extensions /// The value to unpack. /// An array of with length 32. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static bool[] Unpack(this int value) { var ret = new bool[Size]; @@ -38,7 +35,7 @@ public static class Int32Extensions /// When this method returns, contains the unpacked booleans from . /// is not large enough to contain the result. [ExcludeFromCodeCoverage] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static void Unpack(this int value, Span destination) { if (destination.Length < Size) @@ -46,7 +43,6 @@ public static class Int32Extensions throw new ArgumentException(ExceptionMessages.DestinationSpanLengthTooShort, nameof(destination)); } -#if NETCOREAPP3_0_OR_GREATER if (Avx2.IsSupported) { UnpackInternal_Avx2(value, destination); @@ -58,12 +54,11 @@ public static class Int32Extensions UnpackInternal_Ssse3(value, destination); return; } -#endif UnpackInternal_Fallback(value, destination); } - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static void UnpackInternal_Fallback(this int value, Span destination) { for (var index = 0; index < Size; index++) @@ -72,8 +67,7 @@ public static class Int32Extensions } } -#if NETCOREAPP3_0_OR_GREATER - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static unsafe void UnpackInternal_Ssse3(this int value, Span destination) { fixed (bool* pDestination = destination) @@ -130,5 +124,4 @@ public static class Int32Extensions Avx.Store((byte*)pDestination, correctness); } } -#endif } 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..900fd9f 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,29 +236,14 @@ 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; + (int start, int length) = range.GetOffsetAndLength(source.Count); - if (end < start) - { - throw new ArgumentException(ExceptionMessages.EndIndexLessThanStartIndex); - } - - if (end >= source.Count) - { - throw new ArgumentOutOfRangeException(nameof(range), ExceptionMessages.EndIndexGreaterThanCount); - } - - for (int index = end; index >= start; index--) + for (int index = start + length; index >= start; index--) { source.RemoveAt(index); } @@ -300,14 +261,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 +291,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 +316,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 +355,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 +364,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..7c3ee0a 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 @@ -53,6 +53,7 @@ public static class SpanExtensions return source; } +#if !NET8_0_OR_GREATER /// /// Replaces all occurrences of a specified element in a span of elements with another specified element. /// @@ -72,6 +73,7 @@ public static class SpanExtensions } } } +#endif /// /// Splits a span of elements into sub-spans based on a delimiting element. 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..373a366 100644 --- a/X10D/src/CompilerServices/CompilerResources.cs +++ b/X10D/src/CompilerServices/CompilerResources.cs @@ -1,13 +1,9 @@ -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; namespace X10D.CompilerServices; internal static class CompilerResources { -#if NETCOREAPP3_0_OR_GREATER - public const MethodImplOptions MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining | - System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization; -#else - public const MethodImplOptions MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining; -#endif + public const MethodImplOptions MaxOptimization = MethodImplOptions.AggressiveInlining | + MethodImplOptions.AggressiveOptimization; } diff --git a/X10D/src/Core/EnumExtensions.cs b/X10D/src/Core/EnumExtensions.cs index 29b7649..6b813ef 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; @@ -20,11 +20,7 @@ public static class EnumExtensions public static T Next(this T value) where T : struct, Enum { -#if NET5_0_OR_GREATER T[] values = Enum.GetValues(); -#else - T[] values = Enum.GetValues(typeof(T)).Cast().ToArray(); -#endif int index = Array.IndexOf(values, value) + 1; index %= values.Length; return values[index]; @@ -44,11 +40,7 @@ public static class EnumExtensions public static T NextUnchecked(this T value) where T : struct, Enum { -#if NET5_0_OR_GREATER T[] values = Enum.GetValues(); -#else - T[] values = Enum.GetValues(typeof(T)).Cast().ToArray(); -#endif int index = Array.IndexOf(values, value) + 1; return values[index]; } @@ -66,11 +58,7 @@ public static class EnumExtensions public static T Previous(this T value) where T : struct, Enum { -#if NET5_0_OR_GREATER T[] values = Enum.GetValues(); -#else - T[] values = Enum.GetValues(typeof(T)).Cast().ToArray(); -#endif int index = Array.IndexOf(values, value) - 1; int length = values.Length; @@ -94,11 +82,7 @@ public static class EnumExtensions public static T PreviousUnchecked(this T value) where T : struct, Enum { -#if NET5_0_OR_GREATER T[] values = Enum.GetValues(); -#else - T[] values = Enum.GetValues(typeof(T)).Cast().ToArray(); -#endif int index = Array.IndexOf(values, value) - 1; return values[index]; } 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..7a98d64 100644 --- a/X10D/src/Core/IntrinsicExtensions.cs +++ b/X10D/src/Core/IntrinsicExtensions.cs @@ -1,4 +1,3 @@ -#if NETCOREAPP3_0_OR_GREATER using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; @@ -30,7 +29,7 @@ public static class IntrinsicExtensions /// A of which remapped back to 0 and 1 based on boolean truthiness. /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static Vector64 CorrectBoolean(this Vector64 vector) { Vector64 output = IntrinsicUtility.GetUninitializedVector64(); @@ -65,7 +64,7 @@ public static class IntrinsicExtensions /// A of which remapped back to 0 and 1 based on boolean truthiness. /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] [ExcludeFromCodeCoverage] public static Vector128 CorrectBoolean(this Vector128 vector) { @@ -88,7 +87,7 @@ public static class IntrinsicExtensions /// A of which remapped back to 0 and 1 based on boolean truthiness. /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] [ExcludeFromCodeCoverage] public static Vector256 CorrectBoolean(this Vector256 vector) { @@ -112,7 +111,7 @@ public static class IntrinsicExtensions /// [Pure] [CLSCompliant(false)] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] [ExcludeFromCodeCoverage] public static Vector128 ReverseElements(this Vector128 vector) { @@ -120,7 +119,7 @@ public static class IntrinsicExtensions } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector128 CorrectBooleanInternal_Fallback(this Vector128 vector) { Vector128 output = IntrinsicUtility.GetUninitializedVector128(); @@ -135,7 +134,7 @@ public static class IntrinsicExtensions } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector128 CorrectBooleanInternal_Sse2(this Vector128 vector) { Vector128 cmp = Sse2.CompareEqual(vector, Vector128.Zero); @@ -145,7 +144,7 @@ public static class IntrinsicExtensions } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector256 CorrectBooleanInternal_Fallback(this Vector256 vector) { Vector256 output = IntrinsicUtility.GetUninitializedVector256(); @@ -160,7 +159,7 @@ public static class IntrinsicExtensions } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector256 CorrectBooleanInternal_Avx2(this Vector256 vector) { Vector256 cmp = Avx2.CompareEqual(vector, Vector256.Zero); @@ -170,7 +169,7 @@ public static class IntrinsicExtensions } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector128 ReverseElementsInternal_Fallback(this Vector128 vector) { Vector128 output = IntrinsicUtility.GetUninitializedVector128(); @@ -182,10 +181,9 @@ public static class IntrinsicExtensions } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector128 ReverseElementsInternal_Sse2(this Vector128 vector) { return Sse2.Shuffle(vector.AsDouble(), vector.AsDouble(), 0b01).AsUInt64(); } } -#endif diff --git a/X10D/src/Core/IntrinsicUtility.cs b/X10D/src/Core/IntrinsicUtility.cs index ff573b8..73685d1 100644 --- a/X10D/src/Core/IntrinsicUtility.cs +++ b/X10D/src/Core/IntrinsicUtility.cs @@ -1,5 +1,3 @@ -#if NETCOREAPP3_0_OR_GREATER - using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; @@ -33,7 +31,7 @@ public static class IntrinsicUtility /// The truncated product vector. [Pure] [CLSCompliant(false)] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] [ExcludeFromCodeCoverage] public static Vector128 Multiply(Vector128 left, Vector128 right) { @@ -64,7 +62,7 @@ public static class IntrinsicUtility /// [Pure] [CLSCompliant(false)] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] [ExcludeFromCodeCoverage] public static Vector256 Multiply(Vector256 lhs, Vector256 rhs) { @@ -92,7 +90,7 @@ public static class IntrinsicUtility /// A of whose elements is 64-bit truncated product of lhs and rhs. /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static Vector128 Multiply(Vector128 lhs, Vector128 rhs) { return Multiply(lhs.AsUInt64(), rhs.AsUInt64()).AsInt64(); @@ -116,7 +114,7 @@ public static class IntrinsicUtility /// A of whose elements is 64-bit truncated product of lhs and rhs. /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static Vector256 Multiply(Vector256 lhs, Vector256 rhs) { return Multiply(lhs.AsUInt64(), rhs.AsUInt64()).AsInt64(); @@ -142,7 +140,7 @@ public static class IntrinsicUtility /// elements in lhs and rhs. /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] [ExcludeFromCodeCoverage] public static Vector128 HorizontalOr(Vector128 left, Vector128 right) { @@ -173,7 +171,7 @@ public static class IntrinsicUtility /// elements in lhs and rhs. /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] [CLSCompliant(false)] public static Vector128 HorizontalOr(Vector128 left, Vector128 right) { @@ -181,41 +179,29 @@ public static class IntrinsicUtility } // Helper methods - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector64 GetUninitializedVector64() where T : struct { -#if NET6_0_OR_GREATER Unsafe.SkipInit(out Vector64 output); return output; -#else - return default; -#endif } - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector128 GetUninitializedVector128() where T : struct { -#if NET6_0_OR_GREATER Unsafe.SkipInit(out Vector128 output); return output; -#else - return default; -#endif } - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector256 GetUninitializedVector256() where T : struct { -#if NET6_0_OR_GREATER Unsafe.SkipInit(out Vector256 output); return output; -#else - return default; -#endif } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector128 HorizontalOr_Sse(Vector128 left, Vector128 right) { Vector128 leftSingle = left.AsSingle(); @@ -230,7 +216,7 @@ public static class IntrinsicUtility } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector128 HorizontalOrInternal_Fallback(Vector128 left, Vector128 right) { Vector128 output = GetUninitializedVector128(); @@ -249,7 +235,7 @@ public static class IntrinsicUtility } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector128 MultiplyInternal_Fallback(Vector128 left, Vector128 right) { ulong leftInteger1 = Unsafe.As, ulong>(ref left); @@ -266,7 +252,7 @@ public static class IntrinsicUtility } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector128 MultiplyInternal_Sse2(Vector128 left, Vector128 right) { // https://stackoverflow.com/questions/17863411/sse-multiplication-of-2-64-bit-integers @@ -283,7 +269,7 @@ public static class IntrinsicUtility } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector256 MultiplyInternal_Fallback(Vector256 left, Vector256 right) { Vector256 output = GetUninitializedVector256(); @@ -299,7 +285,7 @@ public static class IntrinsicUtility } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static Vector256 MultiplyInternal_Avx2(Vector256 left, Vector256 right) { // https://stackoverflow.com/questions/17863411/sse-multiplication-of-2-64-bit-integers @@ -315,5 +301,3 @@ public static class IntrinsicUtility return Avx2.Add(high, ac); } } - -#endif 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..7cbdcc0 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; @@ -11,10 +11,6 @@ namespace X10D.Core; /// public static class RandomExtensions { -#if !NET6_0_OR_GREATER - private static readonly Random Shared = new(); -#endif - /// /// Returns a random value that defined in a specified enum. /// @@ -27,14 +23,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 +46,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 +69,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 +101,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 +135,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 +144,6 @@ public static class RandomExtensions { throw new ArgumentNullException(nameof(source)); } -#endif if (source is T[] array) { @@ -206,14 +181,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 +213,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 +231,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 +255,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 +284,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 +302,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 +327,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 +361,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 +402,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 +434,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 +465,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 +474,6 @@ public static class RandomExtensions { throw new ArgumentNullException(nameof(source)); } -#endif if (length < 0) { @@ -571,10 +501,6 @@ public static class RandomExtensions internal static Random GetShared() { -#if NET6_0_OR_GREATER return Random.Shared; -#else - return Shared; -#endif } } diff --git a/X10D/src/Core/SpanExtensions.cs b/X10D/src/Core/SpanExtensions.cs index 6c0b6c0..c1f2a1e 100644 --- a/X10D/src/Core/SpanExtensions.cs +++ b/X10D/src/Core/SpanExtensions.cs @@ -1,14 +1,10 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using X10D.CompilerServices; - -#if NETCOREAPP3_0_OR_GREATER using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -using System.Runtime.Intrinsics.Arm; -#endif +using X10D.CompilerServices; #if NET7_0_OR_GREATER using System.Diagnostics; @@ -21,7 +17,6 @@ namespace X10D.Core; /// public static class SpanExtensions { -#if NETCOREAPP3_0_OR_GREATER private const ulong IntegerPackingMagic = 0x0102040810204080; [ExcludeFromCodeCoverage] @@ -35,7 +30,6 @@ public static class SpanExtensions { get => Vector256.Create(IntegerPackingMagic); } -#endif /// /// Returns a value indicating whether a specific enumeration value is contained with the current span of elements. @@ -49,7 +43,7 @@ public static class SpanExtensions /// /// The size of is unsupported. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static bool Contains(this Span span, T value) where T : struct, Enum { return Contains((ReadOnlySpan)span, value); @@ -68,63 +62,46 @@ public static class SpanExtensions /// /// The size of is unsupported. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static bool Contains(this ReadOnlySpan span, T value) where T : struct, Enum { -#if NET6_0_OR_GREATER - unsafe + switch (Unsafe.SizeOf()) { -#pragma warning disable CS8500 - switch (sizeof(T)) -#pragma warning restore CS8500 - { - case 1: - { - ref byte enums = ref Unsafe.As(ref MemoryMarshal.GetReference(span)); - return MemoryMarshal.CreateSpan(ref enums, span.Length).Contains(Unsafe.As(ref value)); - } + case 1: + { + ref byte enums = ref Unsafe.As(ref MemoryMarshal.GetReference(span)); + return MemoryMarshal.CreateSpan(ref enums, span.Length).Contains(Unsafe.As(ref value)); + } - case 2: - { - ref ushort enums = ref Unsafe.As(ref MemoryMarshal.GetReference(span)); - return MemoryMarshal.CreateSpan(ref enums, span.Length).Contains(Unsafe.As(ref value)); - } + case 2: + { + ref ushort enums = ref Unsafe.As(ref MemoryMarshal.GetReference(span)); + return MemoryMarshal.CreateSpan(ref enums, span.Length).Contains(Unsafe.As(ref value)); + } - case 4: - { - ref uint enums = ref Unsafe.As(ref MemoryMarshal.GetReference(span)); - return MemoryMarshal.CreateSpan(ref enums, span.Length).Contains(Unsafe.As(ref value)); - } + case 4: + { + ref uint enums = ref Unsafe.As(ref MemoryMarshal.GetReference(span)); + return MemoryMarshal.CreateSpan(ref enums, span.Length).Contains(Unsafe.As(ref value)); + } - case 8: - { - ref ulong enums = ref Unsafe.As(ref MemoryMarshal.GetReference(span)); - return MemoryMarshal.CreateSpan(ref enums, span.Length).Contains(Unsafe.As(ref value)); - } + case 8: + { + ref ulong enums = ref Unsafe.As(ref MemoryMarshal.GetReference(span)); + return MemoryMarshal.CreateSpan(ref enums, span.Length).Contains(Unsafe.As(ref value)); + } - // dotcover disable - //NOSONAR - default: + // dotcover disable + //NOSONAR + default: #if NET7_0_OR_GREATER - throw new UnreachableException(ExceptionMessages.EnumSizeIsUnexpected); + throw new UnreachableException(string.Format(ExceptionMessages.EnumSizeIsUnexpected, Unsafe.SizeOf())); #else - throw new ArgumentException(ExceptionMessages.EnumSizeIsUnexpected); + throw new ArgumentException(string.Format(ExceptionMessages.EnumSizeIsUnexpected, Unsafe.SizeOf())); #endif - //NOSONAR - // dotcover enable - } + //NOSONAR + // dotcover enable } -#else - foreach (var it in span) - { - if (EqualityComparer.Default.Equals(it, value)) - { - return true; - } - } - - return false; -#endif } /// @@ -134,7 +111,7 @@ public static class SpanExtensions /// An 8-bit unsigned integer containing the packed booleans. /// contains more than 8 elements. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static byte PackByte(this Span source) { return PackByte((ReadOnlySpan)source); @@ -147,7 +124,7 @@ public static class SpanExtensions /// An 8-bit unsigned integer containing the packed booleans. /// contains more than 8 elements. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] [ExcludeFromCodeCoverage] public static byte PackByte(this ReadOnlySpan source) { @@ -161,7 +138,6 @@ public static class SpanExtensions return PackByteInternal_Fallback(source); } -#if NETCOREAPP3_0_OR_GREATER if (!BitConverter.IsLittleEndian) { return PackByteInternal_Fallback(source); @@ -172,12 +148,6 @@ public static class SpanExtensions return PackByteInternal_Sse2(source); } - if (AdvSimd.IsSupported) - { - return PackByteInternal_AdvSimd(source); - } -#endif - return PackByteInternal_Fallback(source); } @@ -201,7 +171,7 @@ public static class SpanExtensions /// A 16-bit signed integer containing the packed booleans. /// contains more than 16 elements. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] [ExcludeFromCodeCoverage] public static short PackInt16(this ReadOnlySpan source) { @@ -217,12 +187,10 @@ public static class SpanExtensions goto default; } -#if NETCOREAPP3_0_OR_GREATER if (Sse2.IsSupported) { return PackInt16Internal_Sse2(source); } -#endif goto default; case < 16: @@ -240,7 +208,7 @@ public static class SpanExtensions /// A 32-bit signed integer containing the packed booleans. /// contains more than 32 elements. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static int PackInt32(this Span source) { return PackInt32((ReadOnlySpan)source); @@ -253,7 +221,7 @@ public static class SpanExtensions /// A 32-bit signed integer containing the packed booleans. /// contains more than 32 elements. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] [ExcludeFromCodeCoverage] public static int PackInt32(this ReadOnlySpan source) { @@ -269,7 +237,6 @@ public static class SpanExtensions return PackInt16(source); case 32: -#if NETCOREAPP3_0_OR_GREATER if (!BitConverter.IsLittleEndian) { goto default; @@ -285,11 +252,6 @@ public static class SpanExtensions return PackInt32Internal_Sse2(source); } - if (AdvSimd.IsSupported) - { - return PackInt32Internal_AdvSimd(source); - } -#endif goto default; default: @@ -304,7 +266,7 @@ public static class SpanExtensions /// A 64-bit signed integer containing the packed booleans. /// contains more than 64 elements. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static long PackInt64(this Span source) { return PackInt64((ReadOnlySpan)source); @@ -317,7 +279,7 @@ public static class SpanExtensions /// A 64-bit signed integer containing the packed booleans. /// contains more than 64 elements. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static long PackInt64(this ReadOnlySpan source) { switch (source.Length) @@ -342,7 +304,7 @@ public static class SpanExtensions } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static byte PackByteInternal_Fallback(this ReadOnlySpan source) { byte result = 0; @@ -356,7 +318,7 @@ public static class SpanExtensions } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static short PackInt16Internal_Fallback(this ReadOnlySpan source) { short result = 0; @@ -370,7 +332,7 @@ public static class SpanExtensions } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static int PackInt32Internal_Fallback(this ReadOnlySpan source) { var result = 0; @@ -383,9 +345,8 @@ public static class SpanExtensions return result; } -#if NETCOREAPP3_0_OR_GREATER [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static byte PackByteInternal_Sse2(this ReadOnlySpan source) { unsafe @@ -399,7 +360,7 @@ public static class SpanExtensions } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static short PackInt16Internal_Sse2(this ReadOnlySpan source) { unsafe @@ -416,37 +377,8 @@ public static class SpanExtensions } } - // dotcover disable - //NOSONAR [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] - internal static int PackInt32Internal_AdvSimd(this ReadOnlySpan source) - { - unsafe - { - fixed (bool* pSource = source) - { - Vector128 vector1 = AdvSimd.LoadVector128((byte*)pSource).CorrectBoolean().AsUInt64(); - Vector128 vector2 = AdvSimd.LoadVector128((byte*)(pSource + 16)).CorrectBoolean().AsUInt64(); - - Vector128 calc1 = IntrinsicUtility.Multiply(IntegerPackingMagicV128, vector1); - Vector128 calc2 = IntrinsicUtility.Multiply(IntegerPackingMagicV128, vector2); - - calc1 = AdvSimd.ShiftRightLogical(calc1, 56); - calc2 = AdvSimd.ShiftRightLogical(calc2, 56); - - Vector128 shift1 = AdvSimd.ShiftLogical(calc1, Vector128.Create(0, 8)); - Vector128 shift2 = AdvSimd.ShiftLogical(calc2, Vector128.Create(16, 24)); - - return (int)(shift1.GetElement(0) | shift1.GetElement(1) | shift2.GetElement(0) | shift2.GetElement(1)); - } - } - } - //NOSONAR - // dotcover enable - - [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static int PackInt32Internal_Avx2(this ReadOnlySpan source) { unsafe @@ -471,7 +403,7 @@ public static class SpanExtensions } [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] internal static int PackInt32Internal_Sse2(this ReadOnlySpan source) { unsafe @@ -498,25 +430,4 @@ public static class SpanExtensions } } } - -#if NET5_0_OR_GREATER - // dotcover disable - //NOSONAR - [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] - internal static byte PackByteInternal_AdvSimd(this ReadOnlySpan source) - { - unsafe - { - fixed (bool* pSource = source) - { - Vector64 load = AdvSimd.LoadVector64((byte*)pSource); - return unchecked((byte)(IntegerPackingMagic * load.CorrectBoolean().AsUInt64().GetElement(0) >> 56)); - } - } - } - //NOSONAR - // dotcover enable -#endif -#endif } 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..3d90e05 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; @@ -27,7 +27,7 @@ public static class ColorExtensions /// When this method returns, contains the component of . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static void Deconstruct(this Color color, out byte a, out byte r, out byte g, out byte b) { a = color.A; @@ -48,7 +48,7 @@ public static class ColorExtensions /// When this method returns, contains the component of . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static void Deconstruct(this Color color, out byte r, out byte g, out byte b) { r = color.R; @@ -63,7 +63,7 @@ public static class ColorExtensions /// The closest . /// Glenn Slayden, https://stackoverflow.com/a/12340136/1467293 [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static ConsoleColor GetClosestConsoleColor(this Color color) { ConsoleColor result = 0; @@ -72,17 +72,9 @@ public static class ColorExtensions double blue = color.B; var delta = double.MaxValue; -#if NET5_0_OR_GREATER foreach (ConsoleColor consoleColor in Enum.GetValues()) -#else - foreach (ConsoleColor consoleColor in Enum.GetValues(typeof(ConsoleColor))) -#endif { -#if NET5_0_OR_GREATER string name = Enum.GetName(consoleColor)!; -#else - string name = Enum.GetName(typeof(ConsoleColor), consoleColor)!; -#endif Color currentColor = Color.FromName(name == "DarkYellow" ? "Orange" : name); // bug fix double r = currentColor.R - red; double g = currentColor.G - green; @@ -110,7 +102,7 @@ public static class ColorExtensions /// The color to invert. /// The inverted color. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static Color Inverted(this Color color) { return Color.FromArgb(color.A, 255 - color.R, 255 - color.G, 255 - color.B); @@ -128,7 +120,7 @@ public static class ColorExtensions /// component is . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static Color WithA(this Color color, int a) { return Color.FromArgb(a, color.R, color.G, color.B); @@ -146,7 +138,7 @@ public static class ColorExtensions /// component is . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static Color WithB(this Color color, int b) { return Color.FromArgb(color.A, color.R, color.G, b); @@ -164,7 +156,7 @@ public static class ColorExtensions /// component is . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static Color WithG(this Color color, int g) { return Color.FromArgb(color.A, color.R, g, color.B); @@ -182,7 +174,7 @@ public static class ColorExtensions /// component is . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static Color WithR(this Color color, int r) { return Color.FromArgb(color.A, r, color.G, color.B); 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..9153c13 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; @@ -21,7 +21,7 @@ public static class PointExtensions /// . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static bool IsOnLine(this Point point, LineF line) { return ((PointF)point).IsOnLine(line); @@ -38,7 +38,7 @@ public static class PointExtensions /// ; otherwise . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static bool IsOnLine(this Point point, PointF start, PointF end) { return point.IsOnLine(new LineF(start, end)); @@ -55,7 +55,7 @@ public static class PointExtensions /// ; otherwise . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static bool IsOnLine(this Point point, Vector2 start, Vector2 end) { return point.IsOnLine(new LineF(start, end)); @@ -67,7 +67,7 @@ public static class PointExtensions /// The point to convert. /// The resulting . [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static Size ToSize(this Point point) { return new Size(point.X, point.Y); diff --git a/X10D/src/Drawing/PointFExtensions.cs b/X10D/src/Drawing/PointFExtensions.cs index 0b82643..bfa0edf 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; @@ -22,7 +22,7 @@ public static class PointFExtensions /// . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static bool IsOnLine(this PointF point, LineF line) { (float x1, float x2) = (line.Start.X, line.End.X); @@ -42,7 +42,7 @@ public static class PointFExtensions /// ; otherwise . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static bool IsOnLine(this PointF point, PointF start, PointF end) { return point.IsOnLine(new LineF(start, end)); @@ -59,7 +59,7 @@ public static class PointFExtensions /// ; otherwise . /// [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static bool IsOnLine(this PointF point, Vector2 start, Vector2 end) { return point.IsOnLine(new LineF(start, end)); @@ -71,7 +71,7 @@ public static class PointFExtensions /// The point whose components to round. /// The rounded point. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static PointF Round(this PointF point) { return point.Round(1.0f); @@ -84,7 +84,7 @@ public static class PointFExtensions /// The nearest multiple to which the components should be rounded. /// The rounded point. [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static PointF Round(this PointF point, float nearest) { float x = point.X.Round(nearest); @@ -98,7 +98,7 @@ public static class PointFExtensions /// The point to convert. /// The resulting . [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static SizeF ToSizeF(this PointF point) { return new SizeF(point.X, point.Y); 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..dcf3058 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; @@ -17,7 +17,7 @@ public static class SizeExtensions /// The size to convert. /// The resulting . [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static Point ToPoint(this Size size) { return new Point(size.Width, size.Height); @@ -29,7 +29,7 @@ public static class SizeExtensions /// The size to convert. /// The resulting . [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static PointF ToPointF(this Size size) { return new PointF(size.Width, size.Height); @@ -41,7 +41,7 @@ public static class SizeExtensions /// The size to convert. /// The resulting . [Pure] - [MethodImpl(CompilerResources.MethodImplOptions)] + [MethodImpl(CompilerResources.MaxOptimization)] public static Vector2 ToVector2(this Size size) { return new Vector2(size.Width, size.Height); 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..f5ba95d 100644 --- a/X10D/src/ExceptionMessages.Designer.cs +++ b/X10D/src/ExceptionMessages.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // @@ -150,7 +150,7 @@ namespace X10D { } /// - /// Looks up a localized string similar to The enum has a size that is not supported.. + /// Looks up a localized string similar to Enum has unexpected size of {0} bytes.. /// internal static string EnumSizeIsUnexpected { get { diff --git a/X10D/src/ExceptionMessages.resx b/X10D/src/ExceptionMessages.resx index 9bc8b28..5bb74e3 100644 --- a/X10D/src/ExceptionMessages.resx +++ b/X10D/src/ExceptionMessages.resx @@ -1,4 +1,4 @@ - +