Skip to content

Commit

Permalink
Small improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCiliaVincenti committed Oct 5, 2024
1 parent f7735f5 commit 3fd9830
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
7 changes: 1 addition & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
<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'">
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(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" />
Expand Down
4 changes: 0 additions & 4 deletions OpenWeatherMap.Cache/Models/Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,13 @@ 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
}
}
}
2 changes: 1 addition & 1 deletion OpenWeatherMap.Cache/Models/Readings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public sealed class Readings : IEquatable<Readings>

internal Readings(ApiWeatherResult apiWeatherResult)
{
Weather = new List<WeatherCondition>();
Weather = [];
foreach (var weather in apiWeatherResult.Weather)
{
Weather.Add(new WeatherCondition
Expand Down
2 changes: 1 addition & 1 deletion OpenWeatherMap.Cache/OpenWeatherMap.Cache.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net5.0;net6.0;net9.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net5.0;net6.0;net7.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Authors>Mark Cilia Vincenti</Authors>
<RepositoryUrl>https://github.com/MarkCiliaVincenti/OpenWeatherMap.Cache.git</RepositoryUrl>
Expand Down
5 changes: 4 additions & 1 deletion OpenWeatherMap.Cache/OpenWeatherMapCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using OpenWeatherMap.Cache.Constants;
using OpenWeatherMap.Cache.Models;
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Net;
Expand Down Expand Up @@ -160,7 +159,11 @@ private async ValueTask<ApiWeatherResult> GetApiWeatherResultFromUriAsync(string
{
using var response = await GetResponseAsync(request, cancellationToken).ConfigureAwait(false);
using var streamReader = new StreamReader(response.GetResponseStream());
#if NET7_0_OR_GREATER
var content = await streamReader.ReadToEndAsync(cancellationToken).ConfigureAwait(false);
#else
var content = await streamReader.ReadToEndAsync().ConfigureAwait(false);
#endif
if (_logPath != null)
{
File.WriteAllText(Path.Combine(_logPath, logFileName), content);
Expand Down

0 comments on commit 3fd9830

Please sign in to comment.