Output: Prepend fields, events, properties and parameter names using reserved C# keywords with @
This commit is contained in:
@@ -40,6 +40,7 @@ namespace Il2CppInspector.Reflection
|
||||
|
||||
// Name of parameter
|
||||
public string Name { get; }
|
||||
public string CSharpSafeName => Constants.Keywords.Contains(Name) ? "@" + Name : Name;
|
||||
|
||||
// Type of this parameter
|
||||
private readonly int paramTypeUsage;
|
||||
@@ -106,7 +107,7 @@ namespace Il2CppInspector.Reflection
|
||||
public string GetParameterString(Scope usingScope, bool emitPointer = false, bool compileAttributes = false) => IsRetval? null :
|
||||
(Position == 0 && DeclaringMethod.GetCustomAttributes("System.Runtime.CompilerServices.ExtensionAttribute").Any()? "this ":"")
|
||||
+ $"{CustomAttributes.ToString(usingScope, inline: true, emitPointer: emitPointer, mustCompile: compileAttributes).Replace("[ParamArray]", "params")}"
|
||||
+ $"{getCSharpSignatureString(usingScope)} {Name}"
|
||||
+ $"{getCSharpSignatureString(usingScope)} {CSharpSafeName}"
|
||||
+ (IsOptional? " = " + DefaultValue.ToCSharpValue(ParameterType, usingScope)
|
||||
+ (emitPointer && !(DefaultValue is null)? $" /* Metadata: 0x{(uint) DefaultValueMetadataAddress:X8} */" : "") : "");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user