[CSHARP-3432] Support for System.Collections.Immutable Created: 19/Feb/21 Updated: 08/Jan/24 |
|
| Status: | Backlog |
| Project: | C# Driver |
| Component/s: | Serialization |
| Affects Version/s: | 2.11.6 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Andreas Wenger | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Epic Link: | Implement 3.0 release |
| Quarter: | FY24Q4 |
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
| Description |
|
The MongoDB C# Driver does not support System.Collections.Immutable out of the box yet. For example, when a ImmutableList<T> is deserialized, the following exception is thrown:
It is possible, yet cumbersome, to add custom serializers for supporting them. For example, for ImmutableList<T>:
Since immutable collections are a native part of the .NET Runtime and will get increasing attention with the new immutable `record`s possible in C# 9, it would be very useful to support them out-of-the-box. More example code, yet outdated, can be found in this github project: https://github.com/marcpiechura/MongoDB.Immutable
|
| Comments |
| Comment by James Kovacs [ 19/Feb/21 ] |
|
Hi, Andreas, We tested Record types recently with the MongoDB .NET/C# driver and they were already supported by our infrastructure for immutable types. However we did not test immutable collections. We will consider supporting them in a future release. Thank you for your suggestion. Sincerely, |