From b327fdf341b0241acb4a8c0751f9265015d72c21 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Wed, 9 Sep 2020 14:13:50 +0200 Subject: [PATCH] C#: Fix indexer name corruption if length was not 4 characters --- Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs b/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs index b059e9a..57a6e90 100644 --- a/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs +++ b/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs @@ -438,9 +438,10 @@ namespace Il2CppInspector.Outputs // Indexer else { - // Replace "Item" with "this" - preserves explicit interface implementations - sb.Append(prop.CSharpName[..^4] + "this"); - sb.Append("[" + string.Join(", ", primary.DeclaredParameters.SkipLast(getAccess >= setAccess ? 0 : 1) + // Replace indexer name (usually "Item" but not always) with "this" - preserves explicit interface implementations + if (prop.CSharpName.IndexOf('.') != -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))) + "] { "); getBody = " => default;"; setBody = " {}";