Path: redb/redb.Core/Data/ModuleCompatibility.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/Data/ModuleCompatibility.cs ---- namespace redb.Core.Data; /// /// The rule of a database module newer than the package: never replaced, used when it serves the package. Shared by /// the module check of PostgreSQL and SQL Server (versions such as "0.7.24", the compatibility function's /// "<oldest module served>|<package version>") and the file check of SQLite (whole numbers). /// public static class ModuleCompatibility { /// /// Whether is a newer version than . A version that does not /// read as numbers (a hand-set marker such as "0.0.0-test" reads as 0.0.0, anything else not at all) is not newer: /// such a module is replaced as an older one is. /// public static bool IsNewer(string? deployed, string required) => TryParse(deployed, out var d) && TryParse(required, out var r) && d > r; /// /// Whether a module that reports (the value of its compatibility function, null when it /// has none) serves a package whose own module is : the first part of the value is not /// above it. Also returns the package version the module names, null when it names none. /// public static bool Serves(string? compat, string required, out string? fromPackage) { fromPackage = null; if (string.IsNullOrWhiteSpace(compat)) return false; var parts = compat.Split('|'); if (parts.Length == 2 && !string.IsNullOrWhiteSpace(parts[1])) fromPackage = parts[1].Trim(); return TryParse(parts[0], out var oldest) && TryParse(required, out var own) && oldest <= own; } private static bool TryParse(string? text, out Version version) { version = new Version(0, 0); if (string.IsNullOrWhiteSpace(text)) return false; var dash = text.IndexOf('-'); var core = (dash >= 0 ? text[..dash] : text).Trim(); if (!Version.TryParse(core, out var parsed)) return false; version = parsed; return true; } }