diff --git a/src/Generator.Tests/GeneratorTest.cs b/src/Generator.Tests/GeneratorTest.cs index a400bc9739..d2f7e75919 100644 --- a/src/Generator.Tests/GeneratorTest.cs +++ b/src/Generator.Tests/GeneratorTest.cs @@ -42,9 +42,16 @@ public virtual void Setup(Driver driver) testModule.IncludeDirs.Add(path); Diagnostics.Message("Looking for tests in: {0}", path); - var files = Directory.EnumerateFiles(path, "*.h"); + var files = Directory.EnumerateFiles(path, "*.h", SearchOption.AllDirectories); foreach (var file in files) + { + string includeDir = Path.GetDirectoryName(file); + if (!testModule.IncludeDirs.Contains(includeDir)) + { + testModule.IncludeDirs.Add(includeDir); + } testModule.Headers.Add(Path.GetFileName(file)); + } } public virtual void Preprocess(Driver driver, ASTContext ctx) diff --git a/src/Generator/Passes/CleanUnitPass.cs b/src/Generator/Passes/CleanUnitPass.cs index c9978f92fb..0bc9c04782 100644 --- a/src/Generator/Passes/CleanUnitPass.cs +++ b/src/Generator/Passes/CleanUnitPass.cs @@ -31,9 +31,14 @@ private Module GetModule(TranslationUnit unit) includeDir = "."; includeDir = Path.GetFullPath(includeDir); - return Options.Modules.FirstOrDefault( - m => m.IncludeDirs.Any(i => Path.GetFullPath(i) == includeDir)) ?? - Options.Modules[1]; + Module module = Options.Modules.Find( + m => m.IncludeDirs.Any(i => Path.GetFullPath(i) == includeDir)); + if (module == null) + { + unit.ExplicitlyIgnore(); + module = Options.Modules[1]; + } + return module; } public override bool VisitDeclarationContext(DeclarationContext context) diff --git a/src/Generator/Passes/DelegatesPass.cs b/src/Generator/Passes/DelegatesPass.cs index 1f427a47ff..68d205faae 100644 --- a/src/Generator/Passes/DelegatesPass.cs +++ b/src/Generator/Passes/DelegatesPass.cs @@ -215,7 +215,8 @@ private DeclarationContext GetDeclContextForDelegates(DeclarationContext @namesp Namespace parent = null; if (string.IsNullOrEmpty(module.OutputNamespace)) { - var groups = module.Units.SelectMany(u => u.Declarations).OfType( + var groups = module.Units.Where(u => u.IsGenerated).SelectMany( + u => u.Declarations).OfType( ).GroupBy(d => d.Name).Where(g => g.Any(d => d.HasDeclarations)).ToList(); if (groups.Count == 1) parent = groups.Last().Last(); @@ -231,7 +232,7 @@ private DeclarationContext GetDeclContextForDelegates(DeclarationContext @namesp } if (parent == null) - parent = module.Units.Last(); + parent = module.Units.Last(u => u.IsGenerated); var namespaceDelegates = new Namespace {