Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion src/Controls/src/Xaml/Controls.Xaml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<RootNamespace>Microsoft.Maui.Controls.Xaml</RootNamespace>
<IsTrimmable>false</IsTrimmable>
<_MauiDesignDllBuild Condition=" '$(OS)' != 'Unix' ">True</_MauiDesignDllBuild>
<NoWarn>$(NoWarn);CA2200;CS1591;RS0041</NoWarn>
<NoWarn>$(NoWarn);CA2200;RS0041</NoWarn>
<WarningsAsErrors>$(WarningsAsErrors);CS1591</WarningsAsErrors>
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

Enabling CS1591 as an error will require XML documentation on all public members, including the public ProvideValue methods in markup extensions (StaticResourceExtension, TypeExtension, ArrayExtension, DataTemplateExtension, NullExtension, OnPlatformExtension, OnIdiomExtension, ReferenceExtension, RelativeSourceExtension, and StaticExtension). These methods currently lack XML documentation and will cause compilation errors. Either add documentation to these methods or revert this change until they are documented.

Suggested change
<WarningsAsErrors>$(WarningsAsErrors);CS1591</WarningsAsErrors>
<WarningsAsErrors>$(WarningsAsErrors)</WarningsAsErrors>

Copilot uses AI. Check for mistakes.
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
5 changes: 5 additions & 0 deletions src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public static partial class AppHostBuilderExtensions
return builder;
}

/// <summary>
/// Registers the .NET MAUI Controls handlers with the handlers collection.
/// </summary>
/// <param name="handlersCollection">The handlers collection to register handlers with.</param>
/// <returns>The handlers collection for chaining.</returns>
public static IMauiHandlersCollection AddMauiControlsHandlers(this IMauiHandlersCollection handlersCollection) =>
handlersCollection.AddControlsHandlers();

Expand Down
18 changes: 18 additions & 0 deletions src/Controls/src/Xaml/MarkupExtensions/AppThemeBindingExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

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

/// <summary>
/// Gets or sets the default value to use when no theme-specific value is set.
/// </summary>
public object Default
{
get => _default; set
Expand All @@ -28,6 +34,10 @@ public object Default
_hasdefault = true;
}
}

/// <summary>
/// Gets or sets the value to use when the light theme is active.
/// </summary>
public object Light
{
get => _light; set
Expand All @@ -36,6 +46,10 @@ public object Light
_haslight = true;
}
}

/// <summary>
/// Gets or sets the value to use when the dark theme is active.
/// </summary>
public object Dark
{
get => _dark; set
Expand All @@ -44,6 +58,10 @@ public object Dark
_hasdark = true;
}
}

/// <summary>
/// Gets the current value based on the active theme.
/// </summary>
public object Value { get; private set; }

public object ProvideValue(IServiceProvider serviceProvider) => (this as IMarkupExtension<BindingBase>).ProvideValue(serviceProvider);
Expand Down
12 changes: 12 additions & 0 deletions src/Controls/src/Xaml/MarkupExtensions/ArrayExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,32 @@

namespace Microsoft.Maui.Controls.Xaml
{
/// <summary>
/// Provides a XAML markup extension that creates an array of objects.
/// </summary>
[ContentProperty(nameof(Items))]
[AcceptEmptyServiceProvider]
#if !NETSTANDARD
[RequiresDynamicCode("ArrayExtension is not AOT safe.")]
#endif
public class ArrayExtension : IMarkupExtension<Array>
{
/// <summary>
/// Initializes a new instance of the <see cref="ArrayExtension"/> class.
/// </summary>
public ArrayExtension()
{
Items = new List<object>();
}

/// <summary>
/// Gets the list of items to include in the array.
/// </summary>
public IList Items { get; }

/// <summary>
/// Gets or sets the type of elements in the array.
/// </summary>
public Type Type { get; set; }

public Array ProvideValue(IServiceProvider serviceProvider)
Expand Down
40 changes: 40 additions & 0 deletions src/Controls/src/Xaml/MarkupExtensions/BindingExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,59 @@

namespace Microsoft.Maui.Controls.Xaml
{
/// <summary>
/// Provides a XAML markup extension that creates a <see cref="Binding"/> from a XAML attribute value.
/// </summary>
[ContentProperty(nameof(Path))]
[RequireService([typeof(IXamlTypeResolver), typeof(IXamlDataTypeProvider)])]
public sealed class BindingExtension : IMarkupExtension<BindingBase>
{
/// <summary>
/// Gets or sets the path to the binding source property.
/// </summary>
public string Path { get; set; } = Binding.SelfPath;

/// <summary>
/// Gets or sets the binding mode.
/// </summary>
public BindingMode Mode { get; set; } = BindingMode.Default;

/// <summary>
/// Gets or sets the converter to use when converting between source and target values.
/// </summary>
public IValueConverter Converter { get; set; }

/// <summary>
/// Gets or sets a parameter to pass to the converter.
/// </summary>
public object ConverterParameter { get; set; }

/// <summary>
/// Gets or sets a format string to use when converting the bound value to a string.
/// </summary>
public string StringFormat { get; set; }

/// <summary>
/// Gets or sets the source object for the binding.
/// </summary>
public object Source { get; set; }

/// <summary>
/// Gets or sets the name of the event that triggers the source update in TwoWay bindings.
/// </summary>
public string UpdateSourceEventName { get; set; }

/// <summary>
/// Gets or sets the value to use when the target property value is <see langword="null"/>.
/// </summary>
public object TargetNullValue { get; set; }

/// <summary>
/// Gets or sets the value to use when the binding cannot return a value.
/// </summary>
public object FallbackValue { get; set; }

/// <summary>For internal use only. This API can be changed or removed without notice at any time.</summary>
[EditorBrowsable(EditorBrowsableState.Never)] public TypedBindingBase TypedBinding { get; set; }

BindingBase IMarkupExtension<BindingBase>.ProvideValue(IServiceProvider serviceProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@

namespace Microsoft.Maui.Controls.Xaml
{
/// <summary>
/// Provides a XAML markup extension that creates a <see cref="DataTemplate"/> for a specified type.
/// </summary>
[ContentProperty(nameof(TypeName))]
[ProvideCompiled("Microsoft.Maui.Controls.Build.Tasks.DataTemplateExtension")]
[RequiresUnreferencedCode(TrimmerConstants.XamlRuntimeParsingNotSupportedWarning)]
public sealed class DataTemplateExtension : IMarkupExtension<DataTemplate>
{
/// <summary>
/// Gets or sets the type name for which to create the data template.
/// </summary>
public string TypeName { get; set; }

public DataTemplate ProvideValue(IServiceProvider serviceProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@

namespace Microsoft.Maui.Controls.Xaml
{
/// <summary>
/// Provides a XAML markup extension that creates a <see cref="DynamicResource"/> for dynamic resource lookup.
/// </summary>
[ContentProperty(nameof(Key))]
[RequireService([typeof(IXmlLineInfoProvider)])]
public sealed class DynamicResourceExtension : IMarkupExtension<DynamicResource>
{
/// <summary>
/// Gets or sets the key of the dynamic resource to retrieve.
/// </summary>
public string Key { get; set; }

public object ProvideValue(IServiceProvider serviceProvider) => ((IMarkupExtension<DynamicResource>)this).ProvideValue(serviceProvider);
Expand Down
3 changes: 3 additions & 0 deletions src/Controls/src/Xaml/MarkupExtensions/FontImageExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace Microsoft.Maui.Controls.Xaml;

/// <summary>
/// Provides a XAML markup extension that creates a font image. Use <see cref="FontImageSource"/> instead.
/// </summary>
[Obsolete("Use FontImageSource")]
public class FontImageExtension : FontImageSource
{
Expand Down
3 changes: 3 additions & 0 deletions src/Controls/src/Xaml/MarkupExtensions/NullExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Microsoft.Maui.Controls.Xaml
{
/// <summary>
/// Provides a XAML markup extension that returns <see langword="null"/>.
/// </summary>
[ProvideCompiled("Microsoft.Maui.Controls.Build.Tasks.NullExtension")]
[AcceptEmptyServiceProvider]
public class NullExtension : IMarkupExtension
Expand Down
32 changes: 32 additions & 0 deletions src/Controls/src/Xaml/MarkupExtensions/OnIdiomExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Microsoft.Maui.Controls.Xaml
{
/// <summary>
/// Provides a XAML markup extension that returns different values depending on the device idiom.
/// </summary>
[ContentProperty(nameof(Default))]
[RequireService(
[typeof(IProvideValueTarget),
Expand All @@ -19,15 +22,44 @@ public class OnIdiomExtension : IMarkupExtension
{
// See Device.Idiom

/// <summary>
/// Gets or sets the default value to use if no idiom-specific value is set.
/// </summary>
public object Default { get; set; }

/// <summary>
/// Gets or sets the value to use on phone devices.
/// </summary>
public object Phone { get; set; }

/// <summary>
/// Gets or sets the value to use on tablet devices.
/// </summary>
public object Tablet { get; set; }

/// <summary>
/// Gets or sets the value to use on desktop devices.
/// </summary>
public object Desktop { get; set; }

/// <summary>
/// Gets or sets the value to use on TV devices.
/// </summary>
public object TV { get; set; }

/// <summary>
/// Gets or sets the value to use on watch devices.
/// </summary>
public object Watch { get; set; }

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

/// <summary>
/// Gets or sets a parameter to pass to the converter.
/// </summary>
public object ConverterParameter { get; set; }

public object ProvideValue(IServiceProvider serviceProvider)
Expand Down
39 changes: 39 additions & 0 deletions src/Controls/src/Xaml/MarkupExtensions/OnPlatformExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Microsoft.Maui.Controls.Xaml
{
/// <summary>
/// Provides a XAML markup extension that returns different values depending on the platform the app is running on.
/// </summary>
[ContentProperty(nameof(Default))]
[RequireService(
[typeof(IProvideValueTarget),
Expand All @@ -18,20 +21,56 @@ public class OnPlatformExtension : IMarkupExtension
{
static object s_notset = new object();

/// <summary>
/// Gets or sets the default value to use if no platform-specific value is set.
/// </summary>
public object Default { get; set; } = s_notset;

/// <summary>
/// Gets or sets the value to use on Android.
/// </summary>
public object Android { get; set; } = s_notset;

internal object GTK { get; set; } = s_notset;

/// <summary>
/// Gets or sets the value to use on iOS.
/// </summary>
public object iOS { get; set; } = s_notset;

internal object macOS { get; set; } = s_notset;

/// <summary>
/// Gets or sets the value to use on Mac Catalyst.
/// </summary>
public object MacCatalyst { get; set; } = s_notset;

/// <summary>
/// Gets or sets the value to use on Tizen.
/// </summary>
public object Tizen { get; set; } = s_notset;

/// <summary>
/// Gets or sets the value to use on UWP. Use <see cref="WinUI"/> instead.
/// </summary>
[Obsolete("Use WinUI instead.")]
public object UWP { get; set; } = s_notset;

internal object WPF { get; set; } = s_notset;

/// <summary>
/// Gets or sets the value to use on Windows (WinUI).
/// </summary>
public object WinUI { get; set; } = s_notset;

/// <summary>
/// Gets or sets a converter to apply to the platform-specific value.
/// </summary>
public IValueConverter Converter { get; set; }

/// <summary>
/// Gets or sets a parameter to pass to the converter.
/// </summary>
public object ConverterParameter { get; set; }

public object ProvideValue(IServiceProvider serviceProvider)
Expand Down
6 changes: 6 additions & 0 deletions src/Controls/src/Xaml/MarkupExtensions/ReferenceExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@

namespace Microsoft.Maui.Controls.Xaml
{
/// <summary>
/// Provides a XAML markup extension that returns an object by its x:Name from the current XAML namescope.
/// </summary>
[ContentProperty(nameof(Name))]
[RequireService([typeof(IReferenceProvider), typeof(IProvideValueTarget)])]
public class ReferenceExtension : IMarkupExtension
{
/// <summary>
/// Gets or sets the x:Name of the element to reference.
/// </summary>
public string Name { get; set; }

public object ProvideValue(IServiceProvider serviceProvider)
Expand Down
12 changes: 12 additions & 0 deletions src/Controls/src/Xaml/MarkupExtensions/RelativeSourceExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,34 @@

namespace Microsoft.Maui.Controls.Xaml
{
/// <summary>
/// Provides a XAML markup extension that returns a <see cref="RelativeBindingSource"/> for relative bindings.
/// </summary>
[ContentProperty("Mode")]
[AcceptEmptyServiceProvider]
public sealed class RelativeSourceExtension : IMarkupExtension<RelativeBindingSource>
{
/// <summary>
/// Gets or sets the mode of the relative binding source.
/// </summary>
public RelativeBindingSourceMode Mode
{
get;
set;
}

/// <summary>
/// Gets or sets the level of ancestor to look for when Mode is FindAncestor.
/// </summary>
public int AncestorLevel
{
get;
set;
}

/// <summary>
/// Gets or sets the type of ancestor to look for when Mode is FindAncestor or FindAncestorBindingContext.
/// </summary>
public Type AncestorType
{
get;
Expand Down
Loading
Loading