dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.26k stars 1.76k forks source link

What to do with all the things .NET 9 has now broken? Where is the official .NET 9 Maui code to compare with and find where things have moved? #25767

Closed jonmdev closed 1 week ago

jonmdev commented 1 week ago

Description

I have gone to .NET 9 with Visual Studio 2022 Preview to try some of @albyrock87 's proposed iOS fixes. However, I am greeted with ~45 or so errors (many redundant) I don't know what to make of.

In general, I would go through the code on GItHub and find classes that have changed, etc. But how does this work when there are multiple versions of .NET concurrently?

ie. What am I looking at on Github when I browse the repository? Is this .NET 8 code? .NET 9 code? Somehow both at once? How is this possible? If I want to see and search the .NET 9 version code, how do I do that?

Broken things for example:

1) AppDelegate.cs (which is premade by Maui) in iOS folder now gives for the existing code:

namespace MauiBuild {
    [Register("AppDelegate")]
    public class AppDelegate : MauiUIApplicationDelegate {
        protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
    }
}

The type or namespace name 'MauiUIApplicationDelegate' could not be found (are you missing a using directive or an assembly reference?)

2) Platform types and namespaces for Android text entry/editor seem to have changed, though the github code does not show anything.

These used to be AndroidX.AppCompat.Widget.AppCompatEditText platformEditor & AndroidX.AppCompat.Widget.AppCompatEditText platformEntry as it shows there but now I get:

The type or namespace name 'AppCompat' does not exist in the namespace 'AndroidX' (are you missing an assembly reference?)

Again, the github code still shows you are referring to AndroidX.AppCompat so where is the evidence this doesn't work anymore?

3) Microsoft.Maui.Platform.MauiTextView used to be the platform view for iOS but now it says it doesn't exist, even though it is still here.

4) Community Toolkit Media Element used to use: WindowStateManager.Default.GetCurrentUIViewController(); which is still visible here but now it claims that no longer exists.

5) W2DGraphicsView seems to have disappeared completely in Windows which is no big deal but weird like the rest.

There are about 45 errors related to things like this (many just duplicates over and over) which do not go away even after deleting bin/obj and cleaning the project.

I do not object to things being moved around or changed. Of course, it is part of the process. But I always find this very confusing. How do I see the updated .NET 9 Maui code if the GitHub repository is still showing .NET 8 code and thus providing no explanation for what is broken and how to fix it?

What is a suggested workflow each time this happens to consult the new code and find the new classes or fixes etc? Where is the new code?

Thanks.

Steps to Reproduce

Upgrade from .NET 8 to .NET 9 and see weird errors with things that supposedly don't exist anymore but still show in the GitHub repository.

Link to public reproduction project repository

n/a

Version with bug

9.0.0-rc.2.24503.2

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.92 SR9.2

Affected platforms

iOS, Android, Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

albyrock87 commented 1 week ago

@jonmdev let me ask a few stupid questions first...

Also, make sure to check whether the package restore was successful.

When I encounter these types of errors it usually means there's something wrong with packages or .NET version.

dotnet-policy-service[bot] commented 1 week ago

Hi @jonmdev. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

mattleibow commented 1 week ago

Did you also update the TFMs to net9? These are all platform types that have gone, so I am thinking the NuGets are not restoring to the correct TFMs.

jonmdev commented 1 week ago

Really stupid on my end. I forgot to change the targets in the csproj to 9.0:

<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>

Thanks to the replies as I remembered from that. It has been a while since the last time I updated and I just forgot. Have a good day all.