Skip to content

refactor: Strip dead native #if blocks from Uno.UI sources - #23973

Merged
MartinZikmund merged 2 commits into
feature/breakingchangesfrom
dev/mazi/2096-dead-wasm-ifdefs
Aug 7, 2026
Merged

MartinZikmund merged 2 commits into
feature/breakingchangesfrom
dev/mazi/2096-dead-wasm-ifdefs

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: Part of epic unoplatform/uno-private#2049 — 🦋 Drop native targets. Closes unoplatform/uno-private#2096.

PR Type:

🔄 Refactoring (no functional changes, no api changes)

What changed? 🚀

Strips the dead native #if branches left in shared src/Uno.UI sources after the native drop.

InlineCollection.cs — a sync regression

Six __WASM__ directives. #23671 removed them; master-sync merge 0edfe5fa75 (2026-07-29) put them back, because master had edited the file while this branch had rewritten it.

They are provably dead:

  • src/Uno.UI has exactly two heads — Uno.UI.Skia.csproj (UnoRuntimeIdentifier=Skia) and Uno.UI.Reference.csproj (UnoRuntimeIdentifier=Reference). There is no Uno.UI.Wasm.csproj.
  • src/Uno.CrossTargetting.targets:73 is the only repo-source definition of __WASM__, gated on '$(UnoRuntimeIdentifier)'=='WebAssembly'. Neither head qualifies.
  • The browser head does not compile this file either: Uno.UI.Runtime.Skia.WebAssembly.Browser.csproj defines WASM_SKIA (not __WASM__), and its Compile Include list is four .wasm.cs files. The __WASM__ define in that project's build/*.targets runs in the consuming app, never in Uno.UI.
  • Decisive: the IsOwnedByTextBlock() arm calls _collection.Owner, and DependencyObjectCollection has no Owner member. That branch could not have compiled under any configuration in this tree.

Every !__WASM__ body is kept verbatim — the focus-clearing Clear()/RemoveAt(int), the indexer guard, and ClearFocusForRemovedInline. The only prose change is dropping "Non-WASM" from a comment that no longer has a WASM flavour to contrast against.

DoubleExtensions.cs

Two !XAMARIN directives. XAMARIN is defined only for the native Apple and Android targets (Uno.CrossTargetting.targets:91,95,96,105), none of which Uno.UI builds. Kept the !XAMARIN bodies.

Validation

  • Code review: repo-wide sweep for native #if symbols under src/Uno.UI. The remaining ones are in the WebView interop files that Uno.UI.Runtime.Skia.Android.csproj and .AppleUIKit.csproj <Compile Include>-link — live there, deliberately untouched. The ~76 [Uno.NotImplemented("__ANDROID__", "__WASM__", …)] attribute strings are also untouched; they are data, not directives.
  • Compile: dotnet build src/Uno.UI/Uno.UI.Skia.csproj and src/Uno.UI/Uno.UI.Reference.csproj, both with -p:UnoTargetFrameworkOverride=net10.0 -p:UnoFastDevBuild=true — 0 errors on both.
  • Runtime: not run, and not needed here. Removing a directive whose other arm was never compiled leaves the two heads with byte-identical source; there is no behaviour to exercise. If a reviewer wants belt-and-braces, Given_FocusManager_DetachedElements and Given_TextBlock cover the un-guarded focus path.

PR Checklist ✅

MartinZikmund and others added 2 commits August 5, 2026 14:49
The directives were removed by #23671 and re-introduced by master-sync
merge 0edfe5f. Only Uno.UI.Skia.csproj and Uno.UI.Reference.csproj
compile this file and neither defines __WASM__, so the arms were dead:
the IsOwnedByTextBlock one referenced _collection.Owner, a member
DependencyObjectCollection does not have.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01D5wk47a5fYoVKWwn9xbexY
XAMARIN is only defined for the native Apple and Android targets, which
Uno.UI no longer builds.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01D5wk47a5fYoVKWwn9xbexY
Copilot AI lite review requested due to automatic review settings August 5, 2026 14:54
@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 28s —— View job


PR Review

  • Gather context and read changed files
  • Review DoubleExtensions.cs changes
  • Review InlineCollection.cs changes
  • Verify correctness of dead-code claims
  • Post inline comments for findings
  • Post summary

Summary

Verdict: ✅ LGTM — no blocking issues found.

DoubleExtensions.cs — clean removal of 2 !XAMARIN/XAMARIN branches. The kept arm (!double.IsInfinity(v) && !double.IsNaN(v)) is semantically equivalent to double.IsFinite(v). The XAMARIN symbol is confirmed live only for native Android/Apple targets (Uno.CrossTargetting.targets:89,93,97,106), none of which are heads of Uno.UI.

InlineCollection.cs — clean removal of 6 __WASM__/!__WASM__ branches. The PR's decisive evidence holds: DependencyObjectCollection has no Owner member (confirmed by reading DependencyObjectCollection.cs), so the __WASM__ arm of IsOwnedByTextBlock() (_collection.Owner) was already a compile-time impossibility in any surviving configuration. All kept !__WASM__ bodies are intact; the comment updated from "Non-WASM inline collections…" to "Inline collections…" is accurate.

Repo-wide sweep confirmed: only two files in src/Uno.UI still carry __WASM__ (WebView/Native/NativeCoreWebView2Http*.cs) — both are guard-file-header lines in files linked by the Skia.Android/.AppleUIKit runtimes, exactly as the PR description states.

Non-blocking suggestion (out of scope for this PR): DoubleExtensions.cs now calls !double.IsInfinity() && !double.IsNaN() where double.IsFinite() would be idiomatic on .NET 10 — the verbose form was only needed to avoid the missing API on older Xamarin runtimes. Worth a follow-up cleanup once this lands.

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.

Pull request overview

This PR removes dead preprocessor branches from shared src/Uno.UI sources that no longer compile under any active Uno.UI head (Skia + Reference), reducing maintenance overhead and eliminating unreachable code paths.

Changes:

  • InlineCollection.cs: removes __WASM__-guarded branches and makes the non-WASM implementation unconditional (including focus-clearing paths and parent-walk logic).
  • DoubleExtensions.cs: removes XAMARIN-guarded branches and keeps the non-Xamarin IsFinite implementations.

Cross-cutting note (process):

  • The PR description references private issues (unoplatform/uno-private#...) and uses short-form “Closes …”. Repo contribution rules require a fully qualified public GitHub issue link (or the explicit “Note: No related issue … Approved by …” exception). This should be updated before merge.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Uno.UI/UI/Xaml/Documents/InlineCollection.cs Collapses dead __WASM__ branches and keeps the live Skia/Reference implementation unconditional.
src/Uno.UI/Extensions/DoubleExtensions.cs Collapses dead XAMARIN branches, leaving consistent finite checks across active heads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 225899 found UI Test snapshots differences: skia-linux-screenshots: 74, skia-windows-screenshots: 266

Details
  • skia-linux-screenshots: 74 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DamageRegion_ShadowChildPaintingCaster.png-dark
    • DoubleImageBrushInList.png-dark
    • DynamicFont.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • Buttons.png
    • DisplayInformation.png-dark
    • ContextRequested.png-dark
    • ContextRequested.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • ImageBrush_Stretch.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DropDownButtonPage.png-dark
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • ClipboardTests.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
  • skia-windows-screenshots: 266 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Gamepad_CurrentReading.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • DropDownButtonPage.png-dark
    • DynamicBackgroundSizing.png-dark
    • BasicAcrylicBrushTest2.png-dark
    • DamageRegion_ShadowChildShape.png-dark
    • DamageRegion_ShadowChildShape.png
    • BitmapIcon_Sizing.png-dark
    • Button_Enabled_Control_Disabled.png
    • CompositionPath.png-dark
    • CompositionPath.png
    • DataTransferManager.png
    • BitmapIcon_Sizing.png
    • FlipView_Images.png-dark
    • FlipView_Images.png
    • GetFocus.png-dark
    • GetFocus.png

@MartinZikmund
MartinZikmund requested a review from Xiaoy312 August 6, 2026 11:24
@MartinZikmund MartinZikmund added the ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met label Aug 6, 2026
@MartinZikmund
MartinZikmund enabled auto-merge August 6, 2026 11:24
@MartinZikmund
MartinZikmund merged commit cfa2b73 into feature/breakingchanges Aug 7, 2026
48 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/2096-dead-wasm-ifdefs branch August 7, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants