Aspect that implements the INotifyPropertyChanged interface for the target type, automatically raising the PropertyChanged event when property values change.
Implements
Namespace: Metalama.Patterns.Observability
Assembly: Metalama.Patterns.Observability.dll
Syntax
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface)]
[Inheritable]
public sealed class ObservableAttribute : Attribute, IAspect<INamedType>, IAspect, ICompileTimeSerializable, ITemplateProvider, IEligible<INamedType>Remarks
This aspect analyzes the dependencies between all properties in the type and ensures that the PropertyChanged
event is raised for all affected properties when a value changes. This includes:
- Automatic properties
- Field-backed properties
- Computed properties that depend on other properties
- Properties that depend on child objects implementing INotifyPropertyChanged
If the target type already implements INotifyPropertyChanged, the aspect will
use the existing OnPropertyChanged method (or equivalent) to raise notifications rather than introducing a new implementation.
When the aspect encounters an unsupported code construct, it reports a warning (code LAMA51**).
Use NotObservableAttribute to exclude specific properties from change notifications,
SuppressObservabilityWarningsAttribute to suppress warnings, or
ConstantAttribute to mark methods whose output depends only on their input parameters.
Constructors
| Name | Description |
|---|---|
| ObservableAttribute() |