ReactiveUI.Fody ToPropertyEx throws Ambiguous match found

Created on 15 Jun 2020  路  4Comments  路  Source: reactiveui/ReactiveUI

Describe the bug

With Fody 6.1.1 and ReactiveUI.Fody 11.4.1, I have no problems. After upgrading to Fody 6.2.0 and ReactiveUI 11.4.17, every ToPropertyEx binding in my viewmodels fail, throwing an "Ambiguous match found" exception:

System.Reflection.AmbiguousMatchException: Ambiguous match found.
  at System.RuntimeType.GetField (System.String name, System.Reflection.BindingFlags bindingAttr) [0x0006c] in <b3870d1cc8a043b9b772bb481ef361c8>:0 
  at System.Reflection.TypeInfo.GetDeclaredField (System.String name) [0x00000] in <b3870d1cc8a043b9b772bb481ef361c8>:0 
  at ReactiveUI.Fody.Helpers.ObservableAsPropertyExtensions.ToPropertyEx[TObj,TRet] (System.IObservable`1[T] item, TObj source, System.Linq.Expressions.Expression`1[TDelegate] property, TRet initialValue, System.Boolean deferSubscription, System.Reactive.Concurrency.IScheduler scheduler) [0x0005c] in d:\a\1\s\src\ReactiveUI.Fody.Helpers\ObservableAsPropertyExtensions.cs:57 
  at Redacted.ViewModels.Heating.RoomHeatingViewModel..ctor (System.String roomId) [0x00444] in /redacted-mobile/ViewModels/Heating/RoomHeatingViewModel.cs:243 
  ...

Steps To Reproduce

The failing property binding here is declared as such:

The view model property:

public extern InferredRoomHeatingState HeatingState { [ObservableAsProperty] get; }

In the view model constructor:

heatingStateObs.ToPropertyEx(this, vm => vm.HeatingState, scheduler: RxApp.MainThreadScheduler);

I couldn't find any issue talking about this which surprised me, so let me know if I can provide more information.

Environment

  • OS: Linux Ubuntu 20.04
  • Mono version: 6.8.0.123
  • Version: 11.4.17
  • Device: Android 10
bug

Most helpful comment

Hmm...

Thanks for reporting, will have to play around and see what changed for us in Fody 6.2.0

All 4 comments

Hey @toverux :wave:,

Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our Open Collective and consider contributing financially.

https://opencollective.com/reactiveui

PS.: We offer priority support for all financial contributors. Don't forget to add priority label once you start contributing :smile:

An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms!

Hmm...

Thanks for reporting, will have to play around and see what changed for us in Fody 6.2.0

I'm seeing this as well, but it is intermittent.

iOS Simulator 13.6

The exception occurs on the first-ever call to ToPropertyEx. Rebuilding the Xamarin iOS project resolves the issue.

  at System.RuntimeType.GetField (System.String name, System.Reflection.BindingFlags bindingAttr) [0x00062] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/rttype.cs:3417 
  at System.Reflection.TypeInfo.GetDeclaredField (System.String name) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Reflection/TypeInfo.cs:19 
  at ReactiveUI.Fody.Helpers.ObservableAsPropertyExtensions.ToPropertyEx[TObj,TRet] (System.IObservable`1[T] item, TObj source, System.Linq.Expressions.Expression`1[TDelegate] property, TRet initialValue, System.Boolean deferSubscription, System.Reactive.Concurrency.IScheduler scheduler) [0x0005c] in d:\a\1\s\src\ReactiveUI.Fody.Helpers\ObservableAsPropertyExtensions.cs:57
...

A few fixes have been published to both ReactiveUI and Fody and my Mono installation got an upgrade too, so I tried upgrading again.
Everything works with the latest releases of those libraries.

Was this page helpful?
0 / 5 - 0 ratings