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

Open
wants to merge 167 commits into
base: main
Choose a base branch
from
Open

Support .NET 9.0 #2215

wants to merge 167 commits into from

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

@brminnick
Copy link
Collaborator

brminnick commented Nov 15, 2024

Hey @JoonghyunCho! We're seeing Tizen build errors on this PR. Could you take a look?

error MSB4057: The target "TizenComputeTpkResourceFiles" does not exist in the project

https://dev.azure.com/dotnet/CommunityToolkit/_build/results?buildId=111570&view=logs&j=765bf613-0e88-5993-dfba-bef6ea201168&t=f10d855c-6930-59c7-f214-dfeb514084ff&l=82

These look to be the same build errors we're seeing on open Maui.Markup PRs: CommunityToolkit/Maui.Markup#336 (comment)

@brminnick brminnick mentioned this pull request Nov 17, 2024
@brminnick brminnick closed this Nov 17, 2024
@brminnick brminnick reopened this Nov 17, 2024
@JoonghyunCho
Copy link
Member

Tizen error is fixed

Choose a reason for hiding this comment

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

Copilot reviewed 384 out of 399 changed files in this pull request and generated no suggestions.

Files not reviewed (15)
  • .editorconfig: Language not supported
  • Directory.Build.props: Language not supported
  • global.json: Language not supported
  • samples/CommunityToolkit.Maui.Sample/AppShell.xaml: Language not supported
  • samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj: Language not supported
  • samples/CommunityToolkit.Maui.Sample/Pages/Alerts/SnackbarPage.xaml: Language not supported
  • samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/AnimationBehaviorPage.xaml: Language not supported
  • samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/CharactersValidationBehaviorPage.xaml: Language not supported
  • samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/EmailValidationBehaviorPage.xaml: Language not supported
  • samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/AnimationBehaviorPage.xaml.cs: Evaluated as low risk
  • samples/CommunityToolkit.Maui.Sample/Pages/Base/BaseGalleryPage.cs: Evaluated as low risk
  • samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/CharactersValidationBehaviorPage.xaml.cs: Evaluated as low risk
  • samples/CommunityToolkit.Maui.Sample/Converters/CompareDoubleToColorConverter.cs: Evaluated as low risk
  • samples/CommunityToolkit.Maui.Sample/Pages/Alerts/AlertsGalleryPage.cs: Evaluated as low risk
  • samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/BehaviorsGalleryPage.cs: Evaluated as low risk
@MauiUIui
Copy link

Anyone knows when this is going to be online?

@brminnick
Copy link
Collaborator

brminnick commented Nov 24, 2024

This PR is blocked by dotnet/maui#25871.

We are unable to provide .NET 9 support to the .NET MAUI Community Toolkits until this issue is resolved by the MAUI engineering team.

Once Microsoft resolves their bug, we will merge this PR and publish it as a new release.

Update: The MAUI team has merged their PR fixing our blocker and has scheduled it's release for .NET 9 SR2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked breaking change This label is used for PRs that include a breaking change
Projects
None yet
10 participants