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
I manually changed "PropertyChangedEventArgs(propertyName = null))" -> "PropertyChangedEventArgs(propertyName))" and the PropertyChangedEventArgs.PropertyName came through correctly.
I think this is a bug in ClassModel.Generate()
var param = new CodeParameterDeclarationExpression(typeof(string), "propertyName = null");
param.CustomAttributes.Add(new(TypeRef<System.Runtime.CompilerServices.CallerMemberNameAttribute>()));
var threadSafeDelegateInvokeExpression = new CodeSnippetExpression($"{propertyChangedEvent.Name}?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs({param.Name}))");
param's Name property is set to "propertyName = null" via the constructor, which is correct because CallerMemberNameAttribute requires the parameter to have a default value.
But the string passed to the CodeSnippetExpression constructor reuses the param.Name which is what I believe is creating the bug, because the Name property contains the parameter default expression:
So what do think about changing:
var threadSafeDelegateInvokeExpression = new CodeSnippetExpression($"{propertyChangedEvent.Name}?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs({param.Name}))");
to:
var threadSafeDelegateInvokeExpression = new CodeSnippetExpression($"{propertyChangedEvent.Name}?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName))");
The text was updated successfully, but these errors were encountered:
Hi mganss
I am trying to use the PropertyChanged event handler but I seem to be getting null from PropertyChangedEventArgs.PropertyName.
I noticed that "propertyName = null" is being passed to the PropertyChangedEventArgs constructor inside the generated OnPropertyChanged method.
I manually changed "PropertyChangedEventArgs(propertyName = null))" -> "PropertyChangedEventArgs(propertyName))" and the PropertyChangedEventArgs.PropertyName came through correctly.
I think this is a bug in ClassModel.Generate()
param's Name property is set to "propertyName = null" via the constructor, which is correct because CallerMemberNameAttribute requires the parameter to have a default value.
But the string passed to the CodeSnippetExpression constructor reuses the param.Name which is what I believe is creating the bug, because the Name property contains the parameter default expression:
So what do think about changing:
to:
The text was updated successfully, but these errors were encountered: