$ show Fody/PropertyChanged
PropertyChanged.Fody is a Fody add-in (weaver) and Roslyn source generator that automates the implementation of INotifyPropertyChanged (and optionally INotifyPropertyChanging) for .NET classes. The weaver operates on compiled IL using Mono.Cecil, injecting property change notification code into property setters, while the optional source generator emits boilerplate for partial classes at compile time. The tool supports multiple invocation patterns (event, OnPropertyChanged methods, before/after callbacks), attribute-driven dependency detection ([DependsOn], [AlsoNotifyFor]), equality checks before notifications, and extensible interceptors. Configuration is done via FodyWeavers.xml attributes or custom attributes on classes/properties. The project is mature, well-tested, and widely used (nearly 2000 stars), with extensive test coverage across inheritance, generics, nullable types, F#, and integration with MVVM frameworks like Caliburn.Micro and ReactiveUI.
The LLM identified 4 files worth highlighting for reuse:
Recursively follows method calls in IL to find all instructions reachable from a given method. This is used for automatic dependency detection (e.g., which properties are read in a getter). It is self-contained, works with Mono.Cecil's MethodBody, and can be reused in any IL analysis tool requiring transitive instruction discovery.
Analyzes IL of property getters to automatically infer data dependencies (e.g., FullName depends on GivenNames and FamilyName). It handles auto-properties, camelCase fields, underscores, generic types, and lambdas. This is a non-obvious and reusable pattern for any system that needs to deduce property dependencies from compiled code.
A simple cache that stores PropertyChangedEventArgs instances keyed by property name to avoid repeated allocations during event firing. It uses a ConcurrentDictionary for thread safety and demonstrates an optimization pattern that can be applied in any .NET application that raises PropertyChanged events frequently.
Provides methods for building indented C# source code lines, including AppendLine, AppendIndentedLine, and IncreaseIndent/DecreaseIndent. It's a small but clean utility that isolates indentation logic and can be reused in any C# source generator or code template engine.