Open DrPepperBianco opened 1 month ago
Isn't the purpose of a record to be immutable? Making it an ObservableObject complicates this a lot. I have seen the use of records on structs but rarely in classes. What stops you from using a class? you could wrap your record (UserRecord) in the Observable class? May be I am missing something.
public class ObservableUser : ObservableObject
{
private readonly UserRecord user;
public ObservableUser(UserRecord user) => this.user = user;
public string Name
{
get => user.Name;
set => SetProperty(user.Name, value, user, (u, n) => u.Name = n);
}
}
Describe the bug
The purpose of the
ObservableObjectAttribute
is, to add Member ofObservableObject
to a type, that itself cannot derive fromObservableObject
.That is actually the case for record classes.
Because
ObservableObject
is a class and not a record class, a record class cannot derive from it.But if I put
[ObservableObject]
on mypartial record class
there is no source generated.Regression
No response
Steps to reproduce
Expected behavior
The expected behaviour would be, that the methods "OnPropertyChanging" and "OnPropertyChanged" (among others) should be generated and be available at compile time.
Screenshots
No response
IDE and version
VS 2022
IDE version
17.11
Nuget packages
Nuget package version(s)
8.2.2 (but also doesn’t work with 8.3.0)
Additional context
No response
Help us help you
No, just wanted to report this