Git Product home page Git Product logo

reactiveui.fody's Introduction

ReactiveUI.Fody

Windows Build Status

C# Fody extension to generate RaisePropertyChange notifications for properties and ObservableAsPropertyHelper properties.

Install

Nuget package ReactiveUI.Fody:

Install-Package ReactiveUI.Fody

Currently, you need to manually add <ReactiveUI /> to your Fody weavers configuration. If this is your first Fody plugin then FodyWeavers.xml should look like this after the change:

<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
    <ReactiveUI />
</Weavers>

##Reactive Properties##

Eases the need for boilerplate in your view models when using reactiveui. Typically, in your view models you must declare properties like this:

string _SearchId;

public string SearchId 
{
    get { return _SearchId; }
    set { this.RaiseAndSetIfChanged(ref _SearchId, value); }
}

This is tedious since all you'd like to do is declare properties as normal:

[Reactive]public string SearchId { get; set; }

If a property is annotated with the [Reactive] attribute, the plugin will weave the boilerplate into your output based on the simple auto-property declaration you provide.

##ObservableAsPropertyHelper Properties

Similarly, in order to handle observable property helper properties, you must declare them like this:

ObservableAsPropertyHelper<string> _PersonInfo;

public string PersonInfo 
{
    get { return _PersonInfo.Value; }
}

Then elsewhere you'd set it up via:

...
.ToProperty(this, x => x.PersonInfo, out _PersonInfo);

This plugin will instead allow you to declare the property like:

public extern string PersonInfo { [ObservableAsProperty]get; }

It will generate the field and implement the property for you. Because there is no field for you to pass to .ToProperty, you should use the .ToPropertyEx extension method provided by this library:

...
.ToPropertyEx(this, x => x.PersonInfo);

This extension will assign the auto-generated field for you rather than relying on the out parameter.

reactiveui.fody's People

Contributors

bradtwurst avatar butlerpeter avatar domyd avatar ghuntley avatar hallsbyra avatar kirkplangrid avatar kswoll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reactiveui.fody's Issues

Make unit testing new changes not rely on nuget package

Currently, it's virtually impossible to unit test new changes because the test project relies on the nuget package, which ideally won't be updated until after the test passes. Therefore, change the setup of the test project so that it uses In Solution Weaving where the Weavers folder will be populated by the ReactiveUI.Fody assemblies.

Reactive attribute doesn't appear to function

I'm done a small test console application which compiles correctly (after changing the assembly name for the net45 build for the fodyhelper) but I don't appear to be seeing property values changing.

Simple app :

class Program
{
    public class ViewModel:ReactiveObject
    {
        [Reactive] public int Value1 { get; set; }

        private int _value2;

        public int Value2 { get { return _value2; } set { this.RaiseAndSetIfChanged(ref _value2, value); } }
    }

    public class View : ReactiveObject
    {
        private readonly ViewModel _model;

        public View(ViewModel model)
        {
            _model = model;

            this.WhenAnyValue(m => m._model.Value1).Subscribe(x => Console.WriteLine("value1 ={0}", x));
            this.WhenAnyValue(m => m._model.Value2).Subscribe(x => Console.WriteLine("value2 ={0}", x));
        }
    }

    static void Main(string[] args)
    {
        ViewModel vm = new ViewModel();

        View v = new View(vm);

        vm.Value1 = 2;
        vm.Value2 = 2;

        vm.Value1 = 3;
        vm.Value2 = 3;

        Console.ReadLine();
    }
}

Which produces the output :
value1 =0
value2 =0
value2 =2
value2 =3

which is clearly not right.

ReactiveUI.Fody breaks the Windows Forms designer

Repo

  1. Clone this repo -> https://github.com/ghuntley/hmmpth
  2. Build
  3. Drag user control which uses ToPropertyEx
  4. 💥

Remarks

The exception will be that 7.0.0.0 cannot be found, after adding a binding redirect from that to 7.3.0.0:

+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="ReactiveUI" />
+        <bindingRedirect oldVersion="7.0.0.0" newVersion="7.3.0.0"/>
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>

The exception becomes a little more clear.

---------------------------
Microsoft Visual Studio
---------------------------
Failed to create component 'ColorPickerControl'.  The error message follows:

 'System.TypeLoadException: Could not load type 'ColorPicker.ColorPickerViewModel' from assembly 'ColorPicker, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because the method 'get_Color' has no implementation (no RVA).

   at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)

   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)

   at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Boolean allowPrivate, Assembly& assembly, String description)

   at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description)

   at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchProjectEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, As...'
---------------------------
OK   
---------------------------

Some quick googling lead me to here http://blog.jongallant.com/2009/02/method-has-no-implementation/

Please Update to RxUI 7

Hi,

I just had to find out that ReactiveUI.Fody doesn't work with RxUI7

Please help to make it work again.

Thanks a lot
Thomas

Please support latest Mono.Cecil

Hi,
it turns out if you update to VS2017 and mono 5.0 there are some problems when building with fody. This is part of a reply I got from Xamarin:

We found a possibly related issue that’s also affecting other scenarios. If you’re using VS2017, could you try changing all your class library to be ‘portable’? You can do that in each project’s Build > Advanced section, or you can just place this value in a Directory.Build.targets at the root, with the following contents:

            <PropertyGroup>

                            <DebugType>portable</DebugType>

            </PropertyGroup>

(there was an unintended change in Mono.Cecil that caused full PDB files to not be properly disposed).

Problem is, if you switch to Portable PDBs, Fody uses an older Mono.Cecil that doesn’t support PPDBs :(. Updating all Fody nugets yields an almost working solution, but I’m still getting:

"C:\Users\kzu\Downloads\JistTV\JistTV\JistTV.iOS\JistTV.iOS.csproj" (Build target) (1) ->

(FodyTarget target) ->

MSBUILD : error : Fody: The weaver assembly 'ReactiveUI.Fody, Version=2.0.66.0, Culture=neutral, PublicKeyToken=null' references an out of date version of Mono.Cecil.dll (cecilReference.Version). At least version 0.10 is expected. The weaver needs to add a NuGet reference to FodyCecil version 2.0. [C:\Users\kzu\Downloads\JistTV\JistTV\JistTV.iOS\JistTV.iOS.csproj]

So that one is outdated and no updates are available :(

Also, I’m using latest stable (15.2), which requires updating System.ValueTuple to 4.3.1.

There are sooooo many moving pieces… Any chance you can get an updated version of ReactiveUI.Fody or remove it entirely?

I'm sure a lot of users will soon run into that problem.
Would be awesome if you could have a look at it
Cheers
Thomas

exception when building on a project that has no [Reactive] (or any) attributes defined.

Repro

File -> New Project (PCL 111)
PM> Install-Package ReactiveUI
PM> Install-Package Fody
PM> Install-Package ReactiveUI.Fody

Compile.

Error

Severity    Code    Description Project File    Suppression State   Line
Error       Fody: An unhandled exception occurred:
Exception:
Could not find assembly: ReactiveUI.Fody.Helpers (System.Runtime, System.Resources.ResourceManager, Splat, ReactiveUI, System.Diagnostics.Debug, System.Collections, Akavache, System.Linq.Expressions, System.Threading.Tasks, System.Reactive.Core, System.Reactive.Linq, SimpleFeedReader, Akavache.Sqlite3, System.Reactive.Interfaces, System.Reflection, Conditions, System.ObjectModel)
StackTrace:
at ReactiveUI.Fody.ReactiveUIPropertyWeaver.Execute() in c:\projects\reactiveui-fody\ReactiveUI.Fody\ReactiveUIPropertyWeaver.cs:line 36
at ReactiveUI.Fody.ModuleWeaver.Execute() in c:\projects\reactiveui-fody\ReactiveUI.Fody\ModuleWeaver.cs:line 24
at lambda_method(Closure , Object )
at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 161
at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 82
Source:
ReactiveUI.Fody
TargetSite:
Void Execute()  ReactiveReader.Core         

Add support for Reactive UI 8.0

Reactive UI is release couple of days back and it seems we can't use ReactiveUI.Fody with that version. It would be great to see support for 8.0

NetStandart 1.6 ### XAMARIN FORMS ### FODY 2.2.11

Help me, please, what I must do for deciding this problem:

Severity Code Description Project File Line Suppression State
Error Fody: An unhandled exception occurred:
Exception:
Value cannot be null.
Parameter name: self
StackTrace:
at Mono.Cecil.Rocks.TypeDefinitionRocks.GetConstructors(TypeDefinition self)
at ReactiveUI.Fody.ObservableAsPropertyWeaver.Execute() in C:\projects\reactiveui-fody-ionu7\ReactiveUI.Fody\ObservableAsPropertyWeaver.cs:line 40
at ReactiveUI.Fody.ModuleWeaver.Execute() in C:\projects\reactiveui-fody-ionu7\ReactiveUI.Fody\ModuleWeaver.cs:line 31
at lambda_method(Closure , Object )
at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 180
at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 85
Source:
Mono.Cecil.Rocks
TargetSite:
System.Collections.Generic.IEnumerable`1[Mono.Cecil.MethodDefinition] GetConstructors(Mono.Cecil.TypeDefinition)
CMTKXamarinForms 1

Please Add Generation of ViewModel boiler plate code in Views

Hi,

in all Xaml Views (Xamarin Forms e.g.) we need to add Properties so that the ViewModel can be set:

e.g.

    public partial class StartView : ContentPage,IViewFor<StartViewModel>
    {
        public StartView()
        {
            InitializeComponent();
        }


        public StartViewModel ViewModel
        {
            get { return (StartViewModel)GetValue(ViewModelProperty); }
            set { SetValue(ViewModelProperty, value); }
        }
        public static readonly BindableProperty ViewModelProperty =
            BindableProperty.Create<StartView, StartViewModel>(x => x.ViewModel, default(StartViewModel), BindingMode.OneWay);


        object IViewFor.ViewModel
        {
            get { return ViewModel; }
            set { ViewModel = (StartViewModel)value; }
        }

    }

It would be great if you could add a class attribute that would generate them automatically.

Best
Thomas

ObservableAsProperty no longer works with ReactiveUI 6.5.0

ReactiveUI updated to 6.5.0 recently.

This change is causing the following exception...

Error   3   Fody/ReactiveUI: An unhandled exception occurred:
Exception: Sequence contains more than one matching element
StackTrace:
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   at ReactiveUI.Fody.ReactiveUIPropertyWeaver.Execute() in     c:\Dev\ReactiveUI.Fody\ReactiveUI.Fody\ReactiveUIPropertyWeaver.cs:line 27
   at ReactiveUI.Fody.ModuleWeaver.Execute() in     c:\Dev\ReactiveUI.Fody\ReactiveUI.Fody\ModuleWeaver.cs:line 24
   at lambda_method(Closure , Object )
   at InnerWeaver.Execute() in     c:\TeamCity\buildAgent\work\7495521761d392b9\FodyIsolated\InnerWeaver.cs:line 50
Source:
System.Core
TargetSite:
TSource Single[TSource](System.Collections.Generic.IEnumerable`1[TSource],     System.Func`2[TSource,System.Boolean])
    SalesBudgets

This can be seen in the Fody/FodyAddinSamples project by upgrading to ReactiveUI 6.5.0

Support for NETStandard 1.3 or lower

Hi @kswoll!

It would be nice if ReactiveUI.Fody could be ported to support NETStandard 1.3 or lower. As for now, we are unable to use it with universal windows platform (especially when targeting devices running on good old windows mobile, which is no longer updated).

As described here #26 (comment), UWP releases are not backwards-compatible so in order to use NETStandard 2.0 we have to drop support for older devices and that is not good. I'll try to pull-request if I manage to get it work. A fork from RostislavST also exists here, supporting NETStandard 1.6 https://github.com/RostislavST/Reactive.Fody

Thanks for a great toolset!

Update

Fody is now integrated into ReactiveUI main repository.

Upgraded from 1.1.1 -> 2.2.4 built on ios doesn't work

Hey I updated my Fody and ReactiveUI.Fody today from version 1 to the acutal one

Android works (right now a bit slow, have to look, what you changed, maybe I have to update my code) but iOS doesn't work. When I try to build iOS. While building I get this error:

/Users/xy/dev/universal-app/iOS/MTOUCH: Error MT2002: Failed to resolve assembly: 'ReactiveUI.Fody.Helpers, Version=2.2.4.0, Culture=neutral, PublicKeyToken=null' (MT2002) (App.iOS)

I use .NET Portable PCL 4.5 - Profile7
Fody-version is 2.0.7

When you need more info, just write it down.

One of the advertised dangers of AOP that bit me

Hi,

I have been looking the good last few hours of the day at a problem where one of the nested properties would not announce its change

The problem was not that it was nested but that the the type of the nested properties was not inheriting from ReactiveObject.
The weaver gives not error and there is no run time warning in the output console.

Can we throw an error while weaving or let Fody inject the inheritance to ReactiveObject if its not already inheriting?
I suspect others will run into this as well when using it in a bit more advanced scenarios

Kr, Tom

Xamarin Studio on OS X cannot run Unit Tests

Hi, I wanted to do a few modifications to this wonderful tool, however I can't seem to manage running the the tests. Any ideas why this might be happening?

Here's the error I've been getting.

Can't find custom attr constructor image: /Users/mindw0rk/Projects/HeyJobs/Fody2/ReactiveUI.Fody.Tests/bin/Debug/ReactiveUI.dll mtoken: 0x0a000011
Unhandled loader error: 8, (null) PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (null)
* Assertion: should not be reached at loader.c:299

ObservableAsPropertyHelper of type long fails to compile

Creating an ObservableAsPropertyHelper of type long with ReactiveUI.Fody fails at compile time with an exception.

Repro

This compiles: ✔️(as do string, double, etc.)

public class MainViewModel : ReactiveObject
{
    public extern int Text { [ObservableAsProperty] get; }
}

This doesn't compile: 🙁

public class MainViewModel : ReactiveObject
{
    public extern long Text { [ObservableAsProperty] get; }
}

Substituting Int64 for long also fails to compile.

Stacktrace

Error		Fody: An unhandled exception occurred:
Exception:
opcode
StackTrace:
   at Mono.Cecil.Cil.Instruction.Create(OpCode opcode)
   at ReactiveUI.Fody.ObservableAsPropertyWeaver.EmitDefaultValue(MethodBody methodBody, ILProcessor il, TypeReference type) in C:\projects\reactiveui-fody-ionu7\ReactiveUI.Fody\ObservableAsPropertyWeaver.cs:line 107
   at ReactiveUI.Fody.ObservableAsPropertyWeaver.<>c__DisplayClass8_1.<Execute>b__12(ILProcessor il) in C:\projects\reactiveui-fody-ionu7\ReactiveUI.Fody\ObservableAsPropertyWeaver.cs:line 84
   at ReactiveUI.Fody.CecilExtensions.Emit(MethodBody body, Action`1 il) in C:\projects\reactiveui-fody-ionu7\ReactiveUI.Fody\CecilExtensions.cs:line 13
   at ReactiveUI.Fody.ObservableAsPropertyWeaver.Execute() in C:\projects\reactiveui-fody-ionu7\ReactiveUI.Fody\ObservableAsPropertyWeaver.cs:line 76
   at ReactiveUI.Fody.ModuleWeaver.Execute() in C:\projects\reactiveui-fody-ionu7\ReactiveUI.Fody\ModuleWeaver.cs:line 31
   at lambda_method(Closure , Object )
   at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 180
   at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 85
Source:
Mono.Cecil
TargetSite:
Mono.Cecil.Cil.Instruction Create(Mono.Cecil.Cil.OpCode)	ReactiveUiFodyTest			

Chaining two ObservableAsProperty throws 'InvalidProgramException'

The code below throws InvalidProgramException when accessing P2. If I make the properties int or Single, it works fine. Just not with doubles.

    class Program
    {
        static void Main(string[] args)
        {
            var vm = new VM();
            Console.WriteLine(vm.P2);
        }
    }

    public class VM : ReactiveObject
    {
        [ObservableAsProperty] public double P1 { get; }
        [ObservableAsProperty] public double P2 { get; }

        public VM()
        {
            Observable.Return(0.0).ToPropertyEx(this, vm => vm.P1);
            this.WhenAnyValue(vm => vm.P1).ToPropertyEx(this, vm => vm.P2);
        }
    }

Watching a nested property

As described in "Watching a nested property" on https://docs.reactiveui.net/en/user-guide/when-any/index.html this should work fine:

this.WhenAnyValue(x => x.Foo.Bar.Baz);

However when I use the [Reactive] attribute in my project the changes of the subproperties are not picked up.
When I switch to the native way of defining the property with RaiseAndSetIfChanged it works.

So I thought that I stumbled upon an edge case where the fody weaver had a problem with.
Making a testproject to isolate the problem did not show the problem. The weaver worked just fine with subproperties.
Then I copy pasted the code in the working isolated project in my project and it started failing again.
After spending a good half day on it I give up.

I cannot give an isolated project that shows the issue. Is someone willing to look at my project and to see why it works with RaiseAndSetIfChanged and not [Reactive]? I'll try to strip out the database so it's easy to run.

2.1.0-beta67 Odd behavior (VS2017)

I was able to use 2.0.66 without any issues, but as soon as I upgraded to the prelease 2.1.0-beta67 version (and changed to KirkFody) Reactive tagged properties no longer functioned correctly. I did not have any build issues however. Is there a list of known issues with the prerelease?

Visual Studio 2017, .NET 4.6.2 C#7

Reactive Attribute suggestion

Might be worth considering adding a parameter to reactive attribute to specify the access modifier for the set property . We have a few scenarios whereby the setting of the property value is internal to the view model and shouldn't be settable by 'outside' classes e.g.

public int Value2 { get { return _value2; } private set { this.RaiseAndSetIfChanged(ref _value2, value); } }

Exception when using ToPropertyEx(this, x => x.myCoolOPAH);

Error Fody: An unhandled exception occurred:

Exception:
Sequence contains no elements

StackTrace:
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at ReactiveUI.Fody.ObservableAsPropertyWeaver.Execute() in c:\projects\reactiveui-fody\ReactiveUI.Fody\ObservableAsPropertyWeaver.cs:line 57
at ReactiveUI.Fody.ModuleWeaver.Execute() in c:\projects\reactiveui-fody\ReactiveUI.Fody\ModuleWeaver.cs:line 31
at lambda_method(Closure , Object )
at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 161
at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 82

Source:
System.Core

TargetSite:
TSource SingleTSource MyCoolApp.Core

Here's an example which will cause it to throw, PCL Profile111:

using ReactiveUI;
using ReactiveUI.Fody.Helpers;

public class MyCoolViewModel()
{
    public extern bool IsLoading { get; }
    public ReactiveCommand<Unit> { get; }

    ctor()
    {
        RefreshCommand = ReactiveCommand.CreateAsyncObservable(x => Whatever());
        RefreshCommand.IsExecuting.ToPropertyEx(this, x => x.IsLoading);
    }
}

Using the following packages:

<package id="Fody" version="1.29.4" targetFramework="portable45-net45+win8+wpa81" developmentDependency="true" />
<package id="reactiveui" version="6.5.0" targetFramework="portable45-net45+win8+wpa81" />
<package id="ReactiveUI.Fody" version="1.1.8" targetFramework="portable45-net45+win8+wpa81" />
<package id="reactiveui-core" version="6.5.0" targetFramework="portable45-net45+win8+wpa81" />

Build the NuGet libraries in release mode

The NuGet dlls can't be used on windows store apps because they are built in debug mode. I had an application I was publishing fail certification because of this. It passed after I built the dlls from source in release mode and replaced the NuGet dlls.

An unhandled exception occurred: Value cannot be null. Parameter name: self

I'm using Fody for the first time and I'm getting an unhandled exception.
It's a netstandard 1.1 library project.
I added both Fody and ReactiveUI.Fody packages and then added the FodyWeavers.xml by hand.
The view model has two constructors (one without parameters and another with a parameter).
It has two ObservableAsProperty but exceptions still happens when I remove them.

1> Fody: Fody (version 1.29.4.0) Executing
1> Fody/ReactiveUI: ReactiveUI 7.0.0.0
1> Fody/ReactiveUI: ReactiveUI.Fody.Helpers 2.0.65.0
1> Fody/ReactiveUI: ReactiveUI 7.0.0.0
1> Fody/ReactiveUI: ReactiveUI.Fody.Helpers 2.0.65.0
1>MSBUILD : error : Fody: An unhandled exception occurred:
1>MSBUILD : error : Exception:
1>MSBUILD : error : Value cannot be null.
1>MSBUILD : error : Parameter name: self
1>MSBUILD : error : StackTrace:
1>MSBUILD : error : at Mono.Cecil.Rocks.TypeDefinitionRocks.GetConstructors(TypeDefinition self)
1>MSBUILD : error : at ReactiveUI.Fody.ObservableAsPropertyWeaver.Execute() in C:\projects\reactiveui-fody\ReactiveUI.Fody\ObservableAsPropertyWeaver.cs:line 41
1>MSBUILD : error : at ReactiveUI.Fody.ModuleWeaver.Execute() in C:\projects\reactiveui-fody\ReactiveUI.Fody\ModuleWeaver.cs:line 31
1>MSBUILD : error : at lambda_method(Closure , Object )
1>MSBUILD : error : at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 161
1>MSBUILD : error : at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 82
1>MSBUILD : error : Source:
1>MSBUILD : error : Mono.Cecil.Rocks
1>MSBUILD : error : TargetSite:
1>MSBUILD : error : System.Collections.Generic.IEnumerable`1[Mono.Cecil.MethodDefinition] GetConstructors(Mono.Cecil.TypeDefinition)
1>MSBUILD : error :
1> Fody: Finished Fody 22ms.

Consider different strategies to fix the CS0626 warning

Consider the following example:

[ObservableAsProperty]
private extern string Example { get; }

This produces the following warning on VS2015, .NET 4.6.1:

Warning CS0626 Method, operator, or accessor 'ViewModel.Example' is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation.

On the other hand, this won't produce a warning, but it looks slightly more complicated (and doesn't work at the moment):

private extern string Example
{
    [ObservableAsProperty]
    get;
}

One solution would be to allow both of the usages. Any other ideas how to solve this, other than suppressing the warning? Contact the Roslyn team?

Thanks for the plugin!

Notify about changes in derived properties

Basically, just like in the very first example for https://github.com/Fody/PropertyChanged weaver, I have these three properties:

[Reactive] public int GamesPlayed { get; set; }
[Reactive] public int GamesWon { get; set; }
public int WinRate => Math.Round((double)GamesWon / GamesPlayed * 100);

If I try to annotate WinRate with [Reactive] attribute, your weaver complains that it doesn't have setter so it can't change. Well, that's not correct - it does change when either GamesWon or GamesPlayed changes.

I would like the weaver to inject notification for derived property WinRate into auto-generated notifiers for source properties GamesWon and GamesPlayed, just like how PropertyChanged.Fody does it currently for WPF applications.

VS2017: Live Unit Testing - Unhandled Exception - Sequence contains more than one element

Hi,

Downloaded VS2017 Enterprise and wanted to try the new Live Unit Testing feature in my Xamarin Forms project (PCL, iOS & Android project). Building these projects manually works fine, but when I try to start the Live Unit Testing feature and it tries to build this error occurs:

[12:28:56.291 Verbose] - BuildManager - (0,0): error : Fody: An unhandled exception occurred:
Exception:
Sequence contains more than one element
StackTrace:
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at ReactiveUI.Fody.ReactiveUIPropertyWeaver.Execute() in C:\projects\reactiveui-fody\ReactiveUI.Fody\ReactiveUIPropertyWeaver.cs:line 68
   at ReactiveUI.Fody.ModuleWeaver.Execute() in C:\projects\reactiveui-fody\ReactiveUI.Fody\ModuleWeaver.cs:line 24
   at lambda_method(Closure , Object )
   at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 161
   at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 82
Source:
System.Core
TargetSite:
TSource Single[TSource](System.Collections.Generic.IEnumerable`1[TSource])`

I'll try and see if I can debug this. Just wanted to create an issue in case someone else tries and or have a workaround/solution

Update to Fody Version 2

Fody Version 2 is out and you will need to do an update for your addin to be usable with it

Specifically:

  • Update to the newest Fody.Cecil nuget
  • Change the min dependency range for Fody to be at least 2.0

Please ping me if u need help

Using ReactiveUI.Fody with property initialisers result in unit tests looking for backing fields

We are using ReactiveUI.Fody with C#6, so are taking advantage of property initialisers.
If we have the following code :

[ReactiveUI]
public ObservableCollection<int> {get;set;} = new ObservableCollection<int>();

The unit tests (that use AutoMocker) fail to run, as they are searching for the backing field (not explicitly). If, however, we initialise the property in the constructor, the problem goes away (but we lose the usage of property initialisers).

Just upgraded to ReactiveUI.Fody 2.0.66

During building my project I saw

image

Unfortunately not an opensource project so I can't point you to the sources. Is the stack trace enough for you to figure out what went wrong?

ReactiveUI 6.5.0.0

I have a project using ReactiveUI 6.5.0.0 on which I have just installed your nuget. I now end-up with an application crash saying it can't find ReactiveUI 6.4.0.1. The dependency is properly set to >= on your nuget not = so this should work, isnt' it? I also tried to put a binding redirection into the app.config but except if the key I put is wrong the binding didn't worked.

Any idea?

ReactiveUI 7 Released

Thanks creating this Fody package. Reactive 7 was just released on NuGet in the main feed. When you get a chance, can you update the beta branch's NuGet dependencies to allow reaciveui 7.0.0 instead of 7.0.0.1478039116?

Trouble getting Fody to work

Hi,
I have trouble getting Fody to run its magic after installing it via Nuget. [Reactive] attribute isn't recognized.

Currently, you need to add ReactiveUI to your FodyWeavers.xml manually.

I updated it so it reads:

<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
  <ReactiveUI />
</Weavers>

After project rebuild, Fody throws an error:

Error       Fody: An unhandled exception occurred:
Exception:
Sequence contains no matching element
StackTrace:
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   at ReactiveUI.Fody.ReactiveUIPropertyWeaver.Execute() in c:\Dev\ReactiveUI.Fody\ReactiveUI.Fody\ReactiveUIPropertyWeaver.cs:line 27
   at ReactiveUI.Fody.ModuleWeaver.Execute() in c:\Dev\ReactiveUI.Fody\ReactiveUI.Fody\ModuleWeaver.cs:line 24
   at lambda_method(Closure , Object )
   at InnerWeaver.ExecuteWeavers() in c:\ConsoleBuildAgent\work\ed448661dbb30d2e\FodyIsolated\InnerWeaver.cs:line 144
   at InnerWeaver.Execute() in c:\ConsoleBuildAgent\work\ed448661dbb30d2e\FodyIsolated\InnerWeaver.cs:line 62
Source:
System.Core
TargetSite:
TSource Single[TSource](System.Collections.Generic.IEnumerable`1[TSource], System.Func`2[TSource,System.Boolean])   Util        

That's the following line:

var reactiveObject = ModuleDefinition.FindType("ReactiveUI", "ReactiveObject", reactiveUI);

My ViewModel descends from ReactiveObject.

Null pointer check for ObservableAsProperty

Hi,

Not sure if I'm doing this correctly, but is it possible to initialize value of a field in ObservableAsProperty?
Or maybe even better to have an ability to generate ObservableAsProperty getter with null check?
Otherwise I'm getting exceptions if I'm trying to read properties before my subscriptions kick in.

Thanks

Support PCL targets

Right now a PCL project cannot reference the helper assembly. Create a PCL project to accomodate this.

Conflicts with PropertyChanged.Fody (2.5.3) because of Mono.Cecil version (ReactiveUI.Fody 2.2.11)

Using:
Fody: 3.0.3
PropertyChanged.Fody: 2.5.3
ReactiveUI.Fody: 2.2.11

Fody: The weaver assembly 'ReactiveUI.Fody, Version=2.2.11.0, Culture=neutral, PublicKeyToken=null' references an out of date version of Mono.Cecil.dll. Expected strong name token of '1C-A0-91-87-7D-12-CA-03' but got '50-CE-BF-1C-CE-B9-D0-5E'. The weaver needs to update to at least version 3.0 of FodyHelpers.

Seems like same type of error as Issue #39

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.