Fix NullReferenceException in ToolManager.IsAvailable and remove unnecessary try/catch.
This commit is contained in:
parent
eed94c11cc
commit
1ebdfa149a
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -9,14 +10,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
public ToolAttribute(bool released, string[] supportedSystems, string[] unsupportedCores = null)
|
||||
{
|
||||
Released = released;
|
||||
SupportedSystems = supportedSystems;
|
||||
UnsupportedCores = unsupportedCores;
|
||||
SupportedSystems = supportedSystems ?? Enumerable.Empty<string>();
|
||||
UnsupportedCores = unsupportedCores ?? Enumerable.Empty<string>();
|
||||
}
|
||||
|
||||
public bool Released { get; private set; }
|
||||
public bool Released { get; }
|
||||
|
||||
public IEnumerable<string> SupportedSystems { get; private set; }
|
||||
public IEnumerable<string> SupportedSystems { get; }
|
||||
|
||||
public IEnumerable<string> UnsupportedCores { get; private set; }
|
||||
public IEnumerable<string> UnsupportedCores { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -752,12 +752,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
return false;
|
||||
}
|
||||
|
||||
ToolAttribute attr;
|
||||
try
|
||||
{
|
||||
attr = tool.GetCustomAttributes(false).OfType<ToolAttribute>().Single();
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
ToolAttribute attr = tool.GetCustomAttributes(false).OfType<ToolAttribute>().SingleOrDefault();
|
||||
if (attr == null)
|
||||
{
|
||||
return true; // no ToolAttribute on given type -> assumed all supported
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue