Repository navigation
Fix TableView NullReferenceException in trimmed (Store) builds - #2265
Merged
Merged
Conversation
TableViewSampleItem implements INotifyPropertyChanged and INotifyDataErrorInfo and is marshalled to native via TableViewSource. As a non-partial class, CsWinRT built its CCW vtable via reflection, which fails in trimmed (Store) builds. Marking it partial lets the CsWinRT AOT generator emit a static vtable. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Niels Laute (niels9001)
enabled auto-merge (squash)
October 7, 2026 20:20
Marcel W. (marcelwgn)
approved these changes
Oct 7, 2026
1 of 3 tasks
Niels Laute (niels9001)
added a commit
that referenced
this pull request
Oct 7, 2026
## Description Patch release 3.0.1 for the `release/3.0` branch: - Cherry-picks #2265 (Fix TableView NullReferenceException in trimmed (Store) builds), found during the 3.0.0 flight. - Bumps the version to 3.0.1.0 (`WinUIGallery.csproj`, `Package.appxmanifest`, `Package.Dev.appxmanifest`) and the Store pipeline's default `releaseVersion` to 3.0.1. ## Motivation and Context 3.0.0.0 went out to the `WinUI Gallery 3.0 Flight` package flight, and the TableView sample crashed in the trimmed Store build. Following `docs/PublishingNewVersion.md` ("Fixing issues during the release"), the fix landed on `main` first and is cherry-picked here with a patch bump, so a new flight submission can be made from `release/3.0`. ## How Has This Been Tested? - The fix was validated in #2265 (approved, merged to `main`). - PRValidation runs on this PR. - After merge, 3.0.1 will be published to the flight through the Store-Release pipeline for testers to verify. ## Screenshots (if appropriate): N/A ## Types of changes - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 of 3 tasks
Niels Laute (niels9001)
added a commit
that referenced
this pull request
Oct 7, 2026
## Description Cherry-picks #2266 (Enable mouse and touch inking in InkCanvas toolbar and save/restore samples) into `release/3.0` for 3.0.1. No version bump is needed: 3.0.1 (#2267) hasn't been built or submitted to the Store yet. ## Motivation and Context #2266 was merged to `main` and should ship in the 3.0.1 flight build together with the TableView fix (#2265), following `docs/PublishingNewVersion.md`. ## How Has This Been Tested? - Validated in #2266 (approved, PRValidation passed, merged to `main`). - The cherry-pick applied cleanly onto `release/3.0`, including `catalog/windows-samples.json`. - PRValidation runs on this PR. ## Screenshots (if appropriate): N/A ## Types of changes - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 of 3 tasks
Niels Laute (niels9001)
pushed a commit
that referenced
this pull request
Nov 7, 2026
#2283) ## Description Adds three examples to the TableView page: ### 1. Showing hierarchical rows - A flat folder/file collection (`TableViewHierarchyItem`, with `Id` and `ParentId`) is shown as nested rows through `TableViewSource.ParentBy(Id, ParentId)`. A null parent key makes a top-level row. - Options: a name filter (matches keep their ancestors, which stay expanded while the filter is active), plus **Expand all rows** / **Collapse all rows** (`ExpandAllRows` / `CollapseAllRows`). - Keyboard: Right expands a row; Left collapses it or moves to the parent; `*` expands the focused row's subtree. - The Name column has `MinWidth="200"` so third-level names aren't truncated by the indent. ### 2. Adding context menus to cells, rows, and headers Shows how TableView chooses which menu to open: - **Name cells:** a `CellContextFlyout` with "Copy name". - **Other cells and rows:** the row's `ContextFlyout`, set through an implicit `TableViewRow` style (Copy row / Move to next category / Remove). - **Column headers:** one `HeaderContextFlyout` shared by all columns. Its `Opening` handler reads `MenuFlyout.Target` (`TableViewColumnHeader.Column`) to offer "Hide <column>" (disabled on the last visible column) and "Show all columns". - **Everywhere else:** the table's own `ContextFlyout` ("Restore all items") as the fallback. - Menu items read their row from `DataContext`. Results go to the example's Output. ### 3. Updating rows from live data - A `DispatcherTimer` updates a few observable `TableViewLiveItem` values every second, and the table is sorted by Value, descending. - `TableViewSource.IsLiveShaping = true` re-applies the sort, filter, grouping, and hierarchy on each `PropertyChanged`, so rows move as values change and the selection stays with its row. - A **Shaping** selector (Flat, Grouped by trend, Hierarchy, Grouped hierarchy) shows live shaping on every projection: rows re-sort inside their group or sibling set, move between Rising/Falling/Steady groups as their change flips, and top-level rows keep their nested rows when they move. - Options: pause updates, turn live shaping off (cells still update but rows stay in place), and filter to values of 50 or more (rows join and leave as they cross 50). - The timer starts and stops with the table's `Loaded` and `Unloaded` events. ### Shared - All new models are `partial`, per #2265, so trimmed Store builds keep the CsWinRT vtable. - `ControlInfoData.json`: adds `hierarchy`, `tree`, `context menu` and `live data` tags, and updates the description. `catalog/windows-samples.json` is regenerated. - Tests: - The catalog test now expects 8 examples in order. - New catalog tests cover the hierarchy, context menu, and live data snippets. - `SnippetMatchesThePageImplementation` fails if the three new snippets stop matching `TableViewPage.xaml`, `TableViewPage.xaml.cs`, or the item classes (only AutomationIds are left out of the snippets). - New unit tests cover the hierarchy data (valid acyclic tree) and `TableViewLiveItem` (tree shape, update, trend, clamping, notifications). ## Motivation and Context Follows #2250 (first set of TableView samples) by covering hierarchical rows, context menus and live data updates, which TableView gained in microsoft/microsoft-ui-xaml after #2250. > [!IMPORTANT] > **Blocked on the next Windows App SDK _experimental_ release.** `ParentBy`, `ExpandAllRows`/`CollapseAllRows`, `CellContextFlyout`/`HeaderContextFlyout`, and `TableViewSource.IsLiveShaping` are not in `2.5.4-experimental`, so PR validation fails to compile. The stable `2.6.4` release (27-Oct) doesn't include them either, because TableView ships only in experimental releases. All of these APIs are on the WinUI experimental release branch. This PR deliberately does **not** change `WindowsAppSdkPackageVersion`; the bump will be added when that release ships. ## How Has This Been Tested? Windows x64, .NET SDK 10.0.401, against a local build of microsoft-ui-xaml `main` (466f4a35cb), referenced on top of `2.5.4-experimental` with command-line-only overrides (no project files in this PR change for that). **Hierarchical rows** - Initial tree, Expand all / Collapse all, and per-row expand via `ExpandCollapsePattern` all work. - Filtering: `jpg` keeps Pictures → Vacation → the two images, and `zzz` shows the empty template. - Keyboard: Right, `*` and Left (twice) behave as described. - Checked visually in light and dark (screenshots below). **Context menus** (opened through UI Automation `ShowContextMenu`, the same path Narrator uses for Shift+F10) - A Name cell opens the cell menu, and Copy name puts "Item 3" on the clipboard. - Category and Value cells open the row menu. Move to next category changes Beta to Gamma, and Remove deletes the row. - A header opens "Hide <that column>", and hiding works. On the last visible column, Hide is disabled. Show all columns restores all three. - The table itself opens the fallback menu, and Restore all items brings back 5 rows. **Live data** - Starts sorted by Value, descending: the header reports "Sorted descending". - Rows stay sorted across updates, and the selected row stays selected as it moves. - Pause freezes the values. - With live shaping off, the order drifts out of sort; turning it back on re-sorts immediately. - The ≥ 50 filter drops rows live as they fall below 50. - Shaping: Grouped moves rows between trend groups live; Hierarchy keeps parents and their children sorted; Grouped hierarchy moves a parent with its children to its new trend group; switching back to Flat removes groups and nesting. Filter in Hierarchy keeps matching rows with their parent. - Navigating away and back works, and updates resume. **Builds and tests** - **Trimmed publish:** `Release-Unpackaged` (`PublishTrimmed`, single file). Hierarchy, all three menu levels, and live updates work with no exception. The only trim warnings are pre-existing ones (`ItemPage`, `WinRT.Runtime`). - `dotnet test tests\WinUIGallery.CatalogExporter.Tests`: 172/172 passed. `CatalogExporter -- check`: index is up to date. - `WinUIGallery.UnitTests` (TableView filter, through `vstest.console`): 20/20 passed. ## Screenshots (if appropriate): Hierarchical rows. Screenshots of the context menu and live data examples will be added with the package bump. | Light, all rows expanded | Light, filter "jpg" | | --- | --- | |  |  | | Dark, keyboard focus on a nested row | Dark, no matches | | --- | --- | |  |  | ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) --------- Co-authored-by: Nitin Chaudhary <nitchaudhary@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Marks
TableViewSampleItemaspartial(public sealed partial class).Motivation and Context
In the 3.0 Store flight, opening the TableView page shows an empty page and a
System.NullReferenceException. Debug builds work fine.TableViewSampleItemimplementsINotifyPropertyChangedandINotifyDataErrorInfo, and it is marshalled to native code throughTableViewSource.From(...). Because the class wasn'tpartial, CsWinRT built its CCW vtable at runtime through reflection (ComWrappersSupport.GetInterfaceTableEntriesForJitEnvironment→TypeExtensions.GetAbiToProjectionVftblPtr). Published/Store builds are trimmed (PublishTrimmed=$(Optimized)), and the trimmer removed the ABI helper type that lookup needs, so it threw a NullReferenceException in theTableViewPageconstructor.Making the class
partiallets the CsWinRT AOT source generator emit a staticWinRTExposedTypevtable that survives trimming. Other gallery models that are exposed to WinRT follow the same pattern.How Has This Been Tested?
Release-Unpackagedx64 build (msbuild WinUIGallery\WinUIGallery.csproj /restore /t:Publish /p:Configuration=Release-Unpackaged /p:Platform=x64), opened TableView, and reproduced the crash. The captured stack trace pointed toTableViewSource.From→GetAbiToProjectionVftblPtr.Screenshots (if appropriate):
Types of changes