-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] Add Fody Weaver #170
Comments
Alternatively a Source Generator could be added. There's an INotifyPropertyChanged changed example here: |
@sparkie108 it's always a good idea to use Source Generation when/where possible. That said IL weaving presents certain advantages. As an example here, let's look at a sample BindingObject. Obviously the goal here is to not have to be so verbose. // No Magic
public class Song : BindingObject
{
public string Title
{
get => GetProperty<string>();
set => SetProperty(value);
}
} With Fody we'd be able to write something closer to: // Using Fody
public class Song : BindingObject
{
public string Title { get; set; }
} The benefit here is that it's clear what our actual goals are with this, we want a public property called Title that has a getter and a setter. We just don't care about the verbosity that comes with what we actually are doing in the getter/setter. The negative here is working with IL is voodoo magic that will drive any remotely sane person, insane. Now let's look at code Gen... // Using Code Gen
public class Song : BindingObject
{
[AutoNotify]
private string title;
} While IL weaving allows you to mutate code, Code Gen is an additive process only and cannot modify existing code in any shape way or form. What this ultimately means is that we could indeed generate the public properties here, however we would be left with a bunch of unused private fields, and ultimately it harms the readability since it is no longer clear what our actual intent is in having a public property named Title with a getter and setter. |
I think the newly released Source Generator would be able to do the same thing? |
need any help with this? does the https://github.com/Fody/PropertyChanged not work with comet OOTB? can i make changes to enable that? |
Description
As discussed on Twitch... A Fody Weaver for Comet should be added to make it easy to implement INotifyPropertyRead/INotifyPropertyChanged
The text was updated successfully, but these errors were encountered: