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

Support .NET 9.0 #2215

Merged
merged 191 commits into from
Dec 18, 2024
Merged

Support .NET 9.0 #2215

merged 191 commits into from
Dec 18, 2024

Conversation

bijington
Copy link
Contributor

@bijington bijington commented Sep 18, 2024

Description of Change

Linked Issues

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Breaking Changes

Major Breaking Changes

  • .NET 8 no longer supported
  • Xcode 16.1 Required
  • Stop automatically assigning Behavior.BindingContext
    • .NET MAUI Behaviors do not automatically inherit their parent's BindingContext (a breaking change from Xamarin.Forms)
    • Going forward, the .NET MAUI Community Toolkit will follow this implementation of Behaviors
  • Increase minimum supported OS versions of CommunityToolkit.Maui.MediaElement
    • Android 26.0
    • iOS 15.0
    • MacCatalyst 15.0
  • Increase minimum supported versions of CommunityToolkit.Maui.Camera to 15.0:
    • iOS 15.0
    • MacCatalyst 15.0

Minor Breaking Changes

  • Expander is not trim safe
  • ValidationBehaviors are not trim safe
  • CommunityToolkit.Maui.Maps is not trim safe
  • Remove PopupService.ShowPopop(TViewModel)
    • Removes [Obsolete] method
    • Use PopupService.ShowPopup<T>() instead
  • Remove PopupService.ShowPopopAsync(TViewModel, CancellationToken)
    • Removes [Obsolete] method
    • Use PopupService.ShowPopupAsync<T>() instead
  • Remove ability to subclass BaseConverter<TFrom, TTo>
    • Subclassing from BaseConverter<TFrom, TTo> is not supported
    • Support requires documentation and complete unit tests
  • Remove ability to subclass BaseConverter<TFrom, TTo, TParam>
    • Subclassing from BaseConverter<TFrom, TTo, TParam> is not supported
    • Support requires documentation and complete unit tests
  • ValidationFlags.ValidateOnFocusing renamed to ValidationFlags.ValidateOnFocused
  • ValidationFlags.ValidateOnUnfocusing renamed to ValidationFlags.ValidateOnUnfocused
  • In CommunityToolkit.Maui.Camera, add linker.xml for net9.0-android to avoid the Linker removing Xamarin.AndroidX.Camera.Core, Xamarin.AndroidX.Camera.Lifecycle, Xamarin.AndroidX.Camera.Video, Xamarin.AndroidX.Camera.View, and Xamarin.AndroidX.Camera.Camera2
  • public static Task<bool> ShowKeyboardAsync(this ITextInput, CancellationToken) -> public static ValueTask<bool> ShowKeyboardAsync(this ITextInput, CancellationToken)
  • NuGet package will not support Microsoft.Maui.Controls .NET 10 until .NET 10 GA

Analyzer Benchmarks

.NET 9.0 Mean Error StdDev Median Gen0 Gen1 Allocated
VerifyNoErrorsWhenUseMauiCommunityToolkit 8.863 ms 0.1748 ms 0.3240 ms 8.724 ms 62.5000 31.2500 1.59 MB
VerifyNoErrorsWhenUseMauiCommunityToolkitHasAdditionalWhitespace 8.695 ms 0.1654 ms 0.4358 ms 8.528 ms 62.5000 31.2500 1.59 MB
VerifyErrorsWhenMissingUseMauiCommunityToolkit 12.071 ms 0.3756 ms 1.0470 ms 11.546 ms 66.6667 - 2.29 MB
.NET 8.0 Mean Error StdDev Median Gen0 Allocated
VerifyNoErrorsWhenUseMauiCommunityToolkitMediaElement 9.763 ms 0.1928 ms 0.4765 ms 9.633 ms 31.2500 1.46 MB
VerifyNoErrorsWhenUseMauiCommunityToolkitMediaElementHasAdditonalWhitespace 9.565 ms 0.1862 ms 0.4637 ms 9.460 ms 31.2500 1.46 MB
VerifyErrorsWhenMissingUseMauiCommunityToolkitMediaElement 15.495 ms 0.3879 ms 1.0814 ms 15.058 ms 66.6667 2.24 MB

