Skip to content

Conversation

@simonrozsival
Copy link
Member

Description of Change

Enum source generator generated invalid code with the namespace repeated twice, for example:

flexLayout.SetValue(global::Microsoft.Maui.Controls.FlexLayout.DirectionProperty, global::Microsoft.Maui.Layouts.FlexDirection.Microsoft.Maui.Layouts.FlexDirection.Row);

/cc @davidortinau

Copilot AI review requested due to automatic review settings September 20, 2025 08:43
@simonrozsival simonrozsival added the area-xaml XAML, CSS, Triggers, Behaviors label Sep 20, 2025
@simonrozsival simonrozsival enabled auto-merge (squash) September 20, 2025 08:43
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

Fixes a code generation bug in the enum converter that was outputting duplicate namespace qualifiers in generated XAML source code. The issue caused malformed code like global::Microsoft.Maui.Layouts.FlexDirection.Microsoft.Maui.Layouts.FlexDirection.Row instead of the correct global::Microsoft.Maui.Layouts.FlexDirection.Row.

  • Fixed enum converter to use .Name property instead of string interpolation of the entire field symbol
  • Added comprehensive unit test to verify correct enum conversion behavior and prevent regression

Reviewed Changes

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

File Description
src/Controls/src/SourceGen/TypeConverters/EnumConverter.cs Fixed the core bug by using detectedEnumValue.Name instead of string interpolating the field symbol directly
src/Controls/tests/SourceGen.UnitTests/KnownTypeConvertersTests.cs Added test case validating that FlexDirection enum generates correct code without duplicate namespaces

@PureWeen PureWeen added this to the .NET 10.0-rc2 milestone Sep 21, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Sep 21, 2025
@PureWeen PureWeen disabled auto-merge September 21, 2025 12:53
@PureWeen PureWeen merged commit c84a5d5 into net10.0 Sep 21, 2025
145 of 148 checks passed
@PureWeen PureWeen deleted the dev/srozsival/fix-sg-namespace-bug branch September 21, 2025 12:54
@github-project-automation github-project-automation bot moved this from Ready To Review to Done in MAUI SDK Ongoing Sep 21, 2025
@PureWeen PureWeen mentioned this pull request Oct 21, 2025
2 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Oct 22, 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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants