Repository navigation
DEMO: True Attribute Based Serialization for UncertainPairedData - #154
Open
Brennan1994 wants to merge 3 commits into
Open
Brennan1994 wants to merge 3 commits into
Brennan1994 wants to merge 3 commits into
Conversation
Collaborator
Author
|
This demonstrates the attribute-based serialization approach we initially hoped to use. However, because UncertainOrderedPairedData implements IList, System.Text.Json treats it as a collection and serializes its elements as an array, omitting its additional properties. Property attributes alone cannot override that behavior. To preserve both the collection interface and those properties when serializing this class directly, we use a custom converter in the other approach. This branch removes the collection interface as a proof of concept, allowing ordinary attribute-based object serialization. |
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.
This DEMO shows the simpler JSON serialization available when UncertainOrderedPairedData no longer implements IList or its inherited collection interfaces. It intentionally breaks the collection API and is an exploration, not a production-compatible replacement.
Serialization approach
API tradeoffs
Removing IList/IEnumerable lets System.Text.Json treat UOPD as an object. Interface-based consumers and LINQ extension calls must instead use the exposed Ordinates list or existing collection members. Update the affected TabularFunction call and Count assertions accordingly. Pattern-based foreach remains available through GetEnumerator.
Ordinates exposes the mutable backing list; direct edits bypass UOPD's validation and collection notifications. This demo deliberately prioritizes a simple attribute-based design over API stability and backward compatibility. It has no performance benchmark claims.
Validation
dotnet build -c Release: passed, zero warnings and errors.dotnet test -c Release --no-build --filter "TestCategory!=LiveServiceIntegration": passed; 4,116 tests on net10.0 and 4,099 on net481, zero failures or skips.