diff --git a/source/ProtocolGenerator/Command.cs b/source/ProtocolGenerator/Command.cs new file mode 100644 index 0000000000000000000000000000000000000000..6a3d253991f753c6afe6df05e50c3ff44f6c229d --- /dev/null +++ b/source/ProtocolGenerator/Command.cs @@ -0,0 +1,43 @@ +using System.Collections.ObjectModel; + +namespace MasterDevs.ChromeDevTools.ProtocolGenerator +{ + class Command : ProtocolItem + { + public Collection<Property> Returns + { + get; + set; + } + + public Property Error + { + get; + set; + } + + public Collection<string> Handlers + { + get; + set; + } + + public Collection<Property> Parameters + { + get; + set; + } + + public bool async + { + get; + set; + } + + public string Redirect + { + get; + set; + } + } +} diff --git a/source/ProtocolGenerator/Domain.cs b/source/ProtocolGenerator/Domain.cs new file mode 100644 index 0000000000000000000000000000000000000000..3e706274a7a715215439168a92cb11ce772bf4b2 --- /dev/null +++ b/source/ProtocolGenerator/Domain.cs @@ -0,0 +1,45 @@ +using Newtonsoft.Json; +using System.Collections.ObjectModel; + +namespace MasterDevs.ChromeDevTools.ProtocolGenerator +{ + class Domain : ProtocolItem + { + [JsonProperty(PropertyName = "domain")] + public override string Name + { + get; + set; + } + + public Collection<Type> Types + { + get; + set; + } + + public Collection<Command> Commands + { + get; + set; + } + + public Collection<Event> Events + { + get; + set; + } + + public string Availability + { + get; + set; + } + + public string FeatureGuard + { + get; + set; + } + } +} diff --git a/source/ProtocolGenerator/Event.cs b/source/ProtocolGenerator/Event.cs new file mode 100644 index 0000000000000000000000000000000000000000..ff2b92dffeee9d12de33d82d780d1fcc10f5bf1c --- /dev/null +++ b/source/ProtocolGenerator/Event.cs @@ -0,0 +1,25 @@ +using System.Collections.ObjectModel; + +namespace MasterDevs.ChromeDevTools.ProtocolGenerator +{ + class Event : ProtocolItem + { + public Collection<Property> Parameters + { + get; + set; + } + + public Collection<string> Handlers + { + get; + set; + } + + public bool Deprecated + { + get; + set; + } + } +} diff --git a/source/ProtocolGenerator/MasterDevs.ChromeDevTools.ProtocolGenerator.csproj b/source/ProtocolGenerator/MasterDevs.ChromeDevTools.ProtocolGenerator.csproj index 5e5798e00ea293483da6223185d7828509d4e1e4..4a58f80391dbf58d9e10dd4e977a50dc697846f2 100644 --- a/source/ProtocolGenerator/MasterDevs.ChromeDevTools.ProtocolGenerator.csproj +++ b/source/ProtocolGenerator/MasterDevs.ChromeDevTools.ProtocolGenerator.csproj @@ -50,14 +50,43 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Command.cs" /> + <Compile Include="Domain.cs" /> + <Compile Include="Event.cs" /> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Property.cs" /> + <Compile Include="Protocol.cs" /> + <Compile Include="ProtocolItem.cs" /> + <Compile Include="Type.cs" /> + <Compile Include="Version.cs" /> </ItemGroup> <ItemGroup> <None Include="App.config" /> + <None Include="Inspector-0.1.json"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="Inspector-1.0.json"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="Inspector-1.1.json"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="Inspector-iOS-7.0.json"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="Inspector-iOS-8.0.json"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="Inspector-iOS-9.0.json"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="Inspector-iOS-9.3.json"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> <None Include="packages.config" /> <None Include="protocol.json"> - <CopyToOutputDirectory>Always</CopyToOutputDirectory> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> diff --git a/source/ProtocolGenerator/Program.cs b/source/ProtocolGenerator/Program.cs index 194d205c5264133252d022a023569fa95a7a024c..f418253cbd36809c1c2b68ae300f44f8f4935d15 100644 --- a/source/ProtocolGenerator/Program.cs +++ b/source/ProtocolGenerator/Program.cs @@ -23,6 +23,16 @@ namespace MasterDevs.ChromeDevTools.ProtocolGenerator private static Dictionary<string, List<string>> _DomainEvents = new Dictionary<string, List<string>>(); private static Dictionary<string, string> _SimpleTypes = new Dictionary<string, string>(); + private static Protocol LoadProtocol(string path) + { + string json = File.ReadAllText(path); + JsonSerializerSettings settings = new JsonSerializerSettings(); + settings.MissingMemberHandling = MissingMemberHandling.Error; + settings.MetadataPropertyHandling = MetadataPropertyHandling.Ignore; + Protocol p = JsonConvert.DeserializeObject<Protocol>(json, settings); + return p; + } + private static void Main(string[] args) { var filePath = "protocol.json"; diff --git a/source/ProtocolGenerator/Property.cs b/source/ProtocolGenerator/Property.cs new file mode 100644 index 0000000000000000000000000000000000000000..7645385ba81b78ed4611337f92ddccc4bf00f6d0 --- /dev/null +++ b/source/ProtocolGenerator/Property.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; + +namespace MasterDevs.ChromeDevTools.ProtocolGenerator +{ + class Property : Type + { + [JsonProperty("name")] + public override string Name + { + get; + set; + } + + public bool Optional + { + get; + set; + } + } +} diff --git a/source/ProtocolGenerator/Protocol.cs b/source/ProtocolGenerator/Protocol.cs new file mode 100644 index 0000000000000000000000000000000000000000..ae206ed86f9019041adf5f86c381dc4faa1895e3 --- /dev/null +++ b/source/ProtocolGenerator/Protocol.cs @@ -0,0 +1,25 @@ +using System.Collections.ObjectModel; + +namespace MasterDevs.ChromeDevTools.ProtocolGenerator +{ + class Protocol + { + public Collection<string> Compatible + { + get; + set; + } + + public Version Version + { + get; + set; + } + + public Collection<Domain> Domains + { + get; + set; + } + } +} diff --git a/source/ProtocolGenerator/ProtocolItem.cs b/source/ProtocolGenerator/ProtocolItem.cs new file mode 100644 index 0000000000000000000000000000000000000000..61bae95f698cfcfecdfb486507599265f205e729 --- /dev/null +++ b/source/ProtocolGenerator/ProtocolItem.cs @@ -0,0 +1,28 @@ +namespace MasterDevs.ChromeDevTools.ProtocolGenerator +{ + abstract class ProtocolItem + { + public virtual string Description + { + get; + set; + } + + public virtual bool Hidden + { + get; + set; + } + + public virtual string Name + { + get; + set; + } + + public override string ToString() + { + return this.Name; + } + } +} diff --git a/source/ProtocolGenerator/Type.cs b/source/ProtocolGenerator/Type.cs new file mode 100644 index 0000000000000000000000000000000000000000..775759f0a3a09163d4f382da534726442d3890f3 --- /dev/null +++ b/source/ProtocolGenerator/Type.cs @@ -0,0 +1,59 @@ +using Newtonsoft.Json; +using System.Collections.ObjectModel; + +namespace MasterDevs.ChromeDevTools.ProtocolGenerator +{ + class Type : ProtocolItem + { + [JsonProperty(PropertyName = "Id")] + public override string Name + { + get; + set; + } + + [JsonProperty(PropertyName ="type")] + public string Kind + { + get; + set; + } + + public Collection<string> Enum + { + get; + set; + } + + public Collection<Property> Properties + { + get; + set; + } + + public Type Items + { + get; + set; + } + + public int MinItems + { + get; + set; + } + + public int MaxItems + { + get; + set; + } + + [JsonProperty("$ref")] + public string TypeReference + { + get; + set; + } + } +} diff --git a/source/ProtocolGenerator/Version.cs b/source/ProtocolGenerator/Version.cs new file mode 100644 index 0000000000000000000000000000000000000000..b9d6dc8cb2b39cf3fbdee36cfbd12ca6a3664935 --- /dev/null +++ b/source/ProtocolGenerator/Version.cs @@ -0,0 +1,22 @@ +namespace MasterDevs.ChromeDevTools.ProtocolGenerator +{ + class Version + { + public string Major + { + get; + set; + } + + public string Minor + { + get; + set; + } + + public override string ToString() + { + return $"{this.Major}.{this.Minor}"; + } + } +}