Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.

[net8.0] fix C# compiler error involving x:Name#242

Merged
jonathanpeppers merged 9 commits intonet8.0from
fix-net8.0
Oct 23, 2023
Merged

[net8.0] fix C# compiler error involving x:Name#242
jonathanpeppers merged 9 commits intonet8.0from
fix-net8.0

Conversation

@jonathanpeppers
Copy link
Copy Markdown
Member

Context: dotnet/maui#5611
Fixes: #239

The net8.0 branch currently fails to build with:

src/Mobile/Controls/Player.xaml.cs(54,9): error CS0103: The name 'podcastImage' does not exist in the current context
src/Mobile/Controls/Player.xaml.cs(55,9): error CS0103: The name 'duration' does not exist in the current context

We think that x:Name in .NET 8 appropriately "skips" emitting fields when used in combination with <OnPlatform/>.

We can condition the C# code accessing these files with #if WINDOWS || MACCATALYST to solve this.

There are also a lot places using <On Platform="UWP, macOS">, we could consider cleaning these up in a future PR.

Context: dotnet/maui#5611
Fixes: #239

The `net8.0` branch currently fails to build with:

    src/Mobile/Controls/Player.xaml.cs(54,9): error CS0103: The name 'podcastImage' does not exist in the current context
    src/Mobile/Controls/Player.xaml.cs(55,9): error CS0103: The name 'duration' does not exist in the current context

We think that `x:Name` in .NET 8 appropriately "skips" emitting fields
when used in combination with `<OnPlatform/>`.

We can condition the C# code accessing these files with `#if WINDOWS ||
MACCATALYST` to solve this.

There are also a lot places using `<On Platform="UWP, macOS">`, we could
consider cleaning these up in a future PR.
@jonathanpeppers
Copy link
Copy Markdown
Member Author

There are errors on Catalyst now:

D:\a\dotnet-podcasts\dotnet-podcasts\src\Mobile\Controls\Player.xaml.cs(49,14): error CS1061: 'Player' does not contain a definition for 'playButton' and no accessible extension method 'playButton' accepting a first argument of type 'Player' could be found (are you missing a using directive or an assembly reference?) [D:\a\dotnet-podcasts\dotnet-podcasts\src\Mobile\Microsoft.NetConf2021.Maui.csproj::TargetFramework=net8.0-maccatalyst]
D:\a\dotnet-podcasts\dotnet-podcasts\src\Mobile\Controls\Player.xaml.cs(51,9): error CS0103: The name 'epiosdeTitle' does not exist in the current context [D:\a\dotnet-podcasts\dotnet-podcasts\src\Mobile\Microsoft.NetConf2021.Maui.csproj::TargetFramework=net8.0-maccatalyst]
D:\a\dotnet-podcasts\dotnet-podcasts\src\Mobile\Controls\Player.xaml.cs(52,9): error CS0103: The name 'authorText' does not exist in the current context [D:\a\dotnet-podcasts\dotnet-podcasts\src\Mobile\Microsoft.NetConf2021.Maui.csproj::TargetFramework=net8.0-maccatalyst]
D:\a\dotnet-podcasts\dotnet-podcasts\src\Mobile\Controls\Player.xaml.cs(55,9): error CS0103: The name 'podcastImage' does not exist in the current context [D:\a\dotnet-podcasts\dotnet-podcasts\src\Mobile\Microsoft.NetConf2021.Maui.csproj::TargetFramework=net8.0-maccatalyst]
D:\a\dotnet-podcasts\dotnet-podcasts\src\Mobile\Controls\Player.xaml.cs(56,9): error CS0103: The name 'duration' does not exist in the current context [D:\a\dotnet-podcasts\dotnet-podcasts\src\Mobile\Microsoft.NetConf2021.Maui.csproj::TargetFramework=net8.0-maccatalyst]

I'll go through some more of these tomorrow.

@jonathanpeppers jonathanpeppers marked this pull request as draft October 18, 2023 22:11
Comment thread src/Mobile/Controls/Player.xaml.cs Outdated
error NETSDK1147: To build this project, the following workloads must be installed: wasi-experimental
@jonathanpeppers
Copy link
Copy Markdown
Member Author

Some reason today, the nightly builds are getting:

error NETSDK1147: To build this project, the following workloads must be installed: wasi-experimental

Will investigate tomorrow, this is a new/different problem.

@jonathanpeppers jonathanpeppers marked this pull request as ready for review October 23, 2023 15:42
@jonathanpeppers
Copy link
Copy Markdown
Member Author

I fixed this just by using our .NET 8 RC 2 builds, instead of nightly builds. I think we are at a point this branch should just use the released bits.

Copy link
Copy Markdown
Member

@ivanpovazan ivanpovazan left a comment

Choose a reason for hiding this comment

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

According to macOS -> MacCatalyst changes, should we also change:

Apart from that, looks good, and thank you for looking into this!

@jonathanpeppers jonathanpeppers merged commit 9cae3c9 into net8.0 Oct 23, 2023
@jonathanpeppers jonathanpeppers deleted the fix-net8.0 branch October 23, 2023 16:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants