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

Initial .NET 9 upgrade #147

Merged
merged 8 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/build-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- '**.props'

env:
DOTNET_VERSION: '8.0.x' # The .NET SDK version to use
DOTNET_VERSION: '9.0.x' # The .NET SDK version to use

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ public partial class App : Application
public App()
{
InitializeComponent();
}

MainPage = new AppShell();
protected override Window CreateWindow(IActivationState activationState)
{
return new Window(new AppShell());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@

<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Style TargetType="Shell" ApplyToDerivedTypes="True">
<Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
<Setter Property="Shell.ForegroundColor" Value="{OnPlatform WinUI={StaticResource Primary}, Default=White}" />
<Setter Property="Shell.TitleColor" Value="White" />
<Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
<Setter Property="Shell.UnselectedColor" Value="{AppThemeBinding Dark=#95FFFFFF, Light=#95000000}" />
<Setter Property="Shell.NavBarHasShadow" Value="False" />
<Setter Property="Shell.TabBarBackgroundColor" Value="{AppThemeBinding Dark={StaticResource DarkBackground}, Light={StaticResource LightBackground}}" />
<Setter Property="Shell.TabBarForegroundColor" Value="{AppThemeBinding Dark={StaticResource LightBackground}, Light={StaticResource DarkBackground}}" />
<Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Dark=#95FFFFFF, Light=#95000000}" />
<Setter Property="Shell.TabBarTitleColor" Value="{AppThemeBinding Dark={StaticResource LightBackground}, Light={StaticResource DarkBackground}}" />
<Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Dark=#95FFFFFF, Light=#95000000}" />
</Style>
<Style
ApplyToDerivedTypes="True"
BasedOn="{StaticResource BaseStyle}"
TargetType="ShellItem" />
</ResourceDictionary>
</Shell.Resources>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-android</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>net9.0-android</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net9.0-windows10.0.19041</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>MonkeyFinder</RootNamespace>
<UseMaui>true</UseMaui>
Expand Down Expand Up @@ -41,8 +41,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.82" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.82" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@
<Setter Property="HeightRequest" Value="40" />
<Setter Property="CornerRadius" Value="20" />
</Style>
<Style x:Key="CardView" TargetType="Frame">
<Setter Property="BorderColor" Value="#DDDDDD" />
<Setter Property="HasShadow" Value="{OnPlatform iOS=false, MacCatalyst=false, Default=true}" />
<Setter Property="Padding" Value="0" />
<Setter Property="Background" Value="{AppThemeBinding Light={StaticResource CardBackground}, Dark={StaticResource CardBackgroundDark}}" />
<Setter Property="CornerRadius" Value="10" />
<Setter Property="IsClippedToBounds" Value="True" />
</Style>
<Style x:Key="CardView" TargetType="Border">
<Setter Property="Stroke" Value="#DDDDDD" />
<Setter Property="StrokeThickness" Value="1" />
<Setter Property="StrokeShape" Value="RoundRectangle 10"/>
<Setter Property="Padding" Value="0" />
<Setter Property="Background" Value="{AppThemeBinding Light={StaticResource CardBackground}, Dark={StaticResource CardBackgroundDark}}" />
</Style>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:Monkey">
<Grid Padding="10" HorizontalOptions="Fill">
<Frame HeightRequest="125" Style="{StaticResource CardView}">
<Frame.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MonkeysViewModel}}, Path=GoToDetailsCommand}" CommandParameter="{Binding .}" />
</Frame.GestureRecognizers>
<Border HeightRequest="125" Style="{StaticResource CardView}">
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MonkeysViewModel}}, x:DataType=viewmodel:MonkeysViewModel, Path=GoToDetailsCommand}" CommandParameter="{Binding .}" />
</Border.GestureRecognizers>
<Grid Padding="0" ColumnDefinitions="125,*">
<Image
Aspect="AspectFill"
Expand All @@ -52,7 +52,7 @@
<Label Style="{StaticResource MediumLabel}" Text="{Binding Location}" />
</VerticalStackLayout>
</Grid>
</Frame>
</Border>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
Expand Down
9 changes: 4 additions & 5 deletions Community Modules/XAML/Part 1 - Fundamentals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,12 @@ Now cut and paste the remaining `Resources` from `App.xaml` into `Styles.xaml`.
<Setter Property="HeightRequest" Value="40" />
<Setter Property="CornerRadius" Value="20" />
</Style>
<Style x:Key="CardView" TargetType="Frame">
<Setter Property="BorderColor" Value="#DDDDDD" />
<Setter Property="HasShadow" Value="{OnPlatform iOS=false, MacCatalyst=false, Default=true}" />
<Style x:Key="CardView" TargetType="Border">
<Setter Property="Stroke" Value="#DDDDDD" />
<Setter Property="StrokeThickness" Value="1" />
<Setter Property="StrokeShape" Value="RoundRectangle 10"/>
<Setter Property="Padding" Value="0" />
<Setter Property="Background" Value="{AppThemeBinding Light={StaticResource CardBackground}, Dark={StaticResource CardBackgroundDark}}" />
<Setter Property="CornerRadius" Value="10" />
<Setter Property="IsClippedToBounds" Value="True" />
</Style>
</ResourceDictionary>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ public partial class App : Application
public App()
{
InitializeComponent();
}

MainPage = new AppShell();
protected override Window CreateWindow(IActivationState activationState)
{
return new Window(new AppShell());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@

<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Style TargetType="Shell" ApplyToDerivedTypes="True">
<Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
<Setter Property="Shell.ForegroundColor" Value="{OnPlatform WinUI={StaticResource Primary}, Default=White}" />
<Setter Property="Shell.TitleColor" Value="White" />
<Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
<Setter Property="Shell.UnselectedColor" Value="{AppThemeBinding Dark=#95FFFFFF, Light=#95000000}" />
<Setter Property="Shell.NavBarHasShadow" Value="False" />
<Setter Property="Shell.TabBarBackgroundColor" Value="{AppThemeBinding Dark={StaticResource DarkBackground}, Light={StaticResource LightBackground}}" />
<Setter Property="Shell.TabBarForegroundColor" Value="{AppThemeBinding Dark={StaticResource LightBackground}, Light={StaticResource DarkBackground}}" />
<Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Dark=#95FFFFFF, Light=#95000000}" />
<Setter Property="Shell.TabBarTitleColor" Value="{AppThemeBinding Dark={StaticResource LightBackground}, Light={StaticResource DarkBackground}}" />
<Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Dark=#95FFFFFF, Light=#95000000}" />
</Style>
<Style
ApplyToDerivedTypes="True"
BasedOn="{StaticResource BaseStyle}"
TargetType="ShellItem" />
</ResourceDictionary>
</Shell.Resources>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-android</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>net9.0-android</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net9.0-windows10.0.19041</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>MonkeyFinder</RootNamespace>
<UseMaui>true</UseMaui>
Expand Down Expand Up @@ -41,7 +41,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.82" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.82" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@
<Setter Property="HeightRequest" Value="40" />
<Setter Property="CornerRadius" Value="20" />
</Style>
<Style x:Key="CardView" TargetType="Frame">
<Setter Property="BorderColor" Value="#DDDDDD" />
<Setter Property="HasShadow" Value="{OnPlatform iOS=false, MacCatalyst=false, Default=true}" />
<Setter Property="Padding" Value="0" />
<Setter Property="Background" Value="{AppThemeBinding Light={StaticResource CardBackground}, Dark={StaticResource CardBackgroundDark}}" />
<Setter Property="CornerRadius" Value="10" />
<Setter Property="IsClippedToBounds" Value="True" />
</Style>
<Style x:Key="CardView" TargetType="Border">
<Setter Property="Stroke" Value="#DDDDDD" />
<Setter Property="StrokeThickness" Value="1" />
<Setter Property="StrokeShape" Value="RoundRectangle 10"/>
<Setter Property="Padding" Value="0" />
<Setter Property="Background" Value="{AppThemeBinding Light={StaticResource CardBackground}, Dark={StaticResource CardBackgroundDark}}" />
</Style>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:Monkey">
<Grid Padding="10" HorizontalOptions="Fill">
<Frame HeightRequest="125" Style="{StaticResource CardView}">
<Frame.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MonkeysViewModel}}, Path=GoToDetailsCommand}" CommandParameter="{Binding .}" />
</Frame.GestureRecognizers>
<Border HeightRequest="125" Style="{StaticResource CardView}">
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MonkeysViewModel}}, x:DataType=viewmodel:MonkeysViewModel, Path=GoToDetailsCommand}" CommandParameter="{Binding .}" />
</Border.GestureRecognizers>
<Grid Padding="0" ColumnDefinitions="125,*">
<Image
Aspect="AspectFill"
Expand All @@ -43,7 +43,7 @@
<Label Style="{StaticResource MediumLabel}" Text="{Binding Location}" />
</VerticalStackLayout>
</Grid>
</Frame>
</Border>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ public partial class App : Application
public App()
{
InitializeComponent();
}

