Adding Fody PropertyChanged breaks Realm (Xamarin)


#1

Had a small test app running fine (populated a realm with a few objects, pulled them out again to bind to a ListView, all very simple). Added in the PropertyChanged.Fody nuget and added to the FodyWeavers.xml. After that all objects in the realm appeared to have null values. Removed the nuget and weavers entry, re-built, and everything fine again.

I know that Realm uses Fody to weave all sorts of magic behind the curtain - would you expect it to be upset by using the PropertyChanged weaver as well?


#2

You can work around this by having the PropertyChanged weaver before Realm.

Do note that this way the Realm weaver can and will override weaving done by PropertyChanged, at least partly.


#3

Thanks, I will give that a go.


#4

I have same problem with PropertyChanged.Fody and Realm.
If I having the PropertyChanged weaver before Realm, set break point, then

System.ArgumentNullException: Value cannot be null.
Parameter name: instruction
at Mono.Cecil.Cil.InstructionOffset…ctor(Instruction instruction)
at Mono.Cecil.Cil.CodeReader.ReadScope(ScopeDebugInformation scope)
at Mono.Cecil.Cil.CodeReader.ReadDebugInfo()
at Mono.Cecil.Cil.CodeReader.ReadMethodBody()
at Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
at Mono.Cecil.MethodDefinition.<>c.<get_Body>b__41_0(MethodDefinition method, MetadataReader reader)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func3 read) at Mono.Cecil.MethodDefinition.get_Body() at Mono.Cecil.MethodDefinition.get_DebugInformation() at Mono.Debugging.Soft.SoftDebuggerSession.LoadPdbType(TypeDefinition type, Dictionary2 fileToSourceFileInfos) in E:\A_work\91\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 2645
at Mono.Debugging.Soft.SoftDebuggerSession.LoadPdbFile(String assemblyFileName, String pdbFileName) in E:\A_work\91\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 2637
at Mono.Debugging.Soft.SoftDebuggerSession.LoadDebugFile(String assemblyFileName, String debugFileName, Func`3 loadDebugFile) in E:\A_work\91\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 2733
at Mono.Debugging.Soft.SoftDebuggerSession.CheckBetterMatch(TypeMirror type, String file, Int32 line, Int32 column, Location found) in E:\A_work\91\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 2755
at Mono.Debugging.Soft.SoftDebuggerSession.FindLocationByMethod(MethodMirror method, String file, Int32 line, Int32 column, Boolean& insideTypeRange) in E:\A_work\91\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 2942
at Mono.Debugging.Soft.SoftDebuggerSession.FindLocationByType(TypeMirror type, String file, Int32 line, Int32 column, Boolean& genericMethod, Boolean& insideTypeRange) in E:\A_work\91\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 2960
at Mono.Debugging.Soft.SoftDebuggerSession.ResolveBreakpoints(TypeMirror type) in E:\A_work\91\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 2454
at Mono.Debugging.Soft.SoftDebuggerSession.HandleTypeLoadEvents(TypeLoadEvent[] events) in E:\A_work\91\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 2008
at Mono.Debugging.Soft.SoftDebuggerSession.HandleEventSet(EventSet es) in E:\A_work\91\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 1549
at Mono.Debugging.Soft.SoftDebuggerSession.EventHandler() in E:\A_work\91\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 1471

PropertyChanged.Fody - 2.2.10
Realm - 3.0
Fody - 2.5
Xamarin.Forms - 3.0.0.482510


#5

Hi and thanks in advance.
I have the same problem:

PropertyChanged.Fody -> 2.5.9
Realm -> 3.1.0
Fody -> 3.1.3

but it is also the same with:

PropertyChanged.Fody -> 2.5.7
Realm -> 3.1.0
Fody -> 3.0.3 (minimum target version between Realm and PropertyChanged)

I absolutely need to find a way… :frowning: