Better error reporting when registering LSL function extensions (comms module).

For unknown reasons, a dynamic function signature cannot have more than 5
parameters. Error message now tells you this fact so you can curse MS and
then go change your function definitions.
0.7.6-extended
Robert Adams 2013-08-08 08:56:22 -07:00
parent 50c163ae6c
commit c67c55e0fc
1 changed files with 13 additions and 4 deletions

View File

@ -45,6 +45,7 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static string LogHeader = "[MODULE COMMS]";
private Dictionary<string,object> m_constants = new Dictionary<string,object>();
@ -148,7 +149,7 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
MethodInfo mi = GetMethodInfoFromType(target.GetType(), meth, true);
if (mi == null)
{
m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}", meth);
m_log.WarnFormat("{0} Failed to register method {1}", LogHeader, meth);
return;
}
@ -165,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
{
// m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}", mi.Name, (target is Type) ? ((Type)target).Name : target.GetType().Name);
Type delegateType;
Type delegateType = typeof(void);
List<Type> typeArgs = mi.GetParameters()
.Select(p => p.ParameterType)
.ToList();
@ -176,8 +177,16 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
}
else
{
typeArgs.Add(mi.ReturnType);
delegateType = Expression.GetFuncType(typeArgs.ToArray());
try
{
typeArgs.Add(mi.ReturnType);
delegateType = Expression.GetFuncType(typeArgs.ToArray());
}
catch (Exception e)
{
m_log.ErrorFormat("{0} Failed to create function signature. Most likely more than 5 parameters. Method={1}. Error={2}",
LogHeader, mi.Name, e);
}
}
Delegate fcall;