Support resolving methods with ref/out parameters
This commit is contained in:
@@ -11,20 +11,27 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
public static Type GetType(string typeName)
|
public static Type GetType(string typeName)
|
||||||
{
|
{
|
||||||
|
var byRef = false;
|
||||||
|
if (typeName.StartsWith("out ") || typeName.StartsWith("ref "))
|
||||||
|
{
|
||||||
|
typeName = typeName.Remove(0, 4);
|
||||||
|
byRef = true;
|
||||||
|
}
|
||||||
|
|
||||||
var type = Type.GetType(typeName);
|
var type = Type.GetType(typeName);
|
||||||
if (type != null) return type;
|
if (type != null) return byRef ? type.MakeByRefType() : type;
|
||||||
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
if (CsScriptBase.LoadedAssemblyName.Contains(a.GetName().Name))
|
if (CsScriptBase.LoadedAssemblyName.Contains(a.GetName().Name))
|
||||||
{
|
{
|
||||||
var attrs = a.GetCustomAttributes<AssemblyMetadataAttribute>();
|
var attrs = a.GetCustomAttributes<AssemblyMetadataAttribute>();
|
||||||
var revision = attrs.FirstOrDefault(attr => attr.Key == "Revision")?.Value;
|
var revision = attrs.FirstOrDefault(attr => attr.Key == "Revision")?.Value;
|
||||||
if (revision != null && int.Parse(revision) != (int)CsScriptBase.Revision[a.GetName().Name]) { continue; }
|
if (revision != null && int.Parse(revision) != (int)CsScriptBase.Revision[a.GetName().Name]) { continue; }
|
||||||
}
|
}
|
||||||
type = a.GetType(typeName);
|
type = a.GetType(typeName);
|
||||||
if (type != null)
|
if (type != null)
|
||||||
{
|
{
|
||||||
return type;
|
return byRef ? type.MakeByRefType() : type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user