What I can only assume is a bug is best described with an example plugin:
Lets go through this plugin function by function!Code:namespace Oxide.Plugins { class BugReproduction : RustPlugin { protected override void LoadDefaultConfig() { Config["firstKey", "secondKey"] = false; SaveConfig(); } void OnServerInitialized() { object obj = Config.Get("firstKey", "secondKey", "thirdKey"); } } }
The LoadDefaultConfig() function is simple enough.
It just creates a configuration file with the name BugReproduction.json.
The content of said json file is the following:
The OnServerInitialized() function then tries to get a value with a path that does not exist!Code:{ "firstKey": { "secondKey": false } }
Since the path does not exist the value returned should be null but what happens instead is that we'll get an InvalidCastException:
The same thing happens if we do:
Surely this is not intended. The value returned should just be null, right?Code:Config.Set("firstKey", "secondKey", "thirdKey", false);
Solved InvalidCastException at Oxide.Core.Configuration.DynamicConfigFile.Get
Discussion in 'Rust Development' started by Tuntenfisch, Mar 10, 2016.
-
Calytic Community Admin Community Mod
This is happening because "secondKey" is not a Dictionary<string, object>.
-
Code:{ "firstKey": { "secondKey": { "thirdKey": false } } }
-
Calytic Community Admin Community Mod
My 2 cents, I agree with you that the configuration handler should be more fault-tolerant.
-
Bump!
@Wulf is this an issue you guys are aware off/are going to fix? -
Wulf Community Admin
-
-
Wulf Community Admin