From 5dce147d7760f3b2d55773fb3f55f4ec824aa728 Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 29 May 2013 19:26:16 +0100 Subject: [PATCH] Refactored the internal function generation code to collect all the declarations first and only then generate the needed functions. We also store them in a set to deal with duplicated entries. --- .../Generators/CSharp/CSharpTextTemplate.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs index 5eddb1cf..7cafb56d 100644 --- a/src/Generator/Generators/CSharp/CSharpTextTemplate.cs +++ b/src/Generator/Generators/CSharp/CSharpTextTemplate.cs @@ -335,6 +335,8 @@ namespace CppSharp.Generators.CSharp GenerateClassFields(@class, isInternal: true); + var functions = new HashSet(); + foreach (var ctor in @class.Constructors) { if (ctor.IsCopyConstructor || ctor.IsMoveConstructor) @@ -343,8 +345,7 @@ namespace CppSharp.Generators.CSharp if (ctor.IsPure) continue; - NewLineIfNeeded(); - GenerateInternalFunction(ctor); + functions.Add(ctor); } foreach (var method in @class.Methods) @@ -361,8 +362,13 @@ namespace CppSharp.Generators.CSharp if (method.IsPure) continue; + functions.Add(method); + } + + foreach (var function in functions) + { NewLineIfNeeded(); - GenerateInternalFunction(method); + GenerateInternalFunction(function); } typePrinter.PopContext();