Editor/TypeLibraryFixes/SerializedPropertyProxy.cs
using Sandbox;
using System;
using System.Collections.Generic;

namespace ExtendedEditor.TypeLibraryFixes;

public class SerializedPropertyProxy : SerializedProperty.Proxy
{
    protected override SerializedProperty ProxyTarget { get; }
    public SerializedProperty Target => ProxyTarget;

    private readonly Attribute[] _attributes;
    private readonly Type? _type;

    private Action<object>? _setter;
    private Func<object>? _getter;

    public override Type PropertyType => _type ?? base.PropertyType;

    internal bool? Fixed { get; set; }

    public SerializedPropertyProxy(SerializedProperty target, Type? type = null, params IEnumerable<Attribute> attributes)
    {
        ProxyTarget = target;
        _type = type;
        _attributes = [.. attributes];
    }

    public void ProxyValueSet(Action<object> setter)
    {
        _setter = setter;
    }

    public void ProxyValueGet(Func<object> getter)
    {
        _getter = getter;
    }

    public override IEnumerable<Attribute> GetAttributes() => _attributes;

    public override T GetValue<T>(T defaultValue = default!)
    {
        if(_getter is null)
            return base.GetValue(defaultValue);

        return _getter.Invoke() is T value ? value : defaultValue;
    }

    public override void SetValue<T>(T value)
    {
        if(_setter is null)
        {
            base.SetValue(value);
            return;
        }

        _setter.Invoke(value);
    }

    public override bool TryGetAsObject(out SerializedObject obj)
    {
        return ProxyTarget.TryGetAsObject(out obj);
    }
}