I just wanted to give a quick update to the code, i found a problem when
getting the returnType for a method inside the TypeDefinitionFromPapyrus
function:
and it should look as following:
(it does atleast give me the correct returnTypes, altough the same problem
persists)
public static TypeDefinition TypeDefinitionFromPapyrus(PapyrusAsmObject
input)
{
var newType = new TypeDefinition("PapyrusDotNet.Core", input.Name,
TypeAttributes.Class);
newType.IsPublic = true;
if (!string.IsNullOrEmpty(input.ExtendsName))
{
newType.BaseType = new TypeReference("PapyrusDotNet.Core",
input.ExtendsName, MainModule, MainModule);
newType.DeclaringType = MainModule.Types.FirstOrDefault(t => t.FullName ==
newType.BaseType.FullName);
newType.Scope = MainModule;
}
foreach (var prop in input.PropertyTable)
{
var typeRef = GetTypeReference(null, prop.Type);
var pro = new PropertyDefinition(prop.Name, PropertyAttributes.HasDefault,
typeRef);
newType.Properties.Add(pro);
}
AddEmptyConstructor(newType);
foreach (var state in input.States)
{
* TypeReference typeRef = GetTypeReference(null, state.ReturnType);*
// var typeRef = MainModule.TypeSystem.Void;
var function = new MethodDefinition(state.Name, MethodAttributes.Public,
typeRef);
function.IsStatic = state.IsStatic;
foreach (var par in state.Params)
{
TypeReference typeRefp = GetTypeReference(null, par.Type);
// var typeRefp = MainModule.TypeSystem.Object;
var nPar = new ParameterDefinition(par.Name, ParameterAttributes.None,
typeRefp);
function.Parameters.Add(nPar);
}
bool skipAdd = false;
foreach (var m in newType.Methods)
{
if (m.Name == function.Name)
{
if (m.Parameters.Count == function.Parameters.Count)
{
skipAdd = true;
for (int pi = 0; pi < m.Parameters.Count; pi++)
{
if (m.Parameters[pi].ParameterType.FullName !=
function.Parameters[pi].ParameterType.FullName) skipAdd = false;
}
break;
}
}
}
if (!skipAdd)
newType.Methods.Add(function);
}
return newType;
}
--
--
--
mono-cecil
---
You received this message because you are subscribed to the Google Groups
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.