Skip to content

Commit

Permalink
.NET: Fix overridden methods not having the original names
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Apr 6, 2024
1 parent d752625 commit 7fc9485
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions csharp-api/AssemblyGenerator/ClassGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,16 @@ public ClassGenerator(string className_, REFrameworkNET.TypeDefinition t_, REFra
var methodName = new string(method.Name);
var methodExtension = Il2CppDump.GetMethodExtension(method);

if (methodExtension != null && methodExtension.Override != null && methodExtension.Override == true) {
methodName += "_" + className.Replace('.', '_');
}

var methodDeclaration = SyntaxFactory.MethodDeclaration(returnType, methodName ?? "UnknownMethod")
.AddModifiers(new SyntaxToken[]{SyntaxFactory.Token(SyntaxKind.PublicKeyword)})
/*.AddBodyStatements(SyntaxFactory.ParseStatement("throw new System.NotImplementedException();"))*/;

if (methodExtension != null && methodExtension.Override != null && methodExtension.Override == true) {
//methodName += "_" + className.Replace('.', '_');

methodDeclaration = methodDeclaration.AddModifiers(SyntaxFactory.Token(SyntaxKind.NewKeyword));
}

if (wantsAbstractInstead) {
methodDeclaration = methodDeclaration.AddModifiers(SyntaxFactory.Token(SyntaxKind.AbstractKeyword));
}
Expand Down Expand Up @@ -293,16 +295,18 @@ public ClassGenerator(string className_, REFrameworkNET.TypeDefinition t_, REFra
nestedTypeName = nestedTypeName.Replace("file", "@file");
}

// Enum
if (nestedT.IsEnum()) {
var nestedEnumGenerator = new EnumGenerator(nestedTypeName.Split('.').Last(), nestedT);

if (nestedEnumGenerator.EnumDeclaration != null) {
this.Update(this.typeDeclaration.AddMembers(nestedEnumGenerator.EnumDeclaration));
}

continue;
}

// Class
HashSet<REFrameworkNET.Method> nestedMethods = [];

foreach (var method in nestedT.Methods) {
Expand Down

0 comments on commit 7fc9485

Please sign in to comment.