dotnet icon indicating copy to clipboard operation
dotnet copied to clipboard

CommunityToolkit.Mvvm v8.4.0 Fails to Compile in Default .NET 10 Project Settings

Open ali50m opened this issue 3 months ago • 7 comments

Describe the bug

I have installed the new released .NET 10 SDK and created a new .NET 10 project.

After installing the CommunityToolkit.Mvvm v8.4.0 NuGet package, the project fails to build using the default project settings.

The compilation errors observed are:

MVVMTK0041 (Error related to the MVVM Toolkit Source Generator)

CS9248 and/or CS8050 (C# language version compatibility errors, suggesting a new C# feature is being used without adequate language support configured).

Workaround / Required Fix:

To resolve these errors and successfully compile the project with CommunityToolkit.Mvvm v8.4.0, I am required to explicitly set the LangVersion property to preview in the project file.

code: Net10MvvmLib.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <!--<LangVersion>preview</LangVersion>-->
    <LangVersion>14.0</LangVersion>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
  </ItemGroup>
</Project>

Person.cs

using CommunityToolkit.Mvvm.ComponentModel;

namespace Net10MvvmLib;

internal partial class Person : ObservableObject
{
    [ObservableProperty]
    public partial string Name { get; set; } = "John";
}
Image

Regression

No response

Steps to reproduce

env: Win 10.0.19044 dotnet SDK 10.0.100 visual studio 18.0.0

Expected behavior

Work properly.

Screenshots

No response

IDE and version

Other

IDE version

vs 2026 community

Nuget packages

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

Nuget package version(s)

8.4.0

Additional context

No response

Help us help you

No, just wanted to report this

ali50m avatar Nov 12 '25 03:11 ali50m

This is expected, it's because we need to publish a new version of the MVVM Toolkit targeting the version of Roslyn supporting C# 14, but that's not available just yet. I've started working on things and will finish that up when the new dependencies are available 🙂

Sergio0694 avatar Nov 12 '25 05:11 Sergio0694

@Sergio0694 is there a ticket open for the roslyn team to publish that nuget package?

sensslen avatar Nov 16 '25 15:11 sensslen

Don't think so, but they're working on it.

Also, as a temporary workaround, just set <LangVersion>preview</LangVersion> in your .csproj file 🙂

Sergio0694 avatar Nov 16 '25 18:11 Sergio0694

Don't think so, but they're working on it.

Also, as a temporary workaround, just set <LangVersion>preview</LangVersion> in your .csproj file 🙂

Thanks for the response. I'm using the suggested workaround - however that does not really feel right, as it potentially allows me to use features I don't want to use right now (preview features). Waiting eagerly for the new release

sensslen avatar Nov 17 '25 07:11 sensslen

Also, as a temporary workaround, just set <LangVersion>preview</LangVersion> in your .csproj file 🙂

Please roll out an updated version that functions without relying on the language's preview feature.

egvijayanand avatar Nov 17 '25 13:11 egvijayanand

Any news on this?

sensslen avatar Dec 03 '25 13:12 sensslen

Hello @Sergio0694. Thank you for looking into this. Are there any news on this, please?

MichaelShapiro avatar Dec 09 '25 18:12 MichaelShapiro