Repository navigation
Support consistent XAML type references - #39890
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39890Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39890" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
The parser mistakes a nested TypeName= for an outer assignment, rejecting a supported x:TypeArguments expression and causing inconsistent behavior between runtime XAML and SourceGen.
1 open issue
What changed in this PR
This PR addresses #25231 by making XAML type-reference syntax more consistent across .NET MAUI’s runtime loader and source generator, without XamlC-specific changes.
Changes:
- Resolve bare names for
System.Typevalues and array element types while preserving explicit converters. - Support
{x:Type ...}in generic arguments and respect locally scoped namespace aliases. - Improve invalid-type diagnostics and add runtime/SourceGen regression tests.
| File | Description |
|---|---|
src/Controls/tests/Xaml.UnitTests/Issues/Maui25231.rtsg.xaml.cs |
Tests type resolution, converter precedence, errors, and namespace scope. |
src/Controls/tests/Xaml.UnitTests/Issues/Maui25231.rtsg.xaml |
Supplies runtime/SourceGen cases for supported type-reference forms. |
src/Controls/src/Xaml/TypeArgumentsParser.cs |
Parses type extensions and validates type expressions. |
src/Controls/src/Xaml/ExpandMarkupsVisitor.cs |
Handles nested type extensions in runtime generic arguments. |
src/Controls/src/SourceGen/XmlTypeExtensions.cs |
Handles unresolved generic arguments without constructing invalid symbols. |
src/Controls/src/SourceGen/Visitors/ExpandMarkupsVisitor.cs |
Handles nested type extensions in generated generic arguments. |
src/Controls/src/SourceGen/Visitors/CreateValuesVisitor.cs |
Resolves bare array element types and improves errors. |
src/Controls/src/SourceGen/TypeConverters/TypeTypeConverter.cs |
Uses shared parsing for generated type conversions. |
src/Controls/src/SourceGen/NodeSGExtensions.cs |
Adds fallback conversion for System.Type values. |
src/Controls/src/SourceGen/KnownMarkups.cs |
Reports unresolved relative-source ancestor types. |
src/Controls/src/SourceGen/CodeBehindCodeWriter.cs |
Resolves named-field generic arguments using local namespaces. |
src/Controls/src/Core/Xaml/TypeConversionExtensions.cs |
Adds runtime type-name conversion when no explicit converter exists. |
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
29893ad to
1d93433
Compare
Skill Validation Results
|

Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
System.Typevalues in runtime XAML and SourceGen, while preserving explicitly specified type converters.x:Arrayelement types and{x:Type ...}in generic type arguments, including nested markup extensions and locally scoped namespace aliases.Validation
dotnet build Microsoft.Maui.BuildTasks.slnf --no-restore -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false -v q -clp:ErrorsOnly.dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj -c Debug --no-restore -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false --filter 'FullyQualifiedName~Maui25231' --logger 'console;verbosity=normal' -v q -clp:ErrorsOnly.LC_ALL=en_US.UTF-8 dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj -c Debug --no-build --no-restore -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeAndroidTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -p:IncludeWindowsTargetFrameworks=false --logger 'console;verbosity=minimal' -v q -clp:ErrorsOnly.Under the machine's default locale, two existing decimal-binding tests fail because they parse comma-formatted values using invariant culture. The same tests pass with
LC_ALL=en_US.UTF-8.Issues Fixed
Fixes #25231