Skip to content
This repository has been archived by the owner on Apr 15, 2021. It is now read-only.

[WIP] feature: Bring ReactiveUI.Fody #10

Merged
merged 1 commit into from
Sep 7, 2018
Merged

[WIP] feature: Bring ReactiveUI.Fody #10

merged 1 commit into from
Sep 7, 2018

Conversation

worldbeater
Copy link
Contributor

@worldbeater worldbeater commented Sep 5, 2018

ReactiveUI team has finished working on the ReactiveUI.Fody package so it is now available on NuGet. ReactiveUI.Fody provides an efficient way of managing boilderplate code, instead of writing this:

public class ReactiveViewModel : ReactiveObject 
{
    private string password;
    public string Password
    {
        get => this.password;
        set => this.RaiseAndSetIfChanged(ref password, value);
    }
}

With ReactiveUI.Fody we would write this:

public class ReactiveViewModel : ReactiveObject 
{
    [Reactive] public string Password { get; set; }
}

So let's use ReactiveUI stable release and bring codegen to Egram.Tel! Why not?
Let's discuss. 🥇

@x2bool
Copy link
Collaborator

x2bool commented Sep 6, 2018

Hi, thanks!

Could you please explain how this works. Does it generate code behind the scenes? If so, when this happens?

Is referencing ReactiveUI.Fody enough? Or do I have to follow some special build instructions?

@worldbeater
Copy link
Contributor Author

worldbeater commented Sep 6, 2018

@x2bool thank you for your interest!

To make ReactiveUI.Fody work we have to do two things:

  1. dotnet add package ReactiveUI.Fody
  2. Create a FodyWeavers.xml file at project root to tell Fody we'd like to use ReactiveUI.Fody weaver.

After we've done this, Fody will edit the IL code of our Assembly at compile time and all of our properties marked with [Reactive] attributes will turn into valid ReactiveUI properties with backing fields and this.RaiseAndSetIfChanged method calls. Fody uses Mono.Cecil under the hood, see their github repo and a great article explaining how this works.


BTW, would you mind adding your app to the ReactiveUI sample apps list? :)

@x2bool
Copy link
Collaborator

x2bool commented Sep 7, 2018

I'll merge this. However this repo is a bit outdated. I will push fresh version tomorrow. Thanks for letting me know how this works. I'll upgrade egram to use ReactiveUI.Fody everywhere.

@x2bool
Copy link
Collaborator

x2bool commented Sep 7, 2018

You can add this repo as an example to ReactiveUI sample apps list if you like.

@x2bool x2bool merged commit 5c44608 into egramtel:master Sep 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants