diff --git a/src/Avalonia.Base/Rendering/Composition/Animations/AnimatedValueStore.cs b/src/Avalonia.Base/Rendering/Composition/Animations/AnimatedValueStore.cs index f4735040d5..92aa1f35bb 100644 --- a/src/Avalonia.Base/Rendering/Composition/Animations/AnimatedValueStore.cs +++ b/src/Avalonia.Base/Rendering/Composition/Animations/AnimatedValueStore.cs @@ -32,11 +32,9 @@ namespace Avalonia.Rendering.Composition.Animations /// The value store for non-animated values that can still be referenced by animations. /// Simply stores the value and notifies subscribers /// - [StructLayout(LayoutKind.Sequential)] internal struct ServerValueStore { - // HAS TO BE THE FIRST FIELD, accessed by field offset from ServerObject - private ServerObjectSubscriptionStore Subscriptions; + public ServerObjectSubscriptionStore Subscriptions; private T _value; public T Value { @@ -61,8 +59,7 @@ namespace Avalonia.Rendering.Composition.Animations [StructLayout(LayoutKind.Sequential)] internal struct ServerAnimatedValueStore where T : struct { - // HAS TO BE THE FIRST FIELD, accessed by field offset from ServerObject - private ServerObjectSubscriptionStore Subscriptions; + public ServerObjectSubscriptionStore Subscriptions; private IAnimationInstance? _animation; private T _direct; private T? _lastAnimated; diff --git a/src/Avalonia.Base/Rendering/Composition/Server/ServerObject.cs b/src/Avalonia.Base/Rendering/Composition/Server/ServerObject.cs index e5ae7fa859..b53e31c9cf 100644 --- a/src/Avalonia.Base/Rendering/Composition/Server/ServerObject.cs +++ b/src/Avalonia.Base/Rendering/Composition/Server/ServerObject.cs @@ -63,15 +63,15 @@ namespace Avalonia.Rendering.Composition.Server } [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected int GetOffset(ref T field) where T : struct + protected int GetOffset(ref ServerObjectSubscriptionStore field) { - return Unsafe.ByteOffset(ref Unsafe.As(ref _activationCount), - ref Unsafe.As(ref field)) + return Unsafe.ByteOffset(ref _activationCount, + ref Unsafe.As(ref field)) .ToInt32(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ref ServerObjectSubscriptionStore GetStoreFromOffset(int offset) + protected ref ServerObjectSubscriptionStore GetStoreFromOffset(int offset) { #if DEBUG if (offset == 0) diff --git a/src/Avalonia.Base/Rendering/Composition/Server/ServerVisual.cs b/src/Avalonia.Base/Rendering/Composition/Server/ServerVisual.cs index f2b6b4d880..04eba72594 100644 --- a/src/Avalonia.Base/Rendering/Composition/Server/ServerVisual.cs +++ b/src/Avalonia.Base/Rendering/Composition/Server/ServerVisual.cs @@ -2,7 +2,9 @@ using System; using System.Numerics; using Avalonia.Media; using Avalonia.Platform; +using Avalonia.Rendering.Composition.Animations; using Avalonia.Rendering.Composition.Transport; +using Avalonia.Utilities; namespace Avalonia.Rendering.Composition.Server { diff --git a/src/tools/DevGenerators/CompositionGenerator/Generator.cs b/src/tools/DevGenerators/CompositionGenerator/Generator.cs index f8f86265cf..ad7f2200a6 100644 --- a/src/tools/DevGenerators/CompositionGenerator/Generator.cs +++ b/src/tools/DevGenerators/CompositionGenerator/Generator.cs @@ -298,7 +298,7 @@ namespace Avalonia.SourceGenerator.CompositionGenerator AssignmentExpression(SyntaxKind.SimpleAssignmentExpression, IdentifierName(fieldOffsetName), InvocationExpression(MemberAccess(IdentifierName(uninitializedObjectName), "GetOffset"), ArgumentList(SingletonSeparatedList(Argument( - RefExpression(MemberAccess(IdentifierName(uninitializedObjectName), fieldName))))))))); + RefExpression(MemberAccess(MemberAccess(IdentifierName(uninitializedObjectName), fieldName), "Subscriptions"))))))))); if (prop.DefaultValue != null) {