Closed wffirilat closed 4 years ago
Malformed files can come in two types. Invalid JSON and Invalid Schema. Whilst Invalid JSON is detectable (since it throws an exception), Invalid Schema isn't.
JToken#.ToType<T>()
will create a new instance of T
no matter the serialization of the underlying token.
Using JsonConvert.Deserialize<T>(#JToken)
has a simmilar effect, which leads me to believe that JToken#.ToType<T>()
is how it is implemented.
Attempting to try-catch
any JSONException
was in vain. Same goes for Exception
. Json.NET doesn't throw an exception for invalid schema.
There seems to exist a Json.NET.Schema
package that has an JToken#IsValid(JsonSchema)
extension method.
A Fix for this issue is already implemented but its pending review.
Branch : 33-main-config-porting
Commit : https://github.com/siscodeorg/sisbase/commit/c4ce7ae0a1988f05b980c2cc6379ed617aad61b5
This issue is entirely superseded by the scope of #33. closed.
Current behaviour: The program will crash with an NRE when an invalid config file exists.
Ideal behaviour: The program will backup the existing malformed config file, print a warning, possibly give some information about why it is malformed, and then generate a new file with the default settings