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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
|
@ -9,14 +10,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public ToolAttribute(bool released, string[] supportedSystems, string[] unsupportedCores = null)
|
public ToolAttribute(bool released, string[] supportedSystems, string[] unsupportedCores = null)
|
||||||
{
|
{
|
||||||
Released = released;
|
Released = released;
|
||||||
SupportedSystems = supportedSystems;
|
SupportedSystems = supportedSystems ?? Enumerable.Empty<string>();
|
||||||
UnsupportedCores = unsupportedCores;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolAttribute attr;
|
ToolAttribute attr = tool.GetCustomAttributes(false).OfType<ToolAttribute>().SingleOrDefault();
|
||||||
try
|
if (attr == null)
|
||||||
{
|
|
||||||
attr = tool.GetCustomAttributes(false).OfType<ToolAttribute>().Single();
|
|
||||||
}
|
|
||||||
catch (InvalidOperationException e)
|
|
||||||
{
|
{
|
||||||
return true; // no ToolAttribute on given type -> assumed all supported
|
return true; // no ToolAttribute on given type -> assumed all supported
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue