From 33d3b6fa82590a52dd5c1c77cc7a191d7d0ecede Mon Sep 17 00:00:00 2001 From: Whatstone Date: Sun, 19 Jul 2026 20:46:20 -0400 Subject: [PATCH 1/2] ConfigurationManager: validate CVar methods --- .../Configuration/ConfigurationManager.cs | 30 +++++++++++++++++++ .../Configuration/IConfigurationManager.cs | 16 ++++++++++ 2 files changed, 46 insertions(+) diff --git a/Robust.Shared/Configuration/ConfigurationManager.cs b/Robust.Shared/Configuration/ConfigurationManager.cs index 72844ae3dde..5775b8ce6af 100644 --- a/Robust.Shared/Configuration/ConfigurationManager.cs +++ b/Robust.Shared/Configuration/ConfigurationManager.cs @@ -74,6 +74,23 @@ public HashSet LoadFromTomlStream(Stream file) return LoadFromTomlTable(tblRoot); } + /// + public HashSet ValidateTomlStream(Stream file) + { + TomlTable tblRoot; + try + { + tblRoot = Toml.ReadStream(file); + } + catch (Exception e) + { + _sawmill.Error("Unable to load configuration from table:\n{0}", e); + return []; + } + + return ValidateTomlTable(tblRoot); + } + private HashSet LoadFromTomlTable(TomlTable table) { var loaded = new HashSet(); @@ -98,6 +115,19 @@ private HashSet LoadFromTomlTable(TomlTable table) return loaded; } + /// + /// Validates a TomlTable and returns the set of cvars contained. + /// + private HashSet ValidateTomlTable(TomlTable table) + { + var loaded = new HashSet(); + + foreach (var (cvar, _) in ParseCVarValuesFromToml(table)) + loaded.Add(cvar); + + return loaded; + } + private void RunDeferredInvokeCallbacks(in ValueList callbackEvents) { foreach (var callback in callbackEvents) diff --git a/Robust.Shared/Configuration/IConfigurationManager.cs b/Robust.Shared/Configuration/IConfigurationManager.cs index 13a130bf6e0..06084865ac6 100644 --- a/Robust.Shared/Configuration/IConfigurationManager.cs +++ b/Robust.Shared/Configuration/IConfigurationManager.cs @@ -69,8 +69,24 @@ public interface IConfigurationManager /// void SaveToTomlStream(Stream stream, IEnumerable cvars); + /// + /// Load a TOML config file, using all CVar values specified inside. + /// + /// + /// All CVars in the TOML file must be registered when this function is called. + /// + /// A set of all CVars touched. HashSet LoadFromTomlStream(Stream stream); + /// + /// Load a TOML config file and try and parse its contents without side-effects. + /// + /// + /// All CVars in the TOML file must be registered when this function is called. + /// + /// A set of all CVars that would be touched by this stream. + HashSet ValidateTomlStream(Stream stream); + /// /// Load a TOML config file and use the CVar values specified as an . /// From 8f014c55b8923939f338a44b308d70d2d60cf142 Mon Sep 17 00:00:00 2001 From: Whatstone Date: Fri, 24 Jul 2026 16:21:30 -0400 Subject: [PATCH 2/2] More inheritdoc uses --- Robust.Shared/Configuration/ConfigurationManager.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Robust.Shared/Configuration/ConfigurationManager.cs b/Robust.Shared/Configuration/ConfigurationManager.cs index 5775b8ce6af..860fb0a2211 100644 --- a/Robust.Shared/Configuration/ConfigurationManager.cs +++ b/Robust.Shared/Configuration/ConfigurationManager.cs @@ -91,6 +91,7 @@ public HashSet ValidateTomlStream(Stream file) return ValidateTomlTable(tblRoot); } + /// private HashSet LoadFromTomlTable(TomlTable table) { var loaded = new HashSet(); @@ -115,9 +116,7 @@ private HashSet LoadFromTomlTable(TomlTable table) return loaded; } - /// - /// Validates a TomlTable and returns the set of cvars contained. - /// + /// private HashSet ValidateTomlTable(TomlTable table) { var loaded = new HashSet();