Skip to content

Results of the MVVM source generator are not always compiled #750

Open
@mscholz5

Description

@mscholz5

Describe the bug

I have a solution consisting of multiple projects. Some are libraries and some are desktop applications based on WPF/XAML.
All projects use the code MVVM source generator.

The build of the desktop applications fail with CS0103 in the output window.
The build of the library projects works.

In both cases does IntelliSense not show any errors and I also find the generated code under "Analyse".

"CompilerGeneratedFilesOutputPath" and "EmitCompilerGeneratedFiles" also work only for the library projects, but not for the app projects.
Setting "IncludePackageReferencesDuringMarkupCompilation" to "true" does not solve anything.

Steps to reproduce

  1. Create a C# desktop application project within Visual Studio 17.7.2 based on WPF/XAML/.NET Framework 4.6.2.
  2. Add a nuget package MvvmToolkit v8.2.1
  3. Add the following code
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace example
{
    internal partial class MyClass : ObservableObject
    {
        [ObservableProperty]
        int _foo; // warning CS0169

        [RelayCommand]
        void Bar()
        {
            Foo = 1;  // error CS0103
        }
    }
}

Expected behavior

I expect, that the code generator is working also for the WPF/XAML projects.

IDE and version

VS 2022

IDE version

17.7.2

Nuget packages

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

Nuget package version(s)

8.2.1

Help us help you

I could support, but I do not know how to start. It looks as if the compiler discards the generated sources under unknown circumstances. Perhaps this is a topic for the Microsoft VS-Team.

Metadata

Metadata

Assignees

No one assigned

    Labels

    analyzer 👓A new analyzer being implemented or updatedbug 🐛An unexpected issue that highlights incorrect behaviormvvm-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