From a3d11e35cbabbe8d715eb657048c0e916ab34b74 Mon Sep 17 00:00:00 2001 From: Yoshi Askharoun Date: Mon, 5 Jun 2023 16:08:16 -0500 Subject: [PATCH] Do not attempt to show null values in inspector --- .../UIXCompiled/UIBDisassemblyViewModel.cs | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/ZuneUIXTools/Modules/UIXCompiled/UIBDisassemblyViewModel.cs b/ZuneUIXTools/Modules/UIXCompiled/UIBDisassemblyViewModel.cs index ca3bb86..1fc049c 100644 --- a/ZuneUIXTools/Modules/UIXCompiled/UIBDisassemblyViewModel.cs +++ b/ZuneUIXTools/Modules/UIXCompiled/UIBDisassemblyViewModel.cs @@ -93,20 +93,24 @@ public class UIBDisassemblyViewModel : Document InspectableObjectBuilder builder = new InspectableObjectBuilder() .WithObjectProperties(instance, filter); - var valueProperty = TypeDescriptor.CreateProperty(typeof(InterpreterObject), "Value", instance.Value?.GetType()); - IEditor editor = DefaultPropertyInspectors.CreateEditor(valueProperty); - if (editor is null) + var valueType = instance.Value?.GetType() ?? instance.Type; + if (valueType is not null) { - builder = builder.WithCollapsibleGroup(nameof(instance.Value), b => - b.WithObjectProperties(instance.Value, _ => true)); - } - else - { - var converterProp = editor.GetType().GetProperty("Converter"); - converterProp?.SetValue(editor, new CastValueConverter()); + PropertyDescriptor valueProperty = TypeDescriptor.CreateProperty(typeof(InterpreterObject), "Value", valueType); + IEditor editor = DefaultPropertyInspectors.CreateEditor(valueProperty); + if (editor is null) + { + builder = builder.WithCollapsibleGroup(nameof(instance.Value), b => + b.WithObjectProperties(instance.Value, _ => true)); + } + else + { + var converterProp = editor.GetType().GetProperty("Converter"); + converterProp?.SetValue(editor, new CastValueConverter()); - editor.BoundPropertyDescriptor = new BoundPropertyDescriptor(instance, valueProperty); - builder = builder.WithEditor(instance, i => i.Value, editor); + editor.BoundPropertyDescriptor = new BoundPropertyDescriptor(instance, valueProperty); + builder = builder.WithEditor(instance, i => i.Value, editor); + } } return builder.ToInspectableObject();