diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..ac30c6f
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,2 @@
+github: SixLabors
+open_collective: sixlabors
\ No newline at end of file
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..1fd7ba6
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,11 @@
+### Prerequisites
+
+- [ ] I have written a descriptive pull-request title
+- [ ] I have verified that there are no overlapping [pull-requests](https://github.com/SixLabors/SharedInfrastructure/pulls) open
+- [ ] I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules :cop:.
+- [ ] I have provided test coverage for my change (where applicable)
+
+### Description
+
+
+
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
new file mode 100644
index 0000000..d4840a4
--- /dev/null
+++ b/.github/workflows/build-and-test.yml
@@ -0,0 +1,80 @@
+name: Build
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ branches:
+ - master
+jobs:
+ Build:
+ strategy:
+ matrix:
+ options:
+ - os: ubuntu-latest
+ framework: netcoreapp3.1
+ runtime: -x64
+ codecov: false
+ - os: windows-latest
+ framework: netcoreapp3.1
+ runtime: -x64
+ codecov: true
+ - os: windows-latest
+ framework: netcoreapp2.1
+ runtime: -x64
+ codecov: false
+ - os: windows-latest
+ framework: netcoreapp2.0
+ runtime: -x64
+ codecov: false
+ - os: windows-latest
+ framework: net472
+ runtime: -x64
+ codecov: false
+ - os: windows-latest
+ framework: net472
+ runtime: -x86
+ codecov: false
+ - os: windows-latest
+ framework: net46
+ runtime: -x64
+ codecov: false
+ - os: windows-latest
+ framework: net46
+ runtime: -x86
+ codecov: false
+
+ runs-on: ${{matrix.options.os}}
+ if: "!contains(github.event.head_commit.message, '[skip ci]')"
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Install NuGet
+ uses: NuGet/setup-nuget@v1
+
+ - name: Setup Git
+ shell: bash
+ run: |
+ git config --global core.autocrlf false
+ git config --global core.longpaths true
+ git fetch --prune --unshallow
+ git submodule -q update --init --recursive
+
+ - name: Build
+ shell: pwsh
+ run: ./ci-build.ps1 "${{matrix.options.framework}}"
+
+ - name: Test
+ shell: pwsh
+ run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}"
+ env:
+ CI: True
+ XUNIT_PATH: .\tests\SharedInfrastructure.Tests # Required for xunit
+
+ - name: Update Codecov
+ uses: codecov/codecov-action@v1
+ if: matrix.options.codecov == true && startsWith(github.repository, 'SixLabors')
+ with:
+ flags: unittests
diff --git a/README.md b/README.md
index aa28d1e..668788a 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,14 @@
SixLabors.SharedInfrastructure
+
+
+[](https://github.com/SixLabors/SharedInfrastructure/actions)
+[](https://codecov.io/gh/SixLabors/SharedInfrastructure)
+[](https://opensource.org/licenses/Apache-2.0)
+
+
+
This repository contains:
- Configuration and guidelines for automated linting of C# projects.
- Standardized internal C# utility classes to be reused across SixLabors projects (like `Guard`, `MathF`, and `HashCode`)
@@ -143,31 +151,63 @@ An up-to-date list of which StyleCop rules are implemented and which have code f
To include internals like `Guard.cs`, `MathF`, and `HashCode` into your project you should add configuration like the following to your `.csproj`:
``` xml
-
- $(DefineConstants);SUPPORTS_MATHF;SUPPORTS_HASHCODE;SUPPORTS_EXTENDED_INTRINSICS;SUPPORTS_SPAN_STREAM;SUPPORTS_ENCODING_STRING;SUPPORTS_RUNTIME_INTRINSICS;SUPPORTS_CODECOVERAGE;SUPPORTS_HOTPATH
-
-
-
- $(DefineConstants);SUPPORTS_MATHF;SUPPORTS_HASHCODE;SUPPORTS_EXTENDED_INTRINSICS;SUPPORTS_SPAN_STREAM;SUPPORTS_ENCODING_STRING;SUPPORTS_CODECOVERAGE
-
-
-
- $(DefineConstants);SUPPORTS_MATHF;SUPPORTS_CODECOVERAGE
-
-
-
- $(DefineConstants);SUPPORTS_MATHF;SUPPORTS_HASHCODE;SUPPORTS_SPAN_STREAM;SUPPORTS_ENCODING_STRING;SUPPORTS_CODECOVERAGE
-
-
-
- $(DefineConstants);SUPPORTS_CODECOVERAGE
-
-
-
- $(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS;SUPPORTS_CODECOVERAGE
-
+
+
+
+ $(DefineConstants);SUPPORTS_MATHF
+ $(DefineConstants);SUPPORTS_HASHCODE
+ $(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS
+ $(DefineConstants);SUPPORTS_SPAN_STREAM
+ $(DefineConstants);SUPPORTS_ENCODING_STRING
+ $(DefineConstants);SUPPORTS_RUNTIME_INTRINSICS
+ $(DefineConstants);SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_HOTPATH
+ $(DefineConstants);SUPPORTS_CREATESPAN
+
+
+ $(DefineConstants);SUPPORTS_MATHF
+ $(DefineConstants);SUPPORTS_HASHCODE
+ $(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS
+ $(DefineConstants);SUPPORTS_SPAN_STREAM
+ $(DefineConstants);SUPPORTS_ENCODING_STRING
+ $(DefineConstants);SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_CREATESPAN
+
+
+ $(DefineConstants);SUPPORTS_MATHF
+ $(DefineConstants);SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_CREATESPAN
+
+
+ $(DefineConstants);SUPPORTS_MATHF
+ $(DefineConstants);SUPPORTS_HASHCODE
+ $(DefineConstants);SUPPORTS_SPAN_STREAM
+ $(DefineConstants);SUPPORTS_ENCODING_STRING
+ $(DefineConstants);SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_CREATESPAN
+
+
+ $(DefineConstants);SUPPORTS_CODECOVERAGE
+
+
+ $(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS
+ $(DefineConstants);SUPPORTS_CODECOVERAGE
+
```
And add the `SharedInfrastructure.shproj` as a project dependency.
-*Note:* This might change as soon as we include shared msbuild infrastructure elements (`.props` and `.targets`)
\ No newline at end of file
+*Note:* This might change as soon as we include shared msbuild infrastructure elements (`.props` and `.targets`)
diff --git a/SharedInfrastructure.sln b/SharedInfrastructure.sln
index 3e10df0..4b4cb33 100644
--- a/SharedInfrastructure.sln
+++ b/SharedInfrastructure.sln
@@ -7,11 +7,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharedInfrastructure.Tests"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SharedInfrastructure", "src\SharedInfrastructure\SharedInfrastructure.shproj", "{68A8CC40-6AED-4E96-B524-31B1158FDEEA}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{27502888-A75B-4BCB-8D19-C81198AEF7C7}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_root", "_root", "{27502888-A75B-4BCB-8D19-C81198AEF7C7}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
+ ci-build.ps1 = ci-build.ps1
+ ci-test.ps1 = ci-test.ps1
+ codecov.yml = codecov.yml
LICENSE = LICENSE
README.md = README.md
SixLabors.ruleset = SixLabors.ruleset
@@ -20,6 +23,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
stylecop.json = stylecop.json
EndProjectSection
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{91A98DCB-FA23-444B-865A-3734578F1C28}"
+ ProjectSection(SolutionItems) = preProject
+ .github\FUNDING.yml = .github\FUNDING.yml
+ .github\PULL_REQUEST_TEMPLATE.md = .github\PULL_REQUEST_TEMPLATE.md
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{B3C84CC9-D0F5-4D9F-93A8-D742A73F3674}"
+ ProjectSection(SolutionItems) = preProject
+ .github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{07706BC0-CA04-4558-A005-3F9FA7D9933C}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{478B60EE-3651-4B39-83BD-528C428AC628}"
+ ProjectSection(SolutionItems) = preProject
+ tests\coverlet.runsettings = tests\coverlet.runsettings
+ EndProjectSection
+EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\SharedInfrastructure\SharedInfrastructure.projitems*{1664b46a-d99f-4c66-9424-a3a17c926a4c}*SharedItemsImports = 5
@@ -38,6 +59,12 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {1664B46A-D99F-4C66-9424-A3A17C926A4C} = {478B60EE-3651-4B39-83BD-528C428AC628}
+ {68A8CC40-6AED-4E96-B524-31B1158FDEEA} = {07706BC0-CA04-4558-A005-3F9FA7D9933C}
+ {91A98DCB-FA23-444B-865A-3734578F1C28} = {27502888-A75B-4BCB-8D19-C81198AEF7C7}
+ {B3C84CC9-D0F5-4D9F-93A8-D742A73F3674} = {91A98DCB-FA23-444B-865A-3734578F1C28}
+ EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CDD6BE8E-01A1-4A70-AA7E-F1D64E8FA829}
EndGlobalSection
diff --git a/ci-build.ps1 b/ci-build.ps1
new file mode 100644
index 0000000..d45af6f
--- /dev/null
+++ b/ci-build.ps1
@@ -0,0 +1,11 @@
+param(
+ [Parameter(Mandatory = $true, Position = 0)]
+ [string]$targetFramework
+)
+
+dotnet clean -c Release
+
+$repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY"
+
+# Building for a specific framework.
+dotnet build -c Release -f $targetFramework /p:RepositoryUrl=$repositoryUrl
diff --git a/ci-test.ps1 b/ci-test.ps1
new file mode 100644
index 0000000..3915ae4
--- /dev/null
+++ b/ci-test.ps1
@@ -0,0 +1,37 @@
+param(
+ [Parameter(Mandatory, Position = 0)]
+ [string]$os,
+ [Parameter(Mandatory, Position = 1)]
+ [string]$targetFramework,
+ [Parameter(Mandatory, Position = 2)]
+ [string]$platform,
+ [Parameter(Mandatory, Position = 3)]
+ [string]$codecov,
+ [Parameter(Position = 4)]
+ [string]$codecovProfile = 'Release'
+)
+
+$netFxRegex = '^net\d+'
+
+if ($codecov -eq 'true') {
+
+ # Allow toggling of profile to workaround any potential JIT errors caused by code injection.
+ dotnet clean -c $codecovProfile
+ dotnet test --collect "XPlat Code Coverage" --settings .\tests\coverlet.runsettings -c $codecovProfile -f $targetFramework /p:CodeCov=true
+}
+elseif ($platform -eq '-x86' -and $targetFramework -match $netFxRegex) {
+
+ # xunit doesn't run on core with NET SDK 3.1+.
+ # xunit doesn't actually understand -x64 as an option.
+ #
+ # xunit requires explicit path.
+ Set-Location $env:XUNIT_PATH
+
+ dotnet xunit --no-build -c Release -f $targetFramework ${fxVersion} $platform
+
+ Set-Location $PSScriptRoot
+}
+else {
+
+ dotnet test --no-build -c Release -f $targetFramework
+}
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 0000000..833fc0a
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,11 @@
+# Documentation: https://docs.codecov.io/docs/codecov-yaml
+
+codecov:
+ # Avoid "Missing base report"
+ # https://github.com/codecov/support/issues/363
+ # https://docs.codecov.io/docs/comparing-commits
+ allow_coverage_offsets: true
+
+ # Avoid Report Expired
+ # https://docs.codecov.io/docs/codecov-yaml#section-expired-reports
+ max_report_age: off
diff --git a/src/SharedInfrastructure/DebugGuard.cs b/src/SharedInfrastructure/DebugGuard.cs
index 4dcd67c..cef8992 100644
--- a/src/SharedInfrastructure/DebugGuard.cs
+++ b/src/SharedInfrastructure/DebugGuard.cs
@@ -3,7 +3,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace SixLabors
@@ -12,9 +11,6 @@ namespace SixLabors
/// Provides methods to protect against invalid parameters for a DEBUG build.
///
[DebuggerStepThrough]
-#pragma warning disable CS0436 // Type conflicts with imported type
- [ExcludeFromCodeCoverage]
-#pragma warning restore CS0436 // Type conflicts with imported type
internal static partial class DebugGuard
{
///
diff --git a/src/SharedInfrastructure/Guard.Numeric.cs b/src/SharedInfrastructure/Guard.Numeric.cs
index 1b49773..ab08250 100644
--- a/src/SharedInfrastructure/Guard.Numeric.cs
+++ b/src/SharedInfrastructure/Guard.Numeric.cs
@@ -23,10 +23,12 @@ internal static partial class Guard
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(byte value, byte max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -42,10 +44,12 @@ public static void MustBeLessThan(byte value, byte max, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(byte value, byte max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -61,10 +65,12 @@ public static void MustBeLessThanOrEqualTo(byte value, byte max, string paramete
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(byte value, byte min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -80,10 +86,12 @@ public static void MustBeGreaterThan(byte value, byte min, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(byte value, byte min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -100,10 +108,12 @@ public static void MustBeGreaterThanOrEqualTo(byte value, byte min, string param
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(byte value, byte min, byte max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -118,10 +128,12 @@ public static void MustBeBetweenOrEqualTo(byte value, byte min, byte max, string
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(sbyte value, sbyte max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -137,10 +149,12 @@ public static void MustBeLessThan(sbyte value, sbyte max, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(sbyte value, sbyte max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -156,10 +170,12 @@ public static void MustBeLessThanOrEqualTo(sbyte value, sbyte max, string parame
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(sbyte value, sbyte min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -175,10 +191,12 @@ public static void MustBeGreaterThan(sbyte value, sbyte min, string parameterNam
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(sbyte value, sbyte min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -195,10 +213,12 @@ public static void MustBeGreaterThanOrEqualTo(sbyte value, sbyte min, string par
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(sbyte value, sbyte min, sbyte max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -213,10 +233,12 @@ public static void MustBeBetweenOrEqualTo(sbyte value, sbyte min, sbyte max, str
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(short value, short max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -232,10 +254,12 @@ public static void MustBeLessThan(short value, short max, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(short value, short max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -251,10 +275,12 @@ public static void MustBeLessThanOrEqualTo(short value, short max, string parame
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(short value, short min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -270,10 +296,12 @@ public static void MustBeGreaterThan(short value, short min, string parameterNam
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(short value, short min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -290,10 +318,12 @@ public static void MustBeGreaterThanOrEqualTo(short value, short min, string par
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(short value, short min, short max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -308,10 +338,12 @@ public static void MustBeBetweenOrEqualTo(short value, short min, short max, str
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(ushort value, ushort max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -327,10 +359,12 @@ public static void MustBeLessThan(ushort value, ushort max, string parameterName
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(ushort value, ushort max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -346,10 +380,12 @@ public static void MustBeLessThanOrEqualTo(ushort value, ushort max, string para
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(ushort value, ushort min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -365,10 +401,12 @@ public static void MustBeGreaterThan(ushort value, ushort min, string parameterN
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(ushort value, ushort min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -385,10 +423,12 @@ public static void MustBeGreaterThanOrEqualTo(ushort value, ushort min, string p
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(ushort value, ushort min, ushort max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -403,10 +443,12 @@ public static void MustBeBetweenOrEqualTo(ushort value, ushort min, ushort max,
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(char value, char max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -422,10 +464,12 @@ public static void MustBeLessThan(char value, char max, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(char value, char max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -441,10 +485,12 @@ public static void MustBeLessThanOrEqualTo(char value, char max, string paramete
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(char value, char min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -460,10 +506,12 @@ public static void MustBeGreaterThan(char value, char min, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(char value, char min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -480,10 +528,12 @@ public static void MustBeGreaterThanOrEqualTo(char value, char min, string param
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(char value, char min, char max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -498,10 +548,12 @@ public static void MustBeBetweenOrEqualTo(char value, char min, char max, string
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(int value, int max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -517,10 +569,12 @@ public static void MustBeLessThan(int value, int max, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(int value, int max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -536,10 +590,12 @@ public static void MustBeLessThanOrEqualTo(int value, int max, string parameterN
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(int value, int min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -555,10 +611,12 @@ public static void MustBeGreaterThan(int value, int min, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(int value, int min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -575,10 +633,12 @@ public static void MustBeGreaterThanOrEqualTo(int value, int min, string paramet
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(int value, int min, int max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -593,10 +653,12 @@ public static void MustBeBetweenOrEqualTo(int value, int min, int max, string pa
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(uint value, uint max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -612,10 +674,12 @@ public static void MustBeLessThan(uint value, uint max, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(uint value, uint max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -631,10 +695,12 @@ public static void MustBeLessThanOrEqualTo(uint value, uint max, string paramete
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(uint value, uint min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -650,10 +716,12 @@ public static void MustBeGreaterThan(uint value, uint min, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(uint value, uint min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -670,10 +738,12 @@ public static void MustBeGreaterThanOrEqualTo(uint value, uint min, string param
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(uint value, uint min, uint max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -688,10 +758,12 @@ public static void MustBeBetweenOrEqualTo(uint value, uint min, uint max, string
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(float value, float max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -707,10 +779,12 @@ public static void MustBeLessThan(float value, float max, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(float value, float max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -726,10 +800,12 @@ public static void MustBeLessThanOrEqualTo(float value, float max, string parame
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(float value, float min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -745,10 +821,12 @@ public static void MustBeGreaterThan(float value, float min, string parameterNam
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(float value, float min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -765,10 +843,12 @@ public static void MustBeGreaterThanOrEqualTo(float value, float min, string par
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(float value, float min, float max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -783,10 +863,12 @@ public static void MustBeBetweenOrEqualTo(float value, float min, float max, str
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(long value, long max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -802,10 +884,12 @@ public static void MustBeLessThan(long value, long max, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(long value, long max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -821,10 +905,12 @@ public static void MustBeLessThanOrEqualTo(long value, long max, string paramete
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(long value, long min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -840,10 +926,12 @@ public static void MustBeGreaterThan(long value, long min, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(long value, long min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -860,10 +948,12 @@ public static void MustBeGreaterThanOrEqualTo(long value, long min, string param
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(long value, long min, long max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -878,10 +968,12 @@ public static void MustBeBetweenOrEqualTo(long value, long min, long max, string
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(ulong value, ulong max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -897,10 +989,12 @@ public static void MustBeLessThan(ulong value, ulong max, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(ulong value, ulong max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -916,10 +1010,12 @@ public static void MustBeLessThanOrEqualTo(ulong value, ulong max, string parame
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(ulong value, ulong min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -935,10 +1031,12 @@ public static void MustBeGreaterThan(ulong value, ulong min, string parameterNam
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(ulong value, ulong min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -955,10 +1053,12 @@ public static void MustBeGreaterThanOrEqualTo(ulong value, ulong min, string par
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(ulong value, ulong min, ulong max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -973,10 +1073,12 @@ public static void MustBeBetweenOrEqualTo(ulong value, ulong min, ulong max, str
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(double value, double max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -992,10 +1094,12 @@ public static void MustBeLessThan(double value, double max, string parameterName
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(double value, double max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -1011,10 +1115,12 @@ public static void MustBeLessThanOrEqualTo(double value, double max, string para
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(double value, double min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -1030,10 +1136,12 @@ public static void MustBeGreaterThan(double value, double min, string parameterN
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(double value, double min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -1050,10 +1158,12 @@ public static void MustBeGreaterThanOrEqualTo(double value, double min, string p
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(double value, double min, double max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -1068,10 +1178,12 @@ public static void MustBeBetweenOrEqualTo(double value, double min, double max,
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(decimal value, decimal max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -1087,10 +1199,12 @@ public static void MustBeLessThan(decimal value, decimal max, string parameterNa
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(decimal value, decimal max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -1106,10 +1220,12 @@ public static void MustBeLessThanOrEqualTo(decimal value, decimal max, string pa
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(decimal value, decimal min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -1125,10 +1241,12 @@ public static void MustBeGreaterThan(decimal value, decimal min, string paramete
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(decimal value, decimal min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -1145,10 +1263,12 @@ public static void MustBeGreaterThanOrEqualTo(decimal value, decimal min, string
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(decimal value, decimal min, decimal max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
}
}
diff --git a/src/SharedInfrastructure/Guard.Numeric.tt.bak b/src/SharedInfrastructure/Guard.Numeric.tt.bak
index 3882633..34d8f5e 100644
--- a/src/SharedInfrastructure/Guard.Numeric.tt.bak
+++ b/src/SharedInfrastructure/Guard.Numeric.tt.bak
@@ -35,10 +35,12 @@ for (var i = 0; i < types.Length; i++)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThan(<#=T#> value, <#=T#> max, string parameterName)
{
- if (value >= max)
+ if (value < max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -54,10 +56,12 @@ for (var i = 0; i < types.Length; i++)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeLessThanOrEqualTo(<#=T#> value, <#=T#> max, string parameterName)
{
- if (value > max)
+ if (value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -73,10 +77,12 @@ for (var i = 0; i < types.Length; i++)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThan(<#=T#> value, <#=T#> min, string parameterName)
{
- if (value <= min)
+ if (value > min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -92,10 +98,12 @@ for (var i = 0; i < types.Length; i++)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeGreaterThanOrEqualTo(<#=T#> value, <#=T#> min, string parameterName)
{
- if (value < min)
+ if (value >= min)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -112,10 +120,12 @@ for (var i = 0; i < types.Length; i++)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeBetweenOrEqualTo(<#=T#> value, <#=T#> min, <#=T#> max, string parameterName)
{
- if (value < min || value > max)
+ if (value >= min && value <= max)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
<#
}
diff --git a/src/SharedInfrastructure/Guard.cs b/src/SharedInfrastructure/Guard.cs
index 409647d..2574384 100644
--- a/src/SharedInfrastructure/Guard.cs
+++ b/src/SharedInfrastructure/Guard.cs
@@ -3,7 +3,6 @@
using System;
using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace SixLabors
@@ -12,9 +11,6 @@ namespace SixLabors
/// Provides methods to protect against invalid parameters.
///
[DebuggerStepThrough]
-#pragma warning disable CS0436 // Type conflicts with imported type
- [ExcludeFromCodeCoverage]
-#pragma warning restore CS0436 // Type conflicts with imported type
internal static partial class Guard
{
///
@@ -28,10 +24,12 @@ internal static partial class Guard
public static void NotNull(TValue value, string parameterName)
where TValue : class
{
- if (value is null)
+ if (!(value is null))
{
- ThrowHelper.ThrowArgumentNullExceptionForNotNull(parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentNullExceptionForNotNull(parameterName);
}
///
@@ -44,10 +42,12 @@ public static void NotNull(TValue value, string parameterName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void NotNullOrWhiteSpace(string value, string parameterName)
{
- if (string.IsNullOrWhiteSpace(value))
+ if (!string.IsNullOrWhiteSpace(value))
{
- ThrowHelper.ThrowArgumentExceptionForNotNullOrWhitespace(value, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentExceptionForNotNullOrWhitespace(value, parameterName);
}
///
@@ -64,10 +64,12 @@ public static void NotNullOrWhiteSpace(string value, string parameterName)
public static void MustBeLessThan(TValue value, TValue max, string parameterName)
where TValue : IComparable
{
- if (value.CompareTo(max) >= 0)
+ if (value.CompareTo(max) < 0)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThan(value, max, parameterName);
}
///
@@ -85,10 +87,12 @@ public static void MustBeLessThan(TValue value, TValue max, string param
public static void MustBeLessThanOrEqualTo(TValue value, TValue max, string parameterName)
where TValue : IComparable
{
- if (value.CompareTo(max) > 0)
+ if (value.CompareTo(max) <= 0)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeLessThanOrEqualTo(value, max, parameterName);
}
///
@@ -106,10 +110,12 @@ public static void MustBeLessThanOrEqualTo(TValue value, TValue max, str
public static void MustBeGreaterThan(TValue value, TValue min, string parameterName)
where TValue : IComparable
{
- if (value.CompareTo(min) <= 0)
+ if (value.CompareTo(min) > 0)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThan(value, min, parameterName);
}
///
@@ -127,10 +133,12 @@ public static void MustBeGreaterThan(TValue value, TValue min, string pa
public static void MustBeGreaterThanOrEqualTo(TValue value, TValue min, string parameterName)
where TValue : IComparable
{
- if (value.CompareTo(min) < 0)
+ if (value.CompareTo(min) >= 0)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeGreaterThanOrEqualTo(value, min, parameterName);
}
///
@@ -149,10 +157,12 @@ public static void MustBeGreaterThanOrEqualTo(TValue value, TValue min,
public static void MustBeBetweenOrEqualTo(TValue value, TValue min, TValue max, string parameterName)
where TValue : IComparable
{
- if (value.CompareTo(min) < 0 || value.CompareTo(max) > 0)
+ if (value.CompareTo(min) >= 0 && value.CompareTo(max) <= 0)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeBetweenOrEqualTo(value, min, max, parameterName);
}
///
@@ -168,10 +178,12 @@ public static void MustBeBetweenOrEqualTo(TValue value, TValue min, TVal
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsTrue(bool target, string parameterName, string message)
{
- if (!target)
+ if (target)
{
- ThrowHelper.ThrowArgumentException(message, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentException(message, parameterName);
}
///
@@ -187,10 +199,12 @@ public static void IsTrue(bool target, string parameterName, string message)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsFalse(bool target, string parameterName, string message)
{
- if (target)
+ if (!target)
{
- ThrowHelper.ThrowArgumentException(message, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentException(message, parameterName);
}
///
@@ -206,10 +220,12 @@ public static void IsFalse(bool target, string parameterName, string message)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeSizedAtLeast(ReadOnlySpan source, int minLength, string parameterName)
{
- if (source.Length < minLength)
+ if (source.Length >= minLength)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeSizedAtLeast(minLength, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeSizedAtLeast(minLength, parameterName);
}
///
@@ -225,10 +241,12 @@ public static void MustBeSizedAtLeast(ReadOnlySpan source, int minLength,
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MustBeSizedAtLeast(Span source, int minLength, string parameterName)
{
- if (source.Length < minLength)
+ if (source.Length >= minLength)
{
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeSizedAtLeast(minLength, parameterName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForMustBeSizedAtLeast(minLength, parameterName);
}
///
@@ -245,10 +263,12 @@ public static void DestinationShouldNotBeTooShort(
Span destination,
string destinationParamName)
{
- if (destination.Length < source.Length)
+ if (destination.Length >= source.Length)
{
- ThrowHelper.ThrowArgumentException("Destination span is too short!", destinationParamName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentException("Destination span is too short!", destinationParamName);
}
///
@@ -265,10 +285,12 @@ public static void DestinationShouldNotBeTooShort(
Span destination,
string destinationParamName)
{
- if (destination.Length < source.Length)
+ if (destination.Length >= source.Length)
{
- ThrowHelper.ThrowArgumentException("Destination span is too short!", destinationParamName);
+ return;
}
+
+ ThrowHelper.ThrowArgumentException("Destination span is too short!", destinationParamName);
}
}
}
diff --git a/src/SharedInfrastructure/MathF.cs b/src/SharedInfrastructure/MathF.cs
index d6ec0ac..cd919e8 100644
--- a/src/SharedInfrastructure/MathF.cs
+++ b/src/SharedInfrastructure/MathF.cs
@@ -14,9 +14,6 @@ namespace System
/// Provides single-precision floating point constants and static methods for trigonometric, logarithmic, and other common mathematical functions.
///
/// MathF emulation on platforms that don't support it natively.
-#pragma warning disable CS0436 // Type conflicts with imported type
- [ExcludeFromCodeCoverage]
-#pragma warning restore CS0436 // Type conflicts with imported type
internal static class MathF
{
///
diff --git a/src/SharedInfrastructure/ThrowHelper.cs b/src/SharedInfrastructure/ThrowHelper.cs
index 056384d..344ee31 100644
--- a/src/SharedInfrastructure/ThrowHelper.cs
+++ b/src/SharedInfrastructure/ThrowHelper.cs
@@ -9,7 +9,7 @@ namespace SixLabors
///
/// Helper methods to throw exceptions
///
- internal static class ThrowHelper
+ internal static partial class ThrowHelper
{
///
/// Throws an when fails.
diff --git a/tests/SharedInfrastructure.Tests/DebugGuardTests.cs b/tests/SharedInfrastructure.Tests/DebugGuardTests.cs
index 2985d66..bff48c5 100644
--- a/tests/SharedInfrastructure.Tests/DebugGuardTests.cs
+++ b/tests/SharedInfrastructure.Tests/DebugGuardTests.cs
@@ -9,9 +9,10 @@
using System.Diagnostics;
using System.Linq;
using System.Reflection;
+using SixLabors;
using Xunit;
-namespace SixLabors
+namespace SharedInfrastructure.Tests
{
public class DebugGuardTests
{
diff --git a/tests/SharedInfrastructure.Tests/GuardTests.cs b/tests/SharedInfrastructure.Tests/GuardTests.cs
index 92c630c..0bc89db 100644
--- a/tests/SharedInfrastructure.Tests/GuardTests.cs
+++ b/tests/SharedInfrastructure.Tests/GuardTests.cs
@@ -2,9 +2,10 @@
// Licensed under the Apache License, Version 2.0.
using System;
+using SixLabors;
using Xunit;
-namespace SixLabors
+namespace SharedInfrastructure.Tests
{
public class GuardTests
{
diff --git a/tests/SharedInfrastructure.Tests/MathFTests.cs b/tests/SharedInfrastructure.Tests/MathFTests.cs
index 20048ed..3a729c2 100644
--- a/tests/SharedInfrastructure.Tests/MathFTests.cs
+++ b/tests/SharedInfrastructure.Tests/MathFTests.cs
@@ -4,7 +4,7 @@
using System;
using Xunit;
-namespace SixLabors
+namespace SharedInfrastructure.Tests
{
public class MathFTests
{
diff --git a/tests/SharedInfrastructure.Tests/SharedInfrastructure.Tests.csproj b/tests/SharedInfrastructure.Tests/SharedInfrastructure.Tests.csproj
index 8e35b89..02a41e2 100644
--- a/tests/SharedInfrastructure.Tests/SharedInfrastructure.Tests.csproj
+++ b/tests/SharedInfrastructure.Tests/SharedInfrastructure.Tests.csproj
@@ -2,60 +2,94 @@
netcoreapp3.1;netcoreapp2.1;netcoreapp2.0;net472;net46
- SixLabors
- SixLabors
+ SharedInfrastructure.Tests
+ SharedInfrastructure.Tests
false
..\..\SixLabors.Tests.ruleset
- $(DefineConstants);SUPPORTS_MATHF;SUPPORTS_HASHCODE;SUPPORTS_EXTENDED_INTRINSICS;SUPPORTS_SPAN_STREAM;SUPPORTS_ENCODING_STRING;SUPPORTS_RUNTIME_INTRINSICS;SUPPORTS_CODECOVERAGE;SUPPORTS_HOTPATH
+ $(DefineConstants);SUPPORTS_MATHF
+ $(DefineConstants);SUPPORTS_HASHCODE
+ $(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS
+ $(DefineConstants);SUPPORTS_SPAN_STREAM
+ $(DefineConstants);SUPPORTS_ENCODING_STRING
+ $(DefineConstants);SUPPORTS_RUNTIME_INTRINSICS
+ $(DefineConstants);SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_HOTPATH
+ $(DefineConstants);SUPPORTS_CREATESPAN
- $(DefineConstants);SUPPORTS_MATHF;SUPPORTS_HASHCODE;SUPPORTS_EXTENDED_INTRINSICS;SUPPORTS_SPAN_STREAM;SUPPORTS_ENCODING_STRING;SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_MATHF
+ $(DefineConstants);SUPPORTS_HASHCODE
+ $(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS
+ $(DefineConstants);SUPPORTS_SPAN_STREAM
+ $(DefineConstants);SUPPORTS_ENCODING_STRING
+ $(DefineConstants);SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_CREATESPAN
- $(DefineConstants);SUPPORTS_MATHF;SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_MATHF
+ $(DefineConstants);SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_CREATESPAN
- $(DefineConstants);SUPPORTS_MATHF;SUPPORTS_HASHCODE;SUPPORTS_SPAN_STREAM;SUPPORTS_ENCODING_STRING;SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_MATHF
+ $(DefineConstants);SUPPORTS_HASHCODE
+ $(DefineConstants);SUPPORTS_SPAN_STREAM
+ $(DefineConstants);SUPPORTS_ENCODING_STRING
+ $(DefineConstants);SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_CREATESPAN
$(DefineConstants);SUPPORTS_CODECOVERAGE
- $(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS;SUPPORTS_CODECOVERAGE
+ $(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS
+ $(DefineConstants);SUPPORTS_CODECOVERAGE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
+
diff --git a/tests/coverlet.runsettings b/tests/coverlet.runsettings
new file mode 100644
index 0000000..f99277e
--- /dev/null
+++ b/tests/coverlet.runsettings
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ lcov
+ **/tests/**/*.cs, **/**/*.Program.cs
+ true
+
+
+
+
+