MainPage = new AppShell();
protected override Window CreateWindow(IActivationState activationState)
{
return new Window(new AppShell());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@

<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Style TargetType="Shell" ApplyToDerivedTypes="True">
<Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
<Setter Property="Shell.ForegroundColor" Value="{OnPlatform WinUI={StaticResource Primary}, Default=White}" />
<Setter Property="Shell.TitleColor" Value="White" />
<Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
<Setter Property="Shell.UnselectedColor" Value="{AppThemeBinding Dark=#95FFFFFF, Light=#95000000}" />
<Setter Property="Shell.NavBarHasShadow" Value="False" />
<Setter Property="Shell.TabBarBackgroundColor" Value="{AppThemeBinding Dark={StaticResource DarkBackground}, Light={StaticResource LightBackground}}" />
<Setter Property="Shell.TabBarForegroundColor" Value="{AppThemeBinding Dark={StaticResource LightBackground}, Light={StaticResource DarkBackground}}" />
<Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Dark=#95FFFFFF, Light=#95000000}" />
<Setter Property="Shell.TabBarTitleColor" Value="{AppThemeBinding Dark={StaticResource LightBackground}, Light={StaticResource DarkBackground}}" />
<Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Dark=#95FFFFFF, Light=#95000000}" />
</Style>
<Style
ApplyToDerivedTypes="True"
BasedOn="{StaticResource BaseStyle}"
TargetType="ShellItem" />
</ResourceDictionary>
</Shell.Resources>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-android</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>net9.0-android</TargetFrameworks>
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net9.0-windows10.0.19041</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>MonkeyFinder</RootNamespace>
<UseMaui>true</UseMaui>
Expand Down Expand Up @@ -41,8 +41,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.82" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.82" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,13 @@
<Setter Property="HeightRequest" Value="40" />
<Setter Property="CornerRadius" Value="20" />
</Style>
<Style x:Key="CardView" TargetType="Frame">
<Setter Property="BorderColor" Value="#DDDDDD" />
<Setter Property="HasShadow" Value="{OnPlatform iOS=false, MacCatalyst=false, Default=true}" />
<Setter Property="Padding" Value="0" />
<Setter Property="Background" Value="{AppThemeBinding Light={StaticResource CardBackground}, Dark={StaticResource CardBackgroundDark}}" />
<Setter Property="CornerRadius" Value="10" />
<Setter Property="IsClippedToBounds" Value="True" />
</Style>
<Style x:Key="CardView" TargetType="Border">
<Setter Property="Stroke" Value="#DDDDDD" />
<Setter Property="StrokeThickness" Value="1" />
<Setter Property="StrokeShape" Value="RoundRectangle 10"/>
<Setter Property="Padding" Value="0" />
<Setter Property="Background" Value="{AppThemeBinding Light={StaticResource CardBackground}, Dark={StaticResource CardBackgroundDark}}" />
</Style>

<Style TargetType="Image">
<Setter Property="Aspect" Value="AspectFill" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="model:Monkey">
<Grid Padding="{StaticResource StandardItemPadding}" HorizontalOptions="Fill">
<Frame HeightRequest="{StaticResource SmallSquareImageSize}" Style="{StaticResource CardView}">
<Frame.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MonkeysViewModel}}, Path=GoToDetailsCommand}" CommandParameter="{Binding .}" />
</Frame.GestureRecognizers>
<Border HeightRequest="{StaticResource SmallSquareImageSize}" Style="{StaticResource CardView}">
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MonkeysViewModel}}, x:DataType=viewmodel:MonkeysViewModel, Path=GoToDetailsCommand}" CommandParameter="{Binding .}" />
</Border.GestureRecognizers>
<Grid Padding="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource SmallSquareImageSize}" />
Expand All @@ -48,7 +48,7 @@
<Label Style="{StaticResource MediumLabel}" Text="{Binding Location}" />
</VerticalStackLayout>
</Grid>
</Frame>
</Border>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
Expand Down
12 changes: 6 additions & 6 deletions Community Modules/XAML/Part 3 - Magic Values/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ We've created a resource that we're only using in one place in this app, but it
> **Note**:
> Both `StandardItemPadding` and `InternalSpacing` use the same number "10". This duplication of a numeric value may be something you want to avoid. Sadly, XAML does not make it easy to remove this duplication. There are solutions but they are not currently covered in this workshop.

`MainPage.xaml` also includes a smaller image within the `ItemTemplate`. The size of this is **125**, but you will notice that the same value is also used for the `Frame` and one of the `ColumnDefinitions`. Is it a coincidence that this value appears in multiple places? It's not, but we can make it clearer to someone looking at this code in the future by creating a single resource and using that everywhere.
`MainPage.xaml` also includes a smaller image within the `ItemTemplate`. The size of this is **125**, but you will notice that the same value is also used for the `Border` and one of the `ColumnDefinitions`. Is it a coincidence that this value appears in multiple places? It's not, but we can make it clearer to someone looking at this code in the future by creating a single resource and using that everywhere.

As this is for a smaller image than the other one, let's call this the "SmallSquareImageSize". You create it in `Sizes.xaml` like this:

Expand All @@ -250,11 +250,11 @@ As this is for a smaller image than the other one, let's call this the "SmallSqu
We can now use this in `MainPage.xaml`:

```diff
- <Frame HeightRequest="125" Style="{StaticResource CardView}">
+ <Frame HeightRequest="{StaticResource SmallSquareImageSize}" Style="{StaticResource CardView}">
<Frame.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MonkeysViewModel}}, Path=GoToDetailsCommand}" CommandParameter="{Binding .}" />
</Frame.GestureRecognizers>
- <Border HeightRequest="125" Style="{StaticResource CardView}">
+ <Border HeightRequest="{StaticResource SmallSquareImageSize}" Style="{StaticResource CardView}">
<Border.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={RelativeSource AncestorType={x:Type viewmodel:MonkeysViewModel}}, x:DataType=viewmodel:MonkeysViewModel, Path=GoToDetailsCommand}" CommandParameter="{Binding .}" />
</Border.GestureRecognizers>
- <Grid Padding="0" ColumnDefinitions="125,*">
+ <Grid Padding="0">
+ <Grid.ColumnDefinitions>
Expand Down
Loading