Exceptions when running Odin Validator in batchmode

Issue #779 resolved
Yaroslav Kovtun created an issue

I have Odin Validator wrapped as unit tests that run in batchmode. The validation works fine, but there are multiple exceptions logged. Thus the unit tests fail, unless I set ignoreFailingMessages=true, which is not ideal.

Some examples:

NullReferenceException: Object reference not set to an instance of an object
  at UnityEditor.EditorStyles.get_miniButton () [0x00001] in /home/bokken/buildslave/unity/build/Editor/Mono/GUI/EditorStyles.cs:74 
  at Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer.Initialize () [0x00257] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.OdinDrawer.Initialize (Sirenix.OdinInspector.Editor.InspectorProperty property) [0x00010] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.InspectorProperty.GetActiveDrawerChain (System.Boolean& isNewlyCreated) [0x0005d] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.InspectorProperty.GetActiveDrawerChain () [0x00000] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.PropertyState.SendStateChangedNotifications (System.String state) [0x00000] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.PropertyState.set_Visible (System.Boolean value) [0x0002b] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.StateUpdaters.HideInEditorModeAttributeStateUpdater.OnStateUpdate () [0x00010] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.InspectorProperty.UpdateStates (System.Int32 treeID) [0x00024] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Sirenix.OdinInspector.Editor.InspectorProperty:UpdateStates(Int32)
Sirenix.OdinInspector.Editor.InspectorProperty:RefreshSetup(Boolean)
Sirenix.OdinInspector.Editor.InspectorProperty:RefreshSetup()
Sirenix.OdinInspector.Editor.InspectorProperty:Update(Boolean)
Sirenix.OdinInspector.Editor.PropertyChildren:Get(Int32)
Sirenix.OdinInspector.Editor.PropertyChildren:get_Item(Int32)
Sirenix.OdinInspector.Editor.InspectorProperty:NextProperty(Boolean, Boolean)
Sirenix.OdinInspector.Editor.<EnumerateTree>d__66:MoveNext()
Sirenix.OdinValidator.Editor.ValidationRunner:ValidateObjectRecursively(Object, List`1&) (at Assets/ThirdParty/Sirenix/Odin Validator/Editor/Scripts/Editors/ValidationRunner.cs:145)
Sirenix.OdinValidator.Editor.ValidationRunner:ValidateUnityObjectRecursively(Object) (at Assets/ThirdParty/Sirenix/Odin Validator/Editor/Scripts/Editors/ValidationRunner.cs:165)
Sirenix.OdinValidator.Editor.<Validate>d__10:MoveNext() (at Assets/ThirdParty/Sirenix/Odin Validator/Editor/Scripts/Profiles/SceneValidationProfile.cs:288)
Sirenix.OdinValidator.Editor.<Validate>d__10:MoveNext() (at Assets/ThirdParty/Sirenix/Odin Validator/Editor/Scripts/Profiles/ValidationProfileAsset.cs:67)
EditModeTests.OdinValidatorTests:Validate(IValidationProfile) (at Assets/Scripts/Editor/EditModeTests/OdinValidatorTests.cs:50)

NullReferenceException: Object reference not set to an instance of an object
  at UnityEditor.EditorStyles.get_label () [0x00001] in /home/bokken/buildslave/unity/build/Editor/Mono/GUI/EditorStyles.cs:18 
  at Sirenix.OdinInspector.Editor.Drawers.DictionaryDrawer`3[TDictionary,TKey,TValue].Initialize () [0x000b2] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.OdinDrawer.Initialize (Sirenix.OdinInspector.Editor.InspectorProperty property) [0x00010] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.InspectorProperty.GetActiveDrawerChain (System.Boolean& isNewlyCreated) [0x0005d] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.InspectorProperty.GetActiveDrawerChain () [0x00000] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.PropertyState.SendStateChangedNotifications (System.String state) [0x00000] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.PropertyState.set_Visible (System.Boolean value) [0x0002b] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.StateUpdaters.HideInEditorModeAttributeStateUpdater.OnStateUpdate () [0x00010] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
  at Sirenix.OdinInspector.Editor.InspectorProperty.UpdateStates (System.Int32 treeID) [0x00024] in <db2fca6320954dd69ca3e1f66395d6d1>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Sirenix.OdinInspector.Editor.InspectorProperty:UpdateStates(Int32)
Sirenix.OdinInspector.Editor.InspectorProperty:RefreshSetup(Boolean)
Sirenix.OdinInspector.Editor.InspectorProperty:RefreshSetup()
Sirenix.OdinInspector.Editor.InspectorProperty:Update(Boolean)
Sirenix.OdinInspector.Editor.PropertyChildren:Get(Int32)
Sirenix.OdinInspector.Editor.PropertyChildren:get_Item(Int32)
Sirenix.OdinInspector.Editor.<EnumerateTree>d__66:MoveNext()
Sirenix.OdinValidator.Editor.ValidationRunner:ValidateObjectRecursively(Object, List`1&) (at Assets/ThirdParty/Sirenix/Odin Validator/Editor/Scripts/Editors/ValidationRunner.cs:145)
Sirenix.OdinValidator.Editor.ValidationRunner:ValidateUnityObjectRecursively(Object) (at Assets/ThirdParty/Sirenix/Odin Validator/Editor/Scripts/Editors/ValidationRunner.cs:165)
Sirenix.OdinValidator.Editor.<Validate>d__10:MoveNext() (at Assets/ThirdParty/Sirenix/Odin Validator/Editor/Scripts/Profiles/SceneValidationProfile.cs:288)
Sirenix.OdinValidator.Editor.<Validate>d__10:MoveNext() (at Assets/ThirdParty/Sirenix/Odin Validator/Editor/Scripts/Profiles/ValidationProfileAsset.cs:67)
EditModeTests.OdinValidatorTests:Validate(IValidationProfile) (at Assets/Scripts/Editor/EditModeTests/OdinValidatorTests.cs:50)

I have updated to 3.0.5, which mentions that “Odin will now not initialize its editors when the editor is being run in headless or batch mode.”, but the exceptions are still there.

Unity 2020.3.5, Linux, in batchmode.

Comments (3)

  1. Tor Esa Vestergaard
    • changed status to open

    Ah, that looks like an invocation to the drawer system that slipped us by. Thanks for the headsup - I've fixed this case. The fix will be in the next release of Odin; if you would like to receive a preview build to verify whether the fix works, please contact me on Discord and I will send you a build :)

  2. Log in to comment