Skip to content

Conversation

@StephaneDelcroix
Copy link
Contributor

Description of Change

when we have multiple GridLengthTypeConverter in the codebase, it can be confusing to know which one to use.

Issues Fixed

Fixes #29334

Copilot AI review requested due to automatic review settings May 7, 2025 13:36
@StephaneDelcroix StephaneDelcroix requested a review from a team as a code owner May 7, 2025 13:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR clarifies which GridLengthTypeConverter to use by introducing a new public API in Microsoft.Maui.GridLength and updating converter references across multiple projects.

  • Added new public API entries for Microsoft.Maui.GridLength.GridLengthTypeConverter in PublicAPI.Unshipped.txt files for different platforms.
  • Updated GridLength conversion logic to support string inputs and revised related type converter references in RowDefinition and ColumnDefinition converters.
  • Added a new unit test (Maui29334.xaml.cs) to cover the updated conversion behavior.

Reviewed Changes

Copilot reviewed 14 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt Added public API entries for the new GridLengthTypeConverter.
src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt Added corresponding public API entries for Windows.
src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt Added corresponding public API entries for Tizen.
src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt Added corresponding public API entries for Mac Catalyst.
src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt Added corresponding public API entries for iOS.
src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt Added corresponding public API entries for Android.
src/Core/src/Primitives/GridLength.cs Made GridLengthTypeConverter public and extended conversion logic to support strings.
src/Controls/tests/Xaml.UnitTests/Issues/Maui29334.xaml.cs Added a unit test to verify the new conversion behavior.
src/Controls/src/Core/RowDefinitionCollectionTypeConverter.cs, ColumnDefinitionCollectionTypeConverter.cs, RowDefinition.cs, ColumnDefinition.cs Updated TypeConverter references to use the fully qualified new GridLengthTypeConverter.
src/Controls/src/Core/GridLengthTypeConverter.cs Marked the existing GridLengthTypeConverter as obsolete.
src/Controls/src/Build.Tasks/XamlCache.cs Commented out an import reference for the old grid length converter.
Files not reviewed (3)
  • src/Controls/tests/Xaml.UnitTests/Issues/Maui29334.xaml: Language not supported
  • src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt: Language not supported
  • src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt: Language not supported
Comments suppressed due to low confidence (1)

src/Core/src/Primitives/GridLength.cs:132

  • The GridLengthTypeConverter now supports string conversion; please update or ensure that the XML docs and public API documentation explain the accepted string formats (e.g., 'auto', '', and numeric with optional '' suffix).
string strValue => strValue.Trim().ToLowerInvariant() switch

@@ -1,5 +1,11 @@
#nullable enable
Microsoft.Maui.ElementHandlerExtensions
Microsoft.Maui.GridLength.GridLengthTypeConverter
Copy link

Copilot AI May 7, 2025

Choose a reason for hiding this comment

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

The introduction of the public API for GridLengthTypeConverter may affect downstream consumers; please confirm that the related public documentation in the /docs/ folders is updated accordingly to reflect the new API usage.

Copilot uses AI. Check for mistakes.
@StephaneDelcroix StephaneDelcroix changed the title Dev/stdelc/fix29334 [X|C] only use a single GridLengthTypeConverter May 7, 2025
{ module.ImportReference(this, ("Microsoft.Maui", "Microsoft.Maui.Converters", "FlexAlignSelfTypeConverter")), typeof(EnumTypeConverter<Layouts.FlexAlignSelf>) },
{ module.ImportReference(this, ("Microsoft.Maui", "Microsoft.Maui.Converters", "FlexWrapTypeConverter")), typeof(EnumTypeConverter<Layouts.FlexWrap>) },
{ module.ImportReference(this, ("Microsoft.Maui", "Microsoft.Maui.Converters", "FlexBasisTypeConverter")), typeof(FlexBasisTypeConverter) },
// { module.ImportReference(this, ("Microsoft.Maui", "Microsoft.Maui", "GridLength.GridLengthTypeConverter")), typeof(GridLengthTypeConverter) },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this should be fixed (ImportReference should accept nested types) but of no importance as GridLengthTypeConverters are almost never use directly, but through collections

Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

Pending changes in the foldable project:

C:\a\_work\1\s\src\Controls\Foldable\src\TwoPaneView.cs(165,47): error CS0618: 'GridLengthTypeConverter' is obsolete: 'Microsoft.Maui.Controls.GridLengthTypeConverter is obsolete. Use Microsoft.Maui.GridLengthConverter instead.' [C:\a\_work\1\s\src\Controls\Foldable\src\Controls.Foldable.csproj::TargetFramework=net9.0-ios18.0]
    14 Error(s)

public static bool operator !=(GridLength left, GridLength right) => !(left == right);

private sealed class GridLengthTypeConverter : TypeConverter
public sealed class GridLengthTypeConverter : TypeConverter
Copy link
Contributor Author

Choose a reason for hiding this comment

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

as this is becoming public, I wonder if it should level up in the Converters namespace instead of staying a nested type.

Copy link
Member

Choose a reason for hiding this comment

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

I think that is a good idea!

@rmarinho
Copy link
Member

Are we adding new api in a Service release? Should this target net10 ?

@StephaneDelcroix
Copy link
Contributor Author

@rmarinho the added api is harmless, but this obsolete a type. so if we decide to merge this in a -sr, the deprecation should be delayed to net10

public static bool operator !=(GridLength left, GridLength right) => !(left == right);

private sealed class GridLengthTypeConverter : TypeConverter
public sealed class GridLengthTypeConverter : TypeConverter
Copy link
Member

Choose a reason for hiding this comment

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

I think that is a good idea!

/// Gets the calculated width (in wide mode) or height (in tall mode) of pane 1, or sets the GridLength value of pane 1.
/// </summary>
[System.ComponentModel.TypeConverter(typeof(GridLengthTypeConverter))]
[System.ComponentModel.TypeConverter(typeof(GridLength.GridLengthTypeConverter))]
Copy link
Member

Choose a reason for hiding this comment

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

These changes will be something that users will have to do? What if we were to keep the controls one and inherit from the Core one? Or something. Looking at the code it seems that no one is using it in Core?

Is there a way we can avoid API changes? #apiregret

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what about promoting the nested class to a normal class. that will limit the amount of change users might have to do.

also it is more aligned with other converters.

let's do that

@StephaneDelcroix
Copy link
Contributor Author

I have a rebase to net10 ready if we choose to defer this change

@PureWeen PureWeen modified the milestones: .NET 9 SR9, .NET 9 SR10 Jul 3, 2025
@PureWeen PureWeen modified the milestones: .NET 9 SR10, .NET 9 SR12 Aug 4, 2025
@PureWeen PureWeen removed this from the .NET 9 SR12 milestone Sep 10, 2025
@PureWeen PureWeen added this to the .NET 10 SR1 milestone Sep 10, 2025
@PureWeen PureWeen modified the milestones: .NET 10 SR1, .NET 10.0-rc2 Sep 22, 2025
@PureWeen PureWeen added the p/0 Work that we can't release without label Sep 22, 2025
@StephaneDelcroix StephaneDelcroix changed the base branch from main to net10.0 September 22, 2025 20:32
PureWeen
PureWeen previously approved these changes Sep 22, 2025
@PureWeen PureWeen merged commit af09229 into net10.0 Sep 23, 2025
150 of 153 checks passed
@PureWeen PureWeen deleted the dev/stdelc/fix29334 branch September 23, 2025 15:34
@github-project-automation github-project-automation bot moved this from Todo to Done in MAUI SDK Ongoing Sep 23, 2025
@PureWeen PureWeen mentioned this pull request Oct 21, 2025
2 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-xaml XAML, CSS, Triggers, Behaviors p/0 Work that we can't release without platform/android platform/ios platform/macos macOS / Mac Catalyst platform/windows

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

OnIdiom<GridLength> throws an not implemented Exception (in GridLengthTypeConverter)

6 participants