Fody / PropertyChanged

Injects INotifyPropertyChanged code into properties at compile time
MIT License
1.88k stars 229 forks source link

Use explicit method instead of On_PropertyName_Changed #237

Closed nganbread closed 7 years ago

nganbread commented 7 years ago

Regarding this feature: https://github.com/Fody/PropertyChanged/wiki/On_PropertyName_Changed

Instead of looking for a method with the correct name, it would be useful to be able to declare it using an attribute instead

Something like:

[OnPropertyChanged(nameof(PropertyChanged))]
public string Property { get; set; }

private void PropertyChanged()
{

}
SimonCropp commented 7 years ago

why would that be useful? you would need to define the same thing on every property resulting in a large amount of duplciation

nganbread commented 7 years ago

Sorry, I meant to say that this functionality could be provided alongside the existing On_PropertyName_Changed

When using the nameof operator it creates a reference between the function and the property which is useful for static analysis tools and usage finding. Also, in the case of working in teams (where developers may not be aware of the weaving), it wouldn't look as magical

NewCoderNotInTown commented 7 years ago

Why the fuck i get email when every cunt fucking comment on a fucking issue. Fuck off I didn't subscribe to your shit

-------- Original message -------- From: Scott notifications@github.com Date: 23/05/2017 06:17 (GMT+01:00) To: Fody/PropertyChanged PropertyChanged@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [Fody/PropertyChanged] Use explicit method instead of On_PropertyName_Changed (#237)

Sorry, I meant to say that this functionality could be provided alongside the existing On_PropertyName_Changed

When using the nameof operator it creates a reference between the function and the property which is useful for static analysis tools and usage finding. Also, in the case of working in teams (where developers may not be aware of the weaving), it wouldn't look as magical

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Fody/PropertyChanged/issues/237#issuecomment-303286167, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AaxJDqCpEEdL8xzbQR2INY5JHGCXRXX2ks5r8l3egaJpZM4NjJ1w.

SimonCropp commented 7 years ago

Sorry but explicitness is not one of the aims of the project. It aims to reduce redundant code. This proposal is not in keeping with those aims

navozenko commented 7 years ago

I agree with @nganbread and suggest to return to this issue. I now got an unpleasant situation, when after renaming a property, the method no longer be called. This mistake was not easy to find. Explicitly specifying the name of the called method would protect against the refactoring problem.

And besides, I agree with @nganbread that the existing "magic" with method calling is an inelegant programming style.

It seems to me that the new attribute that he proposed is a convenient and simple solution.