Skip to content

Commit d5c7973

Browse files
Upgrade .NET MAUI Workshop to .NET 10 (#152)
* Initial plan * Update all projects to .NET 10 Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com> * Update to Visual Studio 2026 and replace deprecated DisplayAlert with DisplayAlertAsync Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com> * update workflow * Update logging to 10.0, CommunityToolkit.Mvvm to 8.4.0, and add LangVersion preview Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com> * update csproj with essentials stuff * Update all ViewModels and documentation to use MVVM Toolkit 8.4.0 partial property syntax Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com> * Fix README: Keep manual implementation examples with field syntax Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com> * Change CardView base class from Frame to Border CardView now inherits from Border instead of Frame, enabling use of Border-specific styling and features. This may affect the appearance and layout of CardView components in the application. * 🔧 Refactor IsBusy property in BaseViewModel - Update getter to use `isBusy` instead of `field` - Ensure setter updates `isBusy` and raises PropertyChanged events --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jamesmontemagno <1676321+jamesmontemagno@users.noreply.github.com> Co-authored-by: James Montemagno <james.montemagno@gmail.com>
1 parent 123d476 commit d5c7973

56 files changed

Lines changed: 192 additions & 164 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
- '**.props'
1818

1919
env:
20-
DOTNET_VERSION: '9.0.x' # The .NET SDK version to use
20+
DOTNET_VERSION: '10.0.x' # The .NET SDK version to use
2121

2222
jobs:
2323
build:

Community Modules/XAML/Part 1 - Fundamentals/Finish/MonkeyFinder/MonkeyFinder.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net9.0-android</TargetFrameworks>
5-
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
6-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net9.0-windows10.0.19041</TargetFrameworks>
4+
<TargetFrameworks>net10.0-android</TargetFrameworks>
5+
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net10.0-ios;net10.0-maccatalyst</TargetFrameworks>
6+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net10.0-windows10.0.19041</TargetFrameworks>
77
<OutputType>Exe</OutputType>
88
<RootNamespace>MonkeyFinder</RootNamespace>
99
<UseMaui>true</UseMaui>
1010
<SingleProject>true</SingleProject>
1111
<ImplicitUsings>enable</ImplicitUsings>
12+
<LangVersion>preview</LangVersion>
1213

1314
<!-- Display name -->
1415
<ApplicationTitle>MonkeyFinder</ApplicationTitle>
@@ -44,7 +45,7 @@
4445

4546
<ItemGroup>
4647
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
47-
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
48+
<PackageReference Include="Microsoft.Maui.Essentials" Version="$(MauiVersion)" />
4849
</ItemGroup>
4950

5051
</Project>

Community Modules/XAML/Part 1 - Fundamentals/Finish/MonkeyFinder/ViewModel/BaseViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ public partial class BaseViewModel : ObservableObject
44
{
55
[ObservableProperty]
66
[NotifyPropertyChangedFor(nameof(IsNotBusy))]
7-
bool isBusy;
7+
public partial bool IsBusy { get; set; }
88

99
[ObservableProperty]
10-
string title;
10+
public partial string Title { get; set; }
1111

1212
public bool IsNotBusy => !IsBusy;
1313
}

Community Modules/XAML/Part 1 - Fundamentals/Finish/MonkeyFinder/ViewModel/MonkeyDetailsViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public MonkeyDetailsViewModel(IMap map)
1010
}
1111

1212
[ObservableProperty]
13-
Monkey monkey;
13+
public partial Monkey Monkey { get; set; }
1414

1515
[RelayCommand]
1616
async Task OpenMap()
@@ -26,7 +26,7 @@ async Task OpenMap()
2626
catch (Exception ex)
2727
{
2828
Debug.WriteLine($"Unable to launch maps: {ex.Message}");
29-
await Shell.Current.DisplayAlert("Error, no Maps app!", ex.Message, "OK");
29+
await Shell.Current.DisplayAlertAsync("Error, no Maps app!", ex.Message, "OK");
3030
}
3131
}
3232
}

Community Modules/XAML/Part 1 - Fundamentals/Finish/MonkeyFinder/ViewModel/MonkeysViewModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async Task GoToDetails(Monkey monkey)
2929
}
3030

3131
[ObservableProperty]
32-
bool isRefreshing;
32+
public partial bool IsRefreshing { get; set; }
3333

3434
[RelayCommand]
3535
async Task GetMonkeysAsync()
@@ -41,7 +41,7 @@ async Task GetMonkeysAsync()
4141
{
4242
if (connectivity.NetworkAccess != NetworkAccess.Internet)
4343
{
44-
await Shell.Current.DisplayAlert("No connectivity!",
44+
await Shell.Current.DisplayAlertAsync("No connectivity!",
4545
$"Please check internet and try again.", "OK");
4646
return;
4747
}
@@ -59,7 +59,7 @@ await Shell.Current.DisplayAlert("No connectivity!",
5959
catch (Exception ex)
6060
{
6161
Debug.WriteLine($"Unable to get monkeys: {ex.Message}");
62-
await Shell.Current.DisplayAlert("Error!", ex.Message, "OK");
62+
await Shell.Current.DisplayAlertAsync("Error!", ex.Message, "OK");
6363
}
6464
finally
6565
{
@@ -93,14 +93,14 @@ async Task GetClosestMonkey()
9393
new Location(m.Latitude, m.Longitude), DistanceUnits.Miles))
9494
.FirstOrDefault();
9595

96-
await Shell.Current.DisplayAlert("", first.Name + " " +
96+
await Shell.Current.DisplayAlertAsync("", first.Name + " " +
9797
first.Location, "OK");
9898

9999
}
100100
catch (Exception ex)
101101
{
102102
Debug.WriteLine($"Unable to query location: {ex.Message}");
103-
await Shell.Current.DisplayAlert("Error!", ex.Message, "OK");
103+
await Shell.Current.DisplayAlertAsync("Error!", ex.Message, "OK");
104104
}
105105
}
106106
}

Community Modules/XAML/Part 2 - Responsibility/Finish/MonkeyFinder/MonkeyFinder.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net9.0-android</TargetFrameworks>
5-
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
6-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net9.0-windows10.0.19041</TargetFrameworks>
4+
<TargetFrameworks>net10.0-android</TargetFrameworks>
5+
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net10.0-ios;net10.0-maccatalyst</TargetFrameworks>
6+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net10.0-windows10.0.19041</TargetFrameworks>
77
<OutputType>Exe</OutputType>
88
<RootNamespace>MonkeyFinder</RootNamespace>
99
<UseMaui>true</UseMaui>
1010
<SingleProject>true</SingleProject>
1111
<ImplicitUsings>enable</ImplicitUsings>
12+
<LangVersion>preview</LangVersion>
1213

1314
<!-- Display name -->
1415
<ApplicationTitle>MonkeyFinder</ApplicationTitle>
@@ -44,6 +45,6 @@
4445

4546
<ItemGroup>
4647
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
47-
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
48+
<PackageReference Include="Microsoft.Maui.Essentials" Version="$(MauiVersion)" />
4849
</ItemGroup>
4950
</Project>

Community Modules/XAML/Part 2 - Responsibility/Finish/MonkeyFinder/ViewModel/BaseViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ public partial class BaseViewModel : ObservableObject
44
{
55
[ObservableProperty]
66
[NotifyPropertyChangedFor(nameof(IsNotBusy))]
7-
bool isBusy;
7+
public partial bool IsBusy { get; set; }
88

99
[ObservableProperty]
10-
string title;
10+
public partial string Title { get; set; }
1111

1212
public bool IsNotBusy => !IsBusy;
1313
}

Community Modules/XAML/Part 2 - Responsibility/Finish/MonkeyFinder/ViewModel/MonkeyDetailsViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public MonkeyDetailsViewModel(IMap map)
1010
}
1111

1212
[ObservableProperty]
13-
Monkey monkey;
13+
public partial Monkey Monkey { get; set; }
1414

1515
[RelayCommand]
1616
async Task OpenMap()
@@ -26,7 +26,7 @@ async Task OpenMap()
2626
catch (Exception ex)
2727
{
2828
Debug.WriteLine($"Unable to launch maps: {ex.Message}");
29-
await Shell.Current.DisplayAlert("Error, no Maps app!", ex.Message, "OK");
29+
await Shell.Current.DisplayAlertAsync("Error, no Maps app!", ex.Message, "OK");
3030
}
3131
}
3232
}

Community Modules/XAML/Part 2 - Responsibility/Finish/MonkeyFinder/ViewModel/MonkeysViewModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async Task GoToDetails(Monkey monkey)
2929
}
3030

3131
[ObservableProperty]
32-
bool isRefreshing;
32+
public partial bool IsRefreshing { get; set; }
3333

3434
[RelayCommand]
3535
async Task GetMonkeysAsync()
@@ -41,7 +41,7 @@ async Task GetMonkeysAsync()
4141
{
4242
if (connectivity.NetworkAccess != NetworkAccess.Internet)
4343
{
44-
await Shell.Current.DisplayAlert("No connectivity!",
44+
await Shell.Current.DisplayAlertAsync("No connectivity!",
4545
$"Please check internet and try again.", "OK");
4646
return;
4747
}
@@ -59,7 +59,7 @@ await Shell.Current.DisplayAlert("No connectivity!",
5959
catch (Exception ex)
6060
{
6161
Debug.WriteLine($"Unable to get monkeys: {ex.Message}");
62-
await Shell.Current.DisplayAlert("Error!", ex.Message, "OK");
62+
await Shell.Current.DisplayAlertAsync("Error!", ex.Message, "OK");
6363
}
6464
finally
6565
{
@@ -93,14 +93,14 @@ async Task GetClosestMonkey()
9393
new Location(m.Latitude, m.Longitude), DistanceUnits.Miles))
9494
.FirstOrDefault();
9595

96-
await Shell.Current.DisplayAlert("", first.Name + " " +
96+
await Shell.Current.DisplayAlertAsync("", first.Name + " " +
9797
first.Location, "OK");
9898

9999
}
100100
catch (Exception ex)
101101
{
102102
Debug.WriteLine($"Unable to query location: {ex.Message}");
103-
await Shell.Current.DisplayAlert("Error!", ex.Message, "OK");
103+
await Shell.Current.DisplayAlertAsync("Error!", ex.Message, "OK");
104104
}
105105
}
106106
}

Community Modules/XAML/Part 3 - Magic Values/Finish/MonkeyFinder/MonkeyFinder.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net9.0-android</TargetFrameworks>
5-
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
6-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net9.0-windows10.0.19041</TargetFrameworks>
4+
<TargetFrameworks>net10.0-android</TargetFrameworks>
5+
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('linux'))">$(TargetFrameworks);net10.0-ios;net10.0-maccatalyst</TargetFrameworks>
6+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net10.0-windows10.0.19041</TargetFrameworks>
77
<OutputType>Exe</OutputType>
88
<RootNamespace>MonkeyFinder</RootNamespace>
99
<UseMaui>true</UseMaui>
1010
<SingleProject>true</SingleProject>
1111
<ImplicitUsings>enable</ImplicitUsings>
12+
<LangVersion>preview</LangVersion>
1213

1314
<!-- Display name -->
1415
<ApplicationTitle>MonkeyFinder</ApplicationTitle>
@@ -44,7 +45,7 @@
4445

4546
<ItemGroup>
4647
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
47-
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
48+
<PackageReference Include="Microsoft.Maui.Essentials" Version="$(MauiVersion)" />
4849
</ItemGroup>
4950

5051
<ItemGroup>

0 commit comments

Comments
 (0)