Browse Source

Couldn't remove mobules without translation unit (#1861)

I do not know I'm first to encounter this, however, loop that removes module without translation units, could not have worked.

In C# Enumerator prohibs editing the collection so you cannot remove modules from `options.Module` while iterating `options.Mobule`.

Chose `RemoveAll` for its simplicity. Not necessary optimal solution although it might be.

Co-authored-by: HenrikVDestia <henrik.valve@destia.fi>
pull/1864/head
Henrik Valve 10 months ago committed by GitHub
parent
commit
345de8b1fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      src/Generator/Driver.cs

10
src/Generator/Driver.cs

@ -417,12 +417,12 @@ namespace CppSharp @@ -417,12 +417,12 @@ namespace CppSharp
}
new CleanUnitPass { Context = driver.Context }.VisitASTContext(driver.Context.ASTContext);
foreach (var module in options.Modules.Where(
m => m != options.SystemModule && !m.Units.GetGenerated().Any()))
options.Modules.RemoveAll(m =>
{
Diagnostics.Message($"Removing module {module} because no translation units are generated...");
options.Modules.Remove(module);
}
bool result = m != options.SystemModule && !m.Units.GetGenerated().Any();
if (result) Diagnostics.Message($"Removing module {m} because no translation units are generated...");
return result;
});
if (!options.Quiet)
Diagnostics.Message("Processing code...");

Loading…
Cancel
Save