diff --git a/Terminal.Gui/View/Layout/Dim.cs b/Terminal.Gui/View/Layout/Dim.cs index 073b747f4..3fe4db7cd 100644 --- a/Terminal.Gui/View/Layout/Dim.cs +++ b/Terminal.Gui/View/Layout/Dim.cs @@ -177,12 +177,17 @@ public abstract class Dim /// The maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED. public static Dim? Auto (DimAutoStyle style = DimAutoStyle.Auto, Dim? minimumContentDim = null, Dim? maximumContentDim = null) { - //if (maximumContentDim != null) - //{ - // throw new NotImplementedException (@"maximumContentDim is not implemented"); - //} + if (maximumContentDim is { }) + { + Debug.WriteLine (@"WARNING: maximumContentDim is not fully implemented."); + } - return new DimAuto (style, minimumContentDim, maximumContentDim); + return new DimAuto () + { + MinimumContentDim = minimumContentDim, + MaximumContentDim = maximumContentDim, + Style = style + }; } /// @@ -380,46 +385,43 @@ public class DimAbsolute (int size) : Dim /// methods on the class to create objects instead. /// /// -/// -/// Specifies how will compute the dimension. The default is . -/// -/// The minimum dimension the View's ContentSize will be constrained to. -/// The maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED. -public class DimAuto (DimAutoStyle style, Dim? minimumContentDim, Dim? maximumContentDim) : Dim +public class DimAuto () : Dim { - /// - public override bool Equals (object? other) - { - if (other is not DimAuto auto) - { - return false; - } - - return auto.MinimumContentDim == MinimumContentDim && - auto.MaximumContentDim == MaximumContentDim && - auto.Style == Style; - } - - /// - public override int GetHashCode () - { - return HashCode.Combine (MinimumContentDim, MaximumContentDim, Style); - } + private readonly Dim? _maximumContentDim; /// /// Gets the maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED. /// - public Dim? MaximumContentDim { get; } = maximumContentDim; + // ReSharper disable once ConvertToAutoProperty + public required Dim? MaximumContentDim + { + get => _maximumContentDim; + init => _maximumContentDim = value; + } + + private readonly Dim? _minimumContentDim; /// /// Gets the minimum dimension the View's ContentSize will be constrained to. /// - public Dim? MinimumContentDim { get; } = minimumContentDim; + // ReSharper disable once ConvertToAutoProperty + public required Dim? MinimumContentDim + { + get => _minimumContentDim; + init => _minimumContentDim = value; + } + + private readonly DimAutoStyle _style; /// /// Gets the style of the DimAuto. /// - public DimAutoStyle Style { get; } = style; + // ReSharper disable once ConvertToAutoProperty + public required DimAutoStyle Style + { + get => _style; + init => _style = value; + } /// public override string ToString () { return $"Auto({Style},{MinimumContentDim},{MaximumContentDim})"; } @@ -543,6 +545,26 @@ public class DimAuto (DimAutoStyle style, Dim? minimumContentDim, Dim? maximumCo // BUGBUG: This is not correct. _contentSize may be null. return false; //_style.HasFlag (DimAutoStyle.Content); } + + /// + public override bool Equals (object? other) + { + if (other is not DimAuto auto) + { + return false; + } + + return auto.MinimumContentDim == MinimumContentDim && + auto.MaximumContentDim == MaximumContentDim && + auto.Style == Style; + } + + /// + public override int GetHashCode () + { + return HashCode.Combine (MinimumContentDim, MaximumContentDim, Style); + } + } ///