Repository navigation
Strip residual dead native #if blocks from shared Uno.UI - #23671
Conversation
|
Claude finished @MartinZikmund's task in 4m 58s —— View job Code ReviewTodo List:
Overall Verdict: ✅ Ship (with nit follow-ups)Correctness: All 73 directive simplifications across 28 files are correct. Every transformation was cross-checked:
Issues by severity:
Nits (no blocking issues): All 7 inline comments flag stale text that survives the
No issues found with:
Validation note: Review is code-review assessment only (diff inspection). Build validation ( |
There was a problem hiding this comment.
Pull request overview
This PR continues the “drop native targets” refactor by simplifying remaining native-only preprocessor branches in shared src/Uno.UI code (treating __ANDROID__, __IOS__, __WASM__, __APPLE_UIKIT__ as dead in these heads), and removing orphaned Xamarin-only files that are no longer compiled.
Changes:
- Simplified/removed residual native
#if/#elifbranches across multipleUno.UIXAML/control files, keeping only still-live symbols (e.g.__SKIA__,__NETSTD_REFERENCE__,IS_UNIT_TESTS, etc.). - Removed two orphaned
*.Xamarin.csfiles (UIElementCollection*) that were native-only and no longer built. - Promoted/normalized remaining non-native logic by collapsing conditions like
__SKIA__ || __WASM__→__SKIA__, and removing native-only workarounds.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.UI/UI/Xaml/Window/Window.WinAppSdk.cs | Removes dead __APPLE_UIKIT__ guard around Window.Title. |
| src/Uno.UI/UI/Xaml/Window/Native/Factory/NativeWindowFactory.others.cs | Collapses condition to only exclude Skia builds. |
| src/Uno.UI/UI/Xaml/UIElementExtensions.cs | Removes dead platform guard so the file is always compiled in Uno.UI heads. |
| src/Uno.UI/UI/Xaml/UIElementCollectionExtensions.Xamarin.cs | Deleted orphaned Xamarin-only native-view initializer helper. |
| src/Uno.UI/UI/Xaml/UIElementCollection.Xamarin.cs | Deleted orphaned Xamarin-only native children enumerator. |
| src/Uno.UI/UI/Xaml/UIElement.RoutedEvents.cs | Removes native-only usings/workarounds; collapses WASM/SKIA directives to SKIA-only. |
| src/Uno.UI/UI/Xaml/UIElement.MuxInternal.cs | Removes dead native IsInLiveTree implementations. |
| src/Uno.UI/UI/Xaml/UIElement.cs | Simplifies conditions to exclude only Skia (keeps reference behavior). |
| src/Uno.UI/UI/Xaml/UIElement.crossruntime.cs | Collapses `SKIA |
| src/Uno.UI/UI/Xaml/Shapes/Shape.layout.crossruntime.cs | Removes WASM branches, keeping only SKIA implementation. |
| src/Uno.UI/UI/Xaml/Media/Imaging/RenderTargetBitmap.UnmanagedArrayOfBytes.cs | Removes dead Android guard; file is now always compiled in Uno.UI heads. |
| src/Uno.UI/UI/Xaml/Media/GeometryHelper.cs | Removes dead __APPLE_UIKIT__ guard around ellipse geometry writing. |
| src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs | Removes WASM-only DOM property/update and transform-specific clip adjustments. |
| src/Uno.UI/UI/Xaml/FrameworkElement.EffectiveViewport.cs | Simplifies CHECK_LAYOUTED definition condition by dropping dead native clause. |
| src/Uno.UI/UI/Xaml/FrameworkElement.crossruntime.cs | Removes WASM-only ToString() formatting block. |
| src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.unsupported.cs | Simplifies unsupported-platform guard to match remaining heads. |
| src/Uno.UI/UI/Xaml/Controls/ToggleSwitch/ToggleSwitch.cs | Removes dead native template checks; returns false under remaining heads. |
| src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.cs | Removes dead native/WASM branches in load/setup, properties, and event handling. |
| src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.cs | Removes WASM-only forks; consolidates selection/foreground validation behavior. |
| src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs | Removes dead platform-specific keyboard scrolling exclusions and WASM margin workaround. |
| src/Uno.UI/UI/Xaml/Controls/Pivot/PivotItem.cs | Removes dead Android-only using. |
| src/Uno.UI/UI/Xaml/Controls/NavigationView/NavigationViewItem.Uno.cs | Removes dead Android-only deferred visual state timer method. |
| src/Uno.UI/UI/Xaml/Controls/NavigationView/NavigationViewItem.cs | Removes dead Android-only #define UNO_USE_DEFERRED_VISUAL_STATES. |
| src/Uno.UI/UI/Xaml/Controls/NavigationView/NavigationView.cs | Removes dead Android/iOS arrange-height workarounds and Android-only usings. |
| src/Uno.UI/UI/Xaml/Controls/Image/Image.cs | Collapses non-Skia condition by dropping dead WASM clause. |
| src/Uno.UI/UI/Xaml/Controls/GridView/GridViewHeaderItem.cs | Removes dead WASM guard around constructor. |
| src/Uno.UI/UI/Xaml/Controls/Control/Control.cs | Removes dead native/WASM debug and template-application branches. |
| src/Uno.UI/UI/Xaml/Application.Alc.cs | Collapses `SKIA |
| src/Uno.UI/UI/ViewManagement/InputPane/InputPane.others.cs | Collapses condition to exclude only Skia. |
| src/Uno.UI/FeatureConfiguration.cs | Drops dead WASM/AppleUIKit branches for symbols font and other config toggles. |
Comments suppressed due to low confidence (2)
src/Uno.UI/UI/Xaml/Media/Imaging/RenderTargetBitmap.UnmanagedArrayOfBytes.cs:5
using System.Linq;is unused in this file (no LINQ usage remains), which will trigger CS8019 and break the build due to warnings-as-errors. Remove the unused using.
using System;
using System.Buffers;
using System.Linq;
using System.Runtime.InteropServices;
src/Uno.UI/UI/Xaml/UIElementExtensions.cs:5
- The file now contains only types from the Microsoft.UI.Xaml namespace but still has unused
usingdirectives. WithTreatWarningsAsErrors=true, these unused usings will fail the build (CS8019). Remove the unusedusinglines.
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.UI.Xaml
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23671/wasm-skia-net9/index.html |
|
The build 221073 found UI Test snapshots differences: Details
|
UIElementCollection.Xamarin.cs and UIElementCollectionExtensions.Xamarin.cs are compiled by no remaining project once the native UI targets are dropped: the `.Xamarin.cs` suffix is excluded from the Skia and Reference heads, and no runtime host links them. The live implementations are UIElementCollection.cs and UIElementCollection.crossruntime.cs. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0158dkz3C514Uw7PSy2VnSED
With the native UI targets removed, files under src/Uno.UI compile only in the Skia and Reference heads, where __ANDROID__, __IOS__, __WASM__ and __APPLE_UIKIT__ are never defined. Their #if/#elif branches are dead code interleaved with the live Skia logic. Partial-evaluate those four symbols to false and simplify each condition, preserving the still-live symbols verbatim (__SKIA__, __CROSSRUNTIME__, UNO_REFERENCE_API, __NETSTD_REFERENCE__, IS_UNIT_TESTS, ...). For example `#if !__WASM__ && !__SKIA__` becomes `#if !__SKIA__` (still live on Reference), `#if __SKIA__ || __WASM__` becomes `#if __SKIA__`, and pure native branches are dropped entirely. Files linked into the Skia runtime hosts (Uno.UI.Runtime.Skia.Android and .AppleUIKit) are deliberately left untouched: those hosts target the native TFMs, so their __ANDROID__/__IOS__/__APPLE_UIKIT__ branches are still live. No behavioral change. Validated by building the Uno.UI Skia and Reference heads (both 0 warnings / 0 errors). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_0158dkz3C514Uw7PSy2VnSED
be24821 to
5a6b922
Compare
|
Claude finished @MartinZikmund's task in 5m 10s —— View job Code ReviewTodo List:
Overall Verdict: ✅ Ship (7 prior nits still open, no new blocking issues)The code change is correct — all Unresolved nits from prior reviewAll 7 nits flagged in the previous review remain open. None are blocking, but all affect future readers:
New finding: unused
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23671/wasm-skia-net9/index.html |
|
The build 221973 found UI Test snapshots differences: Details
|
Drop comments and TODOs left dangling by the removed native branches, remove a now-unused `using System;`, and fix TextBlock's [NotImplemented] platform lists (IsTextSelectionEnabled is implemented on Skia, so the still-live __ANDROID__ / __APPLE_UIKIT__ symbols of Skia-on-mobile heads would raise a false Uno0001). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GKBgQoAmRmaFoXXZr93iLB
|
Claude finished @MartinZikmund's task in 2m 17s —— View job Code ReviewTodo List:
Overall Verdict: ✅ Ship (1 nit remaining)The latest commit (
The two remaining inline comments on Validation note: Review is code-review assessment only (diff inspection). Build validation reported by the author; runtime validation N/A for a dead-code strip. |
|
@pr23671-comment.md |
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Claude finished @MartinZikmund's task in 1m 45s —— View job Code ReviewTodo List:
Overall Verdict: ✅ ShipThe latest commit ( All prior nits resolved
No new findings. The Validation note: Review is code-review assessment only (diff inspection). Build validation ( |
Review comments addressed —
|
| file:line | Reviewer point | What changed |
|---|---|---|
src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.cs:785 |
[Uno.NotImplemented] still lists __APPLE_UIKIT__ and __WASM__, which are dead symbols in Uno.UI after the native drop |
Attribute reduced to [Uno.NotImplemented("IS_UNIT_TESTS", "__SKIA__", "__NETSTD_REFERENCE__")], which now exactly matches the surrounding #if IS_UNIT_TESTS || __SKIA__ || __NETSTD_REFERENCE__ guard |
src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.cs:794 |
Same stale list on CharacterCasingProperty |
Same change |
Rationale, verified by inspection: src/Uno.UI/ now ships only Uno.UI.Skia.csproj and Uno.UI.Reference.csproj, so __APPLE_UIKIT__ / __WASM__ / __ANDROID__ can never be defined for this compilation unit. Listing them made the attribute claim those platforms lack an implementation, which is no longer a meaningful statement. This mirrors the shape already applied to TextBlock.cs. The change is string-literal-only inside an attribute, no code paths affected.
No change needed — already handled by bf2f8c6882 (9)
| file:line | Reviewer point | Why no change |
|---|---|---|
Application.Alc.cs:99 |
"Skia and WASM" comment is stale | Comment now reads "ALC app hosting only exists on Skia." — already corrected |
Application.Alc.cs:216 |
Same stale "Skia and WASM" reference | Comment now reads "ALC app hosting only exists on Skia (see ExitAlcApplication)." |
NavigationView/NavigationView.cs:1699 |
// TODO:MZ: Is this still needed for iOS? is moot |
The TODO is gone; grep TODO:MZ over NavigationView/ returns nothing |
ScrollViewer/ScrollViewer.cs:1749 |
Dead WASM-scrolling comment above OnKeyDown |
Comment removed; the block now opens directly on the WinUI TemplatedParentHandlesScrolling note |
TextBlock/TextBlock.cs:610 |
[NotImplemented] lists __ANDROID__ / __APPLE_UIKIT__ |
Already [NotImplemented("IS_UNIT_TESTS", "__NETSTD_REFERENCE__")] |
TextBlock/TextBlock.cs:619 |
Same on IsTextSelectionEnabledProperty |
Same — already reduced |
NavigationViewItem.Uno.cs:18 |
Leftover using System; will trip CS8019 |
The file's only using is using Windows.System;, which is still required by the DispatcherQueueTimer field inside the (still-live for Reference/unit-tests) #if !__SKIA__ block |
TextBox.cs:785 (older duplicate thread) |
Duplicate of the fixed thread above | Superseded — fixed in 08ef1ad28a |
TextBox.cs:794 (older duplicate thread) |
Duplicate of the fixed thread above | Superseded — fixed in 08ef1ad28a |
Needs @MartinZikmund input (0)
Nothing was left open.
Note on scope: ~40 files under src/Uno.UI/ still reference __WASM__ / __ANDROID__ / __APPLE_UIKIT__. That is consistent with this PR being a targeted sweep rather than an exhaustive one; no reviewer thread asked for the remainder.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23671/wasm-skia-net9/index.html |
|
The build 222247 found UI Test snapshots differences: Details
|
|
Tick the box to add this pull request to the merge queue (same as
|
The directives were removed by unoplatform#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
…tform#23619/unoplatform#23671/unoplatform#24020/unoplatform#23999 Fold Application.skia.cs and Application.reference.cs back into Application.cs (unoplatform#24001 skianaming), fix the Lauched->Launched typo (unoplatform#23619), keep the branch's __SKIA__-only ALC window teardown (unoplatform#23671 was WASM+Skia but native heads are gone), and drop the dead UNO_HAS_ENHANCED_LIFECYCLE/__NETSTD_REFERENCE__ guards (unoplatform#24020/unoplatform#23999). Application.reference.cs is dead code in the Skia-only build and is removed, matching master. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XsQppKuZgijApgJxaTZt81
…m#23999/unoplatform#23671 Image.cs still carried the pre-unoplatform#24001 #if-split legacy download/URI pipeline (dead since the Subscribe/ImageData reactive pipeline replaced it) while the neutral rendering lived in the resurrected Image.skia.cs. Fold that neutral rendering into Image.cs, matching master's structure, and drop the legacy members master already removed (OnImageFailed/OnImageOpened/TraceProvider/ToString/etc. - their behavior now lives in BitmapImage/SvgImageSource raising the events directly). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XsQppKuZgijApgJxaTZt81
GitHub Issue: Part of epic unoplatform/uno-private#2049 — 🦋 Drop native targets. Completes unoplatform/uno-private#2096 — Strip dead native
#ifblocks.PR Type:
🔄 Refactoring (no functional changes, no api changes)
What changed? 🚀
Follow-up that finishes the dead native-
#ifstrip for the native-targets drop. #23470 removed the bulk (~270 files across 8 batches), but a residual set of native preprocessor branches survived in the sharedUno.UIsources — mostly__APPLE_UIKIT__-only guards and conditions that mix a native symbol with a live one. This PR collapses the remaining 73 directives across 28 files.With the native UI targets gone, files under
src/Uno.UIcompile only in the Skia and Reference heads, where__ANDROID__,__IOS__,__WASM__and__APPLE_UIKIT__are never defined. Those#if/#elifbranches are dead code interleaved with the live Skia logic.Each condition is partial-evaluated (those four symbols →
false) and simplified, keeping every still-live symbol verbatim (__SKIA__,__CROSSRUNTIME__,UNO_REFERENCE_API,__NETSTD_REFERENCE__,__MACCATALYST__,IS_UNIT_TESTS, …). This is deliberately not blind deletion:#if __SKIA__ || __WASM__→#if __SKIA__#if !__WASM__ && !__SKIA__→#if !__SKIA__(still live on Reference — kept, not removed)#if __APPLE_UIKIT__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__→#if IS_UNIT_TESTS || __SKIA__ || __NETSTD_REFERENCE__#if !(IS_NATIVE_ELEMENT && __APPLE_UIKIT__) && !UNO_HAS_ENHANCED_LIFECYCLE→#if !UNO_HAS_ENHANCED_LIFECYCLE#if __ANDROID__,#if __APPLE_UIKIT__ || __ANDROID__) dropped entirely;#else/#elifbodies promoted where they become unconditional.Deliberately left untouched⚠️
Files that are
<Compile Include>-linked into the native Skia runtime hosts —Uno.UI.Runtime.Skia.Android(targetsnet*-android) andUno.UI.Runtime.Skia.AppleUIKit(targetsnet*-ios/-maccatalyst/-tvos) — still see__ANDROID__/__IOS__/__APPLE_UIKIT__as live symbols. Their native branches are not dead there, so all such files are left exactly as-is (14 files, incl.NativeApplication.cs,GlobalUsings.cs, the sharedNativeCoreWebView2Http*headers, and everyWebView/Native/{Android,iOSmacOS}/*file).Also removed 🗑️
UIElementCollection.Xamarin.csandUIElementCollectionExtensions.Xamarin.cs— orphaned native-only files compiled by no remaining project (live implementations areUIElementCollection.cs/UIElementCollection.crossruntime.cs).Validation ✅
#if/#endifbalance confirmed on all 28 files.Uno.UI.SkiaandUno.UI.Referenceheads both build0 Warning(s) / 0 Error(s)(net10.0).No public API or runtime behavior change on any shipping head.
PR Checklist ✅
Screenshots Compare Test Runresults — N/A: no visual change.🤖 Generated with Claude Code
https://claude.ai/code/session_0158dkz3C514Uw7PSy2VnSED