You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug]Silent propertyChangedCallback: null generation when using WPF standard DependencyPropertyChangedEventArgs signature in OnChanged #165
When using the [AttachedDependencyProperty] (or [DependencyProperty]) attribute and specifying the OnChanged parameter, the generator silently outputs propertyChangedCallback: null if the specified method uses the standard WPF DependencyPropertyChangedEventArgs signature.
There are no compiler errors or Roslyn warnings, causing the property changed event to silently fail at runtime. Developers can spend hours debugging why their attached properties are not firing, only to discover the generated code hardcoded a null callback.
Steps to reproduce the bug
Define an attached property and specify the OnChanged callback.
Define the callback method using the standard WPF signature (DependencyObject, DependencyPropertyChangedEventArgs).
usingSystem.Windows;usingDependencyPropertyGenerator;namespaceRepro;[AttachedDependencyProperty<string>("Test",OnChanged=nameof(OnTestChanged))]publicstaticpartialclassTestHelper{// Standard WPF signatureprivatestaticvoidOnTestChanged(DependencyObjectd,DependencyPropertyChangedEventArgse){// This will NEVER be called.}}
Expected behavior
Actual Behavior (Generated Code)
The generator fails to parse or match the signature and outputs propertyChangedCallback: null without any warnings.
publicstaticreadonlyglobal::System.Windows.DependencyPropertyTestProperty=global::System.Windows.DependencyProperty.RegisterAttached(name:"Test",propertyType:typeof(string),ownerType:typeof(global::Repro.TestHelper),defaultMetadata:newglobal::System.Windows.FrameworkPropertyMetadata(defaultValue:default(string),flags:global::System.Windows.FrameworkPropertyMetadataOptions.None,propertyChangedCallback:null,// 🚨 Silently set to nullcoerceValueCallback:null,isAnimationProhibited:false),validateValueCallback:null);
Screenshots
No response
NuGet package version
Environment
Framework: .NET 8.0 / .NET 10.0 (WPF)
Package: DependencyPropertyGenerator v1.5.1
Language: C# 12+
IDE
No response
Additional context
The generator should ideally support the standard WPF signature. However, if that signature is explicitly unsupported, the generator must emit a Roslyn Diagnostic Error/Warning (e.g., DPG0001: The signature of the specified OnChanged method is unsupported.) so developers are immediately aware of the issue at compile time.
Proposed Solutions
Immediate Mitigation (Analyzer Warning):
Add a diagnostic analyzer rule that triggers an Error or Warning when OnChanged is specified but no compatible method signature can be found/matched in the target class.
Feature Enhancement:
Support parsing and wiring up methods that accept (DependencyObject d, DependencyPropertyChangedEventArgs e), as this is the universally recognized signature in WPF/UWP/WinUI development.
Activity
kassyi commentedon Jul 24, 2026
I fixed this bug in the following repository: https://github.com/kassyi/DependencyPropertyGenerator.