Path: redb/redb.Core/Exceptions/RedbUnsupportedCollectionException.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Exceptions/RedbUnsupportedCollectionException.cs
----
using System;
namespace redb.Core.Exceptions;
///
/// A property is declared with a collection type that redb does not store: HashSet<T>,
/// ISet<T>, ObservableCollection<T>, Queue<T>, Stack<T>,
/// IReadOnlyList<T>, SortedDictionary<K, V>, IReadOnlyDictionary<K, V> or any other
/// collection outside . Before, such a property was stored as one text value holding the name
/// of its type, and the object could not be loaded afterwards. The scheme sync refuses such a property before it writes
/// anything; a save that meets a collection in a single-value property (a scheme synced before the refusal existed)
/// refuses before any row is deleted or written. A class of the application that implements IEnumerable is a class and
/// is not refused.
///
public class RedbUnsupportedCollectionException : Exception
{
/// The collection types redb stores, as the refusal text lists them.
public const string SupportedTypes =
"T[], List, IList, ICollection, IEnumerable, Dictionary and IDictionary";
/// The class (or scheme) that declares the property.
public string OwnerName { get; }
/// The property.
public string PropertyName { get; }
/// The declared type of the property, or the type the save met in it, in C# notation.
public string PropertyTypeName { get; }
/// Refusal of a declared property type, at the scheme sync.
public RedbUnsupportedCollectionException(Type ownerType, string propertyName, Type propertyType)
: this(RedbNestedCollectionException.Display(ownerType), propertyName,
RedbNestedCollectionException.Display(propertyType), atSave: false)
{
}
/// Refusal at a save: the single-value property holds a collection of .
public RedbUnsupportedCollectionException(string ownerName, string propertyName, Type foundType)
: this(ownerName, propertyName, RedbNestedCollectionException.Display(foundType), atSave: true)
{
}
private RedbUnsupportedCollectionException(string ownerName, string propertyName, string typeName, bool atSave)
: base((atSave
? $"The save is refused: the property '{ownerName}.{propertyName}' holds a collection of type '{typeName}'. "
: $"The property '{ownerName}.{propertyName}' of type '{typeName}' is refused. ") +
$"redb stores a collection property declared as {SupportedTypes}; any other collection type would be " +
"written as the name of its type and the object could not be loaded. Declare the property as one of " +
"these types, for example List for a set, a queue or a stack and Dictionary for a " +
"sorted or read-only dictionary.")
{
OwnerName = ownerName;
PropertyName = propertyName;
PropertyTypeName = typeName;
}
}