Maui icon indicating copy to clipboard operation
Maui copied to clipboard

Support .NET 9.0

Open bijington opened this issue 1 year ago • 5 comments

Description of Change

Linked Issues

  • Fixes #

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

Additional information

Breaking Changes

  • .NET 8 no longer supported
  • Remove PopupService.ShowPopop(TViewModel)
    • Removes [Obsolete] method
  • Remove PopupService.ShowPopopAsync(TViewModel, CancellationToken)
    • Removes [Obsolete] method
  • 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
  • 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

bijington avatar Sep 18 '24 08:09 bijington

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 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.

hansmbakker avatar Sep 18 '24 08:09 hansmbakker

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

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.

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 avatar Sep 19 '24 19:09 bijington

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

TheCodeTraveler avatar Oct 16 '24 18:10 TheCodeTraveler

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.

bijington avatar Oct 16 '24 19:10 bijington

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!

Axemasta avatar Oct 21 '24 10:10 Axemasta

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

bijington avatar Oct 24 '24 20:10 bijington

As per the chat on the November Standup I have renamed the ValidateOnUnfocus to ValidateOnUnfocusED and the same for the ValidateOnfocus to ValidateOnfocusED.

CliffAgius avatar Nov 07 '24 21:11 CliffAgius

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.

TheCodeTraveler avatar Nov 14 '24 23:11 TheCodeTraveler

Pinged the team on this! But might not be until next week until we get the time to really look into it.

jfversluis avatar Nov 14 '24 23:11 jfversluis

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

TheCodeTraveler avatar Nov 15 '24 19:11 TheCodeTraveler

Tizen error is fixed

JoonghyunCho avatar Nov 18 '24 02:11 JoonghyunCho

Anyone knows when this is going to be online?

MauiUIui avatar Nov 24 '24 01:11 MauiUIui

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.

TheCodeTraveler avatar Nov 24 '24 04:11 TheCodeTraveler

Things are looking very positive: https://github.com/dotnet/maui/pull/26303#issuecomment-2518488899

bijington avatar Dec 04 '24 20:12 bijington

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?

MauiUIui avatar Dec 05 '24 14:12 MauiUIui

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

bijington avatar Dec 05 '24 14:12 bijington

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 :)

MauiUIui avatar Dec 05 '24 19:12 MauiUIui

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.

TheCodeTraveler avatar Dec 12 '24 23:12 TheCodeTraveler

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

pictos avatar Dec 14 '24 21:12 pictos

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 avatar Dec 15 '24 18:12 espenrl

@espenrl please add the detail to the issue opened at https://github.com/dotnet/runtime/issues/110714

bijington avatar Dec 15 '24 18:12 bijington

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

bijington avatar Dec 17 '24 11:12 bijington

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.

ne0rrmatrix avatar Dec 17 '24 15:12 ne0rrmatrix