Nuget Package: Fody

Fody is a Nuget Packaged that allows you to decorate your code with attributes and from them generate code automatically through IL injection.

From the official project:

Manipulating the IL of an assembly as part of a build requires a significant amount of plumbing code. This plumbing code involves knowledge of both the MSBuild and Visual Studio APIs. Fody attempts to eliminate that plumbing code through an extensible add-in model.

It is also the name of this cute little bird 🙂

Fody

Fody can be found at Github. It has loads of modules and you can create your own modules.

There are some particularly interesting modules such as:

PropertyChanged

Rather than doing this:

public class Foo : INotifyPropertyChanged
{
    private string name;
    public string Name
    {
        get { return name; }
        set
        {
            if (name != value)
            {
                name = value;
                NotifyPropertyChange();
            }
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    public void NotifyPropertyChange([CallerMemberName] string propertyName = null)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

You can simply build it with this:

[PropertyChanged.ImplementPropertyChanged]
public class Foo
{
    public string Name { get; set; }
}

There is also:
Anotar which makes loggin easier.
MethodTimer which makes method performance tracking easier.

Among others.

Advertisements

3 thoughts on “Nuget Package: Fody

  1. Pingback: WPF Controls: Form controls | Coding Wise

  2. Pingback: The MVVM pattern in WPF | Coding Wise

  3. Pingback: Filtering elements in a collection | Coding Wise

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s