-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
Hey guys,
I've been talking to @nirinchev about a weaving problem I had with our Unity SDK and we've tried to analyse it.
I've eventually found the problem (which was as usual sitting in front of the PC) but still wanted to open an issue for this to improve the UX a bit.
Goals
As a developer I'd like to get notified of schema errors and keep this information until it is fixed.
Expected Results
It would be nice to see the below described error after starting the game.
Actual Results
I keep getting the following error (and only this one):
RealmException: Fody not properly installed. TestObject is a RealmObjectBase but has not been woven.
Steps to Reproduce
(1) Create a new project.
(2) Add Realm as a tarball.
(3) Add a script ('RealmTest') to the 'Main Camera' game obejct.
(4) Replace script content with:
using UnityEngine; using Realms; class TestObject : RealmObject { [PrimaryKey] int PrivateKey { get; set; } int Value; //TestObject() { } TestObject(int value) { Value = value; } } public class RealmTest : MonoBehaviour { void Start() { Debug.Log(RealmConfiguration.GetPathToRealm()); Realm.GetInstance(); } }
(5) Go back to Unity and check the console. The following errors shows up. This is the actual problem that would be fixed be uncommenting line 10.
E:\Repositories\Playground\PublicInitCrash\Assets\RealmTest.cs(12, 5): Class TestObject must have a public constructor that takes no parameters. UnityEngine.Debug:LogError (object) RealmWeaver.UnityWeaver/UnityLogger:Error (string,Mono.Cecil.Cil.SequencePoint) RealmWeaver.Weaver:WeaveType (Mono.Cecil.TypeDefinition) RealmWeaver.Weaver:<Execute>b__38_2 (Mono.Cecil.TypeDefinition) System.Linq.Enumerable:ToArray<RealmWeaver.WeaveTypeResult> (System.Collections.Generic.IEnumerable`1<RealmWeaver.WeaveTypeResult>) RealmWeaver.Weaver:Execute () RealmWeaver.UnityWeaver:WeaveAssemblyCore (string,System.Collections.Generic.IEnumerable`1<string>) RealmWeaver.UnityWeaver/<>c:<Initialize>b__2_0 (string,UnityEditor.Compilation.CompilerMessage[]) UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,string[])
(6) Start the game. The error disappears and another errors appears instead. This is the only error shown as soon as the game is started at least once. The error above does not appear again.
RealmException: Fody not properly installed. TestObject is a RealmObjectBase but has not been woven. Realms.Realm.CreateRealmObjectMetadata (Realms.Schema.ObjectSchema schema) (at <dc2d85e76a334423928ff770d3928607>:0) System.Linq.Enumerable+SelectEnumerableIterator`2[TSource,TResult].MoveNext () (at <351e49e2a5bf4fd6beabb458ce2255f3>:0) Realms.Realm+RealmMetadata..ctor (System.Collections.Generic.IEnumerable`1[T] objectsMetadata) (at <dc2d85e76a334423928ff770d3928607>:0) Realms.Realm..ctor (Realms.SharedRealmHandle sharedRealmHandle, Realms.RealmConfigurationBase config, Realms.Schema.RealmSchema schema) (at <dc2d85e76a334423928ff770d3928607>:0) Realms.RealmConfiguration.CreateRealm (Realms.Schema.RealmSchema schema) (at <dc2d85e76a334423928ff770d3928607>:0) Realms.Realm.GetInstance (Realms.RealmConfigurationBase config, Realms.Schema.RealmSchema schema) (at <dc2d85e76a334423928ff770d3928607>:0) Realms.Realm.GetInstance (Realms.RealmConfigurationBase config) (at <dc2d85e76a334423928ff770d3928607>:0) RealmTest.Start () (at Assets/RealmTest.cs:23)
(7) Restarting, making more code changes - anything really - keeps this result.
Code Sample
https://github.com/DominicFrei/Playground/tree/realm/realm-dotnet/public-init-crash
(you'll probably have to import the Realm SDK again since it's not part of the repo)
Version of Realm and Tooling
Realm SDK: realm.unity.bundle-10.5.0-PR-2305.3.tgz (does happen with https://github.com/realm/realm-dotnet/releases/tag/10.1.2 too)
Unity Hub: 2.4.3
Unity Editor: 2020.3.0f1 (happens also with 2020.3.1f1)
OS: Windows 10 Pro x64
Let me know if you need anything.
Happy to help investigate too as soon as I've understood how to debug an imported Unity package.