Files
Il2CppInspectorRedux/Il2CppInspector/Reflection/MethodInfo.cs
Katy Coe 37f1c49828 Model: Ensure all TypeRefs are initialized with the model
Ensures that all types are output in the IDA Python script
Includes TypeRefs that aren't used in any type definition or member
2020-01-30 07:54:45 +01:00

40 lines
1.7 KiB
C#

/*
Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
All rights reserved.
*/
using System.Linq;
using System.Reflection;
namespace Il2CppInspector.Reflection
{
public class MethodInfo : MethodBase
{
public override MemberTypes MemberType => MemberTypes.Method;
// Info about the return parameter
public ParameterInfo ReturnParameter { get; }
// Return type of the method
private readonly int returnTypeReference;
public TypeInfo ReturnType => Assembly.Model.TypesByReferenceIndex[returnTypeReference];
public override bool RequiresUnsafeContext => base.RequiresUnsafeContext || ReturnType.RequiresUnsafeContext;
// IL2CPP doesn't seem to retain return type custom attributes
public MethodInfo(Il2CppInspector pkg, int methodIndex, TypeInfo declaringType) : base(pkg, methodIndex, declaringType) {
// Add return parameter
returnTypeReference = Definition.returnType;
ReturnParameter = new ParameterInfo(pkg, -1, this);
}
// TODO: Generic arguments (and on ConstructorInfo)
public override string ToString() => ReturnType.Name + " " + Name + "(" + string.Join(", ",
DeclaredParameters.Select(x => x.ParameterType.IsByRef? x.ParameterType.Name.TrimEnd('&') + " ByRef" : x.ParameterType.Name)) + ")";
public override string GetSignatureString() => ReturnParameter.GetSignatureString() + " " + Name + GetFullTypeParametersString()
+ "(" + string.Join(",", DeclaredParameters.Select(x => x.GetSignatureString())) + ")";
}
}