Skip to content

Commit

Permalink
Added support for .NET 6 and .NET 7 (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgernand authored Nov 23, 2023
1 parent d0ef2a3 commit cb71663
Show file tree
Hide file tree
Showing 9 changed files with 345 additions and 22 deletions.
24 changes: 19 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ trigger:

variables:
BuildConfiguration: Release
DotNetCoreVersion: 8.0.x
DotNetCoreVersionPreviousPrevious: 6.x
DotNetCoreVersionPrevious: 7.x
DotNetCoreVersionLatest: 8.x

parameters:
- name: publishPackages
Expand All @@ -24,13 +26,25 @@ stages:
fetchDepth: 0
persistCredentials: 'true'
clean: true
# Install the desired .NET SDK.
# Install the desired .NET SDK.
- task: UseDotNet@2
displayName: 'Acquire .NET SDK'
displayName: 'Acquire .NET $(DotNetCoreVersionPreviousPrevious) SDK'
inputs:
packageType: 'sdk'
version: $(DotNetCoreVersion)
includePreviewVersions: false
version: $(DotNetCoreVersionPreviousPrevious)
includePreviewVersions: false
- task: UseDotNet@2
displayName: 'Acquire .NET $(DotNetCoreVersionPrevious) SDK'
inputs:
packageType: 'sdk'
version: $(DotNetCoreVersionPrevious)
includePreviewVersions: false
- task: UseDotNet@2
displayName: 'Acquire .NET $(DotNetCoreVersionLatest) SDK'
inputs:
packageType: 'sdk'
version: $(DotNetCoreVersionLatest)
includePreviewVersions: false
# Build all projects.
- task: DotNetCoreCLI@2
displayName: 'Build Projects'
Expand Down
12 changes: 11 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
</PropertyGroup>

<Target Name="Update Version" BeforeTargets="Build" Condition="'$(TF_BUILD)' == 'true'">
<Target Name="Update Version" BeforeTargets="Build" Condition="'$(TF_BUILD)' == 'true' and '$(TargetFramework)' == 'net6.0'">
<Message Text="Version = $(GITVERSION_FullSemVer)" Importance="High" />
<Message Text="##vso[build.updatebuildnumber]$(GITVERSION_FullSemVer)" Importance="High" />
</Target>

<Target Name="Update Version" BeforeTargets="Build" Condition="'$(TF_BUILD)' == 'true' and '$(TargetFramework)' == 'net7.0'">
<Message Text="Version = $(GITVERSION_FullSemVer)" Importance="High" />
<Message Text="##vso[build.updatebuildnumber]$(GITVERSION_FullSemVer)" Importance="High" />
</Target>

<Target Name="Update Version" BeforeTargets="Build" Condition="'$(TF_BUILD)' == 'true' and '$(TargetFramework)' == 'net8.0'">
<Message Text="Version = $(GITVERSION_FullSemVer)" Importance="High" />
<Message Text="##vso[build.updatebuildnumber]$(GITVERSION_FullSemVer)" Importance="High" />
</Target>
Expand Down
20 changes: 20 additions & 0 deletions src/Fluxera.Utilities/Extensions/Char/Repeat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Fluxera.Utilities.Extensions
[PublicAPI]
public static class CharExtensions
{
#if NET7_0_OR_GREATER
/// <summary>
/// Repeats the given <see cref="char" /> the specified number of times.
/// </summary>
Expand All @@ -26,5 +27,24 @@ public static string Repeat(this char input, int count)
count.Times(() => str = string.Concat(str, input));
return str;
}
#endif

#if NET6_0
/// <summary>
/// Repeats the given <see cref="char" /> the specified number of times.
/// </summary>
/// <param name="input">The char to repeat.</param>
/// <param name="count">The number of times to repeat the string.</param>
/// <returns>The repeated char string.</returns>
[Pure]
public static string Repeat(this char input, int count)
{
Guard.Against.Negative(count, nameof(count));

string str = string.Empty;
count.Times(() => str = string.Concat(str, input));
return str;
}
#endif
}
}
60 changes: 60 additions & 0 deletions src/Fluxera.Utilities/Extensions/Numeric/IsBetween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Fluxera.Utilities.Extensions
/// </summary>
public static partial class NumericExtensions
{
#if NET7_0_OR_GREATER
/// <summary>
/// Determines if the given value is between the specified values a and b (inclusive).
/// </summary>
Expand All @@ -22,5 +23,64 @@ public static bool IsBetween<T>(this T value, T a, T b) where T : notnull, INumb
? value >= a && value <= b
: value >= b && value <= a;
}
#endif

#if NET6_0
/// <summary>
/// Determines if the given value is between the specified values a and b (inclusive).
/// </summary>
/// <returns><c>true</c> if the given value is between the specified values a and b; otherwise, <c>false</c>.</returns>
/// <param name="value">Value.</param>
/// <param name="a">The alpha component.</param>
/// <param name="b">The blue component.</param>
public static bool IsBetween(this byte value, byte a, byte b)
{
return a < b
? value >= a && value <= b
: value >= b && value <= a;
}

/// <summary>
/// Determines if the given value is between the specified values a and b (inclusive).
/// </summary>
/// <returns><c>true</c> if the given value is between the specified values a and b; otherwise, <c>false</c>.</returns>
/// <param name="value">Value.</param>
/// <param name="a">The alpha component.</param>
/// <param name="b">The blue component.</param>
public static bool IsBetween(this short value, short a, short b)
{
return a < b
? value >= a && value <= b
: value >= b && value <= a;
}

/// <summary>
/// Determines if the given value is between the specified values a and b (inclusive).
/// </summary>
/// <returns><c>true</c> if the given value is between the specified values a and b; otherwise, <c>false</c>.</returns>
/// <param name="value">Value.</param>
/// <param name="a">The alpha component.</param>
/// <param name="b">The blue component.</param>
public static bool IsBetween(this int value, int a, int b)
{
return a < b
? value >= a && value <= b
: value >= b && value <= a;
}

/// <summary>
/// Determines if the given value is between the specified values a and b (inclusive).
/// </summary>
/// <returns><c>true</c> if the given value is between the specified values a and b; otherwise, <c>false</c>.</returns>
/// <param name="value">Value.</param>
/// <param name="a">The alpha component.</param>
/// <param name="b">The blue component.</param>
public static bool IsBetween(this long value, long a, long b)
{
return a < b
? value >= a && value <= b
: value >= b && value <= a;
}
#endif
}
}
44 changes: 44 additions & 0 deletions src/Fluxera.Utilities/Extensions/Numeric/IsEven.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Fluxera.Utilities.Extensions
/// </summary>
public static partial class NumericExtensions
{
#if NET7_0_OR_GREATER
/// <summary>
/// Determines whether the value is even.
/// </summary>
Expand All @@ -18,5 +19,48 @@ public static bool IsEven<T>(this T value) where T : INumber<T>
{
return T.IsEvenInteger(value);
}
#endif

#if NET6_0
/// <summary>
/// Determines whether the value is even.
/// </summary>
/// <param name="value">The value to check.</param>
/// <returns>True, if the value is even.</returns>
public static bool IsEven(this byte value)
{
return value % 2 == 0;
}

/// <summary>
/// Determines whether the value is even.
/// </summary>
/// <param name="value">The value to check.</param>
/// <returns>True, if the value is even.</returns>
public static bool IsEven(this short value)
{
return value % 2 == 0;
}

/// <summary>
/// Determines whether the value is even.
/// </summary>
/// <param name="value">The value to check.</param>
/// <returns>True, if the value is even.</returns>
public static bool IsEven(this int value)
{
return value % 2 == 0;
}

/// <summary>
/// Determines whether the value is even.
/// </summary>
/// <param name="value">The value to check.</param>
/// <returns>True, if the value is even.</returns>
public static bool IsEven(this long value)
{
return value % 2 == 0;
}
#endif
}
}
44 changes: 44 additions & 0 deletions src/Fluxera.Utilities/Extensions/Numeric/IsOdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Fluxera.Utilities.Extensions
/// </summary>
public static partial class NumericExtensions
{
#if NET7_0_OR_GREATER
/// <summary>
/// Determines whether the value is odd.
/// </summary>
Expand All @@ -18,5 +19,48 @@ public static bool IsOdd<T>(this T value) where T : notnull, INumber<T>
{
return !value.IsEven();
}
#endif

#if NET6_0
/// <summary>
/// Determines whether the value is odd.
/// </summary>
/// <param name="value">The value to check.</param>
/// <returns>True, if the value is odd.</returns>
public static bool IsOdd(this byte value)
{
return !value.IsEven();
}

/// <summary>
/// Determines whether the value is odd.
/// </summary>
/// <param name="value">The value to check.</param>
/// <returns>True, if the value is odd.</returns>
public static bool IsOdd(this short value)
{
return !value.IsEven();
}

/// <summary>
/// Determines whether the value is odd.
/// </summary>
/// <param name="value">The value to check.</param>
/// <returns>True, if the value is odd.</returns>
public static bool IsOdd(this int value)
{
return !value.IsEven();
}

/// <summary>
/// Determines whether the value is odd.
/// </summary>
/// <param name="value">The value to check.</param>
/// <returns>True, if the value is odd.</returns>
public static bool IsOdd(this long value)
{
return !value.IsEven();
}
#endif
}
}
Loading

0 comments on commit cb71663

Please sign in to comment.