Move duplicated sanitizeIdentifier to Extensions

Also ensure that the identifier always starts with an underscore or
letter, which fixes issues with obfuscated identifiers.
This commit is contained in:
Robert Xiao
2020-06-23 00:12:00 -07:00
committed by Katy
parent 95ee085374
commit de6d9e2230
3 changed files with 18 additions and 15 deletions

View File

@@ -10,7 +10,6 @@ using System.IO;
using System.Text;
using Il2CppInspector.Reflection;
using Il2CppInspector.Outputs.UnityHeaders;
using System.Text.RegularExpressions;
namespace Il2CppInspector.Outputs
{
@@ -118,13 +117,9 @@ typedef __int64 int64_t;
}
}
private static string sanitizeIdentifier(string str) {
return Regex.Replace(str, "[^a-zA-Z0-9_]", "_");
}
private static string stringToIdentifier(string str) {
str = str.Substring(0, Math.Min(32, str.Length));
return sanitizeIdentifier(str);
return str.ToCIdentifier();
}
private void writeUsages() {