diff --git a/src/Generator.Tests/AST/TestAST.cs b/src/Generator.Tests/AST/TestAST.cs index 6c65c798..7af4563d 100644 --- a/src/Generator.Tests/AST/TestAST.cs +++ b/src/Generator.Tests/AST/TestAST.cs @@ -553,5 +553,14 @@ namespace CppSharp.Generator.Tests.AST Assert.That($"{type}", Is.EqualTo("global::Test.TestTemplateClass.NestedInTemplate")); } + + [Test] + public void TestTemplateConstructorName() + { + new CleanInvalidDeclNamesPass { Context = Driver.Context }.VisitASTContext(AstContext); + var template = AstContext.FindClass("TestTemplateClass").First(); + foreach (var constructor in template.Constructors) + Assert.That(constructor.Name, Is.EqualTo("TestTemplateClass")); + } } } diff --git a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs index ad85429b..3ec63d32 100644 --- a/src/Generator/Passes/CleanInvalidDeclNamesPass.cs +++ b/src/Generator/Passes/CleanInvalidDeclNamesPass.cs @@ -47,8 +47,10 @@ namespace CppSharp.Passes return true; } - Function function = decl as Function; - if ((function == null || !function.IsOperator) && !(decl is Enumeration)) + var function = decl as Function; + var method = function as Method; + if ((function == null || !function.IsOperator) && !(decl is Enumeration) && + (method == null || method.Kind == CXXMethodKind.Normal)) decl.Name = CheckName(decl.Name); StringHelpers.CleanupText(ref decl.DebugText);