Model and Output: Implement default method parameter values
This commit is contained in:
@@ -160,7 +160,8 @@ namespace Il2CppInspector.Reflection
|
||||
// Get C# syntax-friendly list of parameters
|
||||
public string GetParametersString() =>
|
||||
string.Join(", ", DeclaredParameters.Select(p => $"{p.CustomAttributes.ToString(inline: true).Replace("[ParamArray]", "params")}"
|
||||
+ $"{p.GetModifierString()}{p.ParameterType.CSharpName} {p.Name}"));
|
||||
+ $"{p.GetModifierString()}{p.ParameterType.CSharpName} {p.Name}"
|
||||
+ (p.HasDefaultValue? " = " + p.DefaultValue.ToCSharpValue() : "")));
|
||||
|
||||
public string GetTypeParametersString() => GenericTypeParameters == null? "" :
|
||||
"<" + string.Join(", ", GenericTypeParameters.Select(p => p.CSharpName)) + ">";
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Il2CppInspector.Reflection
|
||||
public bool HasDefaultValue => (Attributes & ParameterAttributes.HasDefault) != 0;
|
||||
|
||||
// Default value for the parameter
|
||||
public object DefaultValue => throw new NotImplementedException();
|
||||
public object DefaultValue { get; }
|
||||
|
||||
public bool IsIn => (Attributes & ParameterAttributes.In) != 0;
|
||||
public bool IsOptional => (Attributes & ParameterAttributes.Optional) != 0;
|
||||
@@ -80,11 +80,12 @@ namespace Il2CppInspector.Reflection
|
||||
if (Position == -1)
|
||||
Attributes |= ParameterAttributes.Retval;
|
||||
|
||||
// TODO: DefaultValue/HasDefaultValue
|
||||
// Default initialization value if present
|
||||
if (pkg.ParameterDefaultValue.TryGetValue(paramIndex, out object variant))
|
||||
DefaultValue = variant;
|
||||
}
|
||||
|
||||
public string GetModifierString() =>
|
||||
(IsOptional? "optional " : "") +
|
||||
(IsOut? "out " : "");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user