Skip to content

Commit

Permalink
feat: Support net9.0, update packages, and refactor code
Browse files Browse the repository at this point in the history
Updated Directory.build.props to support net9.0 alongside net8.0.
Introduced
conditional compilation in DateTimeHumanize.cs for
System.Threading and Lock
object usage in .NET 9.0 or greater.
Updated MyNet.Humanizer.UnitTests.csproj
with newer versions of
Microsoft.NET.Test.Sdk (17.12.0), xunit (2.9.2), and
xunit.runner.visualstudio (3.0.0).
Updated MyNet.Humanizer.csproj t
reference MyNet.Utilities
version 6.0.0, up from 5.0.0.

BREAKING CHANGE: Support net9.0
  • Loading branch information
Stéphane ANDRE (E104915) committed Dec 21, 2024
1 parent 75b5926 commit f731b8d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<!-- Configuration -->
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<BaseOutputPath>bin</BaseOutputPath>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
Expand Down
8 changes: 8 additions & 0 deletions src/MyNet.Humanizer.UnitTests/DateTimeHumanize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@
using MyNet.Humanizer.DateTimes;
using Xunit;

#if NET9_0_OR_GREATER
using System.Threading;
#endif

namespace MyNet.Humanizer.UnitTests
{
public static class DateTimeHumanize
{
#if NET9_0_OR_GREATER
private static readonly Lock LockObject = new();
#else
private static readonly object LockObject = new();
#endif

private static void VerifyWithCurrentDate(string expectedString, string expectedCultureName, TimeSpan deltaFromNow, CultureInfo? culture)
{
Expand Down
2 changes: 2 additions & 0 deletions src/MyNet.Humanizer.UnitTests/InflectorExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void SingularizeWordsWithUnknownSingularity(string singular, string plura

[Theory, UseCulture("fr-FR")]
[ClassData(typeof(FrenchPluralTestSource))]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S4144:Methods should not have identical implementations", Justification = "Culture changes")]
public void PluralizeWordsWithUnknownPluralityFrench(string singular, string plural)
{
Assert.Equal(plural, plural.Pluralize(false));
Expand All @@ -51,6 +52,7 @@ public void PluralizeWordsWithUnknownPluralityFrench(string singular, string plu

[Theory, UseCulture("fr-FR")]
[ClassData(typeof(FrenchPluralTestSource))]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S4144:Methods should not have identical implementations", Justification = "Culture changes")]
public void SingularizeWordsWithUnknownSingularityFrench(string singular, string plural)
{
Assert.Equal(singular, singular.Singularize(false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0-pre.30">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/MyNet.Humanizer/MyNet.Humanizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MyNet.Utilities" Version="5.0.0" />
<PackageReference Include="MyNet.Utilities" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/MyNet.Humanizer/TimeSpanHumanizeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static List<string> CreateTheTimePartsWithUpperAndLowerLimits(TimeSpan t

private static IEnumerable<TimeUnit> GetEnumTypesForTimeUnit()
{
var enumTypeEnumerator = (IEnumerable<TimeUnit>)Enum.GetValues(typeof(TimeUnit));
var enumTypeEnumerator = Enum.GetValues<TimeUnit>();
return enumTypeEnumerator.Reverse();
}

Expand Down

0 comments on commit f731b8d

Please sign in to comment.