Skip to content

Commit ab4de0e

Browse files
jfversluisCopilot
andauthored
Add XML documentation to Controls.Xaml and enable CS1591 (#33669)
> [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could <a href="https://github.com/dotnet/maui/wiki/Testing-PR-Builds">test the resulting artifacts</a> from this PR and let us know in a comment if this change resolves your issue. Thank you! ## Description Adds XML documentation to all public members in **Microsoft.Maui.Controls.Xaml** and enables CS1591 as a warning-as-error to prevent future documentation gaps. ## Changes ### Markup Extensions Documented - `BindingExtension` - All 11 properties - `StaticResourceExtension` - Key property - `DynamicResourceExtension` - Key property - `OnPlatformExtension` - All platform properties - `OnIdiomExtension` - All idiom properties - `ReferenceExtension` - Name property - `TypeExtension` - TypeName property - `StaticExtension` - Member property - `NullExtension` - Class summary - `ArrayExtension` - Type property and Items collection - `TemplateBindingExtension` - All binding properties - `RelativeSourceExtension` - Mode and AncestorType properties - `DataTemplateExtension` - TypeName property - `AppThemeBindingExtension` - Light/Dark/Default properties - `StyleSheetExtension` - Style and Source properties - `FontImageExtension` - Class summary (obsolete type) ### Other Types Documented - `Extensions` class - LoadFromXaml methods - `XamlFilePathAttribute` - Constructor and FilePath property - `AppHostBuilderExtensions.AddMauiControlsHandlers` method ### Build Configuration - Removed CS1591 from NoWarn - Added CS1591 to WarningsAsErrors ## Stats - **20 files changed** - **+260 lines** of documentation --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d499a67 commit ab4de0e

20 files changed

+260
-1
lines changed

src/Controls/src/Xaml/Controls.Xaml.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
<RootNamespace>Microsoft.Maui.Controls.Xaml</RootNamespace>
88
<IsTrimmable>false</IsTrimmable>
99
<_MauiDesignDllBuild Condition=" '$(OS)' != 'Unix' ">True</_MauiDesignDllBuild>
10-
<NoWarn>$(NoWarn);CA2200;CS1591;RS0041</NoWarn>
10+
<NoWarn>$(NoWarn);CA2200;RS0041</NoWarn>
11+
<WarningsAsErrors>$(WarningsAsErrors);CS1591</WarningsAsErrors>
1112
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1213
</PropertyGroup>
1314

src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public static partial class AppHostBuilderExtensions
3535
return builder;
3636
}
3737

38+
/// <summary>
39+
/// Registers the .NET MAUI Controls handlers with the handlers collection.
40+
/// </summary>
41+
/// <param name="handlersCollection">The handlers collection to register handlers with.</param>
42+
/// <returns>The handlers collection for chaining.</returns>
3843
public static IMauiHandlersCollection AddMauiControlsHandlers(this IMauiHandlersCollection handlersCollection) =>
3944
handlersCollection.AddControlsHandlers();
4045

src/Controls/src/Xaml/MarkupExtensions/AppThemeBindingExtension.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace Microsoft.Maui.Controls.Xaml
77
{
8+
/// <summary>
9+
/// Provides a XAML markup extension that creates a binding with different values for light and dark themes.
10+
/// </summary>
811
[ContentProperty(nameof(Default))]
912
[RequireService(
1013
[typeof(IProvideValueTarget),
@@ -20,6 +23,9 @@ public class AppThemeBindingExtension : IMarkupExtension<BindingBase>
2023
object _dark;
2124
bool _hasdark;
2225

26+
/// <summary>
27+
/// Gets or sets the default value to use when no theme-specific value is set.
28+
/// </summary>
2329
public object Default
2430
{
2531
get => _default; set
@@ -28,6 +34,10 @@ public object Default
2834
_hasdefault = true;
2935
}
3036
}
37+
38+
/// <summary>
39+
/// Gets or sets the value to use when the light theme is active.
40+
/// </summary>
3141
public object Light
3242
{
3343
get => _light; set
@@ -36,6 +46,10 @@ public object Light
3646
_haslight = true;
3747
}
3848
}
49+
50+
/// <summary>
51+
/// Gets or sets the value to use when the dark theme is active.
52+
/// </summary>
3953
public object Dark
4054
{
4155
get => _dark; set
@@ -44,6 +58,10 @@ public object Dark
4458
_hasdark = true;
4559
}
4660
}
61+
62+
/// <summary>
63+
/// Gets the current value based on the active theme.
64+
/// </summary>
4765
public object Value { get; private set; }
4866

4967
public object ProvideValue(IServiceProvider serviceProvider) => (this as IMarkupExtension<BindingBase>).ProvideValue(serviceProvider);

src/Controls/src/Xaml/MarkupExtensions/ArrayExtension.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,32 @@
55

66
namespace Microsoft.Maui.Controls.Xaml
77
{
8+
/// <summary>
9+
/// Provides a XAML markup extension that creates an array of objects.
10+
/// </summary>
811
[ContentProperty(nameof(Items))]
912
[AcceptEmptyServiceProvider]
1013
#if !NETSTANDARD
1114
[RequiresDynamicCode("ArrayExtension is not AOT safe.")]
1215
#endif
1316
public class ArrayExtension : IMarkupExtension<Array>
1417
{
18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="ArrayExtension"/> class.
20+
/// </summary>
1521
public ArrayExtension()
1622
{
1723
Items = new List<object>();
1824
}
1925

26+
/// <summary>
27+
/// Gets the list of items to include in the array.
28+
/// </summary>
2029
public IList Items { get; }
2130

31+
/// <summary>
32+
/// Gets or sets the type of elements in the array.
33+
/// </summary>
2234
public Type Type { get; set; }
2335

2436
public Array ProvideValue(IServiceProvider serviceProvider)

src/Controls/src/Xaml/MarkupExtensions/BindingExtension.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,59 @@
55

66
namespace Microsoft.Maui.Controls.Xaml
77
{
8+
/// <summary>
9+
/// Provides a XAML markup extension that creates a <see cref="Binding"/> from a XAML attribute value.
10+
/// </summary>
811
[ContentProperty(nameof(Path))]
912
[RequireService([typeof(IXamlTypeResolver), typeof(IXamlDataTypeProvider)])]
1013
public sealed class BindingExtension : IMarkupExtension<BindingBase>
1114
{
15+
/// <summary>
16+
/// Gets or sets the path to the binding source property.
17+
/// </summary>
1218
public string Path { get; set; } = Binding.SelfPath;
19+
20+
/// <summary>
21+
/// Gets or sets the binding mode.
22+
/// </summary>
1323
public BindingMode Mode { get; set; } = BindingMode.Default;
24+
25+
/// <summary>
26+
/// Gets or sets the converter to use when converting between source and target values.
27+
/// </summary>
1428
public IValueConverter Converter { get; set; }
29+
30+
/// <summary>
31+
/// Gets or sets a parameter to pass to the converter.
32+
/// </summary>
1533
public object ConverterParameter { get; set; }
34+
35+
/// <summary>
36+
/// Gets or sets a format string to use when converting the bound value to a string.
37+
/// </summary>
1638
public string StringFormat { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets the source object for the binding.
42+
/// </summary>
1743
public object Source { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets the name of the event that triggers the source update in TwoWay bindings.
47+
/// </summary>
1848
public string UpdateSourceEventName { get; set; }
49+
50+
/// <summary>
51+
/// Gets or sets the value to use when the target property value is <see langword="null"/>.
52+
/// </summary>
1953
public object TargetNullValue { get; set; }
54+
55+
/// <summary>
56+
/// Gets or sets the value to use when the binding cannot return a value.
57+
/// </summary>
2058
public object FallbackValue { get; set; }
59+
60+
/// <summary>For internal use only. This API can be changed or removed without notice at any time.</summary>
2161
[EditorBrowsable(EditorBrowsableState.Never)] public TypedBindingBase TypedBinding { get; set; }
2262

2363
BindingBase IMarkupExtension<BindingBase>.ProvideValue(IServiceProvider serviceProvider)

src/Controls/src/Xaml/MarkupExtensions/DataTemplateExtension.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33

44
namespace Microsoft.Maui.Controls.Xaml
55
{
6+
/// <summary>
7+
/// Provides a XAML markup extension that creates a <see cref="DataTemplate"/> for a specified type.
8+
/// </summary>
69
[ContentProperty(nameof(TypeName))]
710
[ProvideCompiled("Microsoft.Maui.Controls.Build.Tasks.DataTemplateExtension")]
811
[RequiresUnreferencedCode(TrimmerConstants.XamlRuntimeParsingNotSupportedWarning)]
912
public sealed class DataTemplateExtension : IMarkupExtension<DataTemplate>
1013
{
14+
/// <summary>
15+
/// Gets or sets the type name for which to create the data template.
16+
/// </summary>
1117
public string TypeName { get; set; }
1218

1319
public DataTemplate ProvideValue(IServiceProvider serviceProvider)

src/Controls/src/Xaml/MarkupExtensions/DynamicResourceExtension.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33

44
namespace Microsoft.Maui.Controls.Xaml
55
{
6+
/// <summary>
7+
/// Provides a XAML markup extension that creates a <see cref="DynamicResource"/> for dynamic resource lookup.
8+
/// </summary>
69
[ContentProperty(nameof(Key))]
710
[RequireService([typeof(IXmlLineInfoProvider)])]
811
public sealed class DynamicResourceExtension : IMarkupExtension<DynamicResource>
912
{
13+
/// <summary>
14+
/// Gets or sets the key of the dynamic resource to retrieve.
15+
/// </summary>
1016
public string Key { get; set; }
1117

1218
public object ProvideValue(IServiceProvider serviceProvider) => ((IMarkupExtension<DynamicResource>)this).ProvideValue(serviceProvider);

src/Controls/src/Xaml/MarkupExtensions/FontImageExtension.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace Microsoft.Maui.Controls.Xaml;
55

6+
/// <summary>
7+
/// Provides a XAML markup extension that creates a font image. Use <see cref="FontImageSource"/> instead.
8+
/// </summary>
69
[Obsolete("Use FontImageSource")]
710
public class FontImageExtension : FontImageSource
811
{

src/Controls/src/Xaml/MarkupExtensions/NullExtension.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Microsoft.Maui.Controls.Xaml
44
{
5+
/// <summary>
6+
/// Provides a XAML markup extension that returns <see langword="null"/>.
7+
/// </summary>
58
[ProvideCompiled("Microsoft.Maui.Controls.Build.Tasks.NullExtension")]
69
[AcceptEmptyServiceProvider]
710
public class NullExtension : IMarkupExtension

src/Controls/src/Xaml/MarkupExtensions/OnIdiomExtension.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Microsoft.Maui.Controls.Xaml
1010
{
11+
/// <summary>
12+
/// Provides a XAML markup extension that returns different values depending on the device idiom.
13+
/// </summary>
1114
[ContentProperty(nameof(Default))]
1215
[RequireService(
1316
[typeof(IProvideValueTarget),
@@ -19,15 +22,44 @@ public class OnIdiomExtension : IMarkupExtension
1922
{
2023
// See Device.Idiom
2124

25+
/// <summary>
26+
/// Gets or sets the default value to use if no idiom-specific value is set.
27+
/// </summary>
2228
public object Default { get; set; }
29+
30+
/// <summary>
31+
/// Gets or sets the value to use on phone devices.
32+
/// </summary>
2333
public object Phone { get; set; }
34+
35+
/// <summary>
36+
/// Gets or sets the value to use on tablet devices.
37+
/// </summary>
2438
public object Tablet { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets the value to use on desktop devices.
42+
/// </summary>
2543
public object Desktop { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets the value to use on TV devices.
47+
/// </summary>
2648
public object TV { get; set; }
49+
50+
/// <summary>
51+
/// Gets or sets the value to use on watch devices.
52+
/// </summary>
2753
public object Watch { get; set; }
2854

55+
/// <summary>
56+
/// Gets or sets a converter to apply to the idiom-specific value.
57+
/// </summary>
2958
public IValueConverter Converter { get; set; }
3059

60+
/// <summary>
61+
/// Gets or sets a parameter to pass to the converter.
62+
/// </summary>
3163
public object ConverterParameter { get; set; }
3264

3365
public object ProvideValue(IServiceProvider serviceProvider)

0 commit comments

Comments
 (0)