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 @@
-### 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