Skip to content

Commit

Permalink
Upgrade project to .NET 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaggqvist committed Jul 1, 2024
1 parent f6fb8cf commit f2d1a28
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 36 deletions.
6 changes: 3 additions & 3 deletions Uroskur.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A0AADFB5-E349-4FF6-9D17-7F8E41FD34C0}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{A0AADFB5-E349-4FF6-9D17-7F8E41FD34C0}.Debug|Any CPU.Build.0 = Release|Any CPU
{A0AADFB5-E349-4FF6-9D17-7F8E41FD34C0}.Debug|Any CPU.Deploy.0 = Release|Any CPU
{A0AADFB5-E349-4FF6-9D17-7F8E41FD34C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0AADFB5-E349-4FF6-9D17-7F8E41FD34C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0AADFB5-E349-4FF6-9D17-7F8E41FD34C0}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{A0AADFB5-E349-4FF6-9D17-7F8E41FD34C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0AADFB5-E349-4FF6-9D17-7F8E41FD34C0}.Release|Any CPU.Build.0 = Release|Any CPU
{A0AADFB5-E349-4FF6-9D17-7F8E41FD34C0}.Release|Any CPU.Deploy.0 = Release|Any CPU
Expand Down
4 changes: 2 additions & 2 deletions src/Converters/MeterToKilometerConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

public class MeterToKilometerConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return (double)value / 1000;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Converters/StringToDateTimeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

public class StringToDateTimeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return DateTime.Parse((string)value);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
Expand Down
29 changes: 19 additions & 10 deletions src/Uroskur.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-maccatalyst;net7.0-ios;net7.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0-maccatalyst;net8.0-ios;net8.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
Expand All @@ -11,6 +11,7 @@
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>

<!-- Display name -->
<ApplicationTitle>Uroskur</ApplicationTitle>
Expand Down Expand Up @@ -67,21 +68,21 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="6.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="MonkeyCache.FileStore" Version="2.0.1" />
<PackageReference Include="CommunityToolkit.Maui" Version="9.0.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="MonkeyCache.FileStore" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Polly" Version="8.0.0" />
<PackageReference Include="SkiaSharp" Version="2.88.6" />
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.6" />
<PackageReference Include="Polly" Version="8.4.1" />
<PackageReference Include="SkiaSharp" Version="2.88.8" />
<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.8" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net7.0-android')) != true">
<ItemGroup Condition="$(TargetFramework.StartsWith('net8.0-android')) != true">
<Compile Remove="**\**\*.Android.cs" />
<None Include="**\**\*.Android.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net7.0-ios')) != true AND $(TargetFramework.StartsWith('ne7.0-maccatalyst')) != true">
<ItemGroup Condition="$(TargetFramework.StartsWith('net8.0-ios')) != true AND $(TargetFramework.StartsWith('net8.0-maccatalyst')) != true">
<Compile Remove="**\**\*.iOS.cs" />
<None Include="**\**\*.iOS.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
Expand Down Expand Up @@ -141,4 +142,12 @@
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Maui.Controls" Version="8.0.61" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.61" />
</ItemGroup>
</Project>
16 changes: 8 additions & 8 deletions src/Utils/ChartHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,7 @@ private static IEnumerable<ChartEntry> GetChartEntries(
chartEntries.Add(CreateChartEntry(value, locationWeatherForecast.DateTime, withLabel));
}

static float GetValue(HourlyWeatherForecast hourlyWeatherForecast, string propertyName)
{
var type = typeof(HourlyWeatherForecast);
var field = type.GetProperty(propertyName);
var obj = field?.GetValue(hourlyWeatherForecast);
return Convert.ToSingle(obj);
}
return chartEntries;

static ChartEntry CreateChartEntry(float value, DateTime dateTime, bool withLabel)
{
Expand All @@ -136,6 +130,12 @@ static ChartEntry CreateChartEntry(float value, DateTime dateTime, bool withLabe
};
}

return chartEntries;
static float GetValue(HourlyWeatherForecast hourlyWeatherForecast, string propertyName)
{
var type = typeof(HourlyWeatherForecast);
var field = type.GetProperty(propertyName);
var obj = field?.GetValue(hourlyWeatherForecast);
return Convert.ToSingle(obj);
}
}
}
12 changes: 6 additions & 6 deletions src/Utils/LocationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ public static class LocationHelper
private static double CalculateDistanceBetweenLocations(double lat1, double lon1, double lat2,
double lon2)
{
return 12745.6 *
Math.Asin(Math.Sqrt(
Havf(lat2 - lat1) +
Math.Cos(Rad(lat1)) * Math.Cos(Rad(lat2)) *
Havf(lon2 - lon1)));

double Rad(double angle)
{
return angle * 0.017453292519943295769236907684886127d;
Expand All @@ -16,12 +22,6 @@ double Havf(double diff)
{
return Math.Pow(Math.Sin(Rad(diff) / 2d), 2);
}

return 12745.6 *
Math.Asin(Math.Sqrt(
Havf(lat2 - lat1) +
Math.Cos(Rad(lat1)) * Math.Cos(Rad(lat2)) *
Havf(lon2 - lon1)));
}

public static double CalculateTotalDistance(IEnumerable<Location> locations)
Expand Down
10 changes: 5 additions & 5 deletions tests/Uroskur.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand All @@ -13,13 +13,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit f2d1a28

Please sign in to comment.