Skip to content

Commit b7e85e1

Browse files
committed
#6: Update for RoomOS 11.20
1 parent 71a3772 commit b7e85e1

20 files changed

+2586
-2525
lines changed

ApiExtractor/ApiExtractor.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<LangVersion>latest</LangVersion>
77
<Nullable>enable</Nullable>
88
<NoWarn>CS8524, CS8846, CS8509</NoWarn>
99
<Authors>Ben Hutchison</Authors>
10-
<Copyright2024 $(Authors)</Copyright>
10+
<Copyright2025 $(Authors)</Copyright>
1111
<Company>$(Authors)</Company>
1212
<StartupObject>ApiExtractor.ApiExtractor</StartupObject>
1313
<IsPackable>false</IsPackable>
@@ -16,7 +16,7 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="jaytwo.FluentUri" Version="0.1.4" />
19-
<PackageReference Include="morelinq" Version="4.2.0" />
19+
<PackageReference Include="morelinq" Version="4.3.0" />
2020
<PackageReference Include="PdfPig" Version="0.1.8" />
2121
</ItemGroup>
2222

Binary file not shown.
+94-94
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,95 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Xml.Linq;
5-
6-
namespace ApiExtractor.Extraction;
7-
8-
public class EventReader {
9-
10-
private readonly ExtractedDocumentation docs;
11-
12-
public EventReader(ExtractedDocumentation docs) {
13-
this.docs = docs;
14-
}
15-
16-
public void parseEventXml(string xmlFilename) {
17-
XDocument doc = XDocument.Load(xmlFilename);
18-
19-
foreach (XElement secondLevelElements in doc.Root!.Elements()) {
20-
visit(secondLevelElements, new[] { "xEvent" });
21-
}
22-
23-
Console.WriteLine($"Parsed {docs.events.Count:N0} xEvents from XML");
24-
}
25-
26-
private void visit(XElement el, IList<string> path) {
27-
path = path.Append(el.Name.LocalName).ToList();
28-
29-
if (attributeEquals(el, "event", "True")) {
30-
DocXEvent xEvent = new() {
31-
name = path,
32-
access = EventAccessParser.parse(el.Attribute("access")!.Value),
33-
requiresUserRole = (el.Attribute("role")?.Value.Split(";").Select(rawRole => Enum.Parse<UserRole>(rawRole, true)) ?? Enumerable.Empty<UserRole>()).ToHashSet(),
34-
};
35-
36-
if (xEvent.access == EventAccess.PUBLIC_API) {
37-
docs.events.Add(xEvent);
38-
39-
foreach (XElement childEl in el.Elements()) {
40-
visit(childEl, xEvent);
41-
}
42-
}
43-
} else {
44-
foreach (XElement childEl in el.Elements()) {
45-
visit(childEl, path);
46-
}
47-
}
48-
}
49-
50-
private static void visit(XElement el, IEventParent parent) {
51-
IList<string> name = parent.name.Append(el.Attribute("className")?.Value ?? el.Name.LocalName).ToList();
52-
bool required = !attributeEquals(el, "optional", "True");
53-
54-
if (attributeEquals(el, "type", "literal") && el.HasElements) {
55-
parent.children.Add(new EnumChild {
56-
name = name,
57-
required = required,
58-
possibleValues = el.Elements("Value").Select(valueEl => new EnumValue(valueEl.Value)).ToHashSet()
59-
});
60-
} else if (attributeEquals(el, "type", "string") || (attributeEquals(el, "type", "literal") && !el.HasElements)) {
61-
parent.children.Add(new StringChild {
62-
name = name,
63-
required = required
64-
});
65-
} else if (attributeEquals(el, "type", "int")) {
66-
parent.children.Add(new IntChild {
67-
name = name,
68-
required = required,
69-
implicitAnonymousSingleton = attributeEquals(el, "onlyTextNode", "true")
70-
});
71-
} else if (attributeEquals(el, "multiple", "True")) {
72-
ListContainer listContainer = new() { name = name };
73-
parent.children.Add(listContainer);
74-
75-
foreach (XElement childEl in el.Elements()) {
76-
visit(childEl, listContainer);
77-
}
78-
} else /*if (attributeEquals(el, "basenode", "True"))*/ {
79-
ObjectContainer objectContainer = new() {
80-
name = name,
81-
required = required
82-
};
83-
parent.children.Add(objectContainer);
84-
85-
foreach (XElement childEl in el.Elements()) {
86-
visit(childEl, objectContainer);
87-
}
88-
}
89-
}
90-
91-
private static bool attributeEquals(XElement el, string attributeName, string? comparisonValue) {
92-
return string.Equals(el.Attribute(attributeName)?.Value, comparisonValue, StringComparison.InvariantCultureIgnoreCase);
93-
}
94-
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Xml.Linq;
5+
6+
namespace ApiExtractor.Extraction;
7+
8+
public class EventReader {
9+
10+
private readonly ExtractedDocumentation docs;
11+
12+
public EventReader(ExtractedDocumentation docs) {
13+
this.docs = docs;
14+
}
15+
16+
public void parseEventXml(string xmlFilename) {
17+
XDocument doc = XDocument.Load(xmlFilename);
18+
19+
foreach (XElement secondLevelElements in doc.Root!.Elements()) {
20+
visit(secondLevelElements, new[] { "xEvent" });
21+
}
22+
23+
Console.WriteLine($"Parsed {docs.events.Count:N0} xEvents from XML");
24+
}
25+
26+
private void visit(XElement el, IList<string> path) {
27+
path = path.Append(el.Name.LocalName).ToList();
28+
29+
if (attributeEquals(el, "event", "True")) {
30+
DocXEvent xEvent = new() {
31+
name = path,
32+
access = EventAccessParser.parse(el.Attribute("access")!.Value),
33+
requiresUserRole = (el.Attribute("role")?.Value.Split(";").Select(rawRole => Enum.Parse<UserRole>(rawRole, true)) ?? Enumerable.Empty<UserRole>()).ToHashSet(),
34+
};
35+
36+
if (xEvent.access == EventAccess.PUBLIC_API) {
37+
docs.events.Add(xEvent);
38+
39+
foreach (XElement childEl in el.Elements()) {
40+
visit(childEl, xEvent);
41+
}
42+
}
43+
} else {
44+
foreach (XElement childEl in el.Elements()) {
45+
visit(childEl, path);
46+
}
47+
}
48+
}
49+
50+
private static void visit(XElement el, IEventParent parent) {
51+
IList<string> name = parent.name.Append(el.Attribute("className")?.Value ?? el.Name.LocalName).ToList();
52+
bool required = !attributeEquals(el, "optional", "True");
53+
54+
if (attributeEquals(el, "type", "literal") && el.HasElements) {
55+
parent.children.Add(new EnumChild {
56+
name = name,
57+
required = required,
58+
possibleValues = el.Elements("Value").Select(valueEl => new EnumValue(valueEl.Value)).ToHashSet()
59+
});
60+
} else if (attributeEquals(el, "type", "string") || (attributeEquals(el, "type", "literal") && !el.HasElements)) {
61+
parent.children.Add(new StringChild {
62+
name = name,
63+
required = required
64+
});
65+
} else if (attributeEquals(el, "type", "int")) {
66+
parent.children.Add(new IntChild {
67+
name = name,
68+
required = required,
69+
implicitAnonymousSingleton = attributeEquals(el, "onlyTextNode", "true")
70+
});
71+
} else if (attributeEquals(el, "multiple", "True")) {
72+
ListContainer listContainer = new() { name = name };
73+
parent.children.Add(listContainer);
74+
75+
foreach (XElement childEl in el.Elements()) {
76+
visit(childEl, listContainer);
77+
}
78+
} else /*if (attributeEquals(el, "basenode", "True"))*/ {
79+
ObjectContainer objectContainer = new() {
80+
name = name,
81+
required = required
82+
};
83+
parent.children.Add(objectContainer);
84+
85+
foreach (XElement childEl in el.Elements()) {
86+
visit(childEl, objectContainer);
87+
}
88+
}
89+
}
90+
91+
private static bool attributeEquals(XElement el, string attributeName, string? comparisonValue) {
92+
return string.Equals(el.Attribute(attributeName)?.Value, comparisonValue, StringComparison.InvariantCultureIgnoreCase);
93+
}
94+
9595
}

0 commit comments

Comments
 (0)