C#: Fix indexer name corruption if length was not 4 characters

This commit is contained in:
Katy Coe
2020-09-09 14:13:50 +02:00
parent 84a3530556
commit b327fdf341

View File

@@ -438,9 +438,10 @@ namespace Il2CppInspector.Outputs
// Indexer // Indexer
else { else {
// Replace "Item" with "this" - preserves explicit interface implementations // Replace indexer name (usually "Item" but not always) with "this" - preserves explicit interface implementations
sb.Append(prop.CSharpName[..^4] + "this"); if (prop.CSharpName.IndexOf('.') != -1)
sb.Append("[" + string.Join(", ", primary.DeclaredParameters.SkipLast(getAccess >= setAccess ? 0 : 1) sb.Append(prop.CSharpName.Substring(0, prop.CSharpName.IndexOf('.') + 1));
sb.Append("this[" + string.Join(", ", primary.DeclaredParameters.SkipLast(getAccess >= setAccess ? 0 : 1)
.Select(p => p.GetParameterString(scope, !SuppressMetadata, MustCompile))) + "] { "); .Select(p => p.GetParameterString(scope, !SuppressMetadata, MustCompile))) + "] { ");
getBody = " => default;"; getBody = " => default;";
setBody = " {}"; setBody = " {}";