diff --git a/src/generators/Silk.NET.SilkTouch.Scraper/XmlVisitor.cs b/src/generators/Silk.NET.SilkTouch.Scraper/XmlVisitor.cs index 01e9e46f1e..d02a7758eb 100644 --- a/src/generators/Silk.NET.SilkTouch.Scraper/XmlVisitor.cs +++ b/src/generators/Silk.NET.SilkTouch.Scraper/XmlVisitor.cs @@ -23,6 +23,8 @@ public IEnumerable Visit(XmlNode node) return VisitNamespace(@namespace); case XmlElement { Name: "struct" } @struct: return VisitStruct(@struct); + case XmlElement { Name: "field" } field: + return VisitField(field); default: { throw new NotImplementedException(); @@ -30,6 +32,28 @@ public IEnumerable Visit(XmlNode node) } } + private IEnumerable VisitField(XmlElement field) + { + var name = field.Attributes["name"]?.Value; + if (name is null) + { + throw new InvalidOperationException("Field requires a name"); + } + + var type = new StructSymbol + ( + new IdentifierSymbol( + field.ChildNodes.Cast().SingleOrDefault(x => x.Name == "type")?.InnerText ?? + throw new InvalidOperationException("Could not decode Field Type")), + StructLayout.Empty + ); + + return new[] + { + new FieldSymbol(type, new IdentifierSymbol(name)) + }; + } + private IEnumerable VisitStruct(XmlElement @struct) { return new[]