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.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
3.07k stars 300 forks source link

Can't compile under linux_x86_64 with dynamic type in ObservableProperty #876

Open jindongjie opened 6 months ago

jindongjie commented 6 months ago

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

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

shahine44 commented 6 months ago

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

jindongjie commented 6 months ago

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