mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 04:18:43 +00:00
Make plugmanager not throw exceptions when plug targets are not found.
This commit is contained in:
parent
00658f9923
commit
3bfaf7f670
4 changed files with 20 additions and 7 deletions
|
|
@ -236,6 +236,7 @@ namespace Cosmos.IL2CPU
|
|||
using (var xScanner = new ILScanner(xAsm))
|
||||
{
|
||||
xScanner.LogException = LogException;
|
||||
xScanner.LogWarning = LogWarning;
|
||||
CompilerHelpers.DebugEvent += LogMessage;
|
||||
if (EnableLogging)
|
||||
{
|
||||
|
|
@ -249,7 +250,7 @@ namespace Cosmos.IL2CPU
|
|||
}
|
||||
xScanner.QueueMethod(xInitMethod.DeclaringType.BaseType.GetMethod("Start"));
|
||||
xScanner.Execute(xInitMethod);
|
||||
|
||||
|
||||
AppAssemblerRingsCheck.Execute(xScanner, xInitMethod.DeclaringType.Assembly);
|
||||
|
||||
using (var xOut = new StreamWriter(OutputFilename, false, Encoding.ASCII, 128 * 1024))
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ namespace Cosmos.IL2CPU
|
|||
public class ILScanner : IDisposable
|
||||
{
|
||||
public LogExceptionDelegate LogException = null;
|
||||
public Action<string> LogWarning = null;
|
||||
|
||||
protected ILReader mReader;
|
||||
protected AppAssembler mAsmblr;
|
||||
|
|
@ -71,7 +72,7 @@ namespace Cosmos.IL2CPU
|
|||
mAsmblr = aAsmblr;
|
||||
mReader = new ILReader();
|
||||
|
||||
mPlugManager = new PlugManager(LogException);
|
||||
mPlugManager = new PlugManager(LogException, LogWarning);
|
||||
}
|
||||
|
||||
public bool EnableLogging(string aPathname)
|
||||
|
|
|
|||
|
|
@ -68,9 +68,10 @@ namespace Cosmos.IL2CPU
|
|||
return LabelName.GenerateFullName(m);
|
||||
}
|
||||
|
||||
public PlugManager(LogExceptionDelegate aLogException)
|
||||
public PlugManager(LogExceptionDelegate aLogException, Action<string> aLogWarning)
|
||||
{
|
||||
LogException = aLogException;
|
||||
LogWarning = aLogWarning;
|
||||
}
|
||||
|
||||
public void FindPlugImpls()
|
||||
|
|
@ -321,7 +322,10 @@ namespace Cosmos.IL2CPU
|
|||
if (xAttrib == null
|
||||
|| xAttrib.IsOptional)
|
||||
{
|
||||
throw new Exception("Invalid plug method! Target method not found. : " + xMethod.GetFullName());
|
||||
if (LogWarning != null)
|
||||
{
|
||||
LogWarning("Invalid plug method! Target method not found. : " + xMethod.GetFullName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -330,7 +334,10 @@ namespace Cosmos.IL2CPU
|
|||
if (xAttrib.IsWildcard
|
||||
&& xAttrib.Assembler == null)
|
||||
{
|
||||
throw new Exception("Wildcard PlugMethods need to use an assembler for now.");
|
||||
if (LogWarning != null)
|
||||
{
|
||||
LogWarning("Wildcard PlugMethods need to use an assembler for now.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -355,6 +362,8 @@ namespace Cosmos.IL2CPU
|
|||
}
|
||||
}
|
||||
|
||||
public Action<string> LogWarning;
|
||||
|
||||
private MethodBase ResolvePlug(Type aTargetType, List<Type> aImpls, MethodBase aMethod, Type[] aParamTypes)
|
||||
{
|
||||
//TODO: This method is "reversed" from old - remember that when porting
|
||||
|
|
@ -717,7 +726,7 @@ namespace Cosmos.IL2CPU
|
|||
}
|
||||
else
|
||||
{
|
||||
// private
|
||||
// private
|
||||
xBindingFlagsToFindMethod = BindingFlags.NonPublic;
|
||||
}
|
||||
if (aMethod.IsStatic)
|
||||
|
|
|
|||
|
|
@ -74,7 +74,9 @@ namespace PlugsInspector
|
|||
|
||||
plugManager = new PlugManager((Exception ex) => {
|
||||
AddExceptionEntry(ex.Message);
|
||||
});
|
||||
}, warning =>
|
||||
{
|
||||
});
|
||||
plugManager.ThrowExceptions = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue