Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve debugger experience #27017

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#nullable disable
using System;
using System.Diagnostics;
using Microsoft.Maui.Graphics;

namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/ActivityIndicator.xml" path="Type[@FullName='Microsoft.Maui.Controls.ActivityIndicator']/Docs/*" />
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class ActivityIndicator : View, IColorElement, IElementConfiguration<ActivityIndicator>, IActivityIndicator
{
/// <summary>Bindable property for <see cref="IsRunning"/>.</summary>
Expand Down Expand Up @@ -40,5 +42,10 @@ public IPlatformElementConfiguration<T, ActivityIndicator> On<T>() where T : ICo
{
return _platformConfigurationRegistry.Value.On<T>();
}

private protected override string GetDebbugerDisplay()
{
return $"IsRunning = {IsRunning}, " + base.GetDebbugerDisplay();
}
}
}
2 changes: 2 additions & 0 deletions src/Controls/src/Core/Application/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -15,6 +16,7 @@
namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/Application.xml" path="Type[@FullName='Microsoft.Maui.Controls.Application']/Docs/*" />
[DebuggerDisplay("Windows Count: {Windows.Count}, MainPage = {MainPage}")]
pictos marked this conversation as resolved.
Show resolved Hide resolved
public partial class Application : Element, IResourcesProvider, IApplicationController, IElementConfiguration<Application>, IVisualTreeElement, IApplication
{
readonly WeakEventManager _weakEventManager = new WeakEventManager();
Expand Down
6 changes: 6 additions & 0 deletions src/Controls/src/Core/Button/Button.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Microsoft.Maui.Controls
/// <summary>
/// A button <see cref="View" /> that reacts to touch events.
/// </summary>
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class Button : View, IFontElement, ITextElement, IBorderElement, IButtonController, IElementConfiguration<Button>, IPaddingElement, IImageController, IViewController, IButtonElement, ICommandElement, IImageElement, IButton, ITextButton, IImageButton
{
const double DefaultSpacing = 10;
Expand Down Expand Up @@ -607,5 +608,10 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
=> throw new NotSupportedException();
}

private protected override string GetDebbugerDisplay()
{
return $"Text = {Text}, Command = {Command}, " + base.GetDebbugerDisplay();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this look? The command will just be command, so not super useful? Maybe I am wrong tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would work like the BindingContext, here's an image to show how it will work

image

}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/CheckBox/CheckBox.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#nullable disable
using System;
using System.Diagnostics;
using Microsoft.Maui.Graphics;

namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/CheckBox.xml" path="Type[@FullName='Microsoft.Maui.Controls.CheckBox']/Docs/*" />
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class CheckBox : View, IElementConfiguration<CheckBox>, IBorderElement, IColorElement, ICheckBox
{
readonly Lazy<PlatformConfigurationRegistry<CheckBox>> _platformConfigurationRegistry;
Expand Down Expand Up @@ -79,5 +81,10 @@ bool ICheckBox.IsChecked
get => IsChecked;
set => SetValue(IsCheckedProperty, value, SetterSpecificity.FromHandler);
}

private protected override string GetDebbugerDisplay()
{
return $"IsChecked = {IsChecked}, " + base.GetDebbugerDisplay();
}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/ContentPage/ContentPage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable disable

using System;
using System.Diagnostics;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.HotReload;
using Microsoft.Maui.Layouts;
Expand All @@ -9,6 +10,7 @@ namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/ContentPage.xml" path="Type[@FullName='Microsoft.Maui.Controls.ContentPage']/Docs/*" />
[ContentProperty("Content")]
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class ContentPage : TemplatedPage, IContentView, HotReload.IHotReloadableView
{
/// <summary>Bindable property for <see cref="Content"/>.</summary>
Expand Down Expand Up @@ -147,5 +149,10 @@ Size IContentView.CrossPlatformMeasure(double widthConstraint, double heightCons
{
return (this as ICrossPlatformLayout).CrossPlatformMeasure(widthConstraint, heightConstraint);
}

private protected override string GetDebbugerDisplay()
{
return $"Content = {Content}, BindingContext = {BindingContext}";
}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/ContentView/ContentView.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#nullable disable
using System.Diagnostics;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Layouts;

namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/ContentView.xml" path="Type[@FullName='Microsoft.Maui.Controls.ContentView']/Docs/*" />
[ContentProperty("Content")]
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class ContentView : TemplatedView, IContentView
{
/// <summary>Bindable property for <see cref="Content"/>.</summary>
Expand Down Expand Up @@ -46,5 +48,10 @@ internal override void SetChildInheritedBindingContext(Element child, object con
object IContentView.Content => Content;

IView IContentView.PresentedContent => ((this as IControlTemplated).TemplateRoot as IView) ?? Content;

private protected override string GetDebbugerDisplay()
{
return $"Content = {Content}, " + base.GetDebbugerDisplay();
}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/DatePicker/DatePicker.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#nullable disable
using System;
using System.Diagnostics;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;

namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/DatePicker.xml" path="Type[@FullName='Microsoft.Maui.Controls.DatePicker']/Docs/*" />
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class DatePicker : View, IFontElement, ITextElement, IElementConfiguration<DatePicker>, IDatePicker
{
/// <summary>Bindable property for <see cref="Format"/>.</summary>
Expand Down Expand Up @@ -239,5 +241,10 @@ string IDatePicker.Format
get => Format;
set => SetValue(FormatProperty, value, SetterSpecificity.FromHandler);
}

private protected override string GetDebbugerDisplay()
{
return $"Date = {Date}, " + base.GetDebbugerDisplay();
}
}
}
4 changes: 4 additions & 0 deletions src/Controls/src/Core/FlyoutPage/FlyoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,5 +381,9 @@ double IFlyoutView.FlyoutWidth
#else
double IFlyoutView.FlyoutWidth => -1;
#endif
private protected override string GetDebbugerDisplay()
{
return $"DetailPage = {Detail}, FlyoutPage = {Flyout}, BindingContext = {BindingContext}";
}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/Image/Image.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#nullable disable
using System;
using System.ComponentModel;
using System.Diagnostics;

namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/Image.xml" path="Type[@FullName='Microsoft.Maui.Controls.Image']/Docs/*" />
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class Image : View, IImageController, IElementConfiguration<Image>, IViewController, IImageElement, IImage
{
/// <summary>Bindable property for <see cref="Source"/>.</summary>
Expand Down Expand Up @@ -103,5 +105,10 @@ void IImageElement.RaiseImageSourcePropertyChanged() =>

void IImageSourcePart.UpdateIsLoading(bool isLoading) =>
IsLoading = isLoading;

private protected override string GetDebbugerDisplay()
{
return $"Source = {Source}, " + base.GetDebbugerDisplay();
}
}
}
8 changes: 8 additions & 0 deletions src/Controls/src/Core/IndicatorView/IndicatorView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Diagnostics;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Layouts;
Expand All @@ -10,6 +11,8 @@ namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/IndicatorView.xml" path="Type[@FullName='Microsoft.Maui.Controls.IndicatorView']/Docs/*" />
[ContentProperty(nameof(IndicatorLayout))]

[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class IndicatorView : TemplatedView, ITemplatedIndicatorView
{
const int DefaultPadding = 4;
Expand Down Expand Up @@ -193,5 +196,10 @@ int IIndicatorView.Position
get => Position;
set => SetValue(PositionProperty, value, SetterSpecificity.FromHandler);
}

private protected override string GetDebbugerDisplay()
{
return $"Position = {Position}, Count = {Count}, " + base.GetDebbugerDisplay();
}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/InputView/InputView.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#nullable disable
using System;
using System.Diagnostics;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;

namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/InputView.xml" path="Type[@FullName='Microsoft.Maui.Controls.InputView']/Docs/*" />
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class InputView : View, IPlaceholderElement, ITextElement, ITextInput, IFontElement
{
/// <summary>Bindable property for <see cref="Text"/>.</summary>
Expand Down Expand Up @@ -271,5 +273,10 @@ string ITextInput.Text
get => Text;
set => SetValue(TextProperty, value, SetterSpecificity.FromHandler);
}

private protected override string GetDebbugerDisplay()
{
return $"Text = {Text}, " + base.GetDebbugerDisplay();
}
}
}
5 changes: 5 additions & 0 deletions src/Controls/src/Core/Items/ItemsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,10 @@ protected override void OnBindingContextChanged()
if (InternalItemsLayout is BindableObject bo)
SetInheritedBindingContext(bo, BindingContext);
}

private protected override string GetDebbugerDisplay()
{
return $"ItemsSource = {ItemsSource}, " + base.GetDebbugerDisplay();
}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/Label/Label.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;
Expand All @@ -12,6 +13,7 @@ namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/Label.xml" path="Type[@FullName='Microsoft.Maui.Controls.Label']/Docs/*" />
[ContentProperty(nameof(Text))]
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class Label : View, IFontElement, ITextElement, ITextAlignmentElement, ILineHeightElement, IElementConfiguration<Label>, IDecorableTextElement, IPaddingElement, ILabel
{
/// <summary>Bindable property for <see cref="HorizontalTextAlignment"/>.</summary>
Expand Down Expand Up @@ -477,5 +479,10 @@ internal static bool TextChangedShouldInvalidateMeasure(Label label)
// The label may grow/shrink based on the constraints, so we need to invalidate.
return true;
}

private protected override string GetDebbugerDisplay()
{
return $"Text = {Text}, " + base.GetDebbugerDisplay();
}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/Layout/Layout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Maui.Controls.Xaml.Diagnostics;
Expand All @@ -14,6 +15,7 @@ namespace Microsoft.Maui.Controls
/// Base class for layouts that allow you to arrange and group UI controls in your application.
/// </summary>
[ContentProperty(nameof(Children))]
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public abstract partial class Layout : View, Maui.ILayout, IList<IView>, IBindableLayout, IPaddingElement, IVisualTreeElement, ISafeAreaView, IInputTransparentContainerElement
{
protected ILayoutManager _layoutManager;
Expand Down Expand Up @@ -383,5 +385,10 @@ static void OnCascadeInputTransparentPropertyChanged(BindableObject bindable, ob
layout.RefreshInputTransparentProperty();
}
}

private protected override string GetDebbugerDisplay()
{
return $"ChildCount = {Count}, " + base.GetDebbugerDisplay();
}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/Page/Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -18,6 +19,7 @@ namespace Microsoft.Maui.Controls
/// </summary>
/// <remarks><see cref = "Page" /> is primarily a base class for more useful derived types. Objects that are derived from the <see cref="Page"/> class are most prominently used as the top level UI element in .NET MAUI applications. In addition to their role as the main pages of applications, <see cref="Page"/> objects and their descendants can be used with navigation classes, such as <see cref="NavigationPage"/> or <see cref="FlyoutPage"/>, among others, to provide rich user experiences that conform to the expected behaviors on each platform.
/// </remarks>
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class Page : VisualElement, ILayout, IPageController, IElementConfiguration<Page>, IPaddingElement, ISafeAreaView, ISafeAreaView2, IView, ITitledElement, IToolbarElement
#if IOS
,IiOSPageSpecifics
Expand Down Expand Up @@ -938,5 +940,10 @@ protected virtual void OnNavigatedFrom(NavigatedFromEventArgs args) { }
/// <returns>The <see cref="Window"/> instance that parents the page.</returns>
public virtual Window GetParentWindow()
=> this.FindParentOfType<Window>();

private protected override string GetDebbugerDisplay()
{
return $"BindingContext = {BindingContext}, Title = {Title}";
}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/Picker/Picker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Xaml;
Expand All @@ -13,6 +14,7 @@
namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/Picker.xml" path="Type[@FullName='Microsoft.Maui.Controls.Picker']/Docs/*" />
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class Picker : View, IFontElement, ITextElement, ITextAlignmentElement, IElementConfiguration<Picker>, IPicker
{
/// <summary>Bindable property for <see cref="TextColor"/>.</summary>
Expand Down Expand Up @@ -460,5 +462,10 @@ string GetItem(int index)

return string.Empty;
}

private protected override string GetDebbugerDisplay()
{
return $"Items = {ItemsSource?.Count ?? 0}, SelectedItem = {SelectedItem}, " + base.GetDebbugerDisplay();
}
}
}
7 changes: 7 additions & 0 deletions src/Controls/src/Core/ProgressBar/ProgressBar.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#nullable disable
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Microsoft.Maui.Controls.Internals;
Expand All @@ -8,6 +9,7 @@
namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/ProgressBar.xml" path="Type[@FullName='Microsoft.Maui.Controls.ProgressBar']/Docs/*" />
[DebuggerDisplay("{GetDebbugerDisplay(), nq}")]
public partial class ProgressBar : View, IElementConfiguration<ProgressBar>, IProgress
{
/// <summary>Bindable property for <see cref="ProgressColor"/>.</summary>
Expand Down Expand Up @@ -53,5 +55,10 @@ public IPlatformElementConfiguration<T, ProgressBar> On<T>() where T : IConfigPl
{
return _platformConfigurationRegistry.Value.On<T>();
}

private protected override string GetDebbugerDisplay()
{
return $"Progress = {Progress}, " + base.GetDebbugerDisplay();
}
}
}
Loading
Loading