The source generator is creating code, only if I build the solution.
Please look at the first image.
The annotated field _title
does have the corresponding property Title
. This property was generated only after building the project.
Without building the project it looked like the annotated field _copyright
. There is no code generated. The property does not exist. If the project is build, then the property does show up (or if the generator is manually triggered to re-run).
This happens with all my existing WPF-apps, although they have worked properly in spring this year (Version 8.2.2). I did not touch them since then. I have done my research, but some how I am standing on my toes.
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SampleCommunityToolkit.ViewModels;
public partial class HomeViewModel : ObservableObject
{
[ObservableProperty]
private string? _title;
[ObservableProperty]
private string? _copyright;
public HomeViewModel()
{
Title = "Hello World App";
}
}
After going through all the settings of TextEditor/C#/CodeGeneration
in VS, the answer was found.
Selecting Automatic
turned on the behavior as I knew it.
Maybe this saves someone hours of research and frustration. I was doubting myself so much.