kswoll / ReactiveUI.Fody

C# Fody extension to generate RaisePropertyChange notifications for properties and ObservableAsPropertyHelper properties.
MIT License
154 stars 31 forks source link

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

Open henningms opened 7 years ago

henningms commented 7 years ago

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

kswoll commented 7 years ago

Weird, I don't have enterprise so can't test, but the exception indicates the the generated IL for auto-property in this scenario is different from what we'd expect. It should reference the backing field only once. But somehow the IL is referencing that field twice. It would be interesting if you temporarily disabled the ReactiveUI.Fody plugin and tried to compile. If it's successful, I'd love to take a look at the dll using ILSpy and see what's different in the bytecode from what I expect.