Skip to content

Commit 8221b7d

Browse files
authored
[JavaCallableWrappers] Remove was_scanned from XML import/export (#1325)
Context: bc44f08 Context: dotnet/android#9930 Make a few tweaks to JCW serialization for dotnet/android#9930: - We no longer need `was_scanned`, as we now write a zero byte file to indicate a file was not scanned. - Add an overload to import from an `XElement`, as the full `.jlo.xml` file now contains additional non-JCW data.
1 parent 7b7ae83 commit 8221b7d

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

Diff for: src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers.Adapters/XmlExporter.cs

+7-12
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,27 @@ public static class XmlExporter
1717
OmitXmlDeclaration = true,
1818
};
1919

20-
public static void Export (string filename, IEnumerable<CallableWrapperType> types, bool wasScanned)
20+
public static void Export (string filename, IEnumerable<CallableWrapperType> types)
2121
{
2222
using (var sw = new StreamWriter (filename, false, Encoding.UTF8))
23-
Export (sw, types, wasScanned);
23+
Export (sw, types);
2424
}
2525

26-
public static void Export (TextWriter sw, IEnumerable<CallableWrapperType> types, bool wasScanned)
26+
public static void Export (TextWriter sw, IEnumerable<CallableWrapperType> types)
2727
{
2828
using (var xml = XmlWriter.Create (sw, settings))
29-
Export (xml, types, wasScanned);
29+
Export (xml, types);
3030
}
3131

32-
public static void Export (XmlWriter xml, IEnumerable<CallableWrapperType> types, bool wasScanned)
32+
public static void Export (XmlWriter xml, IEnumerable<CallableWrapperType> types)
3333
{
34-
ExportTypes (xml, types, wasScanned);
34+
ExportTypes (xml, types);
3535
}
3636

37-
static void ExportTypes (XmlWriter xml, IEnumerable<CallableWrapperType> types, bool wasScanned)
37+
static void ExportTypes (XmlWriter xml, IEnumerable<CallableWrapperType> types)
3838
{
39-
xml.WriteStartElement ("types");
40-
xml.WriteAttributeString ("was_scanned", wasScanned.ToString ());
41-
4239
foreach (var type in types)
4340
ExportType (xml, type);
44-
45-
xml.WriteEndElement ();
4641
}
4742

4843
public static void ExportType (XmlWriter xml, CallableWrapperType type)

Diff for: src/Java.Interop.Tools.JavaCallableWrappers/Java.Interop.Tools.JavaCallableWrappers.Adapters/XmlImporter.cs

+16-6
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,41 @@ namespace Java.Interop.Tools.JavaCallableWrappers.Adapters;
1111

1212
public static class XmlImporter
1313
{
14-
public static List<CallableWrapperType> Import (string filename, out bool wasScanned)
14+
public static List<CallableWrapperType> Import (string filename)
1515
{
1616
using (var sr = new StreamReader (filename, Encoding.UTF8))
17-
return Import (sr, out wasScanned);
17+
return Import (sr);
1818
}
1919

20-
public static List<CallableWrapperType> Import (TextReader sr, out bool wasScanned)
20+
public static List<CallableWrapperType> Import (TextReader sr)
2121
{
2222
using (var xml = XmlReader.Create (sr))
23-
return Import (xml, out wasScanned);
23+
return Import (xml);
2424
}
2525

26-
public static List<CallableWrapperType> Import (XmlReader xml, out bool wasScanned)
26+
public static List<CallableWrapperType> Import (XmlReader xml)
2727
{
2828
var doc = XDocument.Load (xml);
2929

3030
var types = new List<CallableWrapperType> ();
31-
wasScanned = doc.Root.GetAttributeOrDefault ("was_scanned", false);
3231

3332
foreach (var type in doc.Root.Elements ("type"))
3433
types.Add (ImportType (type));
3534

3635
return types;
3736
}
3837

38+
39+
public static List<CallableWrapperType> Import (XElement xml)
40+
{
41+
var types = new List<CallableWrapperType> ();
42+
43+
foreach (var type in xml.Elements ("type"))
44+
types.Add (ImportType (type));
45+
46+
return types;
47+
}
48+
3949
public static CallableWrapperType ImportType (XElement xml)
4050
{
4151
var name = xml.GetRequiredAttribute ("name");

0 commit comments

Comments
 (0)