Skip to content

Commit

Permalink
fix - Fixed config validity false negatives
Browse files Browse the repository at this point in the history
---

Caused by improper string comparison, we've managed to fix config validity false negatives.

---

Type: fix
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 6, 2024
1 parent 4ba2eff commit a6a1f89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public void TestCheckProperty() =>
public void TestGetPropertyValueInstance()
{
var Value = PropertyManager.GetPropertyValueInstance(Config.SaverConfig, nameof(KernelSaverConfig.MatrixBleedDelay));
if (Value is string value)
value.ShouldNotBeNullOrEmpty();
else
if (Value is not int)
Assert.Fail("Can't get property value");
}

Expand Down
8 changes: 5 additions & 3 deletions public/Nitrocid/Kernel/Configuration/ConfigTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public static Dictionary<string, bool> CheckConfigVariables(string configTypeNam
/// <summary>
/// Checks all the config variables to see if they can be parsed
/// </summary>
public static Dictionary<string, bool> CheckConfigVariables(BaseKernelConfig entries)
public static Dictionary<string, bool> CheckConfigVariables(BaseKernelConfig? entries)
{
if (entries is null)
throw new KernelException(KernelExceptionType.Config, Translate.DoTranslation("Can't check configuration variables when no entries are specified."));
Expand All @@ -199,8 +199,10 @@ public static Dictionary<string, bool> CheckConfigVariables(BaseKernelConfig ent
/// <summary>
/// Checks all the config variables to see if they can be parsed
/// </summary>
public static Dictionary<string, bool> CheckConfigVariables(SettingsEntry[] entries, BaseKernelConfig config)
public static Dictionary<string, bool> CheckConfigVariables(SettingsEntry[]? entries, BaseKernelConfig? config)
{
if (config is null)
throw new KernelException(KernelExceptionType.Config, Translate.DoTranslation("Can't check configuration variables when no entries are specified."));
if (entries is null || entries.Length == 0)
throw new KernelException(KernelExceptionType.Config, Translate.DoTranslation("Can't check configuration variables when no entries are specified."));
var Results = new Dictionary<string, bool>();
Expand All @@ -224,7 +226,7 @@ public static Dictionary<string, bool> CheckConfigVariables(SettingsEntry[] entr
Results.Add($"{KeyName}, {KeyVariable}", KeyFound);

// Check the enumeration
if (KeyEnumeration is not null)
if (!string.IsNullOrEmpty(KeyEnumeration))
{
bool Result;
if (KeyEnumerationInternal)
Expand Down

0 comments on commit a6a1f89

Please sign in to comment.