I want to use Microsoft MVVM Toolkit [ObservableProperty] attribute, it works fine, but in one case I need to use changed method:
[ObservableProperty]
private string? name;
partial void OnNameChanging(string? value)
{
Console.WriteLine($"Name is about to change to {value}");
}
partial void OnNameChanged(string? value)
{
Console.WriteLine($"Name has changed to {value}");
}
But I can't because VS2022 (v17.4.4) always is adding private modifier on this method when file is saving, which cause error:
Note The generated methods are partial methods with no implementation, meaning that if you choose to implement them, you cannot specify an explicit accessibility for them. That is, implementations of these methods should also be declared as just partial methods, and they will always implicitly have private accessibility. Trying to add an explicit accessibility (eg. adding public or private) will result in an error, as that is not allowed in C#.
Adding any modifier (private, internal, public) causing the same error. also removing partial causing error as well. How to force VS2022 to not add private modifier to methods on file save? Or how to remove this error?