@hansmbakker
Copy link

hansmbakker commented Sep 18, 2024

The errors are because in https://github.com/CommunityToolkit/Maui/blob/feature/sl-dotnet-nine/azure-pipelines.yml the .NET SDK to install is

  • set to the LATEST_NET_VERSION variable instead of picking up the version from global.json
  • set to prevent using prereleases (both in global.json and in azure-pipelines.yml)

See

Maui/azure-pipelines.yml

Lines 73 to 78 in c4169ed

- task: UseDotNet@2
displayName: 'Install Latest .NET SDK, v$(LATEST_NET_VERSION)'
inputs:
packageType: 'sdk'
version: '$(LATEST_NET_VERSION)'
includePreviewVersions: false

Note that the UseDotNet@2 task can pick up global.json to read its settings from - I would recommend to define these SDK settings only in global.json and not redefining it in the pipeline as well.

Copy link
Collaborator

@brminnick brminnick left a comment

Choose a reason for hiding this comment

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

Thanks for updating the Analyzer Unit Tests, Shaun! We can just remove the reference to Net80 since we won't be reverting back to .NET 8 after we update the library to .NET 9.

bijington and others added 2 commits September 19, 2024 20:23
…AnalyzerVerifier`1+Test.cs

Co-authored-by: Brandon Minnick <[email protected]>
…CodeFixVerifier`2+Test.cs

Co-authored-by: Brandon Minnick <[email protected]>
@bijington
Copy link
Contributor Author

The errors are because in https://github.com/CommunityToolkit/Maui/blob/feature/sl-dotnet-nine/azure-pipelines.yml the .NET SDK to install is

  • set to the LATEST_NET_VERSION variable instead of picking up the version from global.json
  • set to prevent using prereleases (both in global.json and in azure-pipelines.yml)

See

Maui/azure-pipelines.yml

Lines 73 to 78 in c4169ed

- task: UseDotNet@2
displayName: 'Install Latest .NET SDK, v$(LATEST_NET_VERSION)'
inputs:
packageType: 'sdk'
version: '$(LATEST_NET_VERSION)'
includePreviewVersions: false

Note that the UseDotNet@2 task can pick up global.json to read its settings from - I would recommend to define these SDK settings only in global.json and not redefining it in the pipeline as well.

Thanks for the suggestions. I know we have been discussing about migrating to GitHub actions so I will leave this with limited change for now

@bijington
Copy link
Contributor Author

We have all check building thanks to @jfversluis for the workaround. I propose we add the workaround into the release notes

jfversluis
jfversluis previously approved these changes Dec 17, 2024
pictos
pictos previously approved these changes Dec 17, 2024
@ne0rrmatrix
Copy link
Contributor

ne0rrmatrix commented Dec 17, 2024

With the latest changes it builds. But clicking on menu's does not work. App loads but I cannot click on navigation link to test any functionality. I have tried the usual dotnet clean and deleting bin/obj folders. It builds and runs but I cannot navigate to any pages from Main Page. This is specific to Mac Catalyst on Mac Mini M2.

edit: After further investigation this is a Release mode issue and debug mode works fine. So possibly another release mode issue if anyone can confirm? Page navigation appears to be non functional in sample app in release mode.

@brminnick brminnick dismissed stale reviews from pictos and jfversluis via 087cbec December 17, 2024 18:17
ne0rrmatrix
ne0rrmatrix previously approved these changes Dec 17, 2024
brminnick
brminnick previously approved these changes Dec 18, 2024
@brminnick brminnick merged commit 725260b into main Dec 18, 2024
10 checks passed
@brminnick brminnick deleted the feature/sl-dotnet-nine branch December 18, 2024 01:14
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.