Skip to content

CommunityToolkit.Mvvm source generators fail on Visual Studio 17.4.0 Preview 6 and 17.5.0 Preview 1 #493

Closed
@nxtn-staged

Description

@nxtn-staged

Note: this is an external issue in Roslyn, see: dotnet/roslyn#67123.

Describe the bug

I recently updated Visual Studio to 17.5.0 Preview 1.0 and my project starts to fail to build.

1>CSC : warning CS8785: Generator 'INotifyPropertyChangedGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'MissingMethodException' with message 'Method not found: 'System.ReadOnlySpan`1<System.__Canon> System.Collections.Immutable.ImmutableArray`1.AsSpan()'.'
1>CSC : warning CS8785: Generator 'ObservablePropertyGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'MissingMethodException' with message 'Method not found: 'System.ReadOnlySpan`1<System.__Canon> System.Collections.Immutable.ImmutableArray`1.AsSpan()'.'

Regression

No response

Steps to reproduce

  1. Add project files
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0-preview1" />
  </ItemGroup>
  
</Project>
using CommunityToolkit.Mvvm.ComponentModel;

[INotifyPropertyChanged]
partial class Foo
{
    [ObservableProperty]
    private int bar;
}

static class Program
{
    static void Main()
    {
        new Foo().Bar = 42;
    }
}
  1. Build in Visual Studio

Expected behavior

It works.

Screenshots

No response

IDE and version

VS 2022 Preview

IDE version

No response

Nuget packages

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

Nuget package version(s)

8.1.0-preview1

Additional context

I can't always reproduce this. I'm also not sure if it's a problem in this project, but my other source generator dependencies are not affected.

Help us help you

Yes, but only if others can assist

Metadata

Metadata

Assignees

No one assigned

    Labels

    external ⤴️Something related to or caused by an external projectmvvm-toolkit 🧰Issues/PRs for the MVVM Toolkit

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions