Support .NET 9.0
Description of Change
Linked Issues
- Fixes #
PR Checklist
- [ ] Has a linked Issue, and the Issue has been
approved(bug) orChampioned(feature/proposal) - [ ] Has tests (if omitted, state reason in description)
- [ ] Has samples (if omitted, state reason in description)
- [ ] Rebased on top of
mainat time of PR - [ ] Changes adhere to coding standard
- [ ] Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls
Additional information
Breaking Changes
- .NET 8 no longer supported
- Remove
PopupService.ShowPopop(TViewModel)- Removes
[Obsolete]method
- Removes
- Remove
PopupService.ShowPopopAsync(TViewModel, CancellationToken)- Removes
[Obsolete]method
- Removes
- Remove ability to subclass
BaseConverter<TFrom, TTo>- Subclassing from
BaseConverter<TFrom, TTo>is not supported - Support requires documentation and complete unit tests
- Subclassing from
- Remove ability to subclass
BaseConverter<TFrom, TTo, TParam>- Subclassing from
BaseConverter<TFrom, TTo, TParam>is not supported - Support requires documentation and complete unit tests
- Subclassing from
- 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
Analyzer Benchmarks
| .NET 9.0 RC2 | Mean | Error | StdDev | Median | Gen0 | Gen1 | Allocated |
|---|---|---|---|---|---|---|---|
| VerifyNoErrorsWhenUseMauiCommunityToolkitMediaElement | 11.20 ms | 0.222 ms | 0.545 ms | 11.13 ms | 62.5000 | 31.2500 | 1.56 MB |
| VerifyNoErrorsWhenUseMauiCommunityToolkitMediaElementHasAdditionalWhitespace | 11.08 ms | 0.220 ms | 0.502 ms | 11.06 ms | 62.5000 | 31.2500 | 1.56 MB |
| VerifyErrorsWhenMissingUseMauiCommunityToolkitMediaElement | 17.08 ms | 0.816 ms | 2.276 ms | 16.15 ms | 90.9091 | - | 2.38 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 |
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_VERSIONvariable instead of picking up the version fromglobal.json - set to prevent using prereleases (both in global.json and in azure-pipelines.yml)
See https://github.com/CommunityToolkit/Maui/blob/c4169edb795bbf6ba917393cf5f0897769239def/azure-pipelines.yml#L73-L78
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.
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_VERSIONvariable instead of picking up the version fromglobal.json- set to prevent using prereleases (both in global.json and in azure-pipelines.yml)
See
https://github.com/CommunityToolkit/Maui/blob/c4169edb795bbf6ba917393cf5f0897769239def/azure-pipelines.yml#L73-L78
Note that the
UseDotNet@2task 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
Hey @bijington! I think we're now super close to having updated everything for .NET 9.
Could you help me resolve this strange XAML error that I can't figure out: https://dev.azure.com/dotnet/CommunityToolkit/_build/results?buildId=110668&view=logs&j=17b0f84d-e186-52d3-858a-533c8ddf3c8c&t=670b1d62-8fe8-5e0d-0040-71e96d237771&l=610
samples/CommunityToolkit.Maui.Sample/Views/Popups/UpdatingPopup.xaml : XamlC error : Object reference not set to an instance of an object.
The compiler is throwing a NullReferenceException, and I can't figure out why! But I'm no XAML expert 😊
Update: This appears to be a bug in RC2 that will be fixed: https://github.com/dotnet/maui/pull/25344
Hey @bijington! I think we're now super close to having updated everything for .NET 9.
Could you help me resolve this strange XAML error that I can't figure out: https://dev.azure.com/dotnet/CommunityToolkit/_build/results?buildId=110668&view=logs&j=17b0f84d-e186-52d3-858a-533c8ddf3c8c&t=670b1d62-8fe8-5e0d-0040-71e96d237771&l=610
samples/CommunityToolkit.Maui.Sample/Views/Popups/UpdatingPopup.xaml : XamlC error : Object reference not set to an instance of an object.
The compiler is throwing a
NullReferenceException, and I can't figure out why! But I'm no XAML expert 😊
Amazing work! Sure I will take a look, I have a clean machine while I complete some work for a client this week but I can try to investigate it over the weekend/early next week.
Probably out of scope for this PR but in my opinion all behaviors that require binding context to operate correctly needed to be ported back to Effects.
I've spoken about it in discord and you can see on this pr that the maui team don't want us adding bindable properties to behaviors...
Regardless of what we've heard about the future of effects, today and in .NET 9 they're more stable, reliable and usable than behaviors!
Probably out of scope for this PR but in my opinion all behaviors that require binding context to operate correctly needed to be ported back to Effects.
I've spoken about it in discord and you can see on this pr that the maui team don't want us adding bindable properties to behaviors...
Regardless of what we've heard about the future of effects, today and in .NET 9 they're more stable, reliable and usable than behaviors!
I really don't know what the answer is here... I am disappointed by the state of Behaviors. It would be nice to get an official statement on how we are supposed to achieve things like this but I don't know how/if we will
As per the chat on the November Standup I have renamed the ValidateOnUnfocus to ValidateOnUnfocusED and the same for the ValidateOnfocus to ValidateOnfocusED.
This PR is blocked by https://github.com/dotnet/maui/issues/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.
Pinged the team on this! But might not be until next week until we get the time to really look into it.
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: https://github.com/CommunityToolkit/Maui.Markup/pull/336#issuecomment-2479585242
Tizen error is fixed
Anyone knows when this is going to be online?
This PR is blocked by https://github.com/dotnet/maui/issues/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.
Things are looking very positive: https://github.com/dotnet/maui/pull/26303#issuecomment-2518488899
Things are looking very positive: dotnet/maui#26303 (comment)
Thanks man. Good news :) Can we say that a nuget update is a day or so away?
Things are looking very positive: dotnet/maui#26303 (comment)
Thanks man. Good news :)
Can we say that a nuget update is a day or so away?
We can say that an update is a day or so away once we receive the official .NET MAUI nuget containing the fix. My test build was against the MAUI nightly feed and I believe we are waiting on SR2 to be released. I am hopeful the release is imminent
Things are looking very positive: dotnet/maui#26303 (comment)
Thanks man. Good news :) Can we say that a nuget update is a day or so away?
We can say that an update is a day or so away once we receive the official .NET MAUI nuget containing the fix. My test build was against the MAUI nightly feed and I believe we are waiting on SR2 to be released. I am hopeful the release is imminent
Thx mate. Appreciate the good work :)
Dang - there is a new error:
ILLink : error IL1012: IL Trimmer has encountered an unexpected error. Please report the issue at https://aka.ms/report-illink [/Users/runner/work/1/s/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj::TargetFramework=net9.0-maccatalyst
https://dev.azure.com/dotnet/CommunityToolkit/_build/results?buildId=112518&view=logs&j=17b0f84d-e186-52d3-858a-533c8ddf3c8c&t=670b1d62-8fe8-5e0d-0040-71e96d237771&l=992
I'll re-add the blocked label while we investigate.
During investigation I found that error is caused by a failing MSBuild task, so I reported the issue to the dotnet runtime, hopefully they can fix it and/or provide a guidance
- https://github.com/dotnet/runtime/issues/110714
This is the exception from the build log above
https://dev.azure.com/dotnet/CommunityToolkit/_build/results?buildId=112518&view=logs&j=17b0f84d-e186-52d3-858a-533c8ddf3c8c&t=670b1d62-8fe8-5e0d-0040-71e96d237771&l=992
ILLink : error IL1012: IL Trimmer has encountered an unexpected error. Please report the issue at https://aka.ms/report-illink [/Users/runner/work/1/s/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj::TargetFramework=net9.0-maccatalyst]
Fatal error in IL Linker
Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Collections.Immutable.ImmutableArray`1.get_Item(Int32 index)
at Mono.Linker.Dataflow.TrimAnalysisMethodCallPattern.Merge(ValueSetLattice`1 lattice, TrimAnalysisMethodCallPattern other)
at Mono.Linker.Dataflow.TrimAnalysisPatternStore.Add(TrimAnalysisMethodCallPattern pattern)
at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.HandleCall(MethodBody callingMethodBody, MethodReference calledMethod, Instruction operation, ValueNodeList methodParams)
at Mono.Linker.Dataflow.MethodBodyScanner.HandleCall(MethodBody callingMethodBody, Instruction operation, Stack`1 currentStack, Dictionary`2 locals, InterproceduralState& interproceduralState, Int32 curBasicBlock)
at Mono.Linker.Dataflow.MethodBodyScanner.Scan(MethodIL methodIL, InterproceduralState& interproceduralState)
at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.Scan(MethodIL methodIL, InterproceduralState& interproceduralState)
at Mono.Linker.Dataflow.MethodBodyScanner.InterproceduralScan(MethodIL startingMethodIL)
at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.InterproceduralScan(MethodIL methodIL)
at Mono.Linker.Steps.MarkStep.MarkReflectionLikeDependencies(MethodIL methodIL, Boolean requiresReflectionMethodBodyScanner, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body, MessageOrigin origin)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.Run(ILogger customLogger)
at Mono.Linker.Driver.Main(String[] args)
And the code can be found here
https://github.com/dotnet/runtime/blob/main/src/tools/illink/src/linker/Linker.Dataflow/TrimAnalysisMethodCallPattern.cs#L45
@espenrl please add the detail to the issue opened at https://github.com/dotnet/runtime/issues/110714
We have all check building thanks to @jfversluis for the workaround. I propose we add the workaround into the release notes
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.