Open tldrlol opened 6 years ago
When C# 8 is released/Default interface implementations feature is available consider alternative patterns.
For example, in pseudo C#8:
class Person {
public string name;
public int age;
}
interface IHasPerson {
Person { get; }
}
interface INotifyPerson : INotifyPropertyChanged, IHasPerson {
public string Name {
get { return Person.name; }
set {
if (Person.name == value)
return;
Person.name = value;
PropertyChanged(nameof(Name));
}
}
public string Age {
get { return Person.age; }
set {
if (Person.age == value)
return;
Person.age = value;
PropertyChanged(nameof(Age));
}
}
}
class PersonViewModel : INotifyPropertyChanged, IHasPerson, INotifyPerson, {
public Person { get; set; }
}
Alternative patterns may emerge with the shapes/extensions language proposal.
Consider:
In addition to the existing analyzers, that implement the INPC interface, and bind directly to
Foo
, it may be useful to bind directly to members ofFoo
instead.For example:
If this is implemented it should also behave intelligently. It should not offer to create an
INPC
property again for the same field. This can either be done by name (convention), or static analysis of existingINPC
compliant properties.There should also be some form of granularity that of what should be implemented.
public
/internal
.