CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.

Home Page:https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't compile under linux_x86_64 with dynamic type in ObservableProperty

LoongArum opened this issue · comments

Describe the bug

I'm trying to compile a C# Avalonia crossplatform project on Linux that uses the MVVM Community Toolkit. The project compiles and runs fine on Windows, but on Linux I'm getting a compilation error with the following line of code:

[ObservableProperty]
private dynamic _selectedDevice = null!;

The program compiles without errors on Windows, even when I target Linux as the runtime. However, when I transfer the compiled program to a Linux machine and try to run it, it fails with the following error:

/home/admin/Desktop/code/BTS/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator/WD_BTS.ViewModels.MainWindowViewModel.g.cs(63,46): error CS8716: There is no target type for the default literal.
/home/admin/Desktop/code/BTS/CommunityToolkit.Mvvm.SourceGenerators/CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator/WD_BTS.ViewModels.MainWindowViewModel.g.cs(67,45): error CS8716: There is no target type for the default literal.

Regression

8.2.2

Steps to reproduce

1. Make sure you are in a Linux environment.
2. Create a new cross-platform project using Avalonia. Make sure to select the Community Toolkit for MVVM during the setup.
3. Create a new View and ViewModel.
4. In the ViewModel, try to write the following code: 
[ObservableProperty]
private dynamic _selectedDevice = null!

Expected behavior

Code work fine :)

Screenshots

No response

IDE and version

Rider

IDE version

No response

Nuget packages

  • CommunityToolkit.Common
  • CommunityToolkit.Diagnostics
  • CommunityToolkit.HighPerformance
  • CommunityToolkit.Mvvm (aka MVVM Toolkit)

Nuget package version(s)

8.2.2

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

How often can I not open the Microsoft Store, it opens but does not bring the applications

How often can I not open the Microsoft Store, it opens but does not bring the applications我多久可以不打开 Microsoft 商店,它会打开但不带来应用程序

I have no-idea what's your talking about :(