protected internal static IEnumerable <IGrouping <Type, Control> > LocalPropertyList(object obj, IViewVariablesManagerInternal vvm,
                                                                                             IRobustSerializer robustSerializer)
        {
            var styleOther = false;
            var type       = obj.GetType();

            var members = new List <(MemberInfo, VVAccess, object?value, Action <object?, bool> onValueChanged, Type)>();

            foreach (var fieldInfo in type.GetAllFields())
            {
                if (!ViewVariablesUtility.TryGetViewVariablesAccess(fieldInfo, out var access))
                {
                    continue;
                }

                members.Add((fieldInfo, (VVAccess)access, fieldInfo.GetValue(obj), (v, _) => fieldInfo.SetValue(obj, v),
                             fieldInfo.FieldType));
            }

            foreach (var propertyInfo in type.GetAllProperties())
            {
                if (!ViewVariablesUtility.TryGetViewVariablesAccess(propertyInfo, out var access))
                {
                    continue;
                }

                if (!propertyInfo.IsBasePropertyDefinition())
                {
                    continue;
                }

                members.Add((propertyInfo, (VVAccess)access, propertyInfo.GetValue(obj),
                             (v, _) => propertyInfo.GetSetMethod(true) !.Invoke(obj, new[] { v }), propertyInfo.PropertyType));
            }

            var groupedSorted = members
                                .OrderBy(p => p.Item1.Name)
                                .GroupBy(p => p.Item1.DeclaringType !, tuple =>
            {
                var(memberInfo, access, value, onValueChanged, memberType) = tuple;
                var data = new ViewVariablesBlobMembers.MemberData
                {
                    Editable   = access == VVAccess.ReadWrite,
                    Name       = memberInfo.Name,
                    Type       = memberType.AssemblyQualifiedName,
                    TypePretty = TypeAbbreviation.Abbreviate(memberType),
                    Value      = value
                };

                var propertyEdit = new ViewVariablesPropertyControl(vvm, robustSerializer);
                propertyEdit.SetStyle(styleOther = !styleOther);
                var editor             = propertyEdit.SetProperty(data);
                editor.OnValueChanged += onValueChanged;
                return(propertyEdit);
            })
                                .OrderByDescending(p => p.Key, TypeHelpers.TypeInheritanceComparer);

            return(groupedSorted);
        }
        protected internal static IEnumerable <Control> LocalPropertyList(object obj, IViewVariablesManagerInternal vvm,
                                                                          IResourceCache resCache)
        {
            var styleOther = false;
            var type       = obj.GetType();

            var members = new List <(MemberInfo, VVAccess, object value, Action <object> onValueChanged, Type)>();

            foreach (var fieldInfo in type.GetAllFields())
            {
                var attr = fieldInfo.GetCustomAttribute <ViewVariablesAttribute>();
                if (attr == null)
                {
                    continue;
                }

                members.Add((fieldInfo, attr.Access, fieldInfo.GetValue(obj), v => fieldInfo.SetValue(obj, v),
                             fieldInfo.FieldType));
            }

            foreach (var propertyInfo in type.GetAllProperties())
            {
                var attr = propertyInfo.GetCustomAttribute <ViewVariablesAttribute>();
                if (attr == null)
                {
                    continue;
                }

                members.Add((propertyInfo, attr.Access, propertyInfo.GetValue(obj),
                             v => propertyInfo.GetSetMethod(true).Invoke(obj, new[] { v }), propertyInfo.PropertyType));
            }

            members.Sort((a, b) => string.Compare(a.Item1.Name, b.Item1.Name, StringComparison.Ordinal));

            foreach (var(memberInfo, access, value, onValueChanged, memberType) in members)
            {
                var data = new ViewVariablesBlobMembers.MemberData
                {
                    Editable   = access == VVAccess.ReadWrite,
                    Name       = memberInfo.Name,
                    Type       = memberType.AssemblyQualifiedName,
                    TypePretty = memberType.ToString(),
                    Value      = value
                };

                var propertyEdit = new ViewVariablesPropertyControl(vvm, resCache);
                propertyEdit.SetStyle(styleOther = !styleOther);
                var editor = propertyEdit.SetProperty(data);
                editor.OnValueChanged += onValueChanged;
                // TODO: should this maybe not be hardcoded?
                if (editor is ViewVariablesPropertyEditorReference refEditor)
                {
                    refEditor.OnPressed += () => vvm.OpenVV(data.Value);
                }

                yield return(propertyEdit);
            }
        }