-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[X] implicit xmlns declarations #29181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 implements support for implicit xmlns declarations by pre-loading available XmlnsPrefix attributes and updating various XAML parsing and code-behind generation routines. Key changes include:
- Adding implicit namespace support in XamlParser, XamlLoader, and related build tasks.
- Refactoring CodeBehindGenerator to incorporate new assembly cache information (including xmlns prefixes) and updated type signatures.
- Updating and adding test cases to verify the new implicit xmlns behavior.
Reviewed Changes
Copilot reviewed 11 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/Controls/tests/Xaml.UnitTests/HRTests.cs | Adds a new SetUp method to reset Application.Current for test isolation. |
src/Controls/tests/Xaml.UnitTests/GlobalXmlns.xaml.cs | Introduces tests for validating behavior when implicit xmlns declarations are used. |
src/Controls/tests/SourceGen.UnitTests/SourceGenXamlTests.cs | Adds tests verifying global namespace handling and behavior when non-XAML is provided. |
src/Controls/src/Xaml/XamlParser.cs | Adds GetXmlnsPrefixAttributes to return preloaded xmlns prefixes using new array initializer syntax. |
src/Controls/src/Xaml/XamlParser.Namespaces.cs | Introduces DefaultImplicitUri to serve as the default implicit xmlns. |
src/Controls/src/Xaml/XamlLoader.cs | Updates XmlNamespaceManager initialization to include the default implicit xmlns and additional prefixes. |
src/Controls/src/SourceGen/CodeBehindGenerator.cs | Refactors methods (including ComputeXamlProjectItem and TryParseXaml) to support the new assembly caches and adjust type signatures accordingly. |
src/Controls/src/Core/Properties/AssemblyInfo.cs | Adds an assembly attribute for the XAML 2009 namespace prefix. |
src/Controls/src/Build.Tasks/* | Updates XAML parsing tasks to use module-specific xmlns prefix resolution. |
Files not reviewed (3)
- Microsoft.Maui-vscode.sln: Language not supported
- src/Controls/src/SourceGen/Controls.SourceGen.csproj: Language not supported
- src/Controls/tests/Xaml.UnitTests/GlobalXmlns.xaml: Language not supported
Comments suppressed due to low confidence (1)
src/Controls/src/SourceGen/CodeBehindGenerator.cs:142
- The variable 'text' is not defined in this scope. It appears that the content from the ProjectItem should be used instead, for example by referencing projectItem.Text.
using var reader = XmlReader.Create(new StringReader(text.ToString(),
Description of Change
Make the default xmlns implicitely pointing to maui default xmlns pre-load all available XmlsPrefixes for use
Enable this feature by adding this into the .csproj
Issues Fixed