Browse Source

Couldn't remove mobules without translation unit

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.
pull/1861/head
HenrikVDestia 10 months ago
parent
commit
6f017a9399
  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