Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void FloatWithDefaultTolerance(float first, float second, bool exp
public static void FloatWithCustomTolerance(float first, float second, float tolerance, bool expected) =>
first.IsApproximately(second, tolerance).Should().Be(expected);

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(1.1, 1.3, 0.5, true)]
[InlineData(100.55, 100.555, 0.00001, false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void FloatWithDefaultTolerance(float first, float second, bool exp
public static void FloatWIthCustomTolerance(float first, float second, float tolerance, bool expected) =>
first.IsGreaterThanOrApproximately(second, tolerance).Should().Be(expected);

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(15.91, 15.9, 0.1, true)]
[InlineData(24.449, 24.45, 0.0001, false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void FloatWithDefaultTolerance(float first, float second, bool exp
public static void FloatWithCustomTolerance(float first, float second, float tolerance, bool expected) =>
first.IsLessThanOrApproximately(second, tolerance).Should().Be(expected);

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(13.25, 13.5, 0.1, true)] // Less than case
[InlineData(13.5, 13.5, 0.1, true)] // Equal case
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using FluentAssertions;
using Xunit;

Expand Down Expand Up @@ -178,7 +178,7 @@ public static void CallerArgumentExpressionWithTolerance_Float()
.WithParameterName(nameof(pi));
}

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(5.1, 5.0, 0.2)]
[InlineData(10.3, 10.3, 0.01)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using FluentAssertions;
using Xunit;

Expand Down Expand Up @@ -202,7 +202,7 @@ public static void CallerArgumentExpressionWithTolerance_Float()
.WithParameterName(nameof(pi));
}

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(15.91, 15.9, 0.1)]
[InlineData(24.4999, 24.45, 0.0001)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using FluentAssertions;
using Xunit;

Expand Down Expand Up @@ -202,7 +202,7 @@ public static void CallerArgumentExpressionWithTolerance_Float()
.WithParameterName(nameof(threePointFive));
}

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(15.9, 15.91, 0.1)]
[InlineData(24.45, 24.4999, 0.0001)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using FluentAssertions;
using Xunit;

Expand Down Expand Up @@ -180,7 +180,7 @@ public static void CallerArgumentExpressionWithTolerance_Float()
.WithParameterName(nameof(pi));
}

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[InlineData(5.3, 5.0, 0.2)]
[InlineData(10.4, 10.3, 0.01)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void IsValidEmailAddress(string email)
isValid.Should().BeTrue();
}

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[ClassData(typeof(InvalidEmailAddressesWithNull))]
public void IsNotValidEmailAddress_ReadOnlySpan(string email)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Text.RegularExpressions;
using FluentAssertions;
using Light.GuardClauses.Exceptions;
Expand Down Expand Up @@ -124,7 +124,7 @@ public static void CallerArgumentExpression()
.WithParameterName(nameof(email));
}

#if NET8_0
#if NET8_0_OR_GREATER
[Theory]
[ClassData(typeof(ValidEmailAddresses))]
public static void ValidEmailAddress_ReadOnlySpan(string email)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !NET8_0
#if !NET8_0_OR_GREATER
// ReSharper disable once CheckNamespace -- CallerArgumentExpression must be in exactly this namespace
namespace System.Runtime.CompilerServices;

Expand Down
2 changes: 1 addition & 1 deletion Code/Light.GuardClauses/Check.DerivesFrom.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET8_0
#if NET8_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
using System;
Expand Down
6 changes: 3 additions & 3 deletions Code/Light.GuardClauses/Check.Implements.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET8_0
#if NET8_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
using System;
Expand All @@ -21,7 +21,7 @@ public static partial class Check
/// <exception cref="ArgumentNullException">Thrown when <paramref name="type" /> or <paramref name="interfaceType" /> is null.</exception>
[ContractAnnotation("type:null => halt; interfaceType:null => halt")]
public static bool Implements(
#if NET8_0
#if NET8_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#endif
[NotNull] [ValidatedNotNull] this Type type,
Expand Down Expand Up @@ -53,7 +53,7 @@ [NotNull] [ValidatedNotNull] Type interfaceType
/// <exception cref="ArgumentNullException">Thrown when <paramref name="type" />, or <paramref name="interfaceType" />, or <paramref name="typeComparer" /> is null.</exception>
[ContractAnnotation("type:null => halt; interfaceType:null => halt; typeComparer:null => halt")]
public static bool Implements(
#if NET8_0
#if NET8_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#endif
[NotNull] [ValidatedNotNull] this Type type,
Expand Down
6 changes: 3 additions & 3 deletions Code/Light.GuardClauses/Check.InheritsFrom.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET8_0
#if NET8_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
using System;
Expand All @@ -23,7 +23,7 @@ public static partial class Check
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ContractAnnotation("type:null => halt; baseClassOrInterfaceType:null => halt")]
public static bool InheritsFrom(
#if NET8_0
#if NET8_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#endif
[NotNull] [ValidatedNotNull] this Type type,
Expand All @@ -46,7 +46,7 @@ [NotNull] [ValidatedNotNull] Type baseClassOrInterfaceType
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ContractAnnotation("type:null => halt; baseClassOrInterfaceType:null => halt; typeComparer:null => halt")]
public static bool InheritsFrom(
#if NET8_0
#if NET8_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#endif
[NotNull] [ValidatedNotNull] this Type type,
Expand Down
6 changes: 3 additions & 3 deletions Code/Light.GuardClauses/Check.IsApproximately.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System;
using System.Runtime.CompilerServices;
#if NET8_0
#if NET8_0_OR_GREATER
using System.Numerics;
#endif

Expand Down Expand Up @@ -62,7 +62,7 @@ public static bool IsApproximately(this float value, float other, float toleranc
public static bool IsApproximately(this float value, float other) =>
Math.Abs(value - other) <= 0.0001f;

#if NET8_0
#if NET8_0_OR_GREATER
/// <summary>
/// Checks if the specified value is approximately the same as the other value, using the given tolerance.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Code/Light.GuardClauses/Check.IsEmailAddress.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -29,7 +29,7 @@ public static bool IsEmailAddress([NotNullWhen(true)] this string? emailAddress)
public static bool IsEmailAddress([NotNullWhen(true)] this string? emailAddress, Regex emailAddressPattern) =>
emailAddress != null && emailAddressPattern.MustNotBeNull(nameof(emailAddressPattern)).IsMatch(emailAddress);

#if NET8_0
#if NET8_0_OR_GREATER
/// <summary>
/// Checks if the specified span is an email address using the default email regular expression
/// defined in <see cref="RegularExpressions.EmailRegex" />.
Expand Down
6 changes: 3 additions & 3 deletions Code/Light.GuardClauses/Check.IsGreaterThanOrApproximately.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Runtime.CompilerServices;
#if NET8_0
using System.Runtime.CompilerServices;
#if NET8_0_OR_GREATER
using System.Numerics;
#endif

Expand Down Expand Up @@ -61,7 +61,7 @@ public static bool IsGreaterThanOrApproximately(this float value, float other, f
public static bool IsGreaterThanOrApproximately(this float value, float other) =>
value > other || value.IsApproximately(other);

#if NET8_0
#if NET8_0_OR_GREATER
/// <summary>
/// Checks if the specified value is greater than or approximately the same as the other value, using the given tolerance.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions Code/Light.GuardClauses/Check.IsLessThanOrApproximately.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Runtime.CompilerServices;
#if NET8_0
using System.Runtime.CompilerServices;
#if NET8_0_OR_GREATER
using System.Numerics;
#endif

Expand Down Expand Up @@ -61,7 +61,7 @@ public static bool IsLessThanOrApproximately(this float value, float other, floa
public static bool IsLessThanOrApproximately(this float value, float other) =>
value < other || value.IsApproximately(other);

#if NET8_0
#if NET8_0_OR_GREATER
/// <summary>
/// Checks if the specified value is less than or approximately the same as the other value, using the given tolerance.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET8_0
#if NET8_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
using System;
Expand Down
2 changes: 1 addition & 1 deletion Code/Light.GuardClauses/Check.IsOrDerivesFrom.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET8_0
#if NET8_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
using System;
Expand Down
6 changes: 3 additions & 3 deletions Code/Light.GuardClauses/Check.IsOrImplements.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET8_0
#if NET8_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
using System;
Expand All @@ -23,7 +23,7 @@ public static partial class Check
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ContractAnnotation("type:null => halt; otherType:null => halt")]
public static bool IsOrImplements(
#if NET8_0
#if NET8_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#endif
[NotNull] [ValidatedNotNull] this Type type,
Expand All @@ -43,7 +43,7 @@ [NotNull] [ValidatedNotNull] Type otherType
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ContractAnnotation("type:null => halt; otherType:null => halt")]
public static bool IsOrImplements(
#if NET8_0
#if NET8_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#endif
[NotNull] [ValidatedNotNull] this Type type,
Expand Down
6 changes: 3 additions & 3 deletions Code/Light.GuardClauses/Check.IsOrInheritsFrom.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET8_0
#if NET8_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
using System;
Expand All @@ -24,7 +24,7 @@ public static partial class Check
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ContractAnnotation("type:null => halt; otherType:null => halt")]
public static bool IsOrInheritsFrom(
#if NET8_0
#if NET8_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#endif
[NotNull] [ValidatedNotNull] this Type type,
Expand All @@ -44,7 +44,7 @@ [NotNull] [ValidatedNotNull] Type otherType
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ContractAnnotation("type:null => halt; otherType:null => halt; typeComparer:null => halt")]
public static bool IsOrInheritsFrom(
#if NET8_0
#if NET8_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)]
#endif
[NotNull] [ValidatedNotNull] this Type type,
Expand Down
6 changes: 3 additions & 3 deletions Code/Light.GuardClauses/Check.MustBeApproximately.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System;
using System.Runtime.CompilerServices;
using Light.GuardClauses.ExceptionFactory;
#if NET8_0
#if NET8_0_OR_GREATER
using System.Numerics;
#endif

Expand Down Expand Up @@ -232,7 +232,7 @@ Func<float, float, float, Exception> exceptionFactory
return parameter;
}

#if NET8_0
#if NET8_0_OR_GREATER
/// <summary>
/// Ensures that the specified <paramref name="parameter" /> is approximately equal to the given
/// <paramref name="other" /> value, or otherwise throws an <see cref="ArgumentOutOfRangeException" />.
Expand Down
4 changes: 2 additions & 2 deletions Code/Light.GuardClauses/Check.MustBeEmailAddress.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using JetBrains.Annotations;
Expand Down Expand Up @@ -109,7 +109,7 @@ public static string MustBeEmailAddress(
return parameter;
}

#if NET8_0
#if NET8_0_OR_GREATER
/// <summary>
/// Ensures that the span represents a valid email address using the default email regular expression
/// defined in <see cref="RegularExpressions.EmailRegex" />, or otherwise throws an <see cref="InvalidEmailAddressException" />.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System;
using System.Runtime.CompilerServices;
using Light.GuardClauses.ExceptionFactory;
#if NET8_0
#if NET8_0_OR_GREATER
using System.Numerics;
#endif

Expand Down Expand Up @@ -227,7 +227,7 @@ Func<float, float, float, Exception> exceptionFactory
return parameter;
}

#if NET8_0
#if NET8_0_OR_GREATER
/// <summary>
/// Ensures that the specified <paramref name="parameter" /> is greater than or approximately equal to the given
/// <paramref name="other" /> value, or otherwise throws an <see cref="ArgumentOutOfRangeException" />.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System;
using System.Runtime.CompilerServices;
using Light.GuardClauses.ExceptionFactory;
#if NET8_0
#if NET8_0_OR_GREATER
using System.Numerics;
#endif

Expand Down Expand Up @@ -227,7 +227,7 @@ Func<float, float, float, Exception> exceptionFactory
return parameter;
}

#if NET8_0
#if NET8_0_OR_GREATER
/// <summary>
/// Ensures that the specified <paramref name="parameter" /> is less than or approximately equal to the given
/// <paramref name="other" /> value, or otherwise throws an <see cref="ArgumentOutOfRangeException" />.
Expand Down
6 changes: 3 additions & 3 deletions Code/Light.GuardClauses/Check.MustNotBeApproximately.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System;
using System.Runtime.CompilerServices;
using Light.GuardClauses.ExceptionFactory;
#if NET8_0
#if NET8_0_OR_GREATER
using System.Numerics;
#endif

Expand Down Expand Up @@ -232,7 +232,7 @@ Func<float, float, float, Exception> exceptionFactory
return parameter;
}

#if NET8_0
#if NET8_0_OR_GREATER
/// <summary>
/// Ensures that the specified <paramref name="parameter" /> is not approximately equal to the given
/// <paramref name="other" /> value, or otherwise throws an <see cref="ArgumentOutOfRangeException" />.
Expand Down
2 changes: 1 addition & 1 deletion Code/Light.GuardClauses/EnumInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static class EnumInfo<T> where T : struct, Enum

static EnumInfo()
{
#if NET8_0
#if NET8_0_OR_GREATER
EnumConstantsArray = Enum.GetValues<T>();
#else
EnumConstantsArray = (T[]) Enum.GetValues(typeof(T));
Expand Down
Loading