Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to .NET 8 #119

Merged
merged 7 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Maui.Tabs/Maui.Tabs.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst</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);net6.0-tizen</TargetFrameworks> -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
<RootNamespace>Sharpnado.Tabs</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
Expand Down Expand Up @@ -92,11 +92,11 @@
</PropertyGroup>

<ItemGroup>
<None Include="..\Docs\logo_maui.png" Pack="true" PackagePath="\images\" />
<None Include="ReadMe.md" Pack="true" PackagePath="\docs\" />
<None Include="..\Docs\logo_maui.png" Pack="true" PackagePath="\images" />
<None Include="ReadMe.md" Pack="true" PackagePath="\docs" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('net6.0-ios')) != true AND $(TargetFramework.StartsWith('net6.0-maccatalyst')) != true ">
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('net8.0-ios')) != true AND $(TargetFramework.StartsWith('net8.0-maccatalyst')) != true ">
<Compile Remove="**\**\*.ios.cs" />
<None Include="**\**\*.ios.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\ios\**\*.cs" />
Expand All @@ -108,13 +108,13 @@
<Compile Remove="**\macos\**\*.cs" />
<None Include="**\macos\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('net6.0-ios')) != true AND $(TargetFramework.StartsWith('net6.0-maccatalyst')) != true">
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('net8.0-ios')) != true AND $(TargetFramework.StartsWith('net8.0-maccatalyst')) != true">
<Compile Remove="**\*.macios.cs" />
<None Include="**\*.macios.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\macios\**\*.cs" />
<None Include="**\macios\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid')) != true AND $(TargetFramework.StartsWith('net6.0-android')) != true ">
<ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid')) != true AND $(TargetFramework.StartsWith('net8.0-android')) != true ">
<Compile Remove="**\**\*.android.cs" />
<None Include="**\**\*.android.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
<Compile Remove="**\android\**\*.cs" />
Expand All @@ -128,6 +128,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Sharpnado.TaskMonitor" Version="1.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164">
<PrivateAssets>all</PrivateAssets>
Expand Down
4 changes: 2 additions & 2 deletions MauiSample/Infrastructure/PlatformService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static ScreenSize ScreenSize
{
get
{
if (Device.RuntimePlatform == Device.iOS)
if (DeviceInfo.Platform == DevicePlatform.iOS)
{
if (MainSize.Width <= 320)
{
Expand Down Expand Up @@ -100,7 +100,7 @@ public static void ForceGarbageCollector()
// I tested it, and in fact, in the most cases, you DO need all
// those calls for the GC to REALLY reclaim resources (especially
// with Android RecyclerView).
Device.BeginInvokeOnMainThread(async () =>
MainThread.BeginInvokeOnMainThread(async () =>
{
GC.Collect();
GC.WaitForPendingFinalizers();
Expand Down
2 changes: 1 addition & 1 deletion MauiSample/Localization/TranslateExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class TranslateExtension : IMarkupExtension

public TranslateExtension()
{
if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Android)
if (DeviceInfo.Platform == DevicePlatform.iOS || DeviceInfo.Platform == DevicePlatform.Android)
{
_cultureInfo = CultureInfo.CurrentUICulture;
}
Expand Down
30 changes: 13 additions & 17 deletions MauiSample/MauiSample.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</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);net6.0-tizen</TargetFrameworks> -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>MauiSample</RootNamespace>
<UseMaui>true</UseMaui>
Expand All @@ -31,40 +31,40 @@
<ProvisioningType>automatic</ProvisioningType>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net6.0-ios'">
<PropertyGroup Condition="'$(TargetFramework)'=='net8.0-ios'">
<CodesignKey>Apple Development: Created via API (K8Q3S2AN24)</CodesignKey>
<CodesignProvision>VS: WildCard Development</CodesignProvision>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-android|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
<MtouchLink>None</MtouchLink>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-android|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
<MtouchLink>None</MtouchLink>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-ios|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
<MtouchLink>None</MtouchLink>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-ios|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
<MtouchLink>None</MtouchLink>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-maccatalyst|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-maccatalyst|AnyCPU'">
<MtouchLink>None</MtouchLink>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-maccatalyst|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-maccatalyst|AnyCPU'">
<MtouchLink>None</MtouchLink>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-windows10.0.19041.0|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-windows10.0.19041.0|AnyCPU'">
<MtouchLink>None</MtouchLink>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-windows10.0.19041.0|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-windows10.0.19041.0|AnyCPU'">
<MtouchLink>None</MtouchLink>
</PropertyGroup>

Expand Down Expand Up @@ -117,11 +117,7 @@
</ItemGroup>

<ItemGroup>
<MauiImage Include="Resources\AppIcon\logo.png" />
<MauiImage Include="Resources\Splash\logo.png" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Sharpnado.Maui.TaskLoaderView" Version="2.5.1" />
<PackageReference Include="SimpleInjector" Version="5.4.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion MauiSample/Presentation/Views/TabA.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<Style x:Key="MaterialTabStyle" TargetType="tabs:MaterialUnderlinedTabItem">
<Setter Property="SelectedTabColor" Value="{StaticResource Primary}" />
<Setter Property="SelectedTabTextColor" Value="{StaticResource Secondary}" />
<!--<Setter Property="SelectedTabTextColor" Value="{StaticResource Secondary}" />-->
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this commented ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix a build error:

Cannot resolve property "SelectedTabTextColor"
on type "MaterialUnderlinedTabItem
(property missing or missing accessors)".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICS the error message is correct, right? SelectedTabTextColor is only available in BottomTabItem, but not in MaterialUnderlinedTabItem (both inherit from TabTextItem, directly or indirectly).
Not sure why this was missed with net6.0. Probably improved diagnostics in net8.0, I guess ...

<Setter Property="IconSize" Value="24" />
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="LabelSize" Value="14" />
Expand Down
3 changes: 1 addition & 2 deletions Tabs/Tabs/DelayedView.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Sharpnado.Tasks;
using Xamarin.Forms;

namespace Sharpnado.Tabs;

Expand All @@ -14,7 +13,7 @@ public override void LoadView()
async () =>
{
View? view = null;
if (Device.RuntimePlatform == Device.Android)
if (DeviceInfo.Platform == DevicePlatform.Android)
{
await Task.Run(
() =>
Expand Down
2 changes: 1 addition & 1 deletion Tabs/Tabs/TabHostView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ private void AddTapCommand(TabItem tabItem)
return;
}

if (Device.RuntimePlatform == Device.UWP)
if (DeviceInfo.Platform == DevicePlatform.WinUI)
{
tabItem.GestureRecognizers.Add(
new TapGestureRecognizer { Command = TabItemTappedCommand, CommandParameter = tabItem });
Expand Down
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"version": "8.0.100",
"rollForward": "latestFeature"
}
}