Browse Source

Reduce code by inlining these in a primary constructor

Not the final form. Just showing steps.
Brandon Thetford 11 months ago
parent
commit
e6b67f0fbf
1 changed files with 4 additions and 22 deletions
  1. 4 22
      Terminal.Gui/View/Layout/DimAuto.cs

+ 4 - 22
Terminal.Gui/View/Layout/DimAuto.cs

@@ -15,46 +15,28 @@ namespace Terminal.Gui;
 ///         methods on the <see cref="Dim"/> class to create <see cref="Dim"/> objects instead.
 ///     </para>
 /// </remarks>
-public record DimAuto : Dim
+public record DimAuto (Dim? MaximumContentDim, Dim? MinimumContentDim, DimAutoStyle Style) : Dim
 {
-    private readonly Dim? _maximumContentDim;
-
     /// <summary>
     ///     Gets the maximum dimension the View's ContentSize will be fit to. NOT CURRENTLY SUPPORTED.
     /// </summary>
 
     // ReSharper disable once ConvertToAutoProperty
-    public required Dim? MaximumContentDim
-    {
-        get => _maximumContentDim;
-        init => _maximumContentDim = value;
-    }
-
-    private readonly Dim? _minimumContentDim;
+    public required Dim? MaximumContentDim { get; init; } = MaximumContentDim;
 
     /// <summary>
     ///     Gets the minimum dimension the View's ContentSize will be constrained to.
     /// </summary>
 
     // ReSharper disable once ConvertToAutoProperty
-    public required Dim? MinimumContentDim
-    {
-        get => _minimumContentDim;
-        init => _minimumContentDim = value;
-    }
-
-    private readonly DimAutoStyle _style;
+    public required Dim? MinimumContentDim { get; init; } = MinimumContentDim;
 
     /// <summary>
     ///     Gets the style of the DimAuto.
     /// </summary>
 
     // ReSharper disable once ConvertToAutoProperty
-    public required DimAutoStyle Style
-    {
-        get => _style;
-        init => _style = value;
-    }
+    public required DimAutoStyle Style { get; init; } = Style;
 
     /// <inheritdoc/>
     public override string ToString () { return $"Auto({Style},{MinimumContentDim},{MaximumContentDim})"; }