C#C
C#10mo ago
Nebula

Property setter disappears on `PublishTrimmed`

After publishing my program, the setter to a float property disappears and cannot be found by .GetProperty when using <PublishTrimmed>.

The code that accesses the property:
public TransformSequence<T> Create<X>(string property, X to, float duration, Easing easing, string? name, Func<X, X, float, X> interpolation) {
    PropertyInfo? propertyInfo = typeof(T).GetProperty(property);
    if (propertyInfo == null) throw new InvalidOperationException($"Property {property} does not exist in {typeof(T).Name}");

    X a = FutureData.TryGetValue(property, out object? value) ? (X)value : (X)propertyInfo.GetValue(Target)!;

    Transform transform = new(t => {
        X value = interpolation(a, to, t);
        propertyInfo.SetValue(Target, value);
    }) {
        Name = name ?? property,
        Duration = duration,
        Easing = EasingHelper.FromEaseType(easing)
    };

    FutureData[property] = to!;
    if (Name == string.Empty) Name = property;

    return Append(transform);
}


The Rotation property:
public float Rotation {
    get => _rotation;
    set {
        if (_rotation == value) return;

        _rotation = value % 360;
        Invalidate(Invalidation.Geometry);

        // Rotation currently does not affect ChildRelativeSizeAxes
        // if (Parent?.ChildRelativeSizeAxes != Axes.None) InvalidateParent(Invalidation.DrawSize);
    }
}


This Scale property works fine, on the other hand:
public Vector2 Scale {
    get => _scale;
    set {
        if (_scale == value) return;

        _scale = Vector2.Max(value, new(float.MinValue));
        Invalidate(Invalidation.DrawSize);
        Parent?.Invalidate(Invalidation.Layout);
    }
}


All Vector2 types work fine, and Rotation is the only float property I've tried. Is there a way to still use PublishTrimmed while keeping this functionality? It's likely me just misunderstanding how the publish trimmed parameter works.
Was this page helpful?