Skip to content

Conversation

@etvorun
Copy link
Contributor

@etvorun etvorun commented Feb 27, 2025

Description of Change

Adding support for XmlnsDefinitionAttribute from "this" assembly

Issues Fixed

#28150

@etvorun etvorun requested a review from StephaneDelcroix March 3, 2025 21:36
@github-actions github-actions bot force-pushed the dev/evgenyt/xmlnsdef_fixes branch from aebf3a8 to fb2ad0e Compare March 5, 2025 09:43
@github-actions github-actions bot force-pushed the dev/evgenyt/xmlnsdef_fixes branch from fb2ad0e to 9a0c875 Compare March 5, 2025 10:54
@etvorun etvorun marked this pull request as ready for review March 5, 2025 18:04
Copilot AI review requested due to automatic review settings March 5, 2025 18:04
@etvorun etvorun requested a review from a team as a code owner March 5, 2025 18:04
@etvorun etvorun requested a review from rmarinho March 5, 2025 18:04
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.

PR Overview

This PR implements support for XmlnsDefinitionAttribute in "this" assembly, addressing issue #28150.

  • Added a new control and assembly attribute to enable XmlnsDefinitionAttribute support.
  • Updated assembly resolution logic in ModuleDefinitionExtensions for improved matching.
  • Refactored XmlnsDefinition attribute gathering in XmlTypeExtensions and updated the accessibility of GetXmlnsDefinition.

Reviewed Changes

File Description
src/Controls/tests/Xaml.UnitTests/Issues/MauiXmlnsDefControl.cs Introduces a new control with an assembly-level XmlnsDefinition attribute for testing.
src/Controls/src/Build.Tasks/ModuleDefinitionExtensions.cs Enhances assembly matching logic by checking both Name and FullName.
src/Controls/src/Build.Tasks/XmlTypeExtensions.cs Refactors attribute gathering using a helper method and changes the accessibility of GetXmlnsDefinition.
src/Controls/tests/Xaml.UnitTests/Issues/MauiXmlnsDef.xaml.cs Provides unit tests to validate the new XmlnsDefinition functionality.

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

@jfversluis jfversluis added this to the .NET 9 SR6 milestone Mar 7, 2025
@mattleibow mattleibow added the area-xaml XAML, CSS, Triggers, Behaviors label Mar 21, 2025
@PureWeen PureWeen modified the milestones: .NET 9 SR6, .NET 9 SR7 Mar 24, 2025
@etvorun etvorun marked this pull request as draft March 24, 2025 14:53
@StephaneDelcroix
Copy link
Contributor

StephaneDelcroix commented Apr 10, 2025

could you rebase on #28909 (when it's green) and un-draft it ? then it's probably good to be merged. Or do you want me to take over this ?

x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.MauiXmlnsDef">
<StackLayout>
<!-- Following control is available via default xmlns -->
<MauiXmlnsDefControl/>
Copy link
Contributor

Choose a reason for hiding this comment

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

the changes works for XamlC, but if you add a x:Name to this the code generator will fail. I'm looking at this

Copy link
Contributor

@StephaneDelcroix StephaneDelcroix left a comment

Choose a reason for hiding this comment

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

do not merge, have to check code behind support

StephaneDelcroix added a commit that referenced this pull request Apr 14, 2025
Allow aggregating multiple xmlns into a single new global
http://schemas.microsoft.com/dotnet/maui/global using XmlnsDefinition
attribute, like this

```csharp
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/maui/global", "http://schemas.microsoft.com/dotnet/2021/maui")]
```

the x: xmlns can not be aggregated, as it serves important purposes for
the parsers

this also brings #28090 to fix #28150

- fixes #28150
- fixes #28843
- closes #28090
StephaneDelcroix added a commit that referenced this pull request Apr 24, 2025
Allow aggregating multiple xmlns into a single new global
http://schemas.microsoft.com/dotnet/maui/global using XmlnsDefinition
attribute, like this

```csharp
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/maui/global", "http://schemas.microsoft.com/dotnet/2021/maui")]
```

the x: xmlns can not be aggregated, as it serves important purposes for
the parsers

this also brings #28090 to fix #28150

- fixes #28150
- fixes #28843
- closes #28090
@PureWeen PureWeen modified the milestones: .NET 9 SR7, .NET 9 SR8 May 8, 2025
StephaneDelcroix added a commit that referenced this pull request May 19, 2025
Allow aggregating multiple xmlns into a single new global
http://schemas.microsoft.com/dotnet/maui/global using XmlnsDefinition
attribute, like this

```csharp
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/maui/global", "http://schemas.microsoft.com/dotnet/2021/maui")]
```

the x: xmlns can not be aggregated, as it serves important purposes for
the parsers

this also brings #28090 to fix #28150

- fixes #28150
- fixes #28843
- closes #28090
StephaneDelcroix added a commit that referenced this pull request May 19, 2025
Allow aggregating multiple xmlns into a single new global
http://schemas.microsoft.com/dotnet/maui/global using XmlnsDefinition
attribute, like this

```csharp
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/maui/global", "http://schemas.microsoft.com/dotnet/2021/maui")]
```

the x: xmlns can not be aggregated, as it serves important purposes for
the parsers

this also brings #28090 to fix #28150

- fixes #28150
- fixes #28843
- closes #28090
StephaneDelcroix added a commit that referenced this pull request May 19, 2025
Allow aggregating multiple xmlns into a single new global
http://schemas.microsoft.com/dotnet/maui/global using XmlnsDefinition
attribute, like this

```csharp
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/maui/global", "http://schemas.microsoft.com/dotnet/2021/maui")]
```

the x: xmlns can not be aggregated, as it serves important purposes for
the parsers

this also brings #28090 to fix #28150

- fixes #28150
- fixes #28843
- closes #28090
StephaneDelcroix added a commit that referenced this pull request May 19, 2025
Allow aggregating multiple xmlns into a single new global
http://schemas.microsoft.com/dotnet/maui/global using XmlnsDefinition
attribute, like this

```csharp
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/maui/global", "http://schemas.microsoft.com/dotnet/2021/maui")]
```

the x: xmlns can not be aggregated, as it serves important purposes for
the parsers

this also brings #28090 to fix #28150

- fixes #28150
- fixes #28843
- closes #28090
StephaneDelcroix added a commit that referenced this pull request May 26, 2025
Allow aggregating multiple xmlns into a single new global
http://schemas.microsoft.com/dotnet/maui/global using XmlnsDefinition
attribute, like this

```csharp
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/maui/global", "http://schemas.microsoft.com/dotnet/2021/maui")]
```

the x: xmlns can not be aggregated, as it serves important purposes for
the parsers

this also brings #28090 to fix #28150

- fixes #28150
- fixes #28843
- closes #28090
StephaneDelcroix added a commit that referenced this pull request Jun 4, 2025
Allow aggregating multiple xmlns into a single new global
http://schemas.microsoft.com/dotnet/maui/global using XmlnsDefinition
attribute, like this

```csharp
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/maui/global", "http://schemas.microsoft.com/dotnet/2021/maui")]
```

the x: xmlns can not be aggregated, as it serves important purposes for
the parsers

this also brings #28090 to fix #28150

- fixes #28150
- fixes #28843
- closes #28090
rmarinho pushed a commit that referenced this pull request Jun 5, 2025
* [X] implicit xmlns declarations

Make the default xmlns implicitely pointing to maui default xmlns
pre-load all available XmlsPrefixes for use

the capability is disabled by default, and you need to opt-in

- fixes #28849
- fixes #28850
- fixes #28847

* [X] global xmlns

Allow aggregating multiple xmlns into a single new global
http://schemas.microsoft.com/dotnet/maui/global using XmlnsDefinition
attribute, like this

```csharp
[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/maui/global", "http://schemas.microsoft.com/dotnet/2021/maui")]
```

the x: xmlns can not be aggregated, as it serves important purposes for
the parsers

this also brings #28090 to fix #28150

- fixes #28150
- fixes #28843
- closes #28090

* [X] Protect some xmlns

protect maui and x: xmlns from overloading.

- fixes #28836

* be less strict while checking for protected xmlns

* fail on collision

* fixing default assembly

* load from current assembly

* fix DataTemplate

* fix BPConverter

* [X] report diagnostice on ambiguous type

* Update src/Controls/src/Build.Tasks/TypeReferenceExtensions.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/Controls/src/Build.Tasks/TypeReferenceExtensions.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@PureWeen PureWeen modified the milestones: .NET 9 SR8, .NET 9 Servicing Jun 9, 2025
@jfversluis
Copy link
Member

Stale, not sure if this is still needed. Closing for now.

@jfversluis jfversluis closed this Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-xaml XAML, CSS, Triggers, Behaviors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants