Skip to content

MVVM Toolkit Source Generator error Unsupported C# language version #613

@woz6

Description

@woz6

Describe the bug

MVVM Toolkit 8.1.0 Code Generator fails with error Unsupported C# language version.

The error description says:
The source generator features from the MVVM Toolkit require consuming projects to set the C# language version to at least C# 8.0. Make sure to add <LangVersion>8.0</LangVersion> (or above) to your .csproj file.

I am running Visual Studio 2022, .NET 6.0 which should be using C# 10.0 by default. Adding <LangVersion>8.0</LangVersion> or <LangVersion>10.0</LangVersion> to the csproj file did not resolve the error.

I am trying to create a WinUI3 project, but have seen the same error reported on StackOverflow by someone who was creating a MAUI project.

This error does not appear when using MVVM Toolkit version 8.0.0

Regression

No response

Steps to reproduce

Windows 10
Visual Studio 2022, version 17.4.5
Create project Blank App, Packaged (WinUI3 in Desktop)
Update Nuget Packages to:
Microsoft.WindowsAppSDK  1.2.230118.102
Microsoft.Windows.SDK.BuildTools  10.0.22621.755

Install Nuget Package:
CommunityToolkit.Mvvm   8.1.0

In Solution Explorer Window, expand Dependencies->Analyzers->CommunityToolKit.Mvvm.SourceGenerators
Error messages are visible 

Source generators do not generate any code.

Expected behavior

There should be no C# language version error and Source Generators should generator code.

Screenshots

No response

IDE and version

VS 2022

IDE version

17.4.5

Nuget packages

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

Nuget package version(s)

8.1.0

Additional context

No response

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