diff --git a/tests/generator-Tests/Unit-Tests/XmlApiImporterTests.cs b/tests/generator-Tests/Unit-Tests/XmlApiImporterTests.cs
index ba91ba96e..9405852d1 100644
--- a/tests/generator-Tests/Unit-Tests/XmlApiImporterTests.cs
+++ b/tests/generator-Tests/Unit-Tests/XmlApiImporterTests.cs
@@ -266,5 +266,41 @@ public void IgnoreKotlinInternalMembers ()
Assert.AreEqual (0, klass.Fields.Count);
Assert.AreEqual (0, klass.Methods.Count);
}
+
+ [Test]
+ public void IgnoreTypesWithInvalidNames ()
+ {
+ var xml = XDocument.Parse (@"
+
+
+
+
+
+
+
+ ");
+
+ var gens = XmlApiImporter.Parse (xml, opt);
+
+ // None of these should be parsed because they have invalid names
+ Assert.AreEqual (0, gens.Count);
+ }
+
+ [Test]
+ public void IgnoreUserObfuscatedTypes ()
+ {
+ var xml = XDocument.Parse (@"
+
+
+
+
+
+ ");
+
+ var gens = XmlApiImporter.Parse (xml, opt);
+
+ // None of these should be parsed because the user has said they are obfuscated
+ Assert.AreEqual (0, gens.Count);
+ }
}
}
diff --git a/tools/generator/Java.Interop.Tools.Generator.Importers/XmlApiImporter.cs b/tools/generator/Java.Interop.Tools.Generator.Importers/XmlApiImporter.cs
index 2a3238eb9..630a923e9 100644
--- a/tools/generator/Java.Interop.Tools.Generator.Importers/XmlApiImporter.cs
+++ b/tools/generator/Java.Interop.Tools.Generator.Importers/XmlApiImporter.cs
@@ -61,14 +61,12 @@ public static List ParsePackage (XElement ns, CodeGenerationOptions opt
switch (elem.Name.LocalName) {
case "class":
- if (elem.XGetAttribute ("obfuscated") == "true")
- continue;
- gen = CreateClass (ns, elem, options);
+ if (ShouldBind (elem))
+ gen = CreateClass (ns, elem, options);
break;
case "interface":
- if (elem.XGetAttribute ("obfuscated") == "true")
- continue;
- gen = CreateInterface (ns, elem, options);
+ if (ShouldBind (elem))
+ gen = CreateInterface (ns, elem, options);
break;
default:
Report.LogCodedWarning (0, Report.WarningUnexpectedPackageChildNode, elem.Name.ToString ());
@@ -522,5 +520,20 @@ static void SetLineInfo (ISourceLineInfo model, XNode node, CodeGenerationOption
model.LinePosition = info.LinePosition;
}
}
+
+ static bool ShouldBind (XElement elem)
+ {
+ // Don't bind things the user has said are "obfuscated"
+ if (elem.XGetAttribute ("obfuscated") == "true")
+ return false;
+
+ var java_name = elem.XGetAttribute ("name");
+
+ // Ignore types that do not have a name (nested classes would end in a period like "Document.")
+ if (!java_name.HasValue () || java_name.EndsWith (".", StringComparison.Ordinal))
+ return false;
+
+ return true;
+ }
}
}