Vendored: Yoga flexbox layout engine
This folder is vendored third-party code. Do not hand-edit it.
It is a C# line-port of Meta's Yoga flexbox engine, authored by
Microsoft as part of the Reactor project. Both
grants are MIT; the full text of both is in THIRD-PARTY-NOTICES.md
at the repo root.
| Upstream | https://github.com/microsoft/microsoft-ui-reactor |
| Tag | v0.1.0-preview.13 |
| Commit | c9191b97c40a2e4d6bcbc72df7714184862b4d36 |
| Upstream path | src/Reactor/Yoga/ |
| Imported | 2026-09-04 |
| Files | 10 of the 11 in that folder (FlexPanel.cs, the WinUI adapter, is not vendored — we write our own) |
Why it is here rather than referenced
Microsoft.UI.Reactor ships as a single net10.0-windows10.0.22621 package with a WindowsAppSDK
dependency and the whole Reactor framework attached, so a PackageReference is not viable for a
multi-target Uno library. See specs/flexpanel-import/spec.md (risk 5).
Why it is not under Controls/
It is not a control, and it must not be mistaken for our own code. The Uno.Toolkit.UI XAML merge
(xamlmerge-toolkit.props) only globs Controls/** and Behaviors/**, so Layout/ is inert there and
no csproj change was needed — the implicit Compile glob picks these files up.
Adaptations applied on import
Every one is mechanical and scripted, by build/scripts/import-yoga.py.
Re-running it against a newer upstream reproduces this folder exactly.
Provenance header. Four lines prepended to each file: upstream repo, tag, commit, that file's original upstream path, import date, and SPDX license with both copyright holders. This offsets every file by 4 lines when diffing against upstream — account for it.
Namespace. Every file →
Uno.Toolkit.UI.Yoga, and upstream's redundant self-usingis dropped.⚠️
Uno.Toolkit.UI.Layout— whichspecs/flexpanel-import/spec.mdoriginally proposed — cannot be used. It collides with the existingpublic enum LayoutinUno.Toolkit.UI(Helpers/ResponsiveHelper.cs), and that enum is public API that cannot be renamed.Explicit
usingdirectives added. Upstream builds withImplicitUsings=enable;Uno.Toolkit.WinUI.csprojdoes not.System,System.Collections.Generic,System.Runtime.CompilerServices,System.DiagnosticsandSystem.Threadingare added per file as needed. The script skips any a file already declares.FlexLayoutDirection.LTR/.RTLrenamed to.LeftToRight/.RightToLeft(spec D3b). The enum is internal now, so this is purely cosmetic; it is kept because it matches WinUI'sFlowDirection.LeftToRightand dropping it would churn every corpus file. Numeric values are not renumbered, includingFlexDirection's Yoga ordering (Column = 0, ColumnReverse = 1, Row = 2, RowReverse = 3).FlexEnums.csmadeinternal. Upstream's six flex enums are the only public types in the folder. Here every top-level type isinternal, so an upstream re-sync can never reshape the package's public API.FlexPanel's public enums are our own, inControls/FlexPanel/FlexEnums.cs, andControls/FlexPanel/FlexEnumMapping.csmaps them onto these by name. The script's self-check fails on any public top-level type left in the engine.Nothing else. No reformatting, no
#nullablepragmas, no analyzer suppressions — none turned out to be necessary.
Accepted as-is
YogaAlgorithmis a static class holdingprivate static uint s_currentGenerationCount, documented upstream as thread-unsafe and bumped viaInterlocked.Increment. Layout runs on the UI thread on every Uno target, so the invariant holds; it is a value type, so it pins nothing and is ALC-safe. Recorded rather than refactored — divergence from upstream has to be paid for (spec D8).- CSS Grid properties present in C++ Yoga are absent from this port.
YogaStylestill carriesJustifyItems/JustifySelf, but grid layout is not implemented and is out of scope.
Conformance tests
The upstream generated corpus is ported alongside the engine to
src/Uno.Toolkit.RuntimeTests/Tests/Yoga/ — 26 files, 590 test methods (544 active, 46 skipped
upstream), 17,784 assertions. It is the
reason this engine was imported rather than hand-written, so keep it green. See that folder's
README.md.
Re-syncing
Clone
microsoft/microsoft-ui-reactorat the new tag.Bump
TAG,COMMITandIMPORTEDinbuild/scripts/import-yoga.py, then run it:REACTOR_SRC=/path/to/reactor python build/scripts/import-yoga.py allIt rewrites both the engine and the test corpus, is idempotent, and self-verifies — it fails on any leftover upstream namespace,
Xunitreference,[Fact], un-renamedLTR/RTL, or missing provenance header.Build, then run the tier-1 corpus. A conformance failure after a sync is an engine regression, not a test problem.
Re-sync deliberately, never opportunistically — upstream is a 0.1.0-preview and moves weekly.