Skip to content

[SourceGen] Fix xmlns prefix expansion and TypedBinding emission in C# expressions - #40263

Merged
kubaflo merged 8 commits into
dotnet:candidate/11.0.1xx-sr2from
KitKeen:fix/xsg-xmlns-prefix-expression
Nov 16, 2026
Merged

kubaflo merged 8 commits into
dotnet:candidate/11.0.1xx-sr2from
KitKeen:fix/xsg-xmlns-prefix-expression

Conversation

@KitKeen

@KitKeen KitKeen commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.

Description of Change

Fixes C# expression xmlns-prefix expansion and TypedBinding generation when xmlns-prefixed static members are used inside ternary conditionals, method calls, interpolated strings, or with source-generated types and bindable properties:

  • CSharpExpressionHelpers.ResolveXmlnsPrefixes: Added a fallback to global::<ClrNamespace>.<TypeName> using namespaceUri.GetClrNamespace() (or a single mapped namespace from xmlnsCache.ClrNamespacesForXmlns) when TryResolveTypeSymbol returns false because the target type (e.g., generated ResX Strings) is emitted by a sibling incremental source generator. Also allowed expanding xmlns-prefixed member accesses parsed inside Roslyn InterpolationFormatClauseSyntax (e.g., $"{res:Strings.FormatMessage(...)}") while keeping standard format specifiers intact, and wrapped top-level global:: expressions in interpolation holes in parentheses (WrapHoleGlobalAlias) so C# does not treat the first : as an interpolation format specifier.
  • MemberResolver, ExpressionAnalyzer, ExpandMarkupsVisitor: Handled AliasQualifiedNameSyntax (global::) roots cleanly without prefixing __source. or reporting false missing-member diagnostics, and passed Compilation into shared MemberResolver.HasMember calls (removing duplicate lookup helpers) so [ObservableProperty] and [RelayCommand] members resolve during expression analysis and binding generation.
  • SetPropertyHelpers: Updated TryHandleExpressionBinding and SetExpressionBinding to check HasBindablePropertyHeuristic when bpFieldSymbol is null so expressions targeting [BindableProperty]-attributed controls emit SetBinding with TypedBinding instead of falling back to one-time SetValue.
  • UpdateComponentCodeWriter: Wired ResolveXmlnsPrefixes and TransformAttachedProperties into ExpandMarkupForUC and TryEmitExpressionBinding so incremental Hot Reload UpdateComponent generation handles xmlns-prefixed C# expressions consistently with InitializeComponent.

Validation

  • dotnet build src/Controls/src/SourceGen/Controls.SourceGen.csproj -c Debug -p:_MauiDotNetVersionMajor=10: succeeded with 0 warnings, 0 errors.
  • Targeted regression tests (XmlnsPrefixedTypeInTernaryAndCallee_ExpandsAndBinds, XmlnsPrefixedUnresolvedType_FallsBackToClrNamespaceAndBinds, ExpressionOnHeuristicBindableProperty_AndObservableProperty_GeneratesTypedBinding, CSharpExpression_XmlnsPrefixedTypeChange_GeneratesUC): 4 passed, 0 failed, 0 skipped.
  • Full SourceGen.UnitTests (-c Debug -p:_MauiDotNetVersionMajor=10): 627 passed, 40 skipped (pre-existing E2E hot reload skips), 2 unrelated pre-existing HotReload.AiAssisted CS0122 (AppThemeBinding accessibility) failures.

Issues Fixed

Fixes #40214

@KitKeen
KitKeen temporarily deployed to copilot-pat-pool November 14, 2026 22:54 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40263

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40263"

@azure-pipelines

This comment has been minimized.

@KitKeen
KitKeen temporarily deployed to copilot-pat-pool November 14, 2026 22:54 — with GitHub Actions Inactive
@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Nov 14, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@KitKeen! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @KitKeen! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 14, 2026
@kubaflo

kubaflo commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@KitKeen — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 4 findings

Reviewed commit bb357c2.

See inline comments for details.

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@KitKeen — test-failure analysis for commit bb357c2.

Scope CI failures Commit bb357c2


🧪 CI Analysis — click to expand
📊 maui-pr

No failures found.


🧪 maui-pr-devicetests

Target parameters/diagnostics are missing; assertions explain the Helix failure, not a proven crash.


🧪 maui-pr-uitests

Expression changes do not explain matching target failures. Partial history leaves yellow entries unresolved.


🧭 Follow-up — actions and refresh

Next action: Compare yellow failures without the fix, preserving runtime/handler/setup; inspect snapshots. Restore checkout access before retrying.

Maintainers: comment /review tests to refresh this report.

…, named args, and ObservableProperty writeback
@KitKeen

KitKeen commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Addressed all 4 review findings in follow-up commit 0cc9c582c:

  1. Generic commas in interpolation holes (CSharpExpressionHelpers.TryFindTopLevelGlobalAliasSplit): Detect alignment/format clauses using Roslyn interpolation syntax (with a balanced generic-argument fallback) so commas inside generic type arguments like res:Helper.Format<int, string>(Value) are not split as alignment separators.
  2. Simple TwoWay [ObservableProperty] bindings (ITypeSymbolExtensions.TryGetProperty, SetPropertyHelpers.ResolveExpressionType / GetExpressionWriteInfo): Propagate inferred property types and writability (isAssumedWritable) through shared member chain resolution in both InitializeComponent and UpdateComponent hot reload codegen, so <Entry Text={Nickname} /> emits a strongly-typed TypedBinding with a non-null setter.
  3. Interpolation format clause vs xmlns prefix (CSharpExpressionHelpers.ResolveXmlnsPrefixes): Move the overlapsFormatClause && !IsFollowedByMemberAccess(...) guard ahead of type resolution so format specifiers like $'{Price:C2}' are preserved even when Price is an xmlns prefix and C2 resolves to a compiled type.
  4. Named arguments matching xmlns prefixes (CSharpExpressionHelpers.IsNamedArgumentSyntax, ExpressionAnalyzer): Guard the sibling-generator fallback against C# named-argument syntax so helpers:Formatter.Format(local:Name) keeps local:__source.Name intact instead of expanding local:Name to a namespace type.

Added regression tests covering all four scenarios in CSharpExpressionDiagnosticsTests and XamlIncrementalHotReloadCSharpExpressionTests (SourceGen.UnitTests: 62 passed, 0 failed in the targeted expression and hot-reload suites).

@kubaflo

This comment has been minimized.

@kubaflo

kubaflo commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

/rebase

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 15, 2026
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The exact-arity filter rejects generic methods with inferred type arguments, causing valid calls to be rewritten incorrectly and fail compilation.

1 open issue
4 resolved since last review

Review effort: Balanced

Comment on lines +2876 to +2877
if (method.Arity != genericArity)
continue;
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 15, 2026
@kubaflo

kubaflo commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@KitKeen — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 15, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 9 findings

Reviewed commit 2918608.

See inline comments for details.

8 findings could not be attached inline; retained in run artifacts.

<VerticalStackLayout>
<Label Text="{= helpers:Formatter.Format(local:Name)}" />
<Label Text="{= helpers:Formatter.Uninferable&lt;int&gt;(local:Name)}" />
<Label Text="{= helpers:Formatter.Uninferable(local:Tag.Value)}" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[moderate] Regression Prevention and Test Coverage - The Uninferable negative fixture does not distinguish rejection by CanInvokeWithArity from rejection by expression scope. Tag exists only in the xmlns namespace, so IsNamedArgumentSyntax rejects local:Tag.Value at HasExpressionRootInScope even if the uninferable generic overload is incorrectly accepted. This assertion still succeeds with the inferability veto removed. Add a page/ViewModel Tag property exposing Value alongside Repro.Models.Tag.Value, and require namespace expansion and clean compilation when type arguments are omitted. That discriminating case catches accidental preservation of a named argument selecting the uninferable generic overload.

@kubaflo
kubaflo changed the base branch from net11 to candidate/11.0.1xx-sr2 November 16, 2026 00:26
@kubaflo
kubaflo merged commit dc1660b into dotnet:candidate/11.0.1xx-sr2 Nov 16, 2026
128 of 186 checks passed
kubaflo added a commit that referenced this pull request Nov 16, 2026
…# expressions (#40263)

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Fixes C# expression `xmlns`-prefix expansion and `TypedBinding`
generation when `xmlns`-prefixed static members are used inside ternary
conditionals, method calls, interpolated strings, or with
source-generated types and bindable properties:

- **`CSharpExpressionHelpers.ResolveXmlnsPrefixes`**: Added a fallback
to `global::<ClrNamespace>.<TypeName>` using
`namespaceUri.GetClrNamespace()` (or a single mapped namespace from
`xmlnsCache.ClrNamespacesForXmlns`) when `TryResolveTypeSymbol` returns
`false` because the target type (e.g., generated ResX `Strings`) is
emitted by a sibling incremental source generator. Also allowed
expanding `xmlns`-prefixed member accesses parsed inside Roslyn
`InterpolationFormatClauseSyntax` (e.g.,
`$"{res:Strings.FormatMessage(...)}"`) while keeping standard format
specifiers intact, and wrapped top-level `global::` expressions in
interpolation holes in parentheses (`WrapHoleGlobalAlias`) so C# does
not treat the first `:` as an interpolation format specifier.
- **`MemberResolver`, `ExpressionAnalyzer`, `ExpandMarkupsVisitor`**:
Handled `AliasQualifiedNameSyntax` (`global::`) roots cleanly without
prefixing `__source.` or reporting false missing-member diagnostics, and
passed `Compilation` into shared `MemberResolver.HasMember` calls
(removing duplicate lookup helpers) so `[ObservableProperty]` and
`[RelayCommand]` members resolve during expression analysis and binding
generation.
- **`SetPropertyHelpers`**: Updated `TryHandleExpressionBinding` and
`SetExpressionBinding` to check `HasBindablePropertyHeuristic` when
`bpFieldSymbol` is `null` so expressions targeting
`[BindableProperty]`-attributed controls emit `SetBinding` with
`TypedBinding` instead of falling back to one-time `SetValue`.
- **`UpdateComponentCodeWriter`**: Wired `ResolveXmlnsPrefixes` and
`TransformAttachedProperties` into `ExpandMarkupForUC` and
`TryEmitExpressionBinding` so incremental Hot Reload `UpdateComponent`
generation handles `xmlns`-prefixed C# expressions consistently with
`InitializeComponent`.

### Validation

- `dotnet build src/Controls/src/SourceGen/Controls.SourceGen.csproj -c
Debug -p:_MauiDotNetVersionMajor=10`: succeeded with 0 warnings, 0
errors.
- Targeted regression tests
(`XmlnsPrefixedTypeInTernaryAndCallee_ExpandsAndBinds`,
`XmlnsPrefixedUnresolvedType_FallsBackToClrNamespaceAndBinds`,
`ExpressionOnHeuristicBindableProperty_AndObservableProperty_GeneratesTypedBinding`,
`CSharpExpression_XmlnsPrefixedTypeChange_GeneratesUC`): 4 passed, 0
failed, 0 skipped.
- Full `SourceGen.UnitTests` (`-c Debug -p:_MauiDotNetVersionMajor=10`):
627 passed, 40 skipped (pre-existing E2E hot reload skips), 2 unrelated
pre-existing `HotReload.AiAssisted` `CS0122` (`AppThemeBinding`
accessibility) failures.

### Issues Fixed

Fixes #40214

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
…# expressions (#40263)

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Fixes C# expression `xmlns`-prefix expansion and `TypedBinding`
generation when `xmlns`-prefixed static members are used inside ternary
conditionals, method calls, interpolated strings, or with
source-generated types and bindable properties:

- **`CSharpExpressionHelpers.ResolveXmlnsPrefixes`**: Added a fallback
to `global::<ClrNamespace>.<TypeName>` using
`namespaceUri.GetClrNamespace()` (or a single mapped namespace from
`xmlnsCache.ClrNamespacesForXmlns`) when `TryResolveTypeSymbol` returns
`false` because the target type (e.g., generated ResX `Strings`) is
emitted by a sibling incremental source generator. Also allowed
expanding `xmlns`-prefixed member accesses parsed inside Roslyn
`InterpolationFormatClauseSyntax` (e.g.,
`$"{res:Strings.FormatMessage(...)}"`) while keeping standard format
specifiers intact, and wrapped top-level `global::` expressions in
interpolation holes in parentheses (`WrapHoleGlobalAlias`) so C# does
not treat the first `:` as an interpolation format specifier.
- **`MemberResolver`, `ExpressionAnalyzer`, `ExpandMarkupsVisitor`**:
Handled `AliasQualifiedNameSyntax` (`global::`) roots cleanly without
prefixing `__source.` or reporting false missing-member diagnostics, and
passed `Compilation` into shared `MemberResolver.HasMember` calls
(removing duplicate lookup helpers) so `[ObservableProperty]` and
`[RelayCommand]` members resolve during expression analysis and binding
generation.
- **`SetPropertyHelpers`**: Updated `TryHandleExpressionBinding` and
`SetExpressionBinding` to check `HasBindablePropertyHeuristic` when
`bpFieldSymbol` is `null` so expressions targeting
`[BindableProperty]`-attributed controls emit `SetBinding` with
`TypedBinding` instead of falling back to one-time `SetValue`.
- **`UpdateComponentCodeWriter`**: Wired `ResolveXmlnsPrefixes` and
`TransformAttachedProperties` into `ExpandMarkupForUC` and
`TryEmitExpressionBinding` so incremental Hot Reload `UpdateComponent`
generation handles `xmlns`-prefixed C# expressions consistently with
`InitializeComponent`.

### Validation

- `dotnet build src/Controls/src/SourceGen/Controls.SourceGen.csproj -c
Debug -p:_MauiDotNetVersionMajor=10`: succeeded with 0 warnings, 0
errors.
- Targeted regression tests
(`XmlnsPrefixedTypeInTernaryAndCallee_ExpandsAndBinds`,
`XmlnsPrefixedUnresolvedType_FallsBackToClrNamespaceAndBinds`,
`ExpressionOnHeuristicBindableProperty_AndObservableProperty_GeneratesTypedBinding`,
`CSharpExpression_XmlnsPrefixedTypeChange_GeneratesUC`): 4 passed, 0
failed, 0 skipped.
- Full `SourceGen.UnitTests` (`-c Debug -p:_MauiDotNetVersionMajor=10`):
627 passed, 40 skipped (pre-existing E2E hot reload skips), 2 unrelated
pre-existing `HotReload.AiAssisted` `CS0122` (`AppThemeBinding`
accessibility) failures.

### Issues Fixed

Fixes #40214

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 17, 2026
…# expressions (#40263)

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Fixes C# expression `xmlns`-prefix expansion and `TypedBinding`
generation when `xmlns`-prefixed static members are used inside ternary
conditionals, method calls, interpolated strings, or with
source-generated types and bindable properties:

- **`CSharpExpressionHelpers.ResolveXmlnsPrefixes`**: Added a fallback
to `global::<ClrNamespace>.<TypeName>` using
`namespaceUri.GetClrNamespace()` (or a single mapped namespace from
`xmlnsCache.ClrNamespacesForXmlns`) when `TryResolveTypeSymbol` returns
`false` because the target type (e.g., generated ResX `Strings`) is
emitted by a sibling incremental source generator. Also allowed
expanding `xmlns`-prefixed member accesses parsed inside Roslyn
`InterpolationFormatClauseSyntax` (e.g.,
`$"{res:Strings.FormatMessage(...)}"`) while keeping standard format
specifiers intact, and wrapped top-level `global::` expressions in
interpolation holes in parentheses (`WrapHoleGlobalAlias`) so C# does
not treat the first `:` as an interpolation format specifier.
- **`MemberResolver`, `ExpressionAnalyzer`, `ExpandMarkupsVisitor`**:
Handled `AliasQualifiedNameSyntax` (`global::`) roots cleanly without
prefixing `__source.` or reporting false missing-member diagnostics, and
passed `Compilation` into shared `MemberResolver.HasMember` calls
(removing duplicate lookup helpers) so `[ObservableProperty]` and
`[RelayCommand]` members resolve during expression analysis and binding
generation.
- **`SetPropertyHelpers`**: Updated `TryHandleExpressionBinding` and
`SetExpressionBinding` to check `HasBindablePropertyHeuristic` when
`bpFieldSymbol` is `null` so expressions targeting
`[BindableProperty]`-attributed controls emit `SetBinding` with
`TypedBinding` instead of falling back to one-time `SetValue`.
- **`UpdateComponentCodeWriter`**: Wired `ResolveXmlnsPrefixes` and
`TransformAttachedProperties` into `ExpandMarkupForUC` and
`TryEmitExpressionBinding` so incremental Hot Reload `UpdateComponent`
generation handles `xmlns`-prefixed C# expressions consistently with
`InitializeComponent`.

### Validation

- `dotnet build src/Controls/src/SourceGen/Controls.SourceGen.csproj -c
Debug -p:_MauiDotNetVersionMajor=10`: succeeded with 0 warnings, 0
errors.
- Targeted regression tests
(`XmlnsPrefixedTypeInTernaryAndCallee_ExpandsAndBinds`,
`XmlnsPrefixedUnresolvedType_FallsBackToClrNamespaceAndBinds`,
`ExpressionOnHeuristicBindableProperty_AndObservableProperty_GeneratesTypedBinding`,
`CSharpExpression_XmlnsPrefixedTypeChange_GeneratesUC`): 4 passed, 0
failed, 0 skipped.
- Full `SourceGen.UnitTests` (`-c Debug -p:_MauiDotNetVersionMajor=10`):
627 passed, 40 skipped (pre-existing E2E hot reload skips), 2 unrelated
pre-existing `HotReload.AiAssisted` `CS0122` (`AppThemeBinding`
accessibility) failures.

### Issues Fixed

Fixes #40214

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…# expressions (#40263)

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Fixes C# expression `xmlns`-prefix expansion and `TypedBinding`
generation when `xmlns`-prefixed static members are used inside ternary
conditionals, method calls, interpolated strings, or with
source-generated types and bindable properties:

- **`CSharpExpressionHelpers.ResolveXmlnsPrefixes`**: Added a fallback
to `global::<ClrNamespace>.<TypeName>` using
`namespaceUri.GetClrNamespace()` (or a single mapped namespace from
`xmlnsCache.ClrNamespacesForXmlns`) when `TryResolveTypeSymbol` returns
`false` because the target type (e.g., generated ResX `Strings`) is
emitted by a sibling incremental source generator. Also allowed
expanding `xmlns`-prefixed member accesses parsed inside Roslyn
`InterpolationFormatClauseSyntax` (e.g.,
`$"{res:Strings.FormatMessage(...)}"`) while keeping standard format
specifiers intact, and wrapped top-level `global::` expressions in
interpolation holes in parentheses (`WrapHoleGlobalAlias`) so C# does
not treat the first `:` as an interpolation format specifier.
- **`MemberResolver`, `ExpressionAnalyzer`, `ExpandMarkupsVisitor`**:
Handled `AliasQualifiedNameSyntax` (`global::`) roots cleanly without
prefixing `__source.` or reporting false missing-member diagnostics, and
passed `Compilation` into shared `MemberResolver.HasMember` calls
(removing duplicate lookup helpers) so `[ObservableProperty]` and
`[RelayCommand]` members resolve during expression analysis and binding
generation.
- **`SetPropertyHelpers`**: Updated `TryHandleExpressionBinding` and
`SetExpressionBinding` to check `HasBindablePropertyHeuristic` when
`bpFieldSymbol` is `null` so expressions targeting
`[BindableProperty]`-attributed controls emit `SetBinding` with
`TypedBinding` instead of falling back to one-time `SetValue`.
- **`UpdateComponentCodeWriter`**: Wired `ResolveXmlnsPrefixes` and
`TransformAttachedProperties` into `ExpandMarkupForUC` and
`TryEmitExpressionBinding` so incremental Hot Reload `UpdateComponent`
generation handles `xmlns`-prefixed C# expressions consistently with
`InitializeComponent`.

### Validation

- `dotnet build src/Controls/src/SourceGen/Controls.SourceGen.csproj -c
Debug -p:_MauiDotNetVersionMajor=10`: succeeded with 0 warnings, 0
errors.
- Targeted regression tests
(`XmlnsPrefixedTypeInTernaryAndCallee_ExpandsAndBinds`,
`XmlnsPrefixedUnresolvedType_FallsBackToClrNamespaceAndBinds`,
`ExpressionOnHeuristicBindableProperty_AndObservableProperty_GeneratesTypedBinding`,
`CSharpExpression_XmlnsPrefixedTypeChange_GeneratesUC`): 4 passed, 0
failed, 0 skipped.
- Full `SourceGen.UnitTests` (`-c Debug -p:_MauiDotNetVersionMajor=10`):
627 passed, 40 skipped (pre-existing E2E hot reload skips), 2 unrelated
pre-existing `HotReload.AiAssisted` `CS0122` (`AppThemeBinding`
accessibility) failures.

### Issues Fixed

Fixes #40214

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…# expressions (#40263)

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Fixes C# expression `xmlns`-prefix expansion and `TypedBinding`
generation when `xmlns`-prefixed static members are used inside ternary
conditionals, method calls, interpolated strings, or with
source-generated types and bindable properties:

- **`CSharpExpressionHelpers.ResolveXmlnsPrefixes`**: Added a fallback
to `global::<ClrNamespace>.<TypeName>` using
`namespaceUri.GetClrNamespace()` (or a single mapped namespace from
`xmlnsCache.ClrNamespacesForXmlns`) when `TryResolveTypeSymbol` returns
`false` because the target type (e.g., generated ResX `Strings`) is
emitted by a sibling incremental source generator. Also allowed
expanding `xmlns`-prefixed member accesses parsed inside Roslyn
`InterpolationFormatClauseSyntax` (e.g.,
`$"{res:Strings.FormatMessage(...)}"`) while keeping standard format
specifiers intact, and wrapped top-level `global::` expressions in
interpolation holes in parentheses (`WrapHoleGlobalAlias`) so C# does
not treat the first `:` as an interpolation format specifier.
- **`MemberResolver`, `ExpressionAnalyzer`, `ExpandMarkupsVisitor`**:
Handled `AliasQualifiedNameSyntax` (`global::`) roots cleanly without
prefixing `__source.` or reporting false missing-member diagnostics, and
passed `Compilation` into shared `MemberResolver.HasMember` calls
(removing duplicate lookup helpers) so `[ObservableProperty]` and
`[RelayCommand]` members resolve during expression analysis and binding
generation.
- **`SetPropertyHelpers`**: Updated `TryHandleExpressionBinding` and
`SetExpressionBinding` to check `HasBindablePropertyHeuristic` when
`bpFieldSymbol` is `null` so expressions targeting
`[BindableProperty]`-attributed controls emit `SetBinding` with
`TypedBinding` instead of falling back to one-time `SetValue`.
- **`UpdateComponentCodeWriter`**: Wired `ResolveXmlnsPrefixes` and
`TransformAttachedProperties` into `ExpandMarkupForUC` and
`TryEmitExpressionBinding` so incremental Hot Reload `UpdateComponent`
generation handles `xmlns`-prefixed C# expressions consistently with
`InitializeComponent`.

### Validation

- `dotnet build src/Controls/src/SourceGen/Controls.SourceGen.csproj -c
Debug -p:_MauiDotNetVersionMajor=10`: succeeded with 0 warnings, 0
errors.
- Targeted regression tests
(`XmlnsPrefixedTypeInTernaryAndCallee_ExpandsAndBinds`,
`XmlnsPrefixedUnresolvedType_FallsBackToClrNamespaceAndBinds`,
`ExpressionOnHeuristicBindableProperty_AndObservableProperty_GeneratesTypedBinding`,
`CSharpExpression_XmlnsPrefixedTypeChange_GeneratesUC`): 4 passed, 0
failed, 0 skipped.
- Full `SourceGen.UnitTests` (`-c Debug -p:_MauiDotNetVersionMajor=10`):
627 passed, 40 skipped (pre-existing E2E hot reload skips), 2 unrelated
pre-existing `HotReload.AiAssisted` `CS0122` (`AppThemeBinding`
accessibility) failures.

### Issues Fixed

Fixes #40214

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…# expressions (#40263)

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Fixes C# expression `xmlns`-prefix expansion and `TypedBinding`
generation when `xmlns`-prefixed static members are used inside ternary
conditionals, method calls, interpolated strings, or with
source-generated types and bindable properties:

- **`CSharpExpressionHelpers.ResolveXmlnsPrefixes`**: Added a fallback
to `global::<ClrNamespace>.<TypeName>` using
`namespaceUri.GetClrNamespace()` (or a single mapped namespace from
`xmlnsCache.ClrNamespacesForXmlns`) when `TryResolveTypeSymbol` returns
`false` because the target type (e.g., generated ResX `Strings`) is
emitted by a sibling incremental source generator. Also allowed
expanding `xmlns`-prefixed member accesses parsed inside Roslyn
`InterpolationFormatClauseSyntax` (e.g.,
`$"{res:Strings.FormatMessage(...)}"`) while keeping standard format
specifiers intact, and wrapped top-level `global::` expressions in
interpolation holes in parentheses (`WrapHoleGlobalAlias`) so C# does
not treat the first `:` as an interpolation format specifier.
- **`MemberResolver`, `ExpressionAnalyzer`, `ExpandMarkupsVisitor`**:
Handled `AliasQualifiedNameSyntax` (`global::`) roots cleanly without
prefixing `__source.` or reporting false missing-member diagnostics, and
passed `Compilation` into shared `MemberResolver.HasMember` calls
(removing duplicate lookup helpers) so `[ObservableProperty]` and
`[RelayCommand]` members resolve during expression analysis and binding
generation.
- **`SetPropertyHelpers`**: Updated `TryHandleExpressionBinding` and
`SetExpressionBinding` to check `HasBindablePropertyHeuristic` when
`bpFieldSymbol` is `null` so expressions targeting
`[BindableProperty]`-attributed controls emit `SetBinding` with
`TypedBinding` instead of falling back to one-time `SetValue`.
- **`UpdateComponentCodeWriter`**: Wired `ResolveXmlnsPrefixes` and
`TransformAttachedProperties` into `ExpandMarkupForUC` and
`TryEmitExpressionBinding` so incremental Hot Reload `UpdateComponent`
generation handles `xmlns`-prefixed C# expressions consistently with
`InitializeComponent`.

### Validation

- `dotnet build src/Controls/src/SourceGen/Controls.SourceGen.csproj -c
Debug -p:_MauiDotNetVersionMajor=10`: succeeded with 0 warnings, 0
errors.
- Targeted regression tests
(`XmlnsPrefixedTypeInTernaryAndCallee_ExpandsAndBinds`,
`XmlnsPrefixedUnresolvedType_FallsBackToClrNamespaceAndBinds`,
`ExpressionOnHeuristicBindableProperty_AndObservableProperty_GeneratesTypedBinding`,
`CSharpExpression_XmlnsPrefixedTypeChange_GeneratesUC`): 4 passed, 0
failed, 0 skipped.
- Full `SourceGen.UnitTests` (`-c Debug -p:_MauiDotNetVersionMajor=10`):
627 passed, 40 skipped (pre-existing E2E hot reload skips), 2 unrelated
pre-existing `HotReload.AiAssisted` `CS0122` (`AppThemeBinding`
accessibility) failures.

### Issues Fixed

Fixes #40214

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
…# expressions (#40263)

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Fixes C# expression `xmlns`-prefix expansion and `TypedBinding`
generation when `xmlns`-prefixed static members are used inside ternary
conditionals, method calls, interpolated strings, or with
source-generated types and bindable properties:

- **`CSharpExpressionHelpers.ResolveXmlnsPrefixes`**: Added a fallback
to `global::<ClrNamespace>.<TypeName>` using
`namespaceUri.GetClrNamespace()` (or a single mapped namespace from
`xmlnsCache.ClrNamespacesForXmlns`) when `TryResolveTypeSymbol` returns
`false` because the target type (e.g., generated ResX `Strings`) is
emitted by a sibling incremental source generator. Also allowed
expanding `xmlns`-prefixed member accesses parsed inside Roslyn
`InterpolationFormatClauseSyntax` (e.g.,
`$"{res:Strings.FormatMessage(...)}"`) while keeping standard format
specifiers intact, and wrapped top-level `global::` expressions in
interpolation holes in parentheses (`WrapHoleGlobalAlias`) so C# does
not treat the first `:` as an interpolation format specifier.
- **`MemberResolver`, `ExpressionAnalyzer`, `ExpandMarkupsVisitor`**:
Handled `AliasQualifiedNameSyntax` (`global::`) roots cleanly without
prefixing `__source.` or reporting false missing-member diagnostics, and
passed `Compilation` into shared `MemberResolver.HasMember` calls
(removing duplicate lookup helpers) so `[ObservableProperty]` and
`[RelayCommand]` members resolve during expression analysis and binding
generation.
- **`SetPropertyHelpers`**: Updated `TryHandleExpressionBinding` and
`SetExpressionBinding` to check `HasBindablePropertyHeuristic` when
`bpFieldSymbol` is `null` so expressions targeting
`[BindableProperty]`-attributed controls emit `SetBinding` with
`TypedBinding` instead of falling back to one-time `SetValue`.
- **`UpdateComponentCodeWriter`**: Wired `ResolveXmlnsPrefixes` and
`TransformAttachedProperties` into `ExpandMarkupForUC` and
`TryEmitExpressionBinding` so incremental Hot Reload `UpdateComponent`
generation handles `xmlns`-prefixed C# expressions consistently with
`InitializeComponent`.

### Validation

- `dotnet build src/Controls/src/SourceGen/Controls.SourceGen.csproj -c
Debug -p:_MauiDotNetVersionMajor=10`: succeeded with 0 warnings, 0
errors.
- Targeted regression tests
(`XmlnsPrefixedTypeInTernaryAndCallee_ExpandsAndBinds`,
`XmlnsPrefixedUnresolvedType_FallsBackToClrNamespaceAndBinds`,
`ExpressionOnHeuristicBindableProperty_AndObservableProperty_GeneratesTypedBinding`,
`CSharpExpression_XmlnsPrefixedTypeChange_GeneratesUC`): 4 passed, 0
failed, 0 skipped.
- Full `SourceGen.UnitTests` (`-c Debug -p:_MauiDotNetVersionMajor=10`):
627 passed, 40 skipped (pre-existing E2E hot reload skips), 2 unrelated
pre-existing `HotReload.AiAssisted` `CS0122` (`AppThemeBinding`
accessibility) failures.

### Issues Fixed

Fixes #40214

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
…# expressions (#40263)

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Fixes C# expression `xmlns`-prefix expansion and `TypedBinding`
generation when `xmlns`-prefixed static members are used inside ternary
conditionals, method calls, interpolated strings, or with
source-generated types and bindable properties:

- **`CSharpExpressionHelpers.ResolveXmlnsPrefixes`**: Added a fallback
to `global::<ClrNamespace>.<TypeName>` using
`namespaceUri.GetClrNamespace()` (or a single mapped namespace from
`xmlnsCache.ClrNamespacesForXmlns`) when `TryResolveTypeSymbol` returns
`false` because the target type (e.g., generated ResX `Strings`) is
emitted by a sibling incremental source generator. Also allowed
expanding `xmlns`-prefixed member accesses parsed inside Roslyn
`InterpolationFormatClauseSyntax` (e.g.,
`$"{res:Strings.FormatMessage(...)}"`) while keeping standard format
specifiers intact, and wrapped top-level `global::` expressions in
interpolation holes in parentheses (`WrapHoleGlobalAlias`) so C# does
not treat the first `:` as an interpolation format specifier.
- **`MemberResolver`, `ExpressionAnalyzer`, `ExpandMarkupsVisitor`**:
Handled `AliasQualifiedNameSyntax` (`global::`) roots cleanly without
prefixing `__source.` or reporting false missing-member diagnostics, and
passed `Compilation` into shared `MemberResolver.HasMember` calls
(removing duplicate lookup helpers) so `[ObservableProperty]` and
`[RelayCommand]` members resolve during expression analysis and binding
generation.
- **`SetPropertyHelpers`**: Updated `TryHandleExpressionBinding` and
`SetExpressionBinding` to check `HasBindablePropertyHeuristic` when
`bpFieldSymbol` is `null` so expressions targeting
`[BindableProperty]`-attributed controls emit `SetBinding` with
`TypedBinding` instead of falling back to one-time `SetValue`.
- **`UpdateComponentCodeWriter`**: Wired `ResolveXmlnsPrefixes` and
`TransformAttachedProperties` into `ExpandMarkupForUC` and
`TryEmitExpressionBinding` so incremental Hot Reload `UpdateComponent`
generation handles `xmlns`-prefixed C# expressions consistently with
`InitializeComponent`.

### Validation

- `dotnet build src/Controls/src/SourceGen/Controls.SourceGen.csproj -c
Debug -p:_MauiDotNetVersionMajor=10`: succeeded with 0 warnings, 0
errors.
- Targeted regression tests
(`XmlnsPrefixedTypeInTernaryAndCallee_ExpandsAndBinds`,
`XmlnsPrefixedUnresolvedType_FallsBackToClrNamespaceAndBinds`,
`ExpressionOnHeuristicBindableProperty_AndObservableProperty_GeneratesTypedBinding`,
`CSharpExpression_XmlnsPrefixedTypeChange_GeneratesUC`): 4 passed, 0
failed, 0 skipped.
- Full `SourceGen.UnitTests` (`-c Debug -p:_MauiDotNetVersionMajor=10`):
627 passed, 40 skipped (pre-existing E2E hot reload skips), 2 unrelated
pre-existing `HotReload.AiAssisted` `CS0122` (`AppThemeBinding`
accessibility) failures.

### Issues Fixed

Fixes #40214

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…40531)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This PR targets the SR2 release candidate, `candidate/11.0.1xx-sr2`,
because this intermittent failure is the only remaining UI-test failure
on #40116 (UI build 1694858 at candidate `e3c8b2ec`). The test is the
same on `net11` and `main`, so the change applies there too.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change to `Issue2241.ChangeOrientationCheckScroll`. Product
code, the host page and the shared Appium helpers are unchanged.

**Root cause: the test reads the layout mid-rotation**

`App.SetOrientationLandscape()` / `SetOrientationPortrait()` return as
soon as the driver accepts the orientation change. They don't wait for
the rotation to finish, which on iOS animates for roughly 300–400 ms.
The test called `GetRect()` immediately after rotating back to portrait,
so it sometimes read an intermediate frame of `MainGrid` instead of the
settled layout.

- Settled portrait layout: `MainGrid` at y=211 with height 400, so
CenterY = **411** (the expected value).
- Values seen mid-animation: **249** and **251** in CI; 211–248 locally.

In the local failing runs, the page source captured at teardown shows
the grid back at x=20, y=211, 335×400 (CenterY 411). The ScrollView
layout settles correctly; only the read was early. This is not a product
regression.

**CI evidence**

- UI build 1694858 (candidate `e3c8b2ec`), `Controls (v18.5)
ScrollView`, run 47329666: `Expected: 411 But was: 249`, then `251` on
the in-job retry.
- 421 iOS ScrollView job runs scanned across `main`, `net11`, inflight,
candidate and unrelated PRs. The same assertion also failed on candidate
build 1684453 (235), #40307 (262) and #40263 (263). It is an
intermittent that occurs on every branch at about 1%, not a candidate
regression.

**Fix**

After each rotation, the new `WaitForMainGridToSettle` helper polls
`MainGrid` every 100 ms until two conditions hold:

1. The rect shows the rotated layout: wider than portrait after going to
landscape, narrower than landscape after going back.
2. The rect has been identical for two consecutive reads.

It fails with the last rect if this doesn't happen within 10 s. The
assertion itself is unchanged: portrait CenterY before and after the
scroll must be equal.

**Causal validation (local, iOS 18.5 iPhone Xs simulator — the CI
configuration)**

`dotnet test
src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj
--no-build --filter "Name=ChangeOrientationCheckScroll"`, repeated in a
loop with `HEADLESS=true`:

| Stage | Test code | Result | Observed CenterY on failure |
| --- | --- | --- | --- |
| Baseline | original | **6 of 15 failed** | 211, 224, 224, 234, 224,
233 |
| Fix | this PR | **20 of 20 passed** | — |
| Trigger removed | original + `Thread.Sleep(3000)` after each rotation
| **12 of 12 passed** | — |
| Fix reverted | original | **9 of 15 failed** | 224, 233, 224, 211,
232, 248, 211, 224, 233 |
| Restored | this PR | **15 of 15 passed** | — |

Adding only a delay after rotating removes the failure, which confirms
the timing cause. The fix doesn't slow the test noticeably: it took
about 20 s per run, as before.

The test also runs on Android. On an Android API 30 emulator (the CI API
level), the fixed test passed 4 of 4 runs (4–7 s each) via `pwsh
.github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter
"Name=ChangeOrientationCheckScroll"`, so the rotation-and-settle wait
also holds there.

### Issues Fixed

Fixes the intermittent `Issue2241.ChangeOrientationCheckScroll` iOS
UI-test failure on #40116. There is no separate issue for it. Related:
#2241.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…# expressions (#40263)

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Fixes C# expression `xmlns`-prefix expansion and `TypedBinding`
generation when `xmlns`-prefixed static members are used inside ternary
conditionals, method calls, interpolated strings, or with
source-generated types and bindable properties:

- **`CSharpExpressionHelpers.ResolveXmlnsPrefixes`**: Added a fallback
to `global::<ClrNamespace>.<TypeName>` using
`namespaceUri.GetClrNamespace()` (or a single mapped namespace from
`xmlnsCache.ClrNamespacesForXmlns`) when `TryResolveTypeSymbol` returns
`false` because the target type (e.g., generated ResX `Strings`) is
emitted by a sibling incremental source generator. Also allowed
expanding `xmlns`-prefixed member accesses parsed inside Roslyn
`InterpolationFormatClauseSyntax` (e.g.,
`$"{res:Strings.FormatMessage(...)}"`) while keeping standard format
specifiers intact, and wrapped top-level `global::` expressions in
interpolation holes in parentheses (`WrapHoleGlobalAlias`) so C# does
not treat the first `:` as an interpolation format specifier.
- **`MemberResolver`, `ExpressionAnalyzer`, `ExpandMarkupsVisitor`**:
Handled `AliasQualifiedNameSyntax` (`global::`) roots cleanly without
prefixing `__source.` or reporting false missing-member diagnostics, and
passed `Compilation` into shared `MemberResolver.HasMember` calls
(removing duplicate lookup helpers) so `[ObservableProperty]` and
`[RelayCommand]` members resolve during expression analysis and binding
generation.
- **`SetPropertyHelpers`**: Updated `TryHandleExpressionBinding` and
`SetExpressionBinding` to check `HasBindablePropertyHeuristic` when
`bpFieldSymbol` is `null` so expressions targeting
`[BindableProperty]`-attributed controls emit `SetBinding` with
`TypedBinding` instead of falling back to one-time `SetValue`.
- **`UpdateComponentCodeWriter`**: Wired `ResolveXmlnsPrefixes` and
`TransformAttachedProperties` into `ExpandMarkupForUC` and
`TryEmitExpressionBinding` so incremental Hot Reload `UpdateComponent`
generation handles `xmlns`-prefixed C# expressions consistently with
`InitializeComponent`.

### Validation

- `dotnet build src/Controls/src/SourceGen/Controls.SourceGen.csproj -c
Debug -p:_MauiDotNetVersionMajor=10`: succeeded with 0 warnings, 0
errors.
- Targeted regression tests
(`XmlnsPrefixedTypeInTernaryAndCallee_ExpandsAndBinds`,
`XmlnsPrefixedUnresolvedType_FallsBackToClrNamespaceAndBinds`,
`ExpressionOnHeuristicBindableProperty_AndObservableProperty_GeneratesTypedBinding`,
`CSharpExpression_XmlnsPrefixedTypeChange_GeneratesUC`): 4 passed, 0
failed, 0 skipped.
- Full `SourceGen.UnitTests` (`-c Debug -p:_MauiDotNetVersionMajor=10`):
627 passed, 40 skipped (pre-existing E2E hot reload skips), 2 unrelated
pre-existing `HotReload.AiAssisted` `CS0122` (`AppThemeBinding`
accessibility) failures.

### Issues Fixed

Fixes #40214

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…40531)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This PR targets the SR2 release candidate, `candidate/11.0.1xx-sr2`,
because this intermittent failure is the only remaining UI-test failure
on #40116 (UI build 1694858 at candidate `e3c8b2ec`). The test is the
same on `net11` and `main`, so the change applies there too.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change to `Issue2241.ChangeOrientationCheckScroll`. Product
code, the host page and the shared Appium helpers are unchanged.

**Root cause: the test reads the layout mid-rotation**

`App.SetOrientationLandscape()` / `SetOrientationPortrait()` return as
soon as the driver accepts the orientation change. They don't wait for
the rotation to finish, which on iOS animates for roughly 300–400 ms.
The test called `GetRect()` immediately after rotating back to portrait,
so it sometimes read an intermediate frame of `MainGrid` instead of the
settled layout.

- Settled portrait layout: `MainGrid` at y=211 with height 400, so
CenterY = **411** (the expected value).
- Values seen mid-animation: **249** and **251** in CI; 211–248 locally.

In the local failing runs, the page source captured at teardown shows
the grid back at x=20, y=211, 335×400 (CenterY 411). The ScrollView
layout settles correctly; only the read was early. This is not a product
regression.

**CI evidence**

- UI build 1694858 (candidate `e3c8b2ec`), `Controls (v18.5)
ScrollView`, run 47329666: `Expected: 411 But was: 249`, then `251` on
the in-job retry.
- 421 iOS ScrollView job runs scanned across `main`, `net11`, inflight,
candidate and unrelated PRs. The same assertion also failed on candidate
build 1684453 (235), #40307 (262) and #40263 (263). It is an
intermittent that occurs on every branch at about 1%, not a candidate
regression.

**Fix**

After each rotation, the new `WaitForMainGridToSettle` helper polls
`MainGrid` every 100 ms until two conditions hold:

1. The rect shows the rotated layout: wider than portrait after going to
landscape, narrower than landscape after going back.
2. The rect has been identical for two consecutive reads.

It fails with the last rect if this doesn't happen within 10 s. The
assertion itself is unchanged: portrait CenterY before and after the
scroll must be equal.

**Causal validation (local, iOS 18.5 iPhone Xs simulator — the CI
configuration)**

`dotnet test
src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj
--no-build --filter "Name=ChangeOrientationCheckScroll"`, repeated in a
loop with `HEADLESS=true`:

| Stage | Test code | Result | Observed CenterY on failure |
| --- | --- | --- | --- |
| Baseline | original | **6 of 15 failed** | 211, 224, 224, 234, 224,
233 |
| Fix | this PR | **20 of 20 passed** | — |
| Trigger removed | original + `Thread.Sleep(3000)` after each rotation
| **12 of 12 passed** | — |
| Fix reverted | original | **9 of 15 failed** | 224, 233, 224, 211,
232, 248, 211, 224, 233 |
| Restored | this PR | **15 of 15 passed** | — |

Adding only a delay after rotating removes the failure, which confirms
the timing cause. The fix doesn't slow the test noticeably: it took
about 20 s per run, as before.

The test also runs on Android. On an Android API 30 emulator (the CI API
level), the fixed test passed 4 of 4 runs (4–7 s each) via `pwsh
.github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter
"Name=ChangeOrientationCheckScroll"`, so the rotation-and-settle wait
also holds there.

### Issues Fixed

Fixes the intermittent `Issue2241.ChangeOrientationCheckScroll` iOS
UI-test failure on #40116. There is no separate issue for it. Related:
#2241.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
devanathan-vaithiyanathan pushed a commit to devanathan-vaithiyanathan/maui that referenced this pull request Nov 24, 2026
…otnet#40531)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This PR targets the SR2 release candidate, `candidate/11.0.1xx-sr2`,
because this intermittent failure is the only remaining UI-test failure
on dotnet#40116 (UI build 1694858 at candidate `e3c8b2ec`). The test is the
same on `net11` and `main`, so the change applies there too.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change to `Issue2241.ChangeOrientationCheckScroll`. Product
code, the host page and the shared Appium helpers are unchanged.

**Root cause: the test reads the layout mid-rotation**

`App.SetOrientationLandscape()` / `SetOrientationPortrait()` return as
soon as the driver accepts the orientation change. They don't wait for
the rotation to finish, which on iOS animates for roughly 300–400 ms.
The test called `GetRect()` immediately after rotating back to portrait,
so it sometimes read an intermediate frame of `MainGrid` instead of the
settled layout.

- Settled portrait layout: `MainGrid` at y=211 with height 400, so
CenterY = **411** (the expected value).
- Values seen mid-animation: **249** and **251** in CI; 211–248 locally.

In the local failing runs, the page source captured at teardown shows
the grid back at x=20, y=211, 335×400 (CenterY 411). The ScrollView
layout settles correctly; only the read was early. This is not a product
regression.

**CI evidence**

- UI build 1694858 (candidate `e3c8b2ec`), `Controls (v18.5)
ScrollView`, run 47329666: `Expected: 411 But was: 249`, then `251` on
the in-job retry.
- 421 iOS ScrollView job runs scanned across `main`, `net11`, inflight,
candidate and unrelated PRs. The same assertion also failed on candidate
build 1684453 (235), dotnet#40307 (262) and dotnet#40263 (263). It is an
intermittent that occurs on every branch at about 1%, not a candidate
regression.

**Fix**

After each rotation, the new `WaitForMainGridToSettle` helper polls
`MainGrid` every 100 ms until two conditions hold:

1. The rect shows the rotated layout: wider than portrait after going to
landscape, narrower than landscape after going back.
2. The rect has been identical for two consecutive reads.

It fails with the last rect if this doesn't happen within 10 s. The
assertion itself is unchanged: portrait CenterY before and after the
scroll must be equal.

**Causal validation (local, iOS 18.5 iPhone Xs simulator — the CI
configuration)**

`dotnet test
src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj
--no-build --filter "Name=ChangeOrientationCheckScroll"`, repeated in a
loop with `HEADLESS=true`:

| Stage | Test code | Result | Observed CenterY on failure |
| --- | --- | --- | --- |
| Baseline | original | **6 of 15 failed** | 211, 224, 224, 234, 224,
233 |
| Fix | this PR | **20 of 20 passed** | — |
| Trigger removed | original + `Thread.Sleep(3000)` after each rotation
| **12 of 12 passed** | — |
| Fix reverted | original | **9 of 15 failed** | 224, 233, 224, 211,
232, 248, 211, 224, 233 |
| Restored | this PR | **15 of 15 passed** | — |

Adding only a delay after rotating removes the failure, which confirms
the timing cause. The fix doesn't slow the test noticeably: it took
about 20 s per run, as before.

The test also runs on Android. On an Android API 30 emulator (the CI API
level), the fixed test passed 4 of 4 runs (4–7 s each) via `pwsh
.github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter
"Name=ChangeOrientationCheckScroll"`, so the rotation-and-settle wait
also holds there.

### Issues Fixed

Fixes the intermittent `Issue2241.ChangeOrientationCheckScroll` iOS
UI-test failure on dotnet#40116. There is no separate issue for it. Related:
dotnet#2241.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…# expressions (dotnet#40263)

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Fixes C# expression `xmlns`-prefix expansion and `TypedBinding`
generation when `xmlns`-prefixed static members are used inside ternary
conditionals, method calls, interpolated strings, or with
source-generated types and bindable properties:

- **`CSharpExpressionHelpers.ResolveXmlnsPrefixes`**: Added a fallback
to `global::<ClrNamespace>.<TypeName>` using
`namespaceUri.GetClrNamespace()` (or a single mapped namespace from
`xmlnsCache.ClrNamespacesForXmlns`) when `TryResolveTypeSymbol` returns
`false` because the target type (e.g., generated ResX `Strings`) is
emitted by a sibling incremental source generator. Also allowed
expanding `xmlns`-prefixed member accesses parsed inside Roslyn
`InterpolationFormatClauseSyntax` (e.g.,
`$"{res:Strings.FormatMessage(...)}"`) while keeping standard format
specifiers intact, and wrapped top-level `global::` expressions in
interpolation holes in parentheses (`WrapHoleGlobalAlias`) so C# does
not treat the first `:` as an interpolation format specifier.
- **`MemberResolver`, `ExpressionAnalyzer`, `ExpandMarkupsVisitor`**:
Handled `AliasQualifiedNameSyntax` (`global::`) roots cleanly without
prefixing `__source.` or reporting false missing-member diagnostics, and
passed `Compilation` into shared `MemberResolver.HasMember` calls
(removing duplicate lookup helpers) so `[ObservableProperty]` and
`[RelayCommand]` members resolve during expression analysis and binding
generation.
- **`SetPropertyHelpers`**: Updated `TryHandleExpressionBinding` and
`SetExpressionBinding` to check `HasBindablePropertyHeuristic` when
`bpFieldSymbol` is `null` so expressions targeting
`[BindableProperty]`-attributed controls emit `SetBinding` with
`TypedBinding` instead of falling back to one-time `SetValue`.
- **`UpdateComponentCodeWriter`**: Wired `ResolveXmlnsPrefixes` and
`TransformAttachedProperties` into `ExpandMarkupForUC` and
`TryEmitExpressionBinding` so incremental Hot Reload `UpdateComponent`
generation handles `xmlns`-prefixed C# expressions consistently with
`InitializeComponent`.

### Validation

- `dotnet build src/Controls/src/SourceGen/Controls.SourceGen.csproj -c
Debug -p:_MauiDotNetVersionMajor=10`: succeeded with 0 warnings, 0
errors.
- Targeted regression tests
(`XmlnsPrefixedTypeInTernaryAndCallee_ExpandsAndBinds`,
`XmlnsPrefixedUnresolvedType_FallsBackToClrNamespaceAndBinds`,
`ExpressionOnHeuristicBindableProperty_AndObservableProperty_GeneratesTypedBinding`,
`CSharpExpression_XmlnsPrefixedTypeChange_GeneratesUC`): 4 passed, 0
failed, 0 skipped.
- Full `SourceGen.UnitTests` (`-c Debug -p:_MauiDotNetVersionMajor=10`):
627 passed, 40 skipped (pre-existing E2E hot reload skips), 2 unrelated
pre-existing `HotReload.AiAssisted` `CS0122` (`AppThemeBinding`
accessibility) failures.

### Issues Fixed

Fixes dotnet#40214

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…otnet#40531)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This PR targets the SR2 release candidate, `candidate/11.0.1xx-sr2`,
because this intermittent failure is the only remaining UI-test failure
on dotnet#40116 (UI build 1694858 at candidate `e3c8b2ec`). The test is the
same on `net11` and `main`, so the change applies there too.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change to `Issue2241.ChangeOrientationCheckScroll`. Product
code, the host page and the shared Appium helpers are unchanged.

**Root cause: the test reads the layout mid-rotation**

`App.SetOrientationLandscape()` / `SetOrientationPortrait()` return as
soon as the driver accepts the orientation change. They don't wait for
the rotation to finish, which on iOS animates for roughly 300–400 ms.
The test called `GetRect()` immediately after rotating back to portrait,
so it sometimes read an intermediate frame of `MainGrid` instead of the
settled layout.

- Settled portrait layout: `MainGrid` at y=211 with height 400, so
CenterY = **411** (the expected value).
- Values seen mid-animation: **249** and **251** in CI; 211–248 locally.

In the local failing runs, the page source captured at teardown shows
the grid back at x=20, y=211, 335×400 (CenterY 411). The ScrollView
layout settles correctly; only the read was early. This is not a product
regression.

**CI evidence**

- UI build 1694858 (candidate `e3c8b2ec`), `Controls (v18.5)
ScrollView`, run 47329666: `Expected: 411 But was: 249`, then `251` on
the in-job retry.
- 421 iOS ScrollView job runs scanned across `main`, `net11`, inflight,
candidate and unrelated PRs. The same assertion also failed on candidate
build 1684453 (235), dotnet#40307 (262) and dotnet#40263 (263). It is an
intermittent that occurs on every branch at about 1%, not a candidate
regression.

**Fix**

After each rotation, the new `WaitForMainGridToSettle` helper polls
`MainGrid` every 100 ms until two conditions hold:

1. The rect shows the rotated layout: wider than portrait after going to
landscape, narrower than landscape after going back.
2. The rect has been identical for two consecutive reads.

It fails with the last rect if this doesn't happen within 10 s. The
assertion itself is unchanged: portrait CenterY before and after the
scroll must be equal.

**Causal validation (local, iOS 18.5 iPhone Xs simulator — the CI
configuration)**

`dotnet test
src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj
--no-build --filter "Name=ChangeOrientationCheckScroll"`, repeated in a
loop with `HEADLESS=true`:

| Stage | Test code | Result | Observed CenterY on failure |
| --- | --- | --- | --- |
| Baseline | original | **6 of 15 failed** | 211, 224, 224, 234, 224,
233 |
| Fix | this PR | **20 of 20 passed** | — |
| Trigger removed | original + `Thread.Sleep(3000)` after each rotation
| **12 of 12 passed** | — |
| Fix reverted | original | **9 of 15 failed** | 224, 233, 224, 211,
232, 248, 211, 224, 233 |
| Restored | this PR | **15 of 15 passed** | — |

Adding only a delay after rotating removes the failure, which confirms
the timing cause. The fix doesn't slow the test noticeably: it took
about 20 s per run, as before.

The test also runs on Android. On an Android API 30 emulator (the CI API
level), the fixed test passed 4 of 4 runs (4–7 s each) via `pwsh
.github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter
"Name=ChangeOrientationCheckScroll"`, so the rotation-and-settle wait
also holds there.

### Issues Fixed

Fixes the intermittent `Issue2241.ChangeOrientationCheckScroll` iOS
UI-test failure on dotnet#40116. There is no separate issue for it. Related:
dotnet#2241.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants