Skip to content

Implement IMobileObjectMetastate on ReadOnlyListBase#4766

Merged
rockfordlhotka merged 5 commits into
mainfrom
copilot/implement-imobileobjectmetastate
Nov 17, 2025
Merged

Implement IMobileObjectMetastate on ReadOnlyListBase#4766
rockfordlhotka merged 5 commits into
mainfrom
copilot/implement-imobileobjectmetastate

Conversation

Copilot AI commented Nov 15, 2025

Copy link
Copy Markdown
Contributor

Reminder: Make sure to review CONTRIBUTING.MD and make sure you've sent in your signed contributor agreement.

Reminder: Add issue number for work item (e.g. #123)

Description

Implements IMobileObjectMetastate interface on ReadOnlyListBase to enable metastate serialization of the IsReadOnly property, completing the interface coverage across CSLA's collection types.

Changes

ReadOnlyListBase.cs

  • Added IMobileObjectMetastate interface implementation with GetMetastate()/SetMetastate() methods delegating to MobileObjectMetastateHelper

MobileObjectMetastateHelper.cs

  • Added ConvertJsonElement() to handle JSON deserialization returning JsonElement instead of primitive types (bool, int, etc.)
  • Modified PopulateSerializationInfo() to convert JsonElement values before adding to SerializationInfo

ReadOnlyListBaseMetastateTests.cs

  • Added test coverage for IsReadOnly property round-tripping through metastate serialization
  • Added validation tests for null/empty metastate handling

The JsonElement conversion fix addresses a limitation where System.Text.Json deserializes object? properties as JsonElement rather than the actual primitive type, causing InvalidCastException during SerializationInfo.GetValue<T>() calls.

// Usage example
var list = dataPortal.Fetch<MyReadOnlyList>();
list.IsReadOnly = false;

// Serialize metastate
byte[] metastate = ((IMobileObjectMetastate)list).GetMetastate();

// Restore to new instance
var restored = dataPortal.Fetch<MyReadOnlyList>();
((IMobileObjectMetastate)restored).SetMetastate(metastate);
// restored.IsReadOnly now matches original value
Original prompt

This section details on the original issue you should resolve

<issue_title>ReadOnlyListBase needs to implement IMobileObjectMetastate</issue_title>
<issue_description>ReadOnlyListBase needs to implement IMobileObjectMetastate.

The class has a IsReadOnly property that needs to be handled by the interface.

These types are in the Csla project. Add tests to ensure that the property value flows through the IMobileObjectMetastate interface.
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Implement IMobileObjectMetastate in ReadOnlyListBase Implement IMobileObjectMetastate on ReadOnlyListBase Nov 15, 2025
Copilot AI requested a review from rockfordlhotka November 15, 2025 18:28
@rockfordlhotka rockfordlhotka marked this pull request as ready for review November 15, 2025 18:52
@rockfordlhotka rockfordlhotka merged commit d28dc8d into main Nov 17, 2025
4 checks passed
@rockfordlhotka rockfordlhotka deleted the copilot/implement-imobileobjectmetastate branch November 17, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReadOnlyListBase needs to implement IMobileObjectMetastate

3 participants