Weaver.ResolveDefaultPublicCtor moved to Resolvers

This commit is contained in:
vis2k 2019-01-02 13:35:55 +01:00
parent a33c20c823
commit ee618ad8f6
2 changed files with 15 additions and 15 deletions

View File

@ -84,5 +84,19 @@ public static MethodReference ResolveMethodWithArg(TypeReference tr, AssemblyDef
{
return ResolveMethodWithArg(tr, scriptDef, name, argType.FullName);
}
public static MethodDefinition ResolveDefaultPublicCtor(TypeReference variable)
{
foreach (MethodDefinition methodRef in variable.Resolve().Methods)
{
if (methodRef.Name == ".ctor" &&
methodRef.Resolve().IsPublic &&
methodRef.Parameters.Count == 0)
{
return methodRef;
}
}
return null;
}
}
}

View File

@ -660,7 +660,7 @@ static MethodDefinition GenerateReadFunction(TypeReference variable)
{
// classes are created with their constructor
var ctor = ResolveDefaultPublicCtor(variable);
MethodDefinition ctor = Resolvers.ResolveDefaultPublicCtor(variable);
if (ctor == null)
{
Log.Error("The class " + variable.Name + " has no default constructor or it's private, aborting.");
@ -1034,20 +1034,6 @@ static bool ProcessNetworkBehaviourType(TypeDefinition td)
return false;
}
static MethodDefinition ResolveDefaultPublicCtor(TypeReference variable)
{
foreach (MethodDefinition methodRef in variable.Resolve().Methods)
{
if (methodRef.Name == ".ctor" &&
methodRef.Resolve().IsPublic &&
methodRef.Parameters.Count == 0)
{
return methodRef;
}
}
return null;
}
static GenericInstanceMethod ResolveMethodGeneric(TypeReference t, string name, TypeReference genericType)
{
foreach (var methodRef in t.Resolve().Methods)