Skip to content

Commit

Permalink
Harden against null plugin Metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Sep 17, 2024
1 parent 39f7dad commit 253908a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ConfigurationManager/SettingSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ public static void CollectSettings(out IEnumerable<SettingEntryBase> results, ou
var type = plugin.GetType();

var pluginInfo = plugin.Info.Metadata;
var pluginName = pluginInfo?.Name ?? plugin.GetType().FullName;

if (type.GetCustomAttributes(typeof(BrowsableAttribute), false).Cast<BrowsableAttribute>()
.Any(x => !x.Browsable))
.Any(x => !x.Browsable))
{
modsWithoutSettings.Add(pluginInfo.Name);
modsWithoutSettings.Add(pluginName);
continue;
}

Expand All @@ -67,7 +68,7 @@ public static void CollectSettings(out IEnumerable<SettingEntryBase> results, ou
detected.RemoveAll(x => x.Browsable == false);

if (detected.Count == 0)
modsWithoutSettings.Add(pluginInfo.Name);
modsWithoutSettings.Add(pluginName);

// Allow to enable/disable plugin if it uses any update methods ------
if (showDebug && type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Any(x => _updateMethodNames.Contains(x.Name)))
Expand Down

0 comments on commit 253908a

Please sign in to comment.