Skip to content

fix: Emit bindings on controls that have a companion markup extension - #22138

Merged
MartinZikmund merged 1 commit into
masterfrom
copilot/fix-binding-codes-issue
Jul 10, 2026
Merged

MartinZikmund merged 1 commit into
masterfrom
copilot/fix-binding-codes-issue

Conversation

Copilot AI commented Dec 15, 2025 •

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #21992

PR Type

  • 🐞 Bugfix

What is the current behavior? 🤔

When a control and a markup extension that share the same base name live in the same namespace (e.g. FluentIcon + FluentIconExtension), the XAML source generator misdetects the control element as a markup extension.

Markup-extension type resolution tries the Extension-suffixed name first, so for <ic:FluentIcon …> the generator resolved FluentIconExtension, concluded the element was a markup extension, and suppressed binding-code generation on the control's properties:

<!-- Binding code was not generated for the control's property -->
<ic:FluentIcon Icon="{x:Bind Icon}" />

This diverges from WinUI, where the Extension-suffix lookup applies only to curly-brace markup-extension usage ({ic:FluentIcon …}), never to object-element syntax.

What is the new behavior? 🚀

The Extension-suffix fallback is now applied only in the context where it is valid. GetMarkupExtensionType takes an allowExtensionSuffix flag:

  • The owner-element check in HasMarkupExtension passes allowExtensionSuffix: false, so a control is no longer confused with its companion markup extension and bindings generate correctly.
  • Every markup-extension usage site keeps the unchanged WinUI suffix-first resolution, so {local:Foo} still resolves to FooExtension.

This matches the documented XAML rule: the Extension suffix is a convenience of curly-brace markup-extension usage and is never appended for object-element syntax.

Modified:

  • XamlFileGenerator.cs — GetMarkupExtensionType (and the namespace-resolution helpers) gained an allowExtensionSuffix parameter; HasMarkupExtension's owner check passes false.

Added:

  • Given_MarkupExtension.TestControlAndCompanionExtensionInSameNamespace — a control + companion MyControlExtension in one namespace, verifying that (a) element-syntax x:Bind generates a binding and (b) brace-syntax {local:MyControl …} still resolves the markup extension. Verified to fail before the fix and pass after.

PR Checklist ✅

  • 📝 Commits follow the Conventional Commits specification.
  • 🧪 Added a regression test for the bug fix.
  • 📚 Docs — not applicable (internal source-generator behavior).
  • 🖼️ Validated PR Screenshots Compare Test Run results — not applicable (no rendering change).
  • ❗ Contains NO breaking changes.

Other information ℹ️

Backwards compatible — the change only affects the edge case where a control and a companion …Extension markup extension coexist in the same namespace. Standard markup-extension resolution ({local:Foo} → FooExtension) is unchanged.

@CLAassistant

CLAassistant commented Dec 15, 2025 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI changed the title [WIP] Fix binding codes not emitted with ControlExtension in namespace fix: Prevent false positive markup extension detection when Extension type exists Dec 15, 2025
Copilot AI requested a review from MartinZikmund December 15, 2025 10:42
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 188093 has failed on Uno.UI - CI.

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days.

@github-actions github-actions Bot added the stale This item has been marked as stale and will be closed if there is no activity. label Feb 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions Bot closed this Feb 24, 2026
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 1, 2026
@MartinZikmund MartinZikmund removed the stale This item has been marked as stale and will be closed if there is no activity. label Jun 23, 2026
@MartinZikmund MartinZikmund reopened this Jun 23, 2026
@github-actions github-actions Bot added the area/code-generation Categorizes an issue or PR as relevant to code generation label Jun 23, 2026
When a control and a markup extension sharing the same base name exist in the
same namespace (e.g. FluentIcon + FluentIconExtension), the XAML generator
misdetected the control element as a markup extension. Markup-extension type
resolution tries the "Extension" suffix first, so the element <local:FluentIcon>
resolved to FluentIconExtension and binding-code generation on the control's
properties was suppressed.

The "Extension" suffix fallback is a markup-extension *usage* feature
({local:Foo} resolves to FooExtension) and must not apply when checking whether
an *element* is a markup extension. GetMarkupExtensionType now takes an
allowExtensionSuffix flag; the owner-element check in HasMarkupExtension passes
false, while every markup-extension usage site keeps the WinUI suffix-first
resolution unchanged so {local:Foo} still resolves to FooExtension.

Fixes #21992

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Kkyh8YiVNW2ACz3XgW1TfQ
Copilot AI review requested due to automatic review settings June 23, 2026 20:19
@MartinZikmund
MartinZikmund force-pushed the copilot/fix-binding-codes-issue branch from 16d43b2 to 6141e1f Compare June 23, 2026 20:19
@MartinZikmund MartinZikmund changed the title fix: Prevent false positive markup extension detection when Extension type exists fix: Emit bindings on controls that have a companion markup extension Jun 23, 2026
@MartinZikmund
MartinZikmund marked this pull request as ready for review June 23, 2026 20:25
@MartinZikmund

Copy link
Copy Markdown
Member

/azp run

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 219508 has failed on Uno.UI - CI.

@unoplatform unoplatform unlocked this conversation Jun 24, 2026
@mergify

mergify Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@MartinZikmund
MartinZikmund merged commit 496158c into master Jul 10, 2026
49 checks passed
@MartinZikmund
MartinZikmund deleted the copilot/fix-binding-codes-issue branch July 10, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/code-generation Categorizes an issue or PR as relevant to code generation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Binding codes are not emitted when the type {Control}Extension exists in the same namespace

6 participants