Repository navigation
Serialize the deleted list only when it is not empty - #4963
Merged
Merged
Conversation
BusinessListBase, BusinessBindingListBase and BusinessDocumentBase skipped the deleted list during serialization only when it was null. IsDirty, IsBusy, CopyState and Deserialized all read the lazily created DeletedList, so in practice every list carried an empty deleted list in every MobileFormatter payload. The deleted list is now serialized only when it contains items, matching how BusinessRules handles the broken rules collection. OnSetChildren resets the field to null when the payload has no deleted list, and the DeletedList accessor recreates it on demand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused changes preserve populated deleted lists and lazy initialization, with regression coverage and no blocking issues identified.
0 open findings
What changed in this PR
Reduces MobileFormatter payload sizes by omitting empty deleted lists across CSLA’s three editable collection types, addressing #4266.
Changes:
- Serialize deleted lists only when populated.
- Reset omitted deleted-list fields to
null, preserving lazy initialization. - Add nine regression tests and document the payload reduction.
| File | Description |
|---|---|
| Source/tests/Csla.test/Serialization/DeletedListSerializationTests.cs | Tests omission, populated round-trips, and deletion after cloning. |
| Source/Csla/BusinessListBase.cs | Omits empty deleted lists and resets absent fields. |
| Source/Csla/BusinessDocumentBase.cs | Applies the same serialization behavior to documents. |
| Source/Csla/BusinessBindingListBase.cs | Applies the same serialization behavior to binding lists. |
| releasenotes.md | Documents the payload-size improvement. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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 #4266
Summary
BusinessListBase,BusinessBindingListBaseandBusinessDocumentBaseskipped the deleted list during serialization only when the field wasnull. ButIsDirty,IsBusy,CopyStateandDeserialized()all read the lazily createdDeletedListaccessor. So in practice every list, even one fresh fromCreate, carried an empty deleted list in every MobileFormatter payload.This change serializes the deleted list only when it contains items, which is how
BusinessRulesalready handles_brokenRules.OnSetChildrenresets the field tonullwhen the payload has no deleted list, and theDeletedListaccessor recreates it on demand. There is no public API change, and the accessor is still nevernull.See the analysis comment on #4266 for why the null-vs-empty question is otherwise already settled.
Payload size (MobileFormatter, orders list with line-item child lists)
That works out to about 44 bytes per list, or 156 bytes for the first list of a type. Serialization time differences were within noise.
Tests
Added
DeletedListSerializationTests, with three tests for each of the three list types:IsDirty) is not written to the payload.ContainsDeletedandIsDirtybehave correctly.The full
csla.test.slnsuite (TestCategory!=SkipOnCIServer) passes on net10.0 and net11.0.🤖 Generated with Claude Code