Skip to content

Commit

Permalink
Support for net9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCiliaVincenti committed Oct 5, 2024
1 parent cd8543f commit d54b92b
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 42 deletions.
8 changes: 8 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<CheckNotRecommendedTargetFramework>false</CheckNotRecommendedTargetFramework>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>
</Project>
35 changes: 35 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="AsyncKeyedLock" Version="7.0.1" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.2.25" />
<PackageVersion Include="FluentAssertions" Version="6.12.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageVersion Include="UnitsNet" Version="5.59.0" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageVersion Include="System.Text.Json" Version="6.0.9" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>
</Project>
12 changes: 6 additions & 6 deletions OpenWeatherMap.Cache.Tests/OpenWeatherMap.Cache.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 6 additions & 0 deletions OpenWeatherMap.Cache.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenWeatherMap.Cache", "Ope
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenWeatherMap.Cache.Tests", "OpenWeatherMap.Cache.Tests\OpenWeatherMap.Cache.Tests.csproj", "{8890580B-BB36-497D-80DC-1F8594D58752}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{93A3FAAE-8CAB-46EE-8578-7B8FBDE80983}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
26 changes: 12 additions & 14 deletions OpenWeatherMap.Cache/Models/Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,21 @@ namespace OpenWeatherMap.Cache.Models
/// <summary>
/// Class for the location with latitude and longitude.
/// </summary>
public class Location : ILocationQuery, IEquatable<Location>
/// <remarks>
/// Initializes a new instance of <see cref="Location"/>.
/// </remarks>
/// <param name="latitude">The latitude of the location.</param>
/// <param name="longitude">The longitude of the location.</param>
public class Location(double latitude, double longitude) : ILocationQuery, IEquatable<Location>
{
/// <summary>
/// The latitude of the <see cref="Location"/>.
/// </summary>
public double Latitude { get; set; }
public double Latitude { get; set; } = latitude;
/// <summary>
/// The longitude of the <see cref="Location"/>.
/// </summary>
public double Longitude { get; set; }

/// <summary>
/// Initializes a new instance of <see cref="Location"/>.
/// </summary>
/// <param name="latitude">The latitude of the location.</param>
/// <param name="longitude">The longitude of the location.</param>
public Location(double latitude, double longitude)
{
Latitude = latitude;
Longitude = longitude;
}
public double Longitude { get; set; } = longitude;

/// <inheritdoc cref="IEquatable{T}.Equals(T)"/>
public bool Equals(Location other)
Expand All @@ -46,13 +40,17 @@ public override bool Equals(object obj)
/// <inheritdoc />
public override int GetHashCode()
{
#if NET5_0_OR_GREATER
return HashCode.Combine(Latitude, Longitude);
#else
unchecked
{
int hash = 17;
hash = hash * 23 + Latitude.GetHashCode();
hash = hash * 23 + Longitude.GetHashCode();
return hash;
}
#endif
}
}
}
32 changes: 10 additions & 22 deletions OpenWeatherMap.Cache/OpenWeatherMap.Cache.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0;net6.0</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<TargetFrameworks>netstandard2.0;net5.0;net6.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Authors>Mark Cilia Vincenti</Authors>
<RepositoryUrl>https://github.com/MarkCiliaVincenti/OpenWeatherMap.Cache.git</RepositoryUrl>
<PackageProjectUrl>https://github.com/MarkCiliaVincenti/OpenWeatherMap.Cache</PackageProjectUrl>
Expand Down Expand Up @@ -35,28 +35,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AsyncKeyedLock" Version="7.0.1" />
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.2.4" PrivateAssets="All" />
<PackageReference Include="UnitsNet" Version="5.56.0" />
<PackageReference Include="AsyncKeyedLock" />
<PackageReference Include="DotNet.ReproducibleBuilds" PrivateAssets="All" />
<PackageReference Include="UnitsNet" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.9" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.9" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net5.0'))">
<PackageReference Include="System.Threading.Tasks.Extensions" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit d54b92b

Please sign in to comment.