diff --git a/src/Generator/Generators/C/CppHeaders.cs b/src/Generator/Generators/C/CppHeaders.cs index eb87f4fd8..b39d6877d 100644 --- a/src/Generator/Generators/C/CppHeaders.cs +++ b/src/Generator/Generators/C/CppHeaders.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using CppSharp.AST; using CppSharp.AST.Extensions; @@ -87,7 +88,8 @@ public void GenerateIncludeForwardRefs(TranslationUnit unit) if (typeRef.Include.TranslationUnit == unit) continue; - if (typeRef.Include.File == unit.FileName) + var filename = Context.Options.GenerateName != null ? $"{Context.Options.GenerateName(TranslationUnit)}{Path.GetExtension(TranslationUnit.FileName)}" : TranslationUnit.FileName; + if (typeRef.Include.File == filename) continue; var include = typeRef.Include; diff --git a/src/Generator/Generators/C/CppSources.cs b/src/Generator/Generators/C/CppSources.cs index a8e7a013b..061809b4c 100644 --- a/src/Generator/Generators/C/CppSources.cs +++ b/src/Generator/Generators/C/CppSources.cs @@ -64,7 +64,8 @@ public virtual void GenerateForwardReferenceHeaders(TranslationUnit unit) foreach (var typeRef in typeReferenceCollector.TypeReferences) { - if (typeRef.Include.File == unit.FileName) + var filename = Context.Options.GenerateName != null ? $"{Context.Options.GenerateName(TranslationUnit)}{Path.GetExtension(TranslationUnit.FileName)}" : TranslationUnit.FileName; + if (typeRef.Include.File == filename) continue; var include = typeRef.Include; diff --git a/src/Generator/Generators/CLI/CLIHeaders.cs b/src/Generator/Generators/CLI/CLIHeaders.cs index a143cf4de..900e2a8a5 100644 --- a/src/Generator/Generators/CLI/CLIHeaders.cs +++ b/src/Generator/Generators/CLI/CLIHeaders.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using CppSharp.AST; using CppSharp.AST.Extensions; @@ -61,7 +62,8 @@ public void GenerateIncludeForwardRefs() if (typeRef.Include.TranslationUnit == TranslationUnit) continue; - if (typeRef.Include.File == TranslationUnit.FileName) + var filename = Context.Options.GenerateName != null ? $"{Context.Options.GenerateName(TranslationUnit)}{Path.GetExtension(TranslationUnit.FileName)}" : TranslationUnit.FileName; + if (typeRef.Include.File == filename) continue; var include = typeRef.Include; diff --git a/src/Generator/Generators/CLI/CLISources.cs b/src/Generator/Generators/CLI/CLISources.cs index 0a8882628..3a1b692bc 100644 --- a/src/Generator/Generators/CLI/CLISources.cs +++ b/src/Generator/Generators/CLI/CLISources.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.IO; using System.Linq; using CppSharp.AST; using CppSharp.AST.Extensions; @@ -61,7 +62,8 @@ public void GenerateForwardReferenceHeaders() foreach (var typeRef in typeReferenceCollector.TypeReferences) { - if (typeRef.Include.File == TranslationUnit.FileName) + var filename = Context.Options.GenerateName != null ? $"{Context.Options.GenerateName(TranslationUnit)}{Path.GetExtension(TranslationUnit.FileName)}" : TranslationUnit.FileName; + if (typeRef.Include.File == filename) continue; var include = typeRef.Include;