Skip to content

Commit

Permalink
In Avalonia.Base, sealed several classes whose constructors aren't …
Browse files Browse the repository at this point in the history
…available from public API, and which have no inheritors (#13043)

* In `Avalonia.Base`, sealed several classes whose constructors aren't available from public API, and which have no inheritors

* un-sealed class that is inherited from

* Made `Delete` method non-virtual

---------

Co-authored-by: Lehonti Ramos <lehonti@ramos>
  • Loading branch information
Lehonti and Lehonti Ramos authored Oct 1, 2023
1 parent 87b7af5 commit bb54602
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/Avalonia.Base/Animation/Easings/CubicBezierEasing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Avalonia.Animation.Easings;

public class CubicBezierEasing : IEasing
public sealed class CubicBezierEasing : IEasing
{
private CubicBezier _bezier;
//cubic-bezier(0.25, 0.1, 0.25, 1.0)
Expand All @@ -24,4 +24,4 @@ double IEasing.Ease(double progress)
{
return _bezier.Solve(progress);
}
}
}
2 changes: 1 addition & 1 deletion src/Avalonia.Base/AttachedProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Avalonia
/// An attached avalonia property.
/// </summary>
/// <typeparam name="TValue">The type of the property's value.</typeparam>
public class AttachedProperty<TValue> : StyledProperty<TValue>
public sealed class AttachedProperty<TValue> : StyledProperty<TValue>
{
/// <summary>
/// Initializes a new instance of the <see cref="AttachedProperty{TValue}"/> class.
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Base/Data/InstancedBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Avalonia.Data
/// *instanced* by calling <see cref="IBinding.Initiate(AvaloniaObject, AvaloniaProperty, object, bool)"/>
/// on a target object.
/// </remarks>
public class InstancedBinding
public sealed class InstancedBinding
{
/// <summary>
/// Initializes a new instance of the <see cref="InstancedBinding"/> class.
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Base/Diagnostics/AppliedStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Avalonia.Diagnostics
{
public class AppliedStyle
public sealed class AppliedStyle
{
private readonly IStyleInstance _instance;

Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Base/Diagnostics/AvaloniaPropertyValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Avalonia.Diagnostics
/// Holds diagnostic-related information about the value of an <see cref="AvaloniaProperty"/>
/// on an <see cref="AvaloniaObject"/>.
/// </summary>
public class AvaloniaPropertyValue
public sealed class AvaloniaPropertyValue
{
internal AvaloniaPropertyValue(
AvaloniaProperty property,
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Base/Input/GestureRecognizers/VelocityTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ internal virtual Velocity GetFlingVelocity()
}

/// An nth degree polynomial fit to a dataset.
internal class PolynomialFit
internal sealed class PolynomialFit
{
/// Creates a polynomial fit of the given degree.
///
Expand All @@ -213,7 +213,7 @@ internal PolynomialFit(int degree)
public double Confidence { get; set; }
}

internal class LeastSquaresSolver
internal sealed class LeastSquaresSolver
{
private const double PrecisionErrorTolerance = 1e-10;

Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Base/Input/ScrollGestureEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ScrollGestureEndedEventArgs(int id) : base(Gestures.ScrollGestureEndedEve
}
}

public class ScrollGestureInertiaStartingEventArgs : RoutedEventArgs
public sealed class ScrollGestureInertiaStartingEventArgs : RoutedEventArgs
{
public int Id { get; }
public Vector Inertia { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Avalonia.Rendering.Composition.Animations
/// of Composition objects, mathematical functions and operators and Input.
/// Use the <see cref="CompositionObject.StartAnimation(string , CompositionAnimation)"/> method to start the animation.
/// </remarks>
public class ExpressionAnimation : CompositionAnimation
public sealed class ExpressionAnimation : CompositionAnimation
{
private string? _expression;
private Expression? _parsedExpression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Avalonia.Rendering.Composition.Animations
/// When expression is used in ImplicitAnimationCollection a special keyword `this.FinalValue` will represent
/// the final value of the animated property that was changed
/// </remarks>
public class ImplicitAnimationCollection : CompositionObject, IDictionary<string, ICompositionAnimationBase>
public sealed class ImplicitAnimationCollection : CompositionObject, IDictionary<string, ICompositionAnimationBase>
{
private readonly Dictionary<string, ICompositionAnimationBase> _inner = new Dictionary<string, ICompositionAnimationBase>();
private readonly IDictionary<string, ICompositionAnimationBase> _innerface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal partial class ServerCompositionSimpleBrush : IBrush
ITransform? IBrush.Transform => Transform;
}

class ServerCompositionSimpleGradientBrush : ServerCompositionSimpleBrush, IGradientBrush
internal class ServerCompositionSimpleGradientBrush : ServerCompositionSimpleBrush, IGradientBrush
{

internal ServerCompositionSimpleGradientBrush(ServerCompositor compositor) : base(compositor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Avalonia.Rendering.Composition.Server;

internal class ServerCompositionSimpleContentBrush : ServerCompositionSimpleTileBrush, ITileBrush, ISceneBrush
internal sealed class ServerCompositionSimpleContentBrush : ServerCompositionSimpleTileBrush, ITileBrush, ISceneBrush
{
private CompositionRenderDataSceneBrushContent? _content;

Expand All @@ -21,4 +21,4 @@ protected override void DeserializeChangesCore(BatchStreamReader reader, TimeSpa
base.DeserializeChangesCore(reader, committedAt);
_content = reader.ReadObject<CompositionRenderDataSceneBrushContent?>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Avalonia.Rendering.Composition.Server;

internal class ServerCompositionSimpleImageBrush : ServerCompositionSimpleTileBrush,
internal sealed class ServerCompositionSimpleImageBrush : ServerCompositionSimpleTileBrush,
IImageBrush, IImageBrushSource
{
public IImageBrushSource? Source => this;
Expand All @@ -34,4 +34,4 @@ protected override void DeserializeChangesCore(BatchStreamReader reader, TimeSpa
Bitmap = null;
Bitmap = reader.ReadObject<IRef<IBitmapImpl>>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Avalonia.Rendering.Composition;

public class CompositionCustomVisual : CompositionContainerVisual
public sealed class CompositionCustomVisual : CompositionContainerVisual
{
private List<object>? _messages;

Expand Down Expand Up @@ -34,4 +34,4 @@ private protected override void SerializeChangesCore(BatchStreamWriter writer)
_messages.Clear();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Avalonia.Rendering.Composition;

public class CompositionDrawingSurface : CompositionSurface, IDisposable
public sealed class CompositionDrawingSurface : CompositionSurface, IDisposable
{
internal new ServerCompositionDrawingSurface Server => (ServerCompositionDrawingSurface)base.Server!;
internal CompositionDrawingSurface(Compositor compositor) : base(compositor, new ServerCompositionDrawingSurface(compositor.Server))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Avalonia.Rendering.Composition
/// <see cref="CompositionPropertySet"/> does not support a delete function – ensure you use <see cref="CompositionPropertySet"/>
/// to store values that will be shared across the application.
/// </summary>
public class CompositionPropertySet : CompositionObject
public sealed class CompositionPropertySet : CompositionObject
{
private readonly Dictionary<string, ExpressionVariant> _variants = new Dictionary<string, ExpressionVariant>();
private readonly Dictionary<string, CompositionObject> _objects = new Dictionary<string, CompositionObject>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Avalonia.Rendering.Composition.Server;

internal class ServerCompositionCustomVisual : ServerCompositionContainerVisual, IServerClockItem
internal sealed class ServerCompositionCustomVisual : ServerCompositionContainerVisual, IServerClockItem
{
private readonly CompositionCustomVisualHandler _handler;
private bool _wantsNextAnimationFrameAfterTick;
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Base/Rendering/Composition/Transport/Batch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Avalonia.Rendering.Composition.Transport
/// <summary>
/// Represents a group of serialized changes from the UI thread to be atomically applied at the render thread
/// </summary>
public class CompositionBatch
public sealed class CompositionBatch
{
private static long _nextSequenceId = 1;
private static readonly ConcurrentBag<BatchStreamData> _pool = new();
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Base/Threading/DispatcherOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void Wait(TimeSpan timeout)
GetTask().GetAwaiter().GetResult();
}

private class DispatcherOperationFrame : DispatcherFrame
private sealed class DispatcherOperationFrame : DispatcherFrame
{
// Note: we pass "exitWhenRequested=false" to the base
// DispatcherFrame construsctor because we do not want to exit
Expand Down Expand Up @@ -373,7 +373,7 @@ public T Result
}
}

internal class SendOrPostCallbackDispatcherOperation : DispatcherOperation
internal sealed class SendOrPostCallbackDispatcherOperation : DispatcherOperation
{
private readonly object? _arg;

Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Base/Threading/DispatcherPriorityAwaitable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void OnCompleted(Action continuation) =>
public DispatcherPriorityAwaitable GetAwaiter() => this;
}

public class DispatcherPriorityAwaitable<T> : DispatcherPriorityAwaitable
public sealed class DispatcherPriorityAwaitable<T> : DispatcherPriorityAwaitable
{
internal DispatcherPriorityAwaitable(Dispatcher dispatcher, Task<T> task, DispatcherPriority priority) : base(
dispatcher, task, priority)
Expand All @@ -37,4 +37,4 @@ internal DispatcherPriorityAwaitable(Dispatcher dispatcher, Task<T> task, Dispat
public new T GetResult() => ((Task<T>)Task).GetAwaiter().GetResult();

public new DispatcherPriorityAwaitable<T> GetAwaiter() => this;
}
}
4 changes: 2 additions & 2 deletions src/Avalonia.Base/Utilities/Span.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Span(object? element, int length)
/// <summary>
/// VECTOR: A series of spans
/// </summary>
internal class SpanVector : IEnumerable
internal sealed class SpanVector : IEnumerable
{
private static readonly Equals s_referenceEquals = object.ReferenceEquals;
private static readonly Equals s_equals = object.Equals;
Expand Down Expand Up @@ -67,7 +67,7 @@ private void Add(Span span)
/// <summary>
/// Delete n elements of vector
/// </summary>
internal virtual void Delete(int index, int count, ref SpanPosition latestPosition)
internal void Delete(int index, int count, ref SpanPosition latestPosition)
{
DeleteInternal(index, count);

Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Base/Utilities/WeakEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Avalonia.Utilities;
/// <summary>
/// Manages subscriptions to events using weak listeners.
/// </summary>
public class WeakEvent<TSender, TEventArgs> : WeakEvent where TEventArgs : EventArgs where TSender : class
public sealed class WeakEvent<TSender, TEventArgs> : WeakEvent where TEventArgs : EventArgs where TSender : class
{
private readonly Func<TSender, EventHandler<TEventArgs>, Action> _subscribe;

Expand Down Expand Up @@ -42,7 +42,7 @@ public void Unsubscribe(TSender target, IWeakEventSubscriber<TEventArgs> subscri
subscription.Remove(subscriber);
}

private class Subscription
private sealed class Subscription
{
private readonly WeakEvent<TSender, TEventArgs> _ev;
private readonly TSender _target;
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Base/Vector3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ public static double DistanceSquared(Vector3D value1, Vector3D value2)
/// Computes the Euclidean distance between the two given points.
/// </summary>
public static double Distance(Vector3D value1, Vector3D value2) => Math.Sqrt(DistanceSquared(value1, value2));
}
}

0 comments on commit bb54602

Please sign in to comment.