diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 3b3d280a..69c13801 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "uno.check": { - "version": "1.20.2", + "version": "1.27.4", "commands": [ "uno-check" ] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f5b6a945..8c646d8b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -154,7 +154,7 @@ jobs: - name: Run SourceGenerators tests id: test-generator - run: vstest.console.exe ./tooling/CommunityToolkit.Tooling.SampleGen.Tests/bin/Release/net6.0/CommunityToolkit.Tooling.SampleGen.Tests.dll /logger:"trx;LogFileName=SourceGenerators.trx" + run: vstest.console.exe ./tooling/CommunityToolkit.Tooling.SampleGen.Tests/bin/Release/net8.0/CommunityToolkit.Tooling.SampleGen.Tests.dll /logger:"trx;LogFileName=SourceGenerators.trx" - name: Run component tests against ${{ matrix.multitarget }} if: ${{ matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk' }} diff --git a/Directory.Build.props b/Directory.Build.props index 7eb72bb7..4cedcd65 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -29,8 +29,11 @@ $(NoWarn);TKSMPL0014; - NU1901;NU1902;NU1903;NU1904 + $(WarningsNotAsErrors);NU1901;NU1902;NU1903;NU1904 $(NoWarn);TKSMPL0014; + + + $(WarningsNotAsErrors);CS0419;CS1570;CS1574 diff --git a/components/Behaviors/src/Headers/FadeHeaderBehavior.cs b/components/Behaviors/src/Headers/FadeHeaderBehavior.cs index a9ca7c34..17aa5404 100644 --- a/components/Behaviors/src/Headers/FadeHeaderBehavior.cs +++ b/components/Behaviors/src/Headers/FadeHeaderBehavior.cs @@ -46,6 +46,9 @@ protected override bool AssignAnimation() return false; } + /// + /// Stops the animation. + /// protected override void StopAnimation() { if (_headerVisual != null) diff --git a/components/Behaviors/src/Headers/HeaderBehaviorBase.cs b/components/Behaviors/src/Headers/HeaderBehaviorBase.cs index 126223ac..57b1c375 100644 --- a/components/Behaviors/src/Headers/HeaderBehaviorBase.cs +++ b/components/Behaviors/src/Headers/HeaderBehaviorBase.cs @@ -22,9 +22,24 @@ public abstract class HeaderBehaviorBase : BehaviorBase // From Doc: https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.canvas.zindex private const int CanvasZIndexMax = 1_000_000; + /// + /// The ScrollViewer associated with the ListViewBase control. + /// protected ScrollViewer? _scrollViewer; + + /// + /// The CompositionPropertySet associated with the ScrollViewer. + /// protected CompositionPropertySet? _scrollProperties; + + /// + /// The CompositionPropertySet associated with the animation. + /// protected CompositionPropertySet? _animationProperties; + + /// + /// The Visual associated with the header element. + /// protected Visual? _headerVisual; /// diff --git a/components/ImageCropper/src/ImageCropperThumb.cs b/components/ImageCropper/src/ImageCropperThumb.cs index 8036dc8f..3cd46e7f 100644 --- a/components/ImageCropper/src/ImageCropperThumb.cs +++ b/components/ImageCropper/src/ImageCropperThumb.cs @@ -46,6 +46,7 @@ public ImageCropperThumb() } + /// protected override void OnApplyTemplate() { PointerEntered -= Control_PointerEntered; @@ -79,8 +80,6 @@ private static void OnXChanged(DependencyObject d, DependencyPropertyChangedEven target.UpdatePosition(); } - - private static void OnYChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var target = (ImageCropperThumb)d; @@ -99,12 +98,18 @@ private static void OnYChanged(DependencyObject d, DependencyPropertyChangedEven public static readonly DependencyProperty YProperty = DependencyProperty.Register(nameof(Y), typeof(double), typeof(ImageCropperThumb), new PropertyMetadata(0d, OnYChanged)); + /// + /// Handles the PointerEntered event. + /// public void Control_PointerEntered(object sender, PointerRoutedEventArgs e) { base.OnPointerEntered(e); VisualStateManager.GoToState(this, PointerOverState, true); } + /// + /// Handles the PointerExited event. + /// public void Control_PointerExited(object sender, PointerRoutedEventArgs e) { base.OnPointerExited(e); @@ -123,12 +128,14 @@ private void Control_PointerCanceled(object sender, PointerRoutedEventArgs e) VisualStateManager.GoToState(this, NormalState, true); } + /// protected override void OnPointerPressed(PointerRoutedEventArgs e) { base.OnPointerPressed(e); VisualStateManager.GoToState(this, PressedState, true); } + /// protected override void OnPointerReleased(PointerRoutedEventArgs e) { base.OnPointerReleased(e); diff --git a/components/Media/src/Helpers/SurfaceLoader.Instance.cs b/components/Media/src/Helpers/SurfaceLoader.Instance.cs index 97245ece..d480c46c 100644 --- a/components/Media/src/Helpers/SurfaceLoader.Instance.cs +++ b/components/Media/src/Helpers/SurfaceLoader.Instance.cs @@ -226,6 +226,7 @@ public async Task LoadFromUri(Uri uri, Size sizeTarge return await LoadFromUri(uri, sizeTarget); } + /// public void Dispose() { compositionDevice?.Dispose(); diff --git a/components/Primitives/src/SwitchPresenter/SwitchConverter.cs b/components/Primitives/src/SwitchPresenter/SwitchConverter.cs index 7ce8bad2..470ca28b 100644 --- a/components/Primitives/src/SwitchPresenter/SwitchConverter.cs +++ b/components/Primitives/src/SwitchPresenter/SwitchConverter.cs @@ -66,6 +66,7 @@ public SwitchConverter() SwitchCases = new CaseCollection(); } + /// public object Convert(object value, Type targetType, object parameter, string language) { var result = SwitchCases.EvaluateCases(value, TargetType ?? targetType); @@ -73,6 +74,7 @@ public object Convert(object value, Type targetType, object parameter, string la return result?.Content!; } + /// public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); diff --git a/components/Primitives/src/SwitchPresenter/SwitchHelpers.cs b/components/Primitives/src/SwitchPresenter/SwitchHelpers.cs index c3698931..8974b8b6 100644 --- a/components/Primitives/src/SwitchPresenter/SwitchHelpers.cs +++ b/components/Primitives/src/SwitchPresenter/SwitchHelpers.cs @@ -61,6 +61,7 @@ internal static partial class SwitchHelpers /// /// Our main value in our SwitchPresenter. /// The value from the case to compare to. + /// The desired type of the result for automatic conversion. /// true if the two values are equal internal static bool CompareValues(object compare, object value, Type targetType) { diff --git a/components/Segmented/src/EqualPanel.cs b/components/Segmented/src/EqualPanel.cs index 415f05df..3caa7cbf 100644 --- a/components/Segmented/src/EqualPanel.cs +++ b/components/Segmented/src/EqualPanel.cs @@ -6,11 +6,18 @@ namespace CommunityToolkit.WinUI.Controls; +/// +/// A panel that arranges its children in equal columns. +/// public partial class EqualPanel : Panel { private double _maxItemWidth = 0; private double _maxItemHeight = 0; private int _visibleItemsCount = 0; + + /// + /// Gets or sets the spacing between items. + /// public double Spacing { get { return (double)GetValue(SpacingProperty); } @@ -27,11 +34,15 @@ public double Spacing typeof(EqualPanel), new PropertyMetadata(default(double), OnSpacingChanged)); + /// + /// Creates a new instance of the class. + /// public EqualPanel() { RegisterPropertyChangedCallback(HorizontalAlignmentProperty, OnHorizontalAlignmentChanged); } + /// protected override Size MeasureOverride(Size availableSize) { _maxItemWidth = 0; @@ -69,6 +80,7 @@ protected override Size MeasureOverride(Size availableSize) } } + /// protected override Size ArrangeOverride(Size finalSize) { double x = 0; diff --git a/components/Segmented/src/Helpers/SegmentedMarginConverter.cs b/components/Segmented/src/Helpers/SegmentedMarginConverter.cs index 9de95ded..1af08675 100644 --- a/components/Segmented/src/Helpers/SegmentedMarginConverter.cs +++ b/components/Segmented/src/Helpers/SegmentedMarginConverter.cs @@ -4,6 +4,9 @@ namespace CommunityToolkit.WinUI.Controls; +/// +/// A converter that returns a margin based on the position of the item in a segmented control. +/// public partial class SegmentedMarginConverter : DependencyObject, IValueConverter { /// @@ -51,6 +54,7 @@ public Thickness RightItemMargin set { SetValue(RightItemMarginProperty, value); } } + /// public object Convert(object value, Type targetType, object parameter, string language) { var segmentedItem = value as SegmentedItem; @@ -72,6 +76,7 @@ public object Convert(object value, Type targetType, object parameter, string la } } + /// public object ConvertBack(object value, Type targetType, object parameter, string language) { return value; diff --git a/components/Segmented/src/Segmented/Segmented.cs b/components/Segmented/src/Segmented/Segmented.cs index 75e0fb0f..8441866a 100644 --- a/components/Segmented/src/Segmented/Segmented.cs +++ b/components/Segmented/src/Segmented/Segmented.cs @@ -6,11 +6,17 @@ namespace CommunityToolkit.WinUI.Controls; +/// +/// A control that displays a set of items that can be selected by the user. +/// public partial class Segmented : ListViewBase { private int _internalSelectedIndex = -1; private bool _hasLoaded = false; + /// + /// Creates a new instance of . + /// public Segmented() { this.DefaultStyleKey = typeof(Segmented); @@ -18,13 +24,16 @@ public Segmented() RegisterPropertyChangedCallback(SelectedIndexProperty, OnSelectedIndexChanged); } + /// protected override DependencyObject GetContainerForItemOverride() => new SegmentedItem(); + /// protected override bool IsItemItsOwnContainerOverride(object item) { return item is SegmentedItem; } + /// protected override void OnApplyTemplate() { base.OnApplyTemplate(); @@ -37,6 +46,7 @@ protected override void OnApplyTemplate() PreviewKeyDown += Segmented_PreviewKeyDown; } + /// protected override void PrepareContainerForItemOverride(DependencyObject element, object item) { base.PrepareContainerForItemOverride(element, item); @@ -63,6 +73,7 @@ private void SegmentedItem_Loaded(object sender, RoutedEventArgs e) } } + /// protected override void OnItemsChanged(object e) { base.OnItemsChanged(e); diff --git a/components/Segmented/src/SegmentedItem/SegmentedItem.cs b/components/Segmented/src/SegmentedItem/SegmentedItem.cs index 94a9769f..6fc91435 100644 --- a/components/Segmented/src/SegmentedItem/SegmentedItem.cs +++ b/components/Segmented/src/SegmentedItem/SegmentedItem.cs @@ -4,6 +4,9 @@ namespace CommunityToolkit.WinUI.Controls; +/// +/// Represents an item in a control. +/// [ContentProperty(Name = nameof(Content))] public partial class SegmentedItem : ListViewItem { @@ -11,11 +14,15 @@ public partial class SegmentedItem : ListViewItem internal const string IconOnlyState = "IconOnly"; internal const string ContentOnlyState = "ContentOnly"; + /// + /// Creates a new instance of . + /// public SegmentedItem() { this.DefaultStyleKey = typeof(SegmentedItem); } + /// protected override void OnApplyTemplate() { base.OnApplyTemplate(); @@ -23,6 +30,9 @@ protected override void OnApplyTemplate() ContentChanged(); } + /// + /// Handles changes to the Content property. + /// protected override void OnContentChanged(object oldContent, object newContent) { base.OnContentChanged(oldContent, newContent); @@ -41,6 +51,9 @@ private void ContentChanged() } } + /// + /// Handles changes to the Icon property. + /// protected virtual void OnIconPropertyChanged(IconElement oldValue, IconElement newValue) { OnIconChanged(); diff --git a/components/SettingsControls/src/Helpers/StyleExtensions.cs b/components/SettingsControls/src/Helpers/StyleExtensions.cs index 2a44d465..b34b9fe9 100644 --- a/components/SettingsControls/src/Helpers/StyleExtensions.cs +++ b/components/SettingsControls/src/Helpers/StyleExtensions.cs @@ -4,7 +4,12 @@ namespace CommunityToolkit.WinUI.Controls; -// Adapted from https://github.com/rudyhuyn/XamlPlus +/// +/// Helper class for setting a ResourceDictionary on a Style. +/// +/// +/// Adapted from https://github.com/rudyhuyn/XamlPlus +/// public static partial class StyleExtensions { // Used to distinct normal ResourceDictionary and the one we add. @@ -12,16 +17,25 @@ private sealed partial class StyleExtensionResourceDictionary : ResourceDictiona { } + /// + /// Get a ResourceDictionary from a Style. + /// public static ResourceDictionary GetResources(Style obj) { return (ResourceDictionary)obj.GetValue(ResourcesProperty); } + /// + /// Set the on a Style to a ResourceDictionary value. + /// public static void SetResources(Style obj, ResourceDictionary value) { obj.SetValue(ResourcesProperty, value); } + /// + /// Attached property to set a Style to a ResourceDictionary value. + /// public static readonly DependencyProperty ResourcesProperty = DependencyProperty.RegisterAttached("Resources", typeof(ResourceDictionary), typeof(StyleExtensions), new PropertyMetadata(null, ResourcesChanged)); diff --git a/components/SettingsControls/src/SettingsCard/SettingsCard.Properties.cs b/components/SettingsControls/src/SettingsCard/SettingsCard.Properties.cs index 6152a04e..559cc775 100644 --- a/components/SettingsControls/src/SettingsCard/SettingsCard.Properties.cs +++ b/components/SettingsControls/src/SettingsCard/SettingsCard.Properties.cs @@ -152,41 +152,62 @@ public bool IsActionIconVisible set => SetValue(IsActionIconVisibleProperty, value); } + /// + /// Called when the IsClickEnabled property changes. + /// protected virtual void OnIsClickEnabledPropertyChanged(bool oldValue, bool newValue) { OnIsClickEnabledChanged(); } + + /// + /// Called when the HeaderIcon property changes. + /// protected virtual void OnHeaderIconPropertyChanged(IconElement oldValue, IconElement newValue) { OnHeaderIconChanged(); } + /// + /// Called when the Header property changes. + /// protected virtual void OnHeaderPropertyChanged(object oldValue, object newValue) { OnHeaderChanged(); } + /// + /// Called when the Description property changes. + /// protected virtual void OnDescriptionPropertyChanged(object oldValue, object newValue) { OnDescriptionChanged(); } + /// + /// Called when the IsActionIconVisible property changes. + /// protected virtual void OnIsActionIconVisiblePropertyChanged(bool oldValue, bool newValue) { OnActionIconChanged(); } } +/// +/// The alignment of Content. +/// public enum ContentAlignment { /// /// The Content is aligned to the right. Default state. /// Right, + /// /// The Content is left-aligned while the Header, HeaderIcon and Description are collapsed. This is commonly used for Content types such as CheckBoxes, RadioButtons and custom layouts. /// Left, + /// /// The Content is vertically aligned. /// diff --git a/components/SettingsControls/src/SettingsCard/SettingsCard.cs b/components/SettingsControls/src/SettingsCard/SettingsCard.cs index 6e1e064b..dbc4f12e 100644 --- a/components/SettingsControls/src/SettingsCard/SettingsCard.cs +++ b/components/SettingsControls/src/SettingsCard/SettingsCard.cs @@ -148,12 +148,18 @@ private void Control_PreviewKeyDown(object sender, KeyRoutedEventArgs e) } } + /// + /// Handles the PointerEntered event. + /// public void Control_PointerEntered(object sender, PointerRoutedEventArgs e) { base.OnPointerEntered(e); VisualStateManager.GoToState(this, PointerOverState, true); } + /// + /// Handles the PointerExited event. + /// public void Control_PointerExited(object sender, PointerRoutedEventArgs e) { base.OnPointerExited(e); @@ -172,6 +178,9 @@ private void Control_PointerCanceled(object sender, PointerRoutedEventArgs e) VisualStateManager.GoToState(this, NormalState, true); } + /// + /// Handles the PointerPressed event. + /// protected override void OnPointerPressed(PointerRoutedEventArgs e) { // e.Handled = true; @@ -182,6 +191,9 @@ protected override void OnPointerPressed(PointerRoutedEventArgs e) } } + /// + /// Handles the PointerReleased event. + /// protected override void OnPointerReleased(PointerRoutedEventArgs e) { if (IsClickEnabled) diff --git a/components/SettingsControls/src/SettingsCard/SettingsCardAutomationPeer.cs b/components/SettingsControls/src/SettingsCard/SettingsCardAutomationPeer.cs index 6d287812..7711035b 100644 --- a/components/SettingsControls/src/SettingsCard/SettingsCardAutomationPeer.cs +++ b/components/SettingsControls/src/SettingsCard/SettingsCardAutomationPeer.cs @@ -44,6 +44,7 @@ protected override string GetClassNameCore() return Owner.GetType().Name; } + /// protected override string GetNameCore() { // We only want to announce the button card name if it is clickable, else it's just a regular card that does not receive focus diff --git a/components/SettingsControls/src/SettingsExpander/SettingsExpander.ItemsControl.cs b/components/SettingsControls/src/SettingsExpander/SettingsExpander.ItemsControl.cs index e9de7832..665dd7dd 100644 --- a/components/SettingsControls/src/SettingsExpander/SettingsExpander.ItemsControl.cs +++ b/components/SettingsControls/src/SettingsExpander/SettingsExpander.ItemsControl.cs @@ -2,44 +2,70 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.UI.Xaml.Controls; + namespace CommunityToolkit.WinUI.Controls; //// Implement properties for ItemsControl like behavior. public partial class SettingsExpander { + /// + /// Gets or sets the collection of items to display. + /// public IList Items { get { return (IList)GetValue(ItemsProperty); } set { SetValue(ItemsProperty, value); } } + /// + /// Identifies the DependencyProperty. + /// public static readonly DependencyProperty ItemsProperty = DependencyProperty.Register(nameof(Items), typeof(IList), typeof(SettingsExpander), new PropertyMetadata(null, OnItemsConnectedPropertyChanged)); + /// + /// Gets or sets the value to use for the inner . + /// public object ItemsSource { get { return (object)GetValue(ItemsSourceProperty); } set { SetValue(ItemsSourceProperty, value); } } + /// + /// Identifies the DependencyProperty. + /// public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(nameof(ItemsSource), typeof(object), typeof(SettingsExpander), new PropertyMetadata(null, OnItemsConnectedPropertyChanged)); + /// + /// Gets or sets the value to use for the inner . + /// public object ItemTemplate { get { return (object)GetValue(ItemTemplateProperty); } set { SetValue(ItemTemplateProperty, value); } } + /// + /// Identifies the DependencyProperty. + /// public static readonly DependencyProperty ItemTemplateProperty = DependencyProperty.Register(nameof(ItemTemplate), typeof(object), typeof(SettingsExpander), new PropertyMetadata(null)); + /// + /// Gets or sets the value to use for the ItemContainerStyle applied to the inner . + /// public StyleSelector ItemContainerStyleSelector { get { return (StyleSelector)GetValue(ItemContainerStyleSelectorProperty); } set { SetValue(ItemContainerStyleSelectorProperty, value); } } + /// + /// Identifies the DependencyProperty. + /// public static readonly DependencyProperty ItemContainerStyleSelectorProperty = DependencyProperty.Register(nameof(ItemContainerStyleSelector), typeof(StyleSelector), typeof(SettingsExpander), new PropertyMetadata(null)); diff --git a/components/SettingsControls/src/SettingsExpander/SettingsExpander.Properties.cs b/components/SettingsControls/src/SettingsExpander/SettingsExpander.Properties.cs index d3924795..53bd92dd 100644 --- a/components/SettingsControls/src/SettingsExpander/SettingsExpander.Properties.cs +++ b/components/SettingsControls/src/SettingsExpander/SettingsExpander.Properties.cs @@ -137,6 +137,8 @@ public bool IsExpanded get => (bool)GetValue(IsExpandedProperty); set => SetValue(IsExpandedProperty, value); } + + /// protected virtual void OnIsExpandedPropertyChanged(bool oldValue, bool newValue) { OnIsExpandedChanged(oldValue, newValue); diff --git a/components/SettingsControls/src/SettingsExpander/SettingsExpander.cs b/components/SettingsControls/src/SettingsExpander/SettingsExpander.cs index d969a16d..b617833c 100644 --- a/components/SettingsControls/src/SettingsExpander/SettingsExpander.cs +++ b/components/SettingsControls/src/SettingsExpander/SettingsExpander.cs @@ -4,6 +4,9 @@ namespace CommunityToolkit.WinUI.Controls; +/// +/// The SettingsExpander is a collapsable control to host multiple SettingsCards. +/// //// Note: ItemsRepeater will request all the available horizontal space: https://github.com/microsoft/microsoft-ui-xaml/issues/3842 [TemplatePart(Name = PART_ItemsRepeater, Type = typeof(MUXC.ItemsRepeater))] public partial class SettingsExpander : Control diff --git a/components/SettingsControls/src/SettingsExpander/SettingsExpanderAutomationPeer.cs b/components/SettingsControls/src/SettingsExpander/SettingsExpanderAutomationPeer.cs index 0fef3e63..d9fe6ecf 100644 --- a/components/SettingsControls/src/SettingsExpander/SettingsExpanderAutomationPeer.cs +++ b/components/SettingsControls/src/SettingsExpander/SettingsExpanderAutomationPeer.cs @@ -42,6 +42,7 @@ protected override string GetClassNameCore() return Owner.GetType().Name; } + /// protected override string GetNameCore() { string name = base.GetNameCore(); diff --git a/components/TokenizingTextBox/src/TokenizingTextBox.cs b/components/TokenizingTextBox/src/TokenizingTextBox.cs index d3972b4e..db1dd012 100644 --- a/components/TokenizingTextBox/src/TokenizingTextBox.cs +++ b/components/TokenizingTextBox/src/TokenizingTextBox.cs @@ -623,5 +623,8 @@ private void GuardAgainstPlaceholderTextLayoutIssue() } } + /// + /// Checks if the XamlRoot property is available via the current API. + /// public static bool IsXamlRootAvailable { get; } = ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "XamlRoot"); } diff --git a/components/Triggers/src/IsNullOrEmptyStateTrigger.cs b/components/Triggers/src/IsNullOrEmptyStateTrigger.cs index 7d792451..6fe934c5 100644 --- a/components/Triggers/src/IsNullOrEmptyStateTrigger.cs +++ b/components/Triggers/src/IsNullOrEmptyStateTrigger.cs @@ -28,6 +28,9 @@ public object Value public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(nameof(Value), typeof(object), typeof(IsNullOrEmptyStateTrigger), new PropertyMetadata(null, OnValuePropertyChanged)); + /// + /// Creates a new instance of . + /// public IsNullOrEmptyStateTrigger() { UpdateTrigger(); diff --git a/tooling b/tooling index 93931e0b..1ac9b809 160000 --- a/tooling +++ b/tooling @@ -1 +1 @@ -Subproject commit 93931e0beda3520fcc68e8bf9975a4ebb7067674 +Subproject commit 1ac9b8094bc263c29f7a883b564371eecb8ff152