-
I see the When adding an interface in PostSharp, if I recall correctly, you either had to add the interface yourself with empty methods and PostSharp would replace the method - or the interface was added post-compile and whenever you wanted to pass your object to something expecting INotifyPropertyChanged you'd have to do something like (INotifyPropertyChanged)(object)myObject, and lose all compile-time type safety checking. Is this the case with Metalama, or can you add interfaces via aspects that are recognised at compile time? [NotifyPropertyChanged]
public class Person
{
public void DoSomething()
{
SomeStaticClass.DoSomethingWithAnInstanceOfINotifyPropertyChanged(this);
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
With Metalama, this is not the case anymore. See the NotifyPropertyChanged example at https://try.metalama.net/#inpc or https://github.com/postsharp/Metalama.Samples/tree/master/src/Metalama.Samples.NotifyPropertyChanged . In the Main method, we're referencing the PropertyChanged event from the introduced INotifyPropertyChanged interface. |
Beta Was this translation helpful? Give feedback.
With Metalama, this is not the case anymore. See the NotifyPropertyChanged example at https://try.metalama.net/#inpc or https://github.com/postsharp/Metalama.Samples/tree/master/src/Metalama.Samples.NotifyPropertyChanged .
In the Main method, we're referencing the PropertyChanged event from the introduced INotifyPropertyChanged interface.