CommunityToolkit / CommunityToolkit/dotnet

Source generator from MVVM Toolkit requiring LangVersion to be set with Visual Studio 2022 Mac

Open
#227 11 comments 0 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C#
Stars
3.8k
Forks
400
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

When using the source generator from the MVVM Toolkit with Visual Studio 2022 for Mac Release Candidate for a Xamarin Forms 5 app, the following error message is generated:

`CSC : error MVVMTK0008: The source generator features from the MVVM Toolkit require consuming projects to set the C# language version to at least C# 8.0`

Work around on the Mac:
Edit the .csproj and add the following
```xml

preview

```
When `LangVersion` is explicitly set, the code compiles and runs as expected. The autogenerated partial classes do not show up in the solution explorer as they would on the Windows Visual Studio.

### Regression

_No response_

### Steps to reproduce

```text
On Mac with Visual Studio 2022 Release Candidate
1. Create new Xamarin.Forms "blank page" project.
2. Add CommunityToolkit.Mvvm, 8.0.0-preview3 via "Manage nuget packages"
3. Create a new public partial class and add `[INotifyPropertyChanged]` and `[ObservableProperty]` attributes.
4. Build the project.
```

### Expected behavior

Project should compile normally.

### Screenshots

_No response_

### IDE and version

VS 2022 Preview

### IDE version

17.0 build 8754

### Nuget packages

- [ ] CommunityToolkit.Common
- [ ] CommunityToolkit.Diagnostics
- [ ] CommunityToolkit.HighPerformance
- [X] CommunityToolkit.Mvvm (aka MVVM Toolkit)

### Nuget package version(s)

8.0.0-preview3

### Additional context

Sample project to illustrate the problem can be found at https://github.com/anotherlab/mvvmgen

### Help us help you

No, just wanted to report this

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.