Skip to content

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

@anotherlab

Description

@anotherlab

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

<PropertyGroup>
      <LangVersion>preview</LangVersion>
</PropertyGroup>

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

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
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛An unexpected issue that highlights incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions