diff --git a/src/Generator/Generator.cs b/src/Generator/Generator.cs index 1606cc2a..436c8909 100644 --- a/src/Generator/Generator.cs +++ b/src/Generator/Generator.cs @@ -71,7 +71,7 @@ namespace CppSharp.Generators if (!unit.IsGenerated || !unit.HasDeclarations) continue; - if (unit.IsSystemHeader) + if (unit.IsSystemHeader || !unit.IsValid) continue; var templates = Generate(unit); diff --git a/src/Generator/Passes/CleanUnitPass.cs b/src/Generator/Passes/CleanUnitPass.cs index 9e933183..2d3628ba 100644 --- a/src/Generator/Passes/CleanUnitPass.cs +++ b/src/Generator/Passes/CleanUnitPass.cs @@ -18,9 +18,12 @@ namespace CppSharp.Passes // Try to get an include path that works from the original include // directories paths. - - unit.IncludePath = GetIncludePath(unit.FilePath); - return true; + if (unit.IsValid) + { + unit.IncludePath = GetIncludePath(unit.FilePath); + return true; + } + return false; } string GetIncludePath(string filePath)