Skip to content

Commit 2d6e439

Browse files
Clarify MobileFormatter collection type limitations in docs (#4822)
* Fix misleading docs claiming List<T> is serializable by MobileFormatter Remove List<int> from the list of supported SerializationInfo types in the CSLA 9 upgrade guide, and correct the serialization.md claim that List<T> and Dictionary<K,V> are supported. These standard .NET collection types are not directly serializable - users should use MobileList<T> or MobileDictionary<K,V> from Csla.Core instead. Fixes #4680 https://claude.ai/code/session_011R3Y2CSgCZrDwdVacjARaW * Restore List<int> to SerializationInfo supported types list CslaBinaryWriter/Reader explicitly handle List<int> (CslaKnownTypes.ListOfInt), so it IS a valid type for use in custom serializers via SerializationInfo.AddValue. Updated the warning to clarify that other generic collection types (List<string>, Dictionary<K,V>, etc.) are not supported. https://claude.ai/code/session_011R3Y2CSgCZrDwdVacjARaW --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f5855ed commit 2d6e439

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

docs/Upgrading to CSLA 9.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ This includes:
166166
* `char[]`
167167
* `List<int>`
168168

169+
> ⚠️ Other generic collection types such as `List<string>`, `Dictionary<K,V>`, etc. are _not_ directly serializable by `SerializationInfo`. For serializable collections in business object properties, use `MobileList<T>` or `MobileDictionary<K,V>` from `Csla.Core`, or register a custom serializer for your type.
170+
169171
If you look at the implementation of [PocoSerializer](https://github.com/MarimerLLC/csla/blob/main/Source/Csla/Serialization/Mobile/CustomSerializers/PocoSerializer.cs) you'll see that it relies on `System.Text.Json` to serialize and deserialize the object, and stores the JSON string in the `SerializationInfo` instance.
170172

171173
The [ClaimsPrincipalSerializer](https://github.com/MarimerLLC/csla/blob/main/Source/Csla/Serialization/Mobile/CustomSerializers/ClaimsPrincipalSerializer.cs) type has two implementations.

docs/serialization.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ The default serializer for CSLA (version 6 and later) is `MobileFormatter`. This
1010

1111
### Using MobileFormatter
1212

13-
MobileFormatter supports many basic .NET types, including "primitive" types like `int`, `string`, `DateTime`, etc. It also supports `List<T>`, `Dictionary<K,V>`, and other common collection types. It also supports any type that implements `IMobileObject`, which includes all CSLA base types.
13+
MobileFormatter supports many basic .NET types, including "primitive" types like `int`, `string`, `DateTime`, etc. It also supports any type that implements `IMobileObject`, which includes all CSLA base types.
14+
15+
> ⚠️ Standard .NET collection types such as `List<T>` and `Dictionary<K,V>` are _not_ directly serializable by `MobileFormatter`. Use `MobileList<T>` or `MobileDictionary<K,V>` from `Csla.Core` for serializable collections, or register a custom serializer for your collection type.
1416
1517
If you create your complex types by subclassing CSLA base types and using the managed property syntax, you don't need to do anything special to support serialization.
1618

0 commit comments

Comments
 (0)