Skip to content

Commit

Permalink
Fixed a bug causing the header file to be included twice when Options…
Browse files Browse the repository at this point in the history
….GenerateName is not null (mono#1803)
  • Loading branch information
zylalx1 authored Dec 7, 2023
1 parent e068f2a commit 12c267d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Generator/Generators/C/CppHeaders.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CppSharp.AST;
using CppSharp.AST.Extensions;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/Generator/Generators/C/CppSources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/Generator/Generators/CLI/CLIHeaders.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using CppSharp.AST;
using CppSharp.AST.Extensions;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/Generator/Generators/CLI/CLISources.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 12c267d

Please sign in to comment.