From d54b92b04fd70cb77f392fddd80fbd7ca0422d5a Mon Sep 17 00:00:00 2001 From: Mark Cilia Vincenti Date: Sat, 5 Oct 2024 18:34:24 +0200 Subject: [PATCH] Support for net9.0 --- Directory.Build.props | 8 +++++ Directory.Packages.props | 35 +++++++++++++++++++ .../OpenWeatherMap.Cache.Tests.csproj | 12 +++---- OpenWeatherMap.Cache.sln | 6 ++++ OpenWeatherMap.Cache/Models/Location.cs | 26 +++++++------- .../OpenWeatherMap.Cache.csproj | 32 ++++++----------- 6 files changed, 77 insertions(+), 42 deletions(-) create mode 100644 Directory.Build.props create mode 100644 Directory.Packages.props diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..a480682 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,8 @@ + + + latest + true + false + false + + \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..77fe49e --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,35 @@ + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenWeatherMap.Cache.Tests/OpenWeatherMap.Cache.Tests.csproj b/OpenWeatherMap.Cache.Tests/OpenWeatherMap.Cache.Tests.csproj index a6fc9a7..c915588 100644 --- a/OpenWeatherMap.Cache.Tests/OpenWeatherMap.Cache.Tests.csproj +++ b/OpenWeatherMap.Cache.Tests/OpenWeatherMap.Cache.Tests.csproj @@ -7,15 +7,15 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/OpenWeatherMap.Cache.sln b/OpenWeatherMap.Cache.sln index b166fb1..7643619 100644 --- a/OpenWeatherMap.Cache.sln +++ b/OpenWeatherMap.Cache.sln @@ -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 diff --git a/OpenWeatherMap.Cache/Models/Location.cs b/OpenWeatherMap.Cache/Models/Location.cs index 621b0fe..4f45402 100644 --- a/OpenWeatherMap.Cache/Models/Location.cs +++ b/OpenWeatherMap.Cache/Models/Location.cs @@ -5,27 +5,21 @@ namespace OpenWeatherMap.Cache.Models /// /// Class for the location with latitude and longitude. /// - public class Location : ILocationQuery, IEquatable + /// + /// Initializes a new instance of . + /// + /// The latitude of the location. + /// The longitude of the location. + public class Location(double latitude, double longitude) : ILocationQuery, IEquatable { /// /// The latitude of the . /// - public double Latitude { get; set; } + public double Latitude { get; set; } = latitude; /// /// The longitude of the . /// - public double Longitude { get; set; } - - /// - /// Initializes a new instance of . - /// - /// The latitude of the location. - /// The longitude of the location. - public Location(double latitude, double longitude) - { - Latitude = latitude; - Longitude = longitude; - } + public double Longitude { get; set; } = longitude; /// public bool Equals(Location other) @@ -46,6 +40,9 @@ public override bool Equals(object obj) /// public override int GetHashCode() { +#if NET5_0_OR_GREATER + return HashCode.Combine(Latitude, Longitude); +#else unchecked { int hash = 17; @@ -53,6 +50,7 @@ public override int GetHashCode() hash = hash * 23 + Longitude.GetHashCode(); return hash; } +#endif } } } diff --git a/OpenWeatherMap.Cache/OpenWeatherMap.Cache.csproj b/OpenWeatherMap.Cache/OpenWeatherMap.Cache.csproj index 0551fca..d13f9e8 100644 --- a/OpenWeatherMap.Cache/OpenWeatherMap.Cache.csproj +++ b/OpenWeatherMap.Cache/OpenWeatherMap.Cache.csproj @@ -1,8 +1,8 @@  - netstandard2.0;net5.0;net6.0 - 8.0 + netstandard2.0;net5.0;net6.0;net9.0 + latest Mark Cilia Vincenti https://github.com/MarkCiliaVincenti/OpenWeatherMap.Cache.git https://github.com/MarkCiliaVincenti/OpenWeatherMap.Cache @@ -35,28 +35,16 @@ - - - + + + + + + - - - - - - - - - - - - - - - - - + +