diff --git a/src/Avalonia.Controls/Grid.cs b/src/Avalonia.Controls/Grid.cs index 67b8ab4eda..7892fdf352 100644 --- a/src/Avalonia.Controls/Grid.cs +++ b/src/Avalonia.Controls/Grid.cs @@ -224,6 +224,9 @@ namespace Avalonia.Controls // Situation 2/2: // If the grid defines some columns or rows. + // Debug Tip: + // - GridLayout doesn't hold any states, so you can drag the debugger execution + // arrow back to any statements and re-run them without any side-effect. var measureCache = new Dictionary(); var (safeColumns, safeRows) = GetSafeColumnRows(); @@ -293,6 +296,9 @@ namespace Avalonia.Controls // Situation 2/2: // If the grid defines some columns or rows. + // Debug Tip: + // - GridLayout doesn't hold any states, so you can drag the debugger execution + // arrow back to any statements and re-run them without any side-effect. var (safeColumns, safeRows) = GetSafeColumnRows(); var columnLayout = new GridLayout(ColumnDefinitions); diff --git a/src/Avalonia.Controls/Utils/GridLayout.cs b/src/Avalonia.Controls/Utils/GridLayout.cs index 6e38a7ceba..cfbe81ba87 100644 --- a/src/Avalonia.Controls/Utils/GridLayout.cs +++ b/src/Avalonia.Controls/Utils/GridLayout.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.Linq; using System.Runtime.CompilerServices; using Avalonia.Layout; @@ -478,6 +479,7 @@ namespace Avalonia.Controls.Utils /// This is mostly the same as or . /// We use this because we can treat the column and the row the same. /// + [DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")] internal class LengthConvention : ICloneable { /// @@ -545,6 +547,12 @@ namespace Avalonia.Controls.Utils /// private bool _isFixed; + /// + /// Helps the debugger to display the intermediate column/row calculation result. + /// + private string DebuggerDisplay => + $"{(_isFixed ? Length.Value.ToString(CultureInfo.InvariantCulture) : (Length.GridUnitType == GridUnitType.Auto ? "Auto" : $"{Length.Value}*"))}, ∈[{MinLength}, {MaxLength}]"; + /// object ICloneable.Clone() => Clone(); @@ -559,6 +567,7 @@ namespace Avalonia.Controls.Utils /// Contains the convention that comes from the grid children. /// Some child span multiple columns or rows, so even a simple column/row can have multiple conventions. /// + [DebuggerDisplay("{" + nameof(DebuggerDisplay) + ",nq}")] internal struct AdditionalLengthConvention { /// @@ -586,6 +595,12 @@ namespace Avalonia.Controls.Utils /// This value is usually provided by the child's desired length. /// public double Min { get; } + + /// + /// Helps the debugger to display the intermediate column/row calculation result. + /// + private string DebuggerDisplay => + $"{{{string.Join(",", Enumerable.Range(Index, Span))}}}, ∈[{Min},∞)"; } ///