Repository navigation
feat: bind DataView and DataTable rows with live ListChanged updates in KumikoUI.Data (#362) - #508
Open
michaelstonis wants to merge 5 commits into
Open
michaelstonis wants to merge 5 commits into
michaelstonis wants to merge 5 commits into
Conversation
| bob.Row.Delete(); | ||
|
|
||
| Assert.Null(Accessor("Customer").GetValue(bob)); | ||
| var deleted = new DataView(table, "", "", DataViewRowState.Deleted); |
| [Fact] | ||
| public void Read_ServesEveryTableWithTheSameAccessor() | ||
| { | ||
| var other = new DataTable(); |
| [Trait("Category", "Performance")] | ||
| public void ItemAdded_OnALargeView_IsIncremental() | ||
| { | ||
| var table = new DataTable { Locale = System.Globalization.CultureInfo.InvariantCulture }; |
This branch has not been deployed
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.
Closes #362.
Changes
Core:
IBindingListadapter (spec #107 section 8.5)KumikoSourcenow observesIBindingList.ListChangedwhen the items implementIBindingListbut notINotifyCollectionChanged(new partial fileModels/KumikoSource.BindingList.cs, with small hooks inSetItems,Attach,ResyncandUnsubscribeFromCollection, soSetItems,DetachandDisposeunsubscribe). This makesDataViewandBindingList<T>live.ListChangedTypeItemAddedthat grew the list by oneAddatNewIndex(the existing incremental path)ItemAddedthat did not grow the listDataViewraisesItemAddedagain when anAddNewrow is committed, so without this the row would be added twiceItemChangedwith a property, for an item already tracked through its ownPropertyChangedItemChangedwithout a property, for a tracked item (ResetItem)ItemChangedwith a property, for an item withoutINotifyPropertyChangedPropertyChangedItemChangedfor an untracked item (list[i] = new)ItemDeleted,ItemMoved,Reset,PropertyDescriptor*When a collection raises both kinds of event,
INotifyCollectionChangedwins. Changes from another thread go through the existing thread-affinity path: the source rejects them and resyncs. The list count is re-read on resync. Core still has noSystem.Datareference.ReorderRownow returnsNotSupportedSourcefor anIBindingListViewsource. Without this, on aDataViewIList.RemoveAtdeletes the row and the followingInsertthrows ("Cannot insert external objects"), so dragging a row would have deleted it.New package
KumikoUI.Data(stage 3)src/KumikoUI.Datatargetsnet10.0, isIsAotCompatibleandIsTrimmable, versions in lockstep, references onlyKumikoUI.Core(System.Data.Commoncomes from the shared framework), has PublicAPI files and package validation with no baseline yet (the same setup as Export.Excel), and ships the NuGet READMEdocs/nuget/README.KumikoUI.Data.md.KumikoDataTable.Use()registers the provider forDataRowViewwithKumikoAccessorRegistry. Calling it again does nothing. It also registers an emptyIKumikoColumnMetadataProviderforDataRowView, soAutoGenerateColumnsdoes not generate columns fromDataRowView's own CLR properties (Row,IsNew, ...).KumikoDataTable.ColumnsFor(DataTable)builds one column perDataColumnthroughKumikoColumnFactory.Create, the same type mapping as generated columns (Columns: auto-generate columns from the item type, with DataAnnotations and an AOT-safe source-generator path #315):ColumnNamebecomesPropertyNameandKey;CaptionbecomesHeader.N0for whole numbers andN2fordecimaland floating-point numbers, right-aligned.boolcolumn withAllowDBNullis three-state.ReadOnlyandExpressioncolumns are read-only;MappingType.Hiddencolumns are hidden.byte[]columns are skipped; other types become Text columns.KumikoDataRowViewAccessorProvider(Instance) is schema-agnostic: it looks the column up on each row withColumns[name](exact name, then ignoring case).DBNull, a missing column, a deleted row (unless the view shows deleted rows) and a row removed from its table all read as null.DataColumn.DataTypewithKumikoValueConverterintable.Locale. Null and blank text storeDBNull. The value is written withview[ordinal] = valueand committed withEndEdit(). If either throws,CancelEdit()runs and the exception propagates, andKumikoValuePathturns its message into the cell's edit error. An edit the app began itself (IsEditorIsNew) is left open.Public API added (
src/KumikoUI.Data/PublicAPI.Unshipped.txt):Core gains no public API.
PublicAPI.Shipped.txtis untouched.Wiring
KumikoUI.slnhas both new projects.eng/update-public-api.shnow coversData.eng/AotSmokehas aDataViewcase: read, convert and edit, a refused edit, grid sort and filter, a live add, and the view's ownSortreset..github/workflows/ci.ymlrestores, builds, runs the type-name check on, tests and dry-run packs the Data project and its tests..github/workflows/publish.ymlrestores, packs, tests and verifies the package, and the validation step now requires six packages. The.githubedits are needed because the issue asks for the new package to build, pack and publish in CI.docs/VERSIONING.mdand the CHANGELOG header now list six packages.Samples and docs
samples/Shared/DataTableData.cs;KumikoDataTable.Use()runs inMauiProgramand in Uno'sApp.OnLaunched). Buttons add a row, delete the selected row, edit a row in code, cycle the view's ownSortand callRejectChanges. The table has a read-only unique key, a non-null column, a three-statePaidcolumn, a hidden column, and aColumnChangedrule that records a negative quantity as a column error.BindingList/ListChangedparagraph and a "DataTable and DataView" section under Live Data, and a sample table row. Alsosamples/README.mdand a CHANGELOG entry under Unreleased > Added.Decisions on the spec's open questions
DataViewkeeps itsDataRowViewinstances when itsSortorRowFilterchanges and when other rows are added or deleted. So selection by reference survives everything except rows that leave the view andClearfollowed by a reload. That case is documented and covered by a test.KumikoUI.Data, namespaceKumikoUI.Data.DataTableasItemsSource): no. Apps bindtable.DefaultView, and no host property type changes.Acceptance criteria
BindingList<T>andDataViewchanges (add, delete, edit, re-sort, reset) appear in the grid, with no double handling when both notification kinds exist. Covered byBindingListAdapterTests(20 tests) andDataViewBindingTests, including the both-events collection,ItemChangedpaired withPropertyChanged(one Redraw or one Rebuild),AddNewthenEndEdit(the row is added once), andItemMovedunder the view's sort.DataRowViewcells read, sort, filter, group, summarize and edit.DBNull, read-only and constraint errors behave as specified, andIDataErrorInfoerrors show (DataRowViewAccessorTests,DataViewBindingTests,DataViewEditingTeststhroughEditSession).ColumnsForproduces the mapped columns (ColumnsForTests). Two deviations from the spec table, made so the mapping matches the generated-column mapping (Columns: auto-generate columns from the item type, with DataAnnotations and an AOT-safe source-generator path #315) as the issue asks:DateTimemaps to theDateTimecolumn type rather thanDate, and nodformat is forced on dates (each column type keeps its default format).ValueTypeis not set; see the Data: bind dictionary, ExpandoObject and DynamicObject rows by key with no app code (#107 Track B) #361 note below.KumikoUI.Data.Testsproject (58 tests) and Core adapter tests intests/KumikoUI.Core.Tests/BindingListAdapterTests.cs.eng/AotSmokeDataViewcase runs: published with Native AOT for osx-arm64 with no IL warnings, and the binary prints "AOT smoke OK".DataView.RowFilterandDataColumn.ExpressionareRequiresUnreferencedCodeinSystem.Dataitself. The smoke test hit that onRowFilter, so it usesSort, and the package README says so instead of suppressing the warning. CI runs of the workflows have not been seen (nothing pushed).DataViewsample page with edits on both sample apps. Partly done: both sample apps build: MAUI for maccatalyst, Uno for desktop. The pages have not been run interactively. Neither host needed a change: they passItemsSourcetoKumikoSource.SetItems.PublicAPI.Unshipped.txtwritten byeng/update-public-api.sh Data.DataRowViewread boxes the stored value, which the existing cell text cache keeps off the frame path.Not done in this PR:
bench/. The add-path target is covered by aCategory=Performancetest:ItemAddedon a 100K-row view takes the incremental Insert path, with a generous time bound.IEditableObject) is limited to leaving app-begun edits open.#361 overlap:
KumikoColumn.ValueTypedoes not exist on this base. The provider therefore converts toDataColumn.DataTypeitself, in the table'sLocale, and no Core hook was added. Once #361 lands,ColumnsForcan also setValueType. The provider's conversion then sees values that already have the right type and does nothing.Verification
dotnet build src/KumikoUI.Core: succeeded.dotnet build src/KumikoUI.Data -c Release --no-incremental: 0 warnings, 0 errors.dotnet test tests/KumikoUI.Core.Tests: Passed 4381, Skipped 5, Failed 0.dotnet test tests/KumikoUI.Data.Tests: Passed 58, Failed 0.dotnet test tests/KumikoUI.Export.Excel.Tests: Passed 122.dotnet test tests/KumikoUI.Maui.Tests: Passed 449.dotnet test tests/KumikoUI.SkiaSharp.Tests: Passed 42.dotnet pack src/KumikoUI.Data -c Release:.nupkgand.snupkgproduced. They containlib/net10.0/KumikoUI.Data.dlland.xml, the README and the logo, with an exact-version dependency on KumikoUI.Core.dotnet run --project eng/TypeNameCheck -c Release -- <Core, SkiaSharp, Export.Excel, Data dlls>: "No public type name collides" (250 types, 4 assemblies).dotnet publish eng/AotSmoke -c Release -r osx-arm64: no IL2xxx or IL3xxx warnings. The binary prints "AOT smoke OK". The local native link neededLIBRARY_PATHpointing at a local OpenSSL; that is a machine toolchain issue, not part of this change.dotnet run --project eng/DocsSnippets -c Releasepicked up the new NuGet README.dotnet build tests/KumikoUI.Docs.Snippets.Uno -f net10.0-desktop -c Release: succeeded, with only existing Uno warnings.dotnet build samples/SampleApp.Uno -f net10.0-desktop: succeeded.dotnet build samples/SampleApp.Maui -f net10.0-maccatalyst -p:KumikoDevFlow=false: succeeded. The default Debug build fails at restore on this machine with NU1605, a DevFlow package version downgrade ofMicrosoft.Maui.Controls; this change touches no package versions.dotnet format whitespace --folder . --verify-no-changes --include <changed folders>: clean.