Path: redb/redb.Core/Exceptions/RedbSchemeNamespaceMismatchException.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/RedbSchemeNamespaceMismatchException.cs
----
namespace redb.Core.Exceptions;
///
/// Thrown when a type resolves to a scheme (by explicit name, FullName, short-name fallback or as the
/// loser of a creation race) that is owned by a different namespace (_schemes._name_space). Adopting it would silently attach
/// one project's type to another project's data — two unrelated Order classes are the textbook
/// case. Schemes written before namespaces were recorded carry NULL there and are still adopted, with
/// a warning, because a pre-namespace database has no other way in (V4, К7).
///
public class RedbSchemeNamespaceMismatchException : Exception
{
/// The type that asked for the scheme.
public Type DeclaringType { get; }
/// The scheme name the type resolved to.
public string SchemeName { get; }
/// Id of the scheme the type resolved to.
public long SchemeId { get; }
/// The namespace recorded on the scheme — its owner.
public string SchemeNameSpace { get; }
/// The namespace of the requesting type (null for the global namespace).
public string? TypeNameSpace { get; }
public RedbSchemeNamespaceMismatchException(
Type declaringType, string schemeName, long schemeId, string schemeNameSpace, string? typeNameSpace)
: base($"Type '{declaringType.FullName ?? declaringType.Name}' resolves to scheme id={schemeId} " +
$"named '{schemeName}', but that scheme belongs to namespace " +
$"'{schemeNameSpace}', not '{typeNameSpace ?? ""}'. Adopting it would attach this " +
"type to another project's data (a scheme has one owner). If the scheme really is this type's - " +
"the type moved - set _schemes._name_space to the new namespace (or NULL to re-adopt); otherwise " +
"give one of the two types a different scheme name.")
{
DeclaringType = declaringType;
SchemeName = schemeName;
SchemeId = schemeId;
SchemeNameSpace = schemeNameSpace;
TypeNameSpace = typeNameSpace;
}
}