diff --git a/.gitignore b/.gitignore index cc27174..64fa334 100644 --- a/.gitignore +++ b/.gitignore @@ -332,3 +332,7 @@ ASALocalRun/ .mfractor/ .vscode/tasks.json .vscode/launch.json + +# Capnp code behind +*.capnp.cs +/globalPackages diff --git a/Capnp.Net.Runtime.Tests.Core21/Capnp.Net.Runtime.Tests.Core21.csproj b/Capnp.Net.Runtime.Tests.Core21/Capnp.Net.Runtime.Tests.Core21.csproj index d72aa67..d4a9e68 100644 --- a/Capnp.Net.Runtime.Tests.Core21/Capnp.Net.Runtime.Tests.Core21.csproj +++ b/Capnp.Net.Runtime.Tests.Core21/Capnp.Net.Runtime.Tests.Core21.csproj @@ -4,6 +4,8 @@ netcoreapp2.2 false + + Debug;Release @@ -31,6 +33,7 @@ + diff --git a/Capnp.Net.Runtime.Tests/Capnp.Net.Runtime.Tests.Std20.csproj b/Capnp.Net.Runtime.Tests/Capnp.Net.Runtime.Tests.Std20.csproj index 5048b1c..d722dd3 100644 --- a/Capnp.Net.Runtime.Tests/Capnp.Net.Runtime.Tests.Std20.csproj +++ b/Capnp.Net.Runtime.Tests/Capnp.Net.Runtime.Tests.Std20.csproj @@ -8,6 +8,8 @@ 7.1 Library + + Debug;Release @@ -15,6 +17,7 @@ + diff --git a/Capnp.Net.Runtime/Capnp.Net.Runtime.csproj b/Capnp.Net.Runtime/Capnp.Net.Runtime.csproj index ae162a8..90555c9 100644 --- a/Capnp.Net.Runtime/Capnp.Net.Runtime.csproj +++ b/Capnp.Net.Runtime/Capnp.Net.Runtime.csproj @@ -7,6 +7,7 @@ Capnp.Net.Runtime Capnp.Net.Runtime true + ..\bin\$(Configuration) Christian Köllner and contributors A Cap'n Proto implementation for .NET Standard & Core capnproto-dotnetcore @@ -17,17 +18,14 @@ MIT Git capnp "Cap'n Proto" RPC serialization cerealization - 1.0.0 + 1.0-local$([System.DateTime]::UtcNow.ToString(yyMMddHHmm)) + Debug;Release TRACE - - - - - + diff --git a/Capnp.Net.sln b/Capnp.Net.sln index 41f5968..ff53c1c 100644 --- a/Capnp.Net.sln +++ b/Capnp.Net.sln @@ -11,7 +11,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Capnp.Net.Runtime.Tests.Std EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Capnp.Net.Runtime.Tests.Core21", "Capnp.Net.Runtime.Tests.Core21\Capnp.Net.Runtime.Tests.Core21.csproj", "{58E8FFC8-D207-4B0F-842A-58ED9D3D9EEF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "capnpc-csharp.tests", "capnpc-csharp.tests\capnpc-csharp.tests.csproj", "{B77AC567-E232-4072-85C3-8689566BF3D4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CapnpC.CSharp.Generator.Tests", "CapnpC.CSharp.Generator.Tests\CapnpC.CSharp.Generator.Tests.csproj", "{B77AC567-E232-4072-85C3-8689566BF3D4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CapnpC.CSharp.MsBuild.Generation", "CapnpC.CSharp.MsBuild.Generation\CapnpC.CSharp.MsBuild.Generation.csproj", "{1EFC1F20-C7BB-4F44-8BF9-DBB123AACCF4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CapnpC.CSharp.Generator", "CapnpC.CSharp.Generator\CapnpC.CSharp.Generator.csproj", "{C3A3BB49-356E-4762-A190-76D877BE18F7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CapnpC.CSharp.MsBuild.Generation.Tests", "CapnpC.CSharp.MsBuild.Generation.Tests\CapnpC.CSharp.MsBuild.Generation.Tests.csproj", "{EF05AD68-DE31-448E-B88D-4144F928ED5D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,6 +45,18 @@ Global {B77AC567-E232-4072-85C3-8689566BF3D4}.Debug|Any CPU.Build.0 = Debug|Any CPU {B77AC567-E232-4072-85C3-8689566BF3D4}.Release|Any CPU.ActiveCfg = Release|Any CPU {B77AC567-E232-4072-85C3-8689566BF3D4}.Release|Any CPU.Build.0 = Release|Any CPU + {1EFC1F20-C7BB-4F44-8BF9-DBB123AACCF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1EFC1F20-C7BB-4F44-8BF9-DBB123AACCF4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1EFC1F20-C7BB-4F44-8BF9-DBB123AACCF4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1EFC1F20-C7BB-4F44-8BF9-DBB123AACCF4}.Release|Any CPU.Build.0 = Release|Any CPU + {C3A3BB49-356E-4762-A190-76D877BE18F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3A3BB49-356E-4762-A190-76D877BE18F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3A3BB49-356E-4762-A190-76D877BE18F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3A3BB49-356E-4762-A190-76D877BE18F7}.Release|Any CPU.Build.0 = Release|Any CPU + {EF05AD68-DE31-448E-B88D-4144F928ED5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF05AD68-DE31-448E-B88D-4144F928ED5D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF05AD68-DE31-448E-B88D-4144F928ED5D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF05AD68-DE31-448E-B88D-4144F928ED5D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/capnpc-csharp.tests/capnpc-csharp.tests.csproj b/CapnpC.CSharp.Generator.Tests/CapnpC.CSharp.Generator.Tests.csproj similarity index 70% rename from capnpc-csharp.tests/capnpc-csharp.tests.csproj rename to CapnpC.CSharp.Generator.Tests/CapnpC.CSharp.Generator.Tests.csproj index ce9a24e..0f3fa11 100644 --- a/capnpc-csharp.tests/capnpc-csharp.tests.csproj +++ b/CapnpC.CSharp.Generator.Tests/CapnpC.CSharp.Generator.Tests.csproj @@ -2,9 +2,11 @@ netcoreapp2.2 - capnpc_csharp.Tests + CapnpC.CSharp.Generator.Tests false + + Debug;Release @@ -16,17 +18,18 @@ - - - - + + + - + + + @@ -34,9 +37,13 @@ + + + + @@ -47,11 +54,16 @@ + + + + SpecFlowSingleFileGenerator CodeGenerator.feature.cs + diff --git a/CapnpC.CSharp.Generator.Tests/CapnpMessageUnitTests.cs b/CapnpC.CSharp.Generator.Tests/CapnpMessageUnitTests.cs new file mode 100644 index 0000000..ce21560 --- /dev/null +++ b/CapnpC.CSharp.Generator.Tests/CapnpMessageUnitTests.cs @@ -0,0 +1,107 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Text; + +namespace CapnpC.CSharp.Generator.Tests +{ + [TestClass] + public class CapnpMessageUnitTests + { + [TestMethod] + public void ParseError() + { + var msg = new CapnpMessage(@"f:\code\invalid.capnp:5:1: error: Parse error."); + Assert.AreEqual(@"f:\code\invalid.capnp:5:1: error: Parse error.", msg.FullMessage); + Assert.IsTrue(msg.IsParseSuccess); + Assert.AreEqual(@"f:\code\invalid.capnp", msg.FileName); + Assert.AreEqual(5, msg.Line); + Assert.AreEqual(1, msg.Column); + Assert.AreEqual(0, msg.EndColumn); + Assert.AreEqual("error", msg.Category); + Assert.AreEqual("Parse error.", msg.MessageText); + } + + [TestMethod] + public void ColumnSpan() + { + var msg = new CapnpMessage(@"f:\code\invalid.capnp:10:7-8: error: Duplicate ordinal number."); + Assert.IsTrue(msg.IsParseSuccess); + Assert.AreEqual(@"f:\code\invalid.capnp", msg.FileName); + Assert.AreEqual(10, msg.Line); + Assert.AreEqual(7, msg.Column); + Assert.AreEqual(8, msg.EndColumn); + Assert.AreEqual("error", msg.Category); + Assert.AreEqual("Duplicate ordinal number.", msg.MessageText); + } + + [TestMethod] + public void NoSuchFile() + { + var msg = new CapnpMessage(@"C:\ProgramData\chocolatey\lib\capnproto\tools\capnproto-tools-win32-0.7.0\capnp.exe compile: doesnotexist.capnp: no such file"); + Assert.IsFalse(msg.IsParseSuccess); + Assert.AreEqual(@"C:\ProgramData\chocolatey\lib\capnproto\tools\capnproto-tools-win32-0.7.0\capnp.exe compile: doesnotexist.capnp: no such file", msg.FullMessage); + } + + [TestMethod] + public void NoId() + { + var msg = new CapnpMessage(@"empty.capnp:1:1: error: File does not declare an ID. I've generated one for you. Add this line to your file: @0xc82955a0c779197d;"); + Assert.IsTrue(msg.IsParseSuccess); + Assert.AreEqual("empty.capnp", msg.FileName); + Assert.AreEqual(1, msg.Line); + Assert.AreEqual(1, msg.Column); + Assert.AreEqual("error", msg.Category); + Assert.AreEqual("File does not declare an ID. I've generated one for you. Add this line to your file: @0xc82955a0c779197d;", msg.MessageText); + } + + [TestMethod] + public void AnnoyingNTFSAlternateDataStream1() + { + var msg = new CapnpMessage(@"3:2:1:1: error: File does not declare an ID. I've generated one for you. Add this line to your file: @0xc82955a0c779197d;"); + Assert.IsTrue(msg.IsParseSuccess); + Assert.AreEqual("3:2", msg.FileName); + Assert.AreEqual(1, msg.Line); + Assert.AreEqual(1, msg.Column); + Assert.AreEqual("error", msg.Category); + Assert.AreEqual("File does not declare an ID. I've generated one for you. Add this line to your file: @0xc82955a0c779197d;", msg.MessageText); + } + + [TestMethod] + public void AnnoyingNTFSAlternateDataStream2() + { + var msg = new CapnpMessage(@"c:\3:2:1:1: error: File does not declare an ID. I've generated one for you. Add this line to your file: @0xc82955a0c779197d;"); + Assert.IsTrue(msg.IsParseSuccess); + Assert.AreEqual(@"c:\3:2", msg.FileName); + Assert.AreEqual(1, msg.Line); + Assert.AreEqual(1, msg.Column); + Assert.AreEqual("error", msg.Category); + Assert.AreEqual("File does not declare an ID. I've generated one for you. Add this line to your file: @0xc82955a0c779197d;", msg.MessageText); + } + + [TestMethod] + public void AnnoyingNTFSAlternateDataStream3() + { + var msg = new CapnpMessage(@"\\?\c:\3:2:1:1: error: File does not declare an ID. I've generated one for you. Add this line to your file: @0xc82955a0c779197d;"); + Assert.IsTrue(msg.IsParseSuccess); + Assert.AreEqual(@"\\?\c:\3:2", msg.FileName); + Assert.AreEqual(1, msg.Line); + Assert.AreEqual(1, msg.Column); + Assert.AreEqual("error", msg.Category); + Assert.AreEqual("File does not declare an ID. I've generated one for you. Add this line to your file: @0xc82955a0c779197d;", msg.MessageText); + } + + [TestMethod] + public void AnnoyingNTFSAlternateDataStream4() + { + var msg = new CapnpMessage(@"1:2-3:10:7-8: error: Duplicate ordinal number."); + Assert.IsTrue(msg.IsParseSuccess); + Assert.AreEqual(@"1:2-3", msg.FileName); + Assert.AreEqual(10, msg.Line); + Assert.AreEqual(7, msg.Column); + Assert.AreEqual(8, msg.EndColumn); + Assert.AreEqual("error", msg.Category); + Assert.AreEqual("Duplicate ordinal number.", msg.MessageText); + } + } +} diff --git a/CapnpC.CSharp.Generator.Tests/CodeGenerator.feature b/CapnpC.CSharp.Generator.Tests/CodeGenerator.feature new file mode 100644 index 0000000..239fd3d --- /dev/null +++ b/CapnpC.CSharp.Generator.Tests/CodeGenerator.feature @@ -0,0 +1,48 @@ +Feature: CodeGenerator + In order to ensure that the generator backend produces valid output + As a contributor + I want to get notified when there is any deviation from reference output + +Scenario: Comparing backend output with reference + Given I have a binary code generator request "test.capnp.bin" + And my reference output is "test.cs" + When I invoke capnpc-csharp + Then the generated output must match the reference + +Scenario Outline: Invalid binary code generator requests + Given I have a binary code generator request + When I invoke capnpc-csharp + Then the invocation must fail + +Examples: + | bin | + | null.bin | + | test.cs | + +Scenario: Combining frontend and backend + Given capnp.exe is installed on my system + And I have a schema "UnitTest1.capnp" + When I try to generate code from that schema + Then code generation must succeed + +Scenario: Missing frontend + Given capnp.exe is not installed on my system + And I have a schema "UnitTest1.capnp" + When I try to generate code from that schema + Then the invocation must fail + +Scenario: Schema without ID + Given capnp.exe is installed on my system + And I have a schema "Empty1.capnp" + When I try to generate code from that schema + Then the invocation must fail + And the reason must be bad input + And the error output must contain "File does not declare an ID" + +Scenario: Multiple errors + Given capnp.exe is installed on my system + And I have a schema "invalid.capnp" + When I try to generate code from that schema + Then the invocation must fail + And the reason must be bad input + And the error output must contain multiple messages diff --git a/capnpc-csharp.tests/CodeGenerator.feature.cs b/CapnpC.CSharp.Generator.Tests/CodeGenerator.feature.cs similarity index 57% rename from capnpc-csharp.tests/CodeGenerator.feature.cs rename to CapnpC.CSharp.Generator.Tests/CodeGenerator.feature.cs index 74bf043..c01b9e3 100644 --- a/capnpc-csharp.tests/CodeGenerator.feature.cs +++ b/CapnpC.CSharp.Generator.Tests/CodeGenerator.feature.cs @@ -10,7 +10,7 @@ // ------------------------------------------------------------------------------ #region Designer generated code #pragma warning disable -namespace capnpc_csharp.Tests +namespace CapnpC.CSharp.Generator.Tests { using TechTalk.SpecFlow; @@ -63,7 +63,7 @@ namespace capnpc_csharp.Tests if (((testRunner.FeatureContext != null) && (testRunner.FeatureContext.FeatureInfo.Title != "CodeGenerator"))) { - global::capnpc_csharp.Tests.CodeGeneratorFeature.FeatureSetup(null); + global::CapnpC.CSharp.Generator.Tests.CodeGeneratorFeature.FeatureSetup(null); } } @@ -149,6 +149,98 @@ this.InvalidBinaryCodeGeneratorRequests("null.bin", ((string[])(null))); this.InvalidBinaryCodeGeneratorRequests("test.cs", ((string[])(null))); #line hidden } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Combining frontend and backend")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "CodeGenerator")] + public virtual void CombiningFrontendAndBackend() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Combining frontend and backend", null, ((string[])(null))); +#line 22 +this.ScenarioInitialize(scenarioInfo); + this.ScenarioStart(); +#line 23 + testRunner.Given("capnp.exe is installed on my system", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 24 + testRunner.And("I have a schema \"UnitTest1.capnp\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 25 + testRunner.When("I try to generate code from that schema", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 26 + testRunner.Then("code generation must succeed", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Missing frontend")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "CodeGenerator")] + public virtual void MissingFrontend() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Missing frontend", null, ((string[])(null))); +#line 28 +this.ScenarioInitialize(scenarioInfo); + this.ScenarioStart(); +#line 29 + testRunner.Given("capnp.exe is not installed on my system", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 30 + testRunner.And("I have a schema \"UnitTest1.capnp\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 31 + testRunner.When("I try to generate code from that schema", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 32 + testRunner.Then("the invocation must fail", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line hidden + this.ScenarioCleanup(); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Schema without ID")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "CodeGenerator")] + public virtual void SchemaWithoutID() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Schema without ID", null, ((string[])(null))); +#line 34 +this.ScenarioInitialize(scenarioInfo); + this.ScenarioStart(); +#line 35 + testRunner.Given("capnp.exe is installed on my system", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 36 + testRunner.And("I have a schema \"Empty1.capnp\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 37 + testRunner.When("I try to generate code from that schema", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 38 + testRunner.Then("the invocation must fail", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 39 + testRunner.And("the reason must be bad input", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 40 + testRunner.And("the error output must contain \"File does not declare an ID\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + this.ScenarioCleanup(); + } + + [Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute()] + [Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute("Multiple errors")] + [Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute("FeatureTitle", "CodeGenerator")] + public virtual void MultipleErrors() + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Multiple errors", null, ((string[])(null))); +#line 42 +this.ScenarioInitialize(scenarioInfo); + this.ScenarioStart(); +#line 43 + testRunner.Given("capnp.exe is installed on my system", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given "); +#line 44 + testRunner.And("I have a schema \"invalid.capnp\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 45 + testRunner.When("I try to generate code from that schema", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When "); +#line 46 + testRunner.Then("the invocation must fail", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then "); +#line 47 + testRunner.And("the reason must be bad input", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line 48 + testRunner.And("the error output must contain multiple messages", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And "); +#line hidden + this.ScenarioCleanup(); + } } } #pragma warning restore diff --git a/capnpc-csharp.tests/UnitTests.cs b/CapnpC.CSharp.Generator.Tests/CodeGeneratorUnitTests.cs similarity index 92% rename from capnpc-csharp.tests/UnitTests.cs rename to CapnpC.CSharp.Generator.Tests/CodeGeneratorUnitTests.cs index e2b80d5..bfec1b7 100644 --- a/capnpc-csharp.tests/UnitTests.cs +++ b/CapnpC.CSharp.Generator.Tests/CodeGeneratorUnitTests.cs @@ -1,13 +1,13 @@ using Capnp; -using Model = CapnpC.Model; -using Generator = CapnpC.Generator; -using CodeGeneratorRequest = CapnpC.Schema.CodeGeneratorRequest; +using Model = CapnpC.CSharp.Generator.Model; +using CodeGen = CapnpC.CSharp.Generator.CodeGen; +using CodeGeneratorRequest = CapnpC.CSharp.Generator.Schema.CodeGeneratorRequest; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq; -namespace capnpc_csharp.Tests +namespace CapnpC.CSharp.Generator.Tests { [TestClass] public class CodeGeneratorUnitTests @@ -98,13 +98,13 @@ namespace capnpc_csharp.Tests struct Run { public Model.SchemaModel Model; - public Generator.CodeGenerator CodeGen; + public CodeGen.CodeGenerator CodeGen; public Model.GenFile FirstFile; public string Code; } - static Generator.CodeGenerator NewGeneratorFor(Model.SchemaModel model) - => new Generator.CodeGenerator(model, new Generator.GeneratorOptions()); + static CodeGen.CodeGenerator NewGeneratorFor(Model.SchemaModel model) + => new CodeGen.CodeGenerator(model, new CodeGen.GeneratorOptions()); Run LoadAndGenerate(string inputName, int? testNum = null) { diff --git a/CapnpC.CSharp.Generator.Tests/Embedded Resources/Empty.capnp b/CapnpC.CSharp.Generator.Tests/Embedded Resources/Empty.capnp new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/CapnpC.CSharp.Generator.Tests/Embedded Resources/Empty.capnp @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/CapnpC.CSharp.Generator.Tests/Embedded Resources/Empty1.capnp b/CapnpC.CSharp.Generator.Tests/Embedded Resources/Empty1.capnp new file mode 100644 index 0000000..e02abfc --- /dev/null +++ b/CapnpC.CSharp.Generator.Tests/Embedded Resources/Empty1.capnp @@ -0,0 +1 @@ + diff --git a/capnpc-csharp.tests/No Resources/UnitTest1.capnp b/CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest1.capnp similarity index 100% rename from capnpc-csharp.tests/No Resources/UnitTest1.capnp rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest1.capnp diff --git a/capnpc-csharp.tests/Embedded Resources/UnitTest1.capnp.bin b/CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest1.capnp.bin similarity index 100% rename from capnpc-csharp.tests/Embedded Resources/UnitTest1.capnp.bin rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest1.capnp.bin diff --git a/capnpc-csharp.tests/Embedded Resources/UnitTest10.capnp.bin b/CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest10.capnp.bin similarity index 100% rename from capnpc-csharp.tests/Embedded Resources/UnitTest10.capnp.bin rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest10.capnp.bin diff --git a/capnpc-csharp.tests/Embedded Resources/UnitTest11.capnp.bin b/CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest11.capnp.bin similarity index 100% rename from capnpc-csharp.tests/Embedded Resources/UnitTest11.capnp.bin rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest11.capnp.bin diff --git a/capnpc-csharp.tests/Embedded Resources/UnitTest2.capnp.bin b/CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest2.capnp.bin similarity index 100% rename from capnpc-csharp.tests/Embedded Resources/UnitTest2.capnp.bin rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest2.capnp.bin diff --git a/capnpc-csharp.tests/Embedded Resources/UnitTest20.capnp.bin b/CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest20.capnp.bin similarity index 100% rename from capnpc-csharp.tests/Embedded Resources/UnitTest20.capnp.bin rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest20.capnp.bin diff --git a/capnpc-csharp.tests/Embedded Resources/UnitTest3.capnp.bin b/CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest3.capnp.bin similarity index 100% rename from capnpc-csharp.tests/Embedded Resources/UnitTest3.capnp.bin rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest3.capnp.bin diff --git a/capnpc-csharp.tests/Embedded Resources/UnitTest4.capnp.bin b/CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest4.capnp.bin similarity index 100% rename from capnpc-csharp.tests/Embedded Resources/UnitTest4.capnp.bin rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/UnitTest4.capnp.bin diff --git a/CapnpC.CSharp.Generator.Tests/Embedded Resources/invalid.capnp b/CapnpC.CSharp.Generator.Tests/Embedded Resources/invalid.capnp new file mode 100644 index 0000000..b56b978 --- /dev/null +++ b/CapnpC.CSharp.Generator.Tests/Embedded Resources/invalid.capnp @@ -0,0 +1,11 @@ +@0xa5ac546b7bf6fbbc + +enum Enumerant { + byte @0; + bit @1; +} + +struct Foo { + foo @0: UInt8; + bar @0: UInt8; +} diff --git a/capnpc-csharp.tests/Embedded Resources/null.bin b/CapnpC.CSharp.Generator.Tests/Embedded Resources/null.bin similarity index 100% rename from capnpc-csharp.tests/Embedded Resources/null.bin rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/null.bin diff --git a/capnpc-csharp.tests/Embedded Resources/schema-with-offsets.capnp.bin b/CapnpC.CSharp.Generator.Tests/Embedded Resources/schema-with-offsets.capnp.bin similarity index 100% rename from capnpc-csharp.tests/Embedded Resources/schema-with-offsets.capnp.bin rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/schema-with-offsets.capnp.bin diff --git a/capnpc-csharp.tests/Embedded Resources/test.capnp.bin b/CapnpC.CSharp.Generator.Tests/Embedded Resources/test.capnp.bin similarity index 100% rename from capnpc-csharp.tests/Embedded Resources/test.capnp.bin rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/test.capnp.bin diff --git a/capnpc-csharp.tests/Embedded Resources/test.cs b/CapnpC.CSharp.Generator.Tests/Embedded Resources/test.cs similarity index 100% rename from capnpc-csharp.tests/Embedded Resources/test.cs rename to CapnpC.CSharp.Generator.Tests/Embedded Resources/test.cs diff --git a/CapnpC.CSharp.Generator.Tests/FeatureSteps/CodeGeneratorSteps.cs b/CapnpC.CSharp.Generator.Tests/FeatureSteps/CodeGeneratorSteps.cs new file mode 100644 index 0000000..83fc17a --- /dev/null +++ b/CapnpC.CSharp.Generator.Tests/FeatureSteps/CodeGeneratorSteps.cs @@ -0,0 +1,149 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using TechTalk.SpecFlow; + +namespace CapnpC.CSharp.Generator.Tests +{ + [Binding] + public class CodeGeneratorSteps + { + Stream _inputStream; + string _inputSchemaFileName; + string _inputSchema; + string _referenceOutputContent; + + GenerationResult _result; + + public static Stream LoadResource(string name) + { + var assembly = Assembly.GetExecutingAssembly(); + string[] names = assembly.GetManifestResourceNames(); + string urn = Array.Find(names, n => n.EndsWith(name, StringComparison.OrdinalIgnoreCase)); + Assert.IsNotNull(urn, $"Test specification error: {name} does not exist"); + return assembly.GetManifestResourceStream(urn); + } + + internal static bool IsCapnpExeInstalled() + { + using (var process = Process.Start("where", "capnp.exe")) + { + if (process == null) + Assert.Fail("Unable to start 'where'"); + + process.WaitForExit(); + + return process.ExitCode == 0; + } + } + + [Given(@"I have a binary code generator request ""(.*)""")] + [Given(@"I have a binary code generator request (.*)")] + public void GivenIHaveABinaryCodeGeneratorRequest(string binaryRequestFileName) + { + _inputStream = LoadResource(binaryRequestFileName); + } + + [Given(@"my reference output is ""(.*)""")] + public void GivenMyReferenceOutputIs(string expectedOutputFileName) + { + using (var stream = LoadResource(expectedOutputFileName)) + using (var reader = new StreamReader(stream)) + { + _referenceOutputContent = reader.ReadToEnd(); + } + } + + [When(@"I invoke capnpc-csharp")] + public void WhenIInvokeCapnpc_Csharp() + { + using (_inputStream) + { + _result = CapnpCompilation.GenerateFromStream(_inputStream); + } + } + + [Then(@"the generated output must match the reference")] + public void ThenTheGeneratedOutputMustMatchTheReference() + { + Assert.IsTrue(_result.IsSuccess, $"Tool invocation failed: {_result.Exception?.Message}"); + Assert.AreEqual(_referenceOutputContent, _result.GeneratedFiles.Single().GeneratedContent); + } + + [Then(@"the invocation must fail")] + public void ThenTheInvocationMustFail() + { + Assert.IsFalse(_result.IsSuccess, "Tool invocation was supposed to fail, but it didn't"); + Assert.IsNotNull(_result.Exception, "Expected an exception"); + } + + [Given(@"capnp\.exe is installed on my system")] + public void GivenCapnp_ExeIsInstalledOnMySystem() + { + if (!IsCapnpExeInstalled()) + { + Assert.Inconclusive("capnp.exe not found. Precondition of this test is not met."); + } + } + + [Given(@"I have a schema ""(.*)""")] + public void GivenIHaveASchema(string capnpFileName) + { + _inputSchemaFileName = capnpFileName; + + using (var stream = LoadResource(capnpFileName)) + using (var reader = new StreamReader(stream)) + { + _inputSchema = reader.ReadToEnd(); + } + } + + [When(@"I try to generate code from that schema")] + public void WhenIWantToGenerateCodeFromThatSchema() + { + string path = Path.Combine(Path.GetTempPath(), _inputSchemaFileName); + File.WriteAllText(path, _inputSchema); + _result = CapnpCompilation.InvokeCapnpAndGenerate(new string[] { path }); + } + + [Then(@"code generation must succeed")] + public void ThenCodeGenerationMustSucceed() + { + Assert.IsNotNull(_result, "expected generation result"); + Assert.IsTrue(_result.IsSuccess, $"Tool invocation failed: {_result.Exception?.Message}"); + Assert.IsTrue(_result.GeneratedFiles.Count == 1, "Expected exactly one file"); + Assert.IsTrue(_result.GeneratedFiles[0].IsSuccess, $"Code generation failed: {_result.GeneratedFiles[0].Exception?.Message}"); + Assert.IsFalse(string.IsNullOrEmpty(_result.GeneratedFiles[0].GeneratedContent), "Expected non-empty generated content"); + } + + [Given(@"capnp\.exe is not installed on my system")] + public void GivenCapnp_ExeIsNotInstalledOnMySystem() + { + if (IsCapnpExeInstalled()) + { + Assert.Inconclusive("capnp.exe found. Precondition of this test is not met."); + } + } + + [Then(@"the reason must be bad input")] + public void ThenTheReasonMustBeBadInput() + { + Assert.IsTrue(_result.ErrorCategory == CapnpProcessFailure.BadInput); + } + + [Then(@"the error output must contain ""(.*)""")] + public void ThenTheErrorOutputMustContain(string p0) + { + Assert.IsTrue(_result.Messages.Any(m => m.FullMessage.Contains(p0))); + } + + [Then(@"the error output must contain multiple messages")] + public void ThenTheErrorOutputMustContainMultipleMessages() + { + Assert.IsTrue(_result.Messages.Count >= 2); + } + } +} diff --git a/capnpc-csharp.tests/No Resources/UnitTest10.capnp b/CapnpC.CSharp.Generator.Tests/No Resources/UnitTest10.capnp similarity index 100% rename from capnpc-csharp.tests/No Resources/UnitTest10.capnp rename to CapnpC.CSharp.Generator.Tests/No Resources/UnitTest10.capnp diff --git a/capnpc-csharp.tests/No Resources/UnitTest10b.capnp b/CapnpC.CSharp.Generator.Tests/No Resources/UnitTest10b.capnp similarity index 100% rename from capnpc-csharp.tests/No Resources/UnitTest10b.capnp rename to CapnpC.CSharp.Generator.Tests/No Resources/UnitTest10b.capnp diff --git a/capnpc-csharp.tests/No Resources/UnitTest11.capnp b/CapnpC.CSharp.Generator.Tests/No Resources/UnitTest11.capnp similarity index 100% rename from capnpc-csharp.tests/No Resources/UnitTest11.capnp rename to CapnpC.CSharp.Generator.Tests/No Resources/UnitTest11.capnp diff --git a/capnpc-csharp.tests/No Resources/UnitTest11b.capnp b/CapnpC.CSharp.Generator.Tests/No Resources/UnitTest11b.capnp similarity index 100% rename from capnpc-csharp.tests/No Resources/UnitTest11b.capnp rename to CapnpC.CSharp.Generator.Tests/No Resources/UnitTest11b.capnp diff --git a/capnpc-csharp.tests/No Resources/UnitTest2.capnp b/CapnpC.CSharp.Generator.Tests/No Resources/UnitTest2.capnp similarity index 100% rename from capnpc-csharp.tests/No Resources/UnitTest2.capnp rename to CapnpC.CSharp.Generator.Tests/No Resources/UnitTest2.capnp diff --git a/capnpc-csharp.tests/No Resources/UnitTest20.capnp b/CapnpC.CSharp.Generator.Tests/No Resources/UnitTest20.capnp similarity index 100% rename from capnpc-csharp.tests/No Resources/UnitTest20.capnp rename to CapnpC.CSharp.Generator.Tests/No Resources/UnitTest20.capnp diff --git a/capnpc-csharp.tests/No Resources/UnitTest3.capnp b/CapnpC.CSharp.Generator.Tests/No Resources/UnitTest3.capnp similarity index 100% rename from capnpc-csharp.tests/No Resources/UnitTest3.capnp rename to CapnpC.CSharp.Generator.Tests/No Resources/UnitTest3.capnp diff --git a/capnpc-csharp.tests/No Resources/UnitTest4.capnp b/CapnpC.CSharp.Generator.Tests/No Resources/UnitTest4.capnp similarity index 100% rename from capnpc-csharp.tests/No Resources/UnitTest4.capnp rename to CapnpC.CSharp.Generator.Tests/No Resources/UnitTest4.capnp diff --git a/capnpc-csharp.tests/No Resources/UnitTest4b.capnp b/CapnpC.CSharp.Generator.Tests/No Resources/UnitTest4b.capnp similarity index 100% rename from capnpc-csharp.tests/No Resources/UnitTest4b.capnp rename to CapnpC.CSharp.Generator.Tests/No Resources/UnitTest4b.capnp diff --git a/capnpc-csharp.tests/No Resources/test.capnp b/CapnpC.CSharp.Generator.Tests/No Resources/test.capnp similarity index 100% rename from capnpc-csharp.tests/No Resources/test.capnp rename to CapnpC.CSharp.Generator.Tests/No Resources/test.capnp diff --git a/CapnpC.CSharp.Generator/CapnpC.CSharp.Generator.csproj b/CapnpC.CSharp.Generator/CapnpC.CSharp.Generator.csproj new file mode 100644 index 0000000..e752fdf --- /dev/null +++ b/CapnpC.CSharp.Generator/CapnpC.CSharp.Generator.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0;netcoreapp2.1 + Debug;Release + + + + + + + + + + + diff --git a/CapnpC.CSharp.Generator/CapnpCompilation.cs b/CapnpC.CSharp.Generator/CapnpCompilation.cs new file mode 100644 index 0000000..3c01261 --- /dev/null +++ b/CapnpC.CSharp.Generator/CapnpCompilation.cs @@ -0,0 +1,111 @@ +using Capnp; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; + +[assembly: InternalsVisibleTo("CapnpC.CSharp.Generator.Tests")] + +namespace CapnpC.CSharp.Generator +{ + /// + /// Provides methods for controlling both the C# code generator backend and the frontend "capnpc" + /// + public static class CapnpCompilation + { + /// + /// Generates C# code from given input stream + /// + /// input stream containing the binary code generation request, which the frontend capnpc emits + /// generation result + /// if is null + public static GenerationResult GenerateFromStream(Stream input) + { + if (input == null) + throw new ArgumentNullException(nameof(input)); + + try + { + var segments = Framing.ReadSegments(input); + var dec = DeserializerState.CreateRoot(segments); + var reader = Schema.CodeGeneratorRequest.Reader.Create(dec); + var model = Model.SchemaModel.Create(reader); + var codeGen = new CodeGen.CodeGenerator(model, new CodeGen.GeneratorOptions()); + return new GenerationResult(codeGen.Generate()); + } + catch (Exception exception) + { + return new GenerationResult(exception); + } + } + + /// + /// Invokes "capnp.exe -o-" with given additional arguments and redirects the output to the C# generator backend. + /// + /// additional command line arguments + /// optional working directory + /// generation result + /// is null + public static GenerationResult InvokeCapnpAndGenerate(IEnumerable arguments, string workingDirectory = null) + { + if (arguments == null) + throw new ArgumentNullException(nameof(arguments)); + + using (var compiler = new Process()) + { + var argList = new List(); + argList.Add("compile"); + argList.Add($"-o-"); + argList.AddRange(arguments); + + compiler.StartInfo.FileName = "capnp.exe"; + compiler.StartInfo.Arguments = string.Join(" ", argList); + compiler.StartInfo.UseShellExecute = false; + compiler.StartInfo.RedirectStandardOutput = true; + compiler.StartInfo.RedirectStandardError = true; + if (!string.IsNullOrWhiteSpace(workingDirectory)) + { + compiler.StartInfo.WorkingDirectory = workingDirectory; + } + + try + { + compiler.Start(); + } + catch (Exception exception) + { + return new GenerationResult(exception) + { + ErrorCategory = CapnpProcessFailure.NotFound + }; + } + + var result = GenerateFromStream(compiler.StandardOutput.BaseStream); + + var messageList = new List(); + + while (!compiler.StandardError.EndOfStream) + { + messageList.Add(new CapnpMessage(compiler.StandardError.ReadLine())); + } + + result.Messages = messageList; + + if (!result.IsSuccess) + { + compiler.WaitForExit(); + int exitCode = compiler.ExitCode; + + if (exitCode == 0) + result.ErrorCategory = CapnpProcessFailure.BadOutput; + else + result.ErrorCategory = CapnpProcessFailure.BadInput; + } + + return result; + } + } + } +} diff --git a/CapnpC.CSharp.Generator/CapnpMessage.cs b/CapnpC.CSharp.Generator/CapnpMessage.cs new file mode 100644 index 0000000..0cc60b8 --- /dev/null +++ b/CapnpC.CSharp.Generator/CapnpMessage.cs @@ -0,0 +1,116 @@ +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; + +[assembly: InternalsVisibleTo("CapnpC.CSharp.Generator.Tests")] + +namespace CapnpC.CSharp.Generator +{ + /// + /// Represents a capnp.exe output message + /// + public class CapnpMessage + { + // capnp outputs look like this: + // empty.capnp:1:1: error: File does not declare an ID. I've generated one for you. Add this line to your file: @0xc82955a0c779197d; + // f:\code\invalid.capnp:9:7-8: error: Ordinal @0 originally used here. + // Parsing them is harder than it seems because the colon may be part of the file name (as in the example above). + // And it becomes even worse! NTFS has a rarely used feature called "alternate data streams", identified by a colon: + // f:\code\somefile:stream.capnp:9:7-8: error: Ordinal @0 originally used here. + // What about a name which looks like a line number? (Hint: the 10 denotes the alternate data stream) + // f:\code\somefile:10:9:7-8: error: Ordinal @0 originally used here. + // Watching for the *last* colon as message separator does not work either, either. See first example. + // Strategy: Watch out for the *last* occurence of pattern :[line]:[column] + + static readonly Regex LineColumnRegex = new Regex(@":(?\d+):(?\d+)(-(?\d+))?:", RegexOptions.Compiled | RegexOptions.RightToLeft); + + /// + /// Constructs an instance from given message + /// + /// output message (one line) + public CapnpMessage(string fullMessage) + { + FullMessage = fullMessage; + + var match = LineColumnRegex.Match(fullMessage); + + if (match.Success) + { + IsParseSuccess = true; + FileName = fullMessage.Substring(0, match.Index); + var lineMatch = match.Groups["Line"]; + if (lineMatch.Success) + { + int.TryParse(lineMatch.Value, out int value); + Line = value; + } + var columnMatch = match.Groups["Column"]; + if (columnMatch.Success) + { + int.TryParse(columnMatch.Value, out int value); + Column = value; + } + var endColumnMatch = match.Groups["EndColumn"]; + if (endColumnMatch.Success) + { + int.TryParse(endColumnMatch.Value, out int value); + EndColumn = value; + } + + int restIndex = match.Index + match.Length; + int bodyIndex = fullMessage.IndexOf(':', restIndex); + + if (bodyIndex >= 0) + { + Category = fullMessage.Substring(restIndex, bodyIndex - restIndex).Trim(); + MessageText = fullMessage.Substring(bodyIndex + 1).Trim(); + } + else + { + // Never observed "in the wild", just in case... + Category = string.Empty; + MessageText = fullMessage.Substring(restIndex).Trim(); + } + } + } + + /// + /// The original message + /// + public string FullMessage { get; } + + /// + /// Whether the message could be decompsed into [filename]:[line]:[column]: [category]: [text] + /// + public bool IsParseSuccess { get; } + + /// + /// Parsed file name (null iff not IsParseSuccess) + /// + public string FileName { get; } + + /// + /// Parsed line (0 if not IsParseSuccess) + /// + public int Line { get; } + + /// + /// Parsed column (0 if not IsParseSuccess) + /// + public int Column { get; } + + /// + /// Parsed end column (0 if there is none) + /// + public int EndColumn { get; } + + /// + /// Parsed category (e.g. "error", null iff not IsParseSuccess) + /// + public string Category { get; } + + /// + /// Parsed message body text (0 if not IsParseSuccess) + /// + public string MessageText { get; } + } +} diff --git a/CapnpC.CSharp.Generator/CapnpProcessFailure.cs b/CapnpC.CSharp.Generator/CapnpProcessFailure.cs new file mode 100644 index 0000000..1d51c0f --- /dev/null +++ b/CapnpC.CSharp.Generator/CapnpProcessFailure.cs @@ -0,0 +1,23 @@ +namespace CapnpC.CSharp.Generator +{ + /// + /// Why did invocation of capnpc.exe fail? + /// + public enum CapnpProcessFailure + { + /// + /// Because capnpc.exe was not found. It is probably not installed. + /// + NotFound, + + /// + /// Because it exited with an error. Probably invalid .capnp file input. + /// + BadInput, + + /// + /// Because it produced an apparently bad code generation request. + /// + BadOutput + } +} diff --git a/capnpc-csharp/Generator/CodeGenerator.cs b/CapnpC.CSharp.Generator/CodeGen/CodeGenerator.cs similarity index 91% rename from capnpc-csharp/Generator/CodeGenerator.cs rename to CapnpC.CSharp.Generator/CodeGen/CodeGenerator.cs index e401b3a..d873108 100644 --- a/capnpc-csharp/Generator/CodeGenerator.cs +++ b/CapnpC.CSharp.Generator/CodeGen/CodeGenerator.cs @@ -1,18 +1,17 @@ -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { using System; using System.Collections.Generic; using System.IO; using System.Linq; - using System.Text; - using CapnpC.Model; + using CapnpC.CSharp.Generator.Model; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; using static SyntaxHelpers; - class CodeGenerator + internal class CodeGenerator { readonly SchemaModel _model; readonly GenNames _names; @@ -169,14 +168,23 @@ return cu.NormalizeWhitespace().ToFullString(); } - public void Generate() + public IReadOnlyList Generate() { + var result = new List(); + foreach (var file in _model.FilesToGenerate) { - string content = Transform(file); - string path = Path.ChangeExtension(file.Name, ".cs"); - File.WriteAllText(path, content); + try + { + result.Add(new FileGenerationResult(file.Name, Transform(file))); + } + catch (System.Exception exception) + { + result.Add(new FileGenerationResult(file.Name, exception)); + } } + + return result; } } } diff --git a/capnpc-csharp/Generator/CommonSnippetGen.cs b/CapnpC.CSharp.Generator/CodeGen/CommonSnippetGen.cs similarity index 94% rename from capnpc-csharp/Generator/CommonSnippetGen.cs rename to CapnpC.CSharp.Generator/CodeGen/CommonSnippetGen.cs index 2e1797d..d89b873 100644 --- a/capnpc-csharp/Generator/CommonSnippetGen.cs +++ b/CapnpC.CSharp.Generator/CodeGen/CommonSnippetGen.cs @@ -1,15 +1,13 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; -using CapnpC.Model; +using CapnpC.CSharp.Generator.Model; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; -using static CapnpC.Generator.SyntaxHelpers; +using static CapnpC.CSharp.Generator.CodeGen.SyntaxHelpers; -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { class CommonSnippetGen { diff --git a/capnpc-csharp/Generator/DomainClassSnippetGen.cs b/CapnpC.CSharp.Generator/CodeGen/DomainClassSnippetGen.cs similarity index 99% rename from capnpc-csharp/Generator/DomainClassSnippetGen.cs rename to CapnpC.CSharp.Generator/CodeGen/DomainClassSnippetGen.cs index 5b27495..fb41086 100644 --- a/capnpc-csharp/Generator/DomainClassSnippetGen.cs +++ b/CapnpC.CSharp.Generator/CodeGen/DomainClassSnippetGen.cs @@ -1,15 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using CapnpC.Model; -using Microsoft.CodeAnalysis; +using CapnpC.CSharp.Generator.Model; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; -using static CapnpC.Generator.SyntaxHelpers; +using static CapnpC.CSharp.Generator.CodeGen.SyntaxHelpers; -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { class DomainClassSnippetGen { diff --git a/capnpc-csharp/Generator/GenNames.cs b/CapnpC.CSharp.Generator/CodeGen/GenNames.cs similarity index 99% rename from capnpc-csharp/Generator/GenNames.cs rename to CapnpC.CSharp.Generator/CodeGen/GenNames.cs index f842413..b9282ab 100644 --- a/capnpc-csharp/Generator/GenNames.cs +++ b/CapnpC.CSharp.Generator/CodeGen/GenNames.cs @@ -1,13 +1,12 @@ -using CapnpC.Model; +using CapnpC.CSharp.Generator.Model; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using System; using System.Collections.Generic; using System.Linq; -using System.Text; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { enum NameUsage { diff --git a/capnpc-csharp/Generator/GeneratorOptions.cs b/CapnpC.CSharp.Generator/CodeGen/GeneratorOptions.cs similarity index 95% rename from capnpc-csharp/Generator/GeneratorOptions.cs rename to CapnpC.CSharp.Generator/CodeGen/GeneratorOptions.cs index 76faf93..e534f2b 100644 --- a/capnpc-csharp/Generator/GeneratorOptions.cs +++ b/CapnpC.CSharp.Generator/CodeGen/GeneratorOptions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { class GeneratorOptions { diff --git a/capnpc-csharp/Generator/InterfaceSnippetGen.cs b/CapnpC.CSharp.Generator/CodeGen/InterfaceSnippetGen.cs similarity index 99% rename from capnpc-csharp/Generator/InterfaceSnippetGen.cs rename to CapnpC.CSharp.Generator/CodeGen/InterfaceSnippetGen.cs index f0adfaa..11d6d36 100644 --- a/capnpc-csharp/Generator/InterfaceSnippetGen.cs +++ b/CapnpC.CSharp.Generator/CodeGen/InterfaceSnippetGen.cs @@ -1,16 +1,15 @@ -using CapnpC.Model; +using CapnpC.CSharp.Generator.Model; using System; using System.Collections.Generic; using System.Linq; -using System.Text; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; -using static CapnpC.Generator.SyntaxHelpers; +using static CapnpC.CSharp.Generator.CodeGen.SyntaxHelpers; using Microsoft.CodeAnalysis.CSharp.Syntax; using System.Threading.Tasks; using System.Threading; using Microsoft.CodeAnalysis.CSharp; -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { class InterfaceSnippetGen { diff --git a/capnpc-csharp/Generator/Name.cs b/CapnpC.CSharp.Generator/CodeGen/Name.cs similarity index 92% rename from capnpc-csharp/Generator/Name.cs rename to CapnpC.CSharp.Generator/CodeGen/Name.cs index f85f324..5b8e877 100644 --- a/capnpc-csharp/Generator/Name.cs +++ b/CapnpC.CSharp.Generator/CodeGen/Name.cs @@ -2,10 +2,8 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using System; -using System.Collections.Generic; -using System.Text; -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { class Name { diff --git a/capnpc-csharp/Generator/ReaderSnippetGen.cs b/CapnpC.CSharp.Generator/CodeGen/ReaderSnippetGen.cs similarity index 99% rename from capnpc-csharp/Generator/ReaderSnippetGen.cs rename to CapnpC.CSharp.Generator/CodeGen/ReaderSnippetGen.cs index 9d57038..869acf1 100644 --- a/capnpc-csharp/Generator/ReaderSnippetGen.cs +++ b/CapnpC.CSharp.Generator/CodeGen/ReaderSnippetGen.cs @@ -1,15 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using CapnpC.Model; -using Microsoft.CodeAnalysis; +using CapnpC.CSharp.Generator.Model; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; -using static CapnpC.Generator.SyntaxHelpers; +using static CapnpC.CSharp.Generator.CodeGen.SyntaxHelpers; -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { class ReaderSnippetGen { diff --git a/capnpc-csharp/Generator/SerializerStateWorder.cs b/CapnpC.CSharp.Generator/CodeGen/SerializerStateWorder.cs similarity index 75% rename from capnpc-csharp/Generator/SerializerStateWorder.cs rename to CapnpC.CSharp.Generator/CodeGen/SerializerStateWorder.cs index 8f64689..29cb72a 100644 --- a/capnpc-csharp/Generator/SerializerStateWorder.cs +++ b/CapnpC.CSharp.Generator/CodeGen/SerializerStateWorder.cs @@ -1,8 +1,6 @@ using Capnp; -using System.Collections.Generic; -using System.Text; -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { class SerializerStateWorder: SerializerState { diff --git a/capnpc-csharp/Generator/SkeletonWorder.cs b/CapnpC.CSharp.Generator/CodeGen/SkeletonWorder.cs similarity index 88% rename from capnpc-csharp/Generator/SkeletonWorder.cs rename to CapnpC.CSharp.Generator/CodeGen/SkeletonWorder.cs index 0d34191..703ee3b 100644 --- a/capnpc-csharp/Generator/SkeletonWorder.cs +++ b/CapnpC.CSharp.Generator/CodeGen/SkeletonWorder.cs @@ -1,6 +1,6 @@ using System; -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { class SkeletonWorder : Capnp.Rpc.Skeleton { diff --git a/capnpc-csharp/Generator/SyntaxHelpers.cs b/CapnpC.CSharp.Generator/CodeGen/SyntaxHelpers.cs similarity index 98% rename from capnpc-csharp/Generator/SyntaxHelpers.cs rename to CapnpC.CSharp.Generator/CodeGen/SyntaxHelpers.cs index 4d087ae..56f258e 100644 --- a/capnpc-csharp/Generator/SyntaxHelpers.cs +++ b/CapnpC.CSharp.Generator/CodeGen/SyntaxHelpers.cs @@ -1,13 +1,11 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { static class SyntaxHelpers { diff --git a/capnpc-csharp/Generator/WriterSnippetGen.cs b/CapnpC.CSharp.Generator/CodeGen/WriterSnippetGen.cs similarity index 98% rename from capnpc-csharp/Generator/WriterSnippetGen.cs rename to CapnpC.CSharp.Generator/CodeGen/WriterSnippetGen.cs index af62b09..262b8eb 100644 --- a/capnpc-csharp/Generator/WriterSnippetGen.cs +++ b/CapnpC.CSharp.Generator/CodeGen/WriterSnippetGen.cs @@ -1,15 +1,12 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; -using CapnpC.Model; -using Microsoft.CodeAnalysis; +using CapnpC.CSharp.Generator.Model; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; -using static CapnpC.Generator.SyntaxHelpers; +using static CapnpC.CSharp.Generator.CodeGen.SyntaxHelpers; -namespace CapnpC.Generator +namespace CapnpC.CSharp.Generator.CodeGen { class WriterSnippetGen { diff --git a/CapnpC.CSharp.Generator/FileGenerationResult.cs b/CapnpC.CSharp.Generator/FileGenerationResult.cs new file mode 100644 index 0000000..6d035e0 --- /dev/null +++ b/CapnpC.CSharp.Generator/FileGenerationResult.cs @@ -0,0 +1,52 @@ +using System; + +namespace CapnpC.CSharp.Generator +{ + /// + /// Represents the generation result of a single .capnp file + /// + public class FileGenerationResult + { + /// + /// Constructs an instance in case of successful generation + /// + /// path to .capnp file + /// generated C# code + public FileGenerationResult(string capnpFilePath, string generatedContent) + { + CapnpFilePath = capnpFilePath; + GeneratedContent = generatedContent; + } + + /// + /// Constructs an instance in case of unsuccessful generation + /// + /// path to .capnp file + /// Exception giving details on the error which prevented generation + public FileGenerationResult(string capnpFilePath, Exception exception) + { + CapnpFilePath = capnpFilePath; + Exception = exception; + } + + /// + /// Path to .capnp file + /// + public string CapnpFilePath { get; } + + /// + /// Generated C# or null if generation failed + /// + public string GeneratedContent { get; } + + /// + /// Exception giving details on the error which prevented generation + /// + public Exception Exception { get; } + + /// + /// true iff generation was successful + /// + public bool IsSuccess => !string.IsNullOrEmpty(GeneratedContent); + } +} diff --git a/CapnpC.CSharp.Generator/GenerationResult.cs b/CapnpC.CSharp.Generator/GenerationResult.cs new file mode 100644 index 0000000..672759a --- /dev/null +++ b/CapnpC.CSharp.Generator/GenerationResult.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; + +namespace CapnpC.CSharp.Generator +{ + /// + /// Represents a .capnp -> code generator result + /// + public class GenerationResult + { + /// + /// Constructs an instance in case of at least partially successful generation. + /// + /// Generation result per file to generate + public GenerationResult(IReadOnlyList generatedFiles) + { + GeneratedFiles = generatedFiles; + } + + /// + /// Constructs an instance in case of total failure. + /// + /// Exception with details on error + public GenerationResult(Exception exception) + { + Exception = exception; + } + + /// + /// Generation result per file to generate or null in case of total failure + /// + public IReadOnlyList GeneratedFiles { get; } + + /// + /// Exception with details on error or null in case of success + /// + public Exception Exception { get; } + + /// + /// true iff generation was successful + /// + public bool IsSuccess => GeneratedFiles != null; + + /// + /// Messages read from standard error. Valid for both failure and success (capnp might spit out some warnings). + /// + public IReadOnlyList Messages { get; internal set; } + + /// + /// Error classification (if any error) + /// + public CapnpProcessFailure ErrorCategory { get; internal set; } + } +} diff --git a/capnpc-csharp/Model/AbstractType.cs b/CapnpC.CSharp.Generator/Model/AbstractType.cs similarity index 96% rename from capnpc-csharp/Model/AbstractType.cs rename to CapnpC.CSharp.Generator/Model/AbstractType.cs index 2c1451a..6b6d4c7 100644 --- a/capnpc-csharp/Model/AbstractType.cs +++ b/CapnpC.CSharp.Generator/Model/AbstractType.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { abstract class AbstractType { diff --git a/capnpc-csharp/Model/Annotation.cs b/CapnpC.CSharp.Generator/Model/Annotation.cs similarity index 93% rename from capnpc-csharp/Model/Annotation.cs rename to CapnpC.CSharp.Generator/Model/Annotation.cs index 36191b6..8b5d40b 100644 --- a/capnpc-csharp/Model/Annotation.cs +++ b/CapnpC.CSharp.Generator/Model/Annotation.cs @@ -1,6 +1,6 @@ using System.Diagnostics; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class Annotation : IDefinition { diff --git a/capnpc-csharp/Model/Constant.cs b/CapnpC.CSharp.Generator/Model/Constant.cs similarity index 93% rename from capnpc-csharp/Model/Constant.cs rename to CapnpC.CSharp.Generator/Model/Constant.cs index 5879100..a01ac7d 100644 --- a/capnpc-csharp/Model/Constant.cs +++ b/CapnpC.CSharp.Generator/Model/Constant.cs @@ -1,6 +1,6 @@ using System.Diagnostics; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class Constant : IDefinition { diff --git a/capnpc-csharp/Model/DefinitionManager.cs b/CapnpC.CSharp.Generator/Model/DefinitionManager.cs similarity index 98% rename from capnpc-csharp/Model/DefinitionManager.cs rename to CapnpC.CSharp.Generator/Model/DefinitionManager.cs index 95b9183..bd638f7 100644 --- a/capnpc-csharp/Model/DefinitionManager.cs +++ b/CapnpC.CSharp.Generator/Model/DefinitionManager.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class DefinitionManager { diff --git a/capnpc-csharp/Model/Enumerant.cs b/CapnpC.CSharp.Generator/Model/Enumerant.cs similarity index 89% rename from capnpc-csharp/Model/Enumerant.cs rename to CapnpC.CSharp.Generator/Model/Enumerant.cs index 96d9137..4ba17f6 100644 --- a/capnpc-csharp/Model/Enumerant.cs +++ b/CapnpC.CSharp.Generator/Model/Enumerant.cs @@ -1,4 +1,4 @@ -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class Enumerant { diff --git a/capnpc-csharp/Model/Field.cs b/CapnpC.CSharp.Generator/Model/Field.cs similarity index 97% rename from capnpc-csharp/Model/Field.cs rename to CapnpC.CSharp.Generator/Model/Field.cs index eee384b..017112c 100644 --- a/capnpc-csharp/Model/Field.cs +++ b/CapnpC.CSharp.Generator/Model/Field.cs @@ -1,4 +1,4 @@ -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class Field { diff --git a/capnpc-csharp/Model/GenFile.cs b/CapnpC.CSharp.Generator/Model/GenFile.cs similarity index 95% rename from capnpc-csharp/Model/GenFile.cs rename to CapnpC.CSharp.Generator/Model/GenFile.cs index f889fce..217a760 100644 --- a/capnpc-csharp/Model/GenFile.cs +++ b/CapnpC.CSharp.Generator/Model/GenFile.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class GenFile: IDefinition, IHasNestedDefinitions { diff --git a/capnpc-csharp/Model/GenericParameter.cs b/CapnpC.CSharp.Generator/Model/GenericParameter.cs similarity index 96% rename from capnpc-csharp/Model/GenericParameter.cs rename to CapnpC.CSharp.Generator/Model/GenericParameter.cs index 8526b0d..eaca7b9 100644 --- a/capnpc-csharp/Model/GenericParameter.cs +++ b/CapnpC.CSharp.Generator/Model/GenericParameter.cs @@ -1,4 +1,4 @@ -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class GenericParameter { diff --git a/capnpc-csharp/Model/HasGenericParameters.cs b/CapnpC.CSharp.Generator/Model/HasGenericParameters.cs similarity index 91% rename from capnpc-csharp/Model/HasGenericParameters.cs rename to CapnpC.CSharp.Generator/Model/HasGenericParameters.cs index 6636ff4..55531b0 100644 --- a/capnpc-csharp/Model/HasGenericParameters.cs +++ b/CapnpC.CSharp.Generator/Model/HasGenericParameters.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; -namespace CapnpC.Model + +namespace CapnpC.CSharp.Generator.Model { static class HasGenericParameters { diff --git a/capnpc-csharp/Model/IDefinition.cs b/CapnpC.CSharp.Generator/Model/IDefinition.cs similarity index 82% rename from capnpc-csharp/Model/IDefinition.cs rename to CapnpC.CSharp.Generator/Model/IDefinition.cs index 9bd8572..70b8501 100644 --- a/capnpc-csharp/Model/IDefinition.cs +++ b/CapnpC.CSharp.Generator/Model/IDefinition.cs @@ -1,5 +1,5 @@  -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { interface IDefinition { diff --git a/capnpc-csharp/Model/IHasGenericParameters.cs b/CapnpC.CSharp.Generator/Model/IHasGenericParameters.cs similarity index 77% rename from capnpc-csharp/Model/IHasGenericParameters.cs rename to CapnpC.CSharp.Generator/Model/IHasGenericParameters.cs index 5b9ce58..fa71f35 100644 --- a/capnpc-csharp/Model/IHasGenericParameters.cs +++ b/CapnpC.CSharp.Generator/Model/IHasGenericParameters.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { interface IHasGenericParameters { diff --git a/capnpc-csharp/Model/IHasNestedDefinitions.cs b/CapnpC.CSharp.Generator/Model/IHasNestedDefinitions.cs similarity index 92% rename from capnpc-csharp/Model/IHasNestedDefinitions.cs rename to CapnpC.CSharp.Generator/Model/IHasNestedDefinitions.cs index 3885c60..06051c8 100644 --- a/capnpc-csharp/Model/IHasNestedDefinitions.cs +++ b/CapnpC.CSharp.Generator/Model/IHasNestedDefinitions.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { interface IHasNestedDefinitions { diff --git a/capnpc-csharp/Model/IdentifierRenamer.cs b/CapnpC.CSharp.Generator/Model/IdentifierRenamer.cs similarity index 93% rename from capnpc-csharp/Model/IdentifierRenamer.cs rename to CapnpC.CSharp.Generator/Model/IdentifierRenamer.cs index 9c6ff07..0c0a6b5 100644 --- a/capnpc-csharp/Model/IdentifierRenamer.cs +++ b/CapnpC.CSharp.Generator/Model/IdentifierRenamer.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Text; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { public class IdentifierRenamer { diff --git a/capnpc-csharp/Model/InvalidSchemaException.cs b/CapnpC.CSharp.Generator/Model/InvalidSchemaException.cs similarity index 80% rename from capnpc-csharp/Model/InvalidSchemaException.cs rename to CapnpC.CSharp.Generator/Model/InvalidSchemaException.cs index 4732ca8..839119f 100644 --- a/capnpc-csharp/Model/InvalidSchemaException.cs +++ b/CapnpC.CSharp.Generator/Model/InvalidSchemaException.cs @@ -1,6 +1,6 @@ using System; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class InvalidSchemaException : Exception { diff --git a/capnpc-csharp/Model/Method.cs b/CapnpC.CSharp.Generator/Model/Method.cs similarity index 93% rename from capnpc-csharp/Model/Method.cs rename to CapnpC.CSharp.Generator/Model/Method.cs index e263f89..1d1ba7b 100644 --- a/capnpc-csharp/Model/Method.cs +++ b/CapnpC.CSharp.Generator/Model/Method.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class Method: IHasGenericParameters { diff --git a/capnpc-csharp/Model/SchemaModel.cs b/CapnpC.CSharp.Generator/Model/SchemaModel.cs similarity index 99% rename from capnpc-csharp/Model/SchemaModel.cs rename to CapnpC.CSharp.Generator/Model/SchemaModel.cs index bd758c6..9d9e223 100644 --- a/capnpc-csharp/Model/SchemaModel.cs +++ b/CapnpC.CSharp.Generator/Model/SchemaModel.cs @@ -4,7 +4,7 @@ using System.Diagnostics; using System.Linq; using System.Text; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class SchemaModel { diff --git a/capnpc-csharp/Model/SpecialName.cs b/CapnpC.CSharp.Generator/Model/SpecialName.cs similarity index 72% rename from capnpc-csharp/Model/SpecialName.cs rename to CapnpC.CSharp.Generator/Model/SpecialName.cs index 89f546f..86887ab 100644 --- a/capnpc-csharp/Model/SpecialName.cs +++ b/CapnpC.CSharp.Generator/Model/SpecialName.cs @@ -1,4 +1,4 @@ -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { enum SpecialName { diff --git a/capnpc-csharp/Model/Type.cs b/CapnpC.CSharp.Generator/Model/Type.cs similarity index 99% rename from capnpc-csharp/Model/Type.cs rename to CapnpC.CSharp.Generator/Model/Type.cs index 17f2736..087f507 100644 --- a/capnpc-csharp/Model/Type.cs +++ b/CapnpC.CSharp.Generator/Model/Type.cs @@ -5,7 +5,7 @@ using System.Diagnostics; using System.Linq; using System.Text; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class Type: AbstractType { diff --git a/capnpc-csharp/Model/TypeCategory.cs b/CapnpC.CSharp.Generator/Model/TypeCategory.cs similarity index 61% rename from capnpc-csharp/Model/TypeCategory.cs rename to CapnpC.CSharp.Generator/Model/TypeCategory.cs index 3411ac1..507659e 100644 --- a/capnpc-csharp/Model/TypeCategory.cs +++ b/CapnpC.CSharp.Generator/Model/TypeCategory.cs @@ -1,4 +1,4 @@ -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { enum TypeCategory { diff --git a/capnpc-csharp/Model/TypeDefinition.cs b/CapnpC.CSharp.Generator/Model/TypeDefinition.cs similarity index 98% rename from capnpc-csharp/Model/TypeDefinition.cs rename to CapnpC.CSharp.Generator/Model/TypeDefinition.cs index dcbe512..9a0557c 100644 --- a/capnpc-csharp/Model/TypeDefinition.cs +++ b/CapnpC.CSharp.Generator/Model/TypeDefinition.cs @@ -1,7 +1,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -namespace CapnpC.Model + +namespace CapnpC.CSharp.Generator.Model { class TypeDefinition : AbstractType, IDefinition, IHasNestedDefinitions, IHasGenericParameters { diff --git a/capnpc-csharp/Model/TypeTag.cs b/CapnpC.CSharp.Generator/Model/TypeTag.cs similarity index 92% rename from capnpc-csharp/Model/TypeTag.cs rename to CapnpC.CSharp.Generator/Model/TypeTag.cs index 122b6d7..756e229 100644 --- a/capnpc-csharp/Model/TypeTag.cs +++ b/CapnpC.CSharp.Generator/Model/TypeTag.cs @@ -1,4 +1,4 @@ -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { enum TypeTag { diff --git a/capnpc-csharp/Model/Types.cs b/CapnpC.CSharp.Generator/Model/Types.cs similarity index 98% rename from capnpc-csharp/Model/Types.cs rename to CapnpC.CSharp.Generator/Model/Types.cs index ee20603..c655010 100644 --- a/capnpc-csharp/Model/Types.cs +++ b/CapnpC.CSharp.Generator/Model/Types.cs @@ -1,6 +1,6 @@ using System; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { static class Types { diff --git a/capnpc-csharp/Model/Value.cs b/CapnpC.CSharp.Generator/Model/Value.cs similarity index 99% rename from capnpc-csharp/Model/Value.cs rename to CapnpC.CSharp.Generator/Model/Value.cs index 955e51a..21c27aa 100644 --- a/capnpc-csharp/Model/Value.cs +++ b/CapnpC.CSharp.Generator/Model/Value.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace CapnpC.Model +namespace CapnpC.CSharp.Generator.Model { class Value { diff --git a/capnpc-csharp/Schema/SchemaSerialization.cs b/CapnpC.CSharp.Generator/Schema/SchemaSerialization.cs similarity index 99% rename from capnpc-csharp/Schema/SchemaSerialization.cs rename to CapnpC.CSharp.Generator/Schema/SchemaSerialization.cs index a61281a..0655f7d 100644 --- a/capnpc-csharp/Schema/SchemaSerialization.cs +++ b/CapnpC.CSharp.Generator/Schema/SchemaSerialization.cs @@ -1,9 +1,7 @@ using Capnp; -using System; using System.Collections.Generic; -using System.Text; -namespace CapnpC.Schema +namespace CapnpC.CSharp.Generator.Schema { namespace Superclass { diff --git a/capnpc-csharp/Schema/schema-with-offsets.capnp b/CapnpC.CSharp.Generator/Schema/schema-with-offsets.capnp similarity index 100% rename from capnpc-csharp/Schema/schema-with-offsets.capnp rename to CapnpC.CSharp.Generator/Schema/schema-with-offsets.capnp diff --git a/CapnpC.CSharp.MsBuild.Generation.Tests/BuildEngineMock.cs b/CapnpC.CSharp.MsBuild.Generation.Tests/BuildEngineMock.cs new file mode 100644 index 0000000..f5afe60 --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation.Tests/BuildEngineMock.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections; +using Microsoft.Build.Framework; + +namespace CapnpC.CSharp.MsBuild.Generation.Tests +{ + class BuildEngineMock : IBuildEngine + { + public bool ContinueOnError => true; + + public int LineNumberOfTaskNode => 0; + + public int ColumnNumberOfTaskNode => 0; + + public string ProjectFileOfTaskNode => null; + + public bool BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs) + { + return true; + } + + public void LogCustomEvent(CustomBuildEventArgs e) + { + Console.WriteLine(e.Message); + } + + public void LogErrorEvent(BuildErrorEventArgs e) + { + Console.WriteLine(e.Message); + } + + public void LogMessageEvent(BuildMessageEventArgs e) + { + Console.WriteLine(e.Message); + } + + public void LogWarningEvent(BuildWarningEventArgs e) + { + Console.WriteLine(e.Message); + } + } +} diff --git a/CapnpC.CSharp.MsBuild.Generation.Tests/CapnpC.CSharp.MsBuild.Generation.Tests.csproj b/CapnpC.CSharp.MsBuild.Generation.Tests/CapnpC.CSharp.MsBuild.Generation.Tests.csproj new file mode 100644 index 0000000..4b48f59 --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation.Tests/CapnpC.CSharp.MsBuild.Generation.Tests.csproj @@ -0,0 +1,23 @@ + + + + netcoreapp2.2 + + false + + Debug;Release + + + + + + + + + + + + + + + diff --git a/CapnpC.CSharp.MsBuild.Generation.Tests/GenerateCapnpFileCodeBehindTaskTest.cs b/CapnpC.CSharp.MsBuild.Generation.Tests/GenerateCapnpFileCodeBehindTaskTest.cs new file mode 100644 index 0000000..b6a7c6b --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation.Tests/GenerateCapnpFileCodeBehindTaskTest.cs @@ -0,0 +1,51 @@ +using CapnpC.CSharp.Generator.Tests; +using Microsoft.Build.Framework; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.IO; + +namespace CapnpC.CSharp.MsBuild.Generation.Tests +{ + [TestClass] + public class GenerateCapnpFileCodeBehindTaskTest + { + string LoadResourceContent(string name) + { + using (var stream = CodeGeneratorSteps.LoadResource("UnitTest1.capnp")) + using (var reader = new StreamReader(stream)) + { + return reader.ReadToEnd(); + } + } + + [TestMethod] + public void ExecutionWithoutParameters() + { + var task = new GenerateCapnpFileCodeBehindTask(); + task.BuildEngine = new BuildEngineMock(); + task.Execute(); + // Should not crash. Should Execute() return true or false if there is no input? + } + + [TestMethod] + public void SimpleGeneration() + { + string capnpFile = "UnitTask1.capnp"; + string content = LoadResourceContent(capnpFile); + string tmpPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + Directory.CreateDirectory(tmpPath); + string capnpPath = Path.Combine(tmpPath, capnpFile); + File.WriteAllText(capnpPath, content); + + var task = new GenerateCapnpFileCodeBehindTask(); + task.BuildEngine = new BuildEngineMock(); + task.ProjectPath = Path.Combine(tmpPath, "doesnotneedtoexist.csproj"); + task.CapnpFiles = new ITaskItem[1] { new TaskItemMock() { ItemSpec = capnpPath } }; + Assert.IsTrue(task.Execute()); + Assert.IsNotNull(task.GeneratedFiles); + Assert.AreEqual(1, task.GeneratedFiles.Length); + string csPath = Path.Combine(tmpPath, task.GeneratedFiles[0].ItemSpec); + Assert.AreEqual(capnpPath + ".cs", csPath); + Assert.IsTrue(File.Exists(csPath)); + } + } +} diff --git a/CapnpC.CSharp.MsBuild.Generation.Tests/TaskItemMock.cs b/CapnpC.CSharp.MsBuild.Generation.Tests/TaskItemMock.cs new file mode 100644 index 0000000..dd6174c --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation.Tests/TaskItemMock.cs @@ -0,0 +1,42 @@ +using System.Collections; +using Microsoft.Build.Framework; + +namespace CapnpC.CSharp.MsBuild.Generation.Tests +{ + + class TaskItemMock : ITaskItem + { + public string ItemSpec { get; set; } + + public ICollection MetadataNames => null; + + public int MetadataCount => 0; + + public IDictionary CloneCustomMetadata() + { + return null; + } + + public void CopyMetadataTo(ITaskItem destinationItem) + { + } + + public string GetMetadata(string metadataName) + { + if (metadataName == "FullPath") + { + return ItemSpec; + } + + return string.Empty; + } + + public void RemoveMetadata(string metadataName) + { + } + + public void SetMetadata(string metadataName, string metadataValue) + { + } + } +} diff --git a/CapnpC.CSharp.MsBuild.Generation/AssemblyAttributes.cs b/CapnpC.CSharp.MsBuild.Generation/AssemblyAttributes.cs new file mode 100644 index 0000000..ff364dc --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/AssemblyAttributes.cs @@ -0,0 +1,4 @@ + +using System.Runtime.CompilerServices; +using System.Security; + diff --git a/CapnpC.CSharp.MsBuild.Generation/CapnpC.CSharp.MsBuild.Generation.csproj b/CapnpC.CSharp.MsBuild.Generation/CapnpC.CSharp.MsBuild.Generation.csproj new file mode 100644 index 0000000..f471873 --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/CapnpC.CSharp.MsBuild.Generation.csproj @@ -0,0 +1,113 @@ + + + net471;netcoreapp2.1 + false + + true + true + + true + true + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + 1.0.0.0 + 1.0.0.0 + 1.0-local$([System.DateTime]::UtcNow.ToString(yyMMddHHmm)) + + $(MSBuildThisFileDirectory)CapnpC.CSharp.MsBuild.Generation.nuspec + version=$(Version);configuration=$(Configuration) + true + ..\bin\$(Configuration) + Debug;Release + + + + + + + + + + + + + + All + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + Microsoft.Build + + + Microsoft.Build.Framework + + + Microsoft.Build.Utilities.Core + + + + + + + Always + + + Always + + + Always + + + Always + + + Always + + + MSBuild:Compile + Always + + + MSBuild:Compile + Always + + + + + + + + \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/CapnpC.CSharp.MsBuild.Generation.nuspec b/CapnpC.CSharp.MsBuild.Generation/CapnpC.CSharp.MsBuild.Generation.nuspec new file mode 100644 index 0000000..e048bb9 --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/CapnpC.CSharp.MsBuild.Generation.nuspec @@ -0,0 +1,31 @@ + + + + CapnpC.CSharp.MsBuild.Generation + $version$ + CapnpC.CSharp.MsBuild.Generation + Christian Köllner and contributors + Christian Köllner + Package to enable the .capnp -> .cs file generation during build time + Package to enable the .capnp -> .cs file generation during build time + en-US + https://github.com/c80k/capnproto-dotnetcore + false + MIT + capnproto csharp msbuild + Christian Köllner and contributors + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/CapnpCodeBehindGenerator.cs b/CapnpC.CSharp.MsBuild.Generation/CapnpCodeBehindGenerator.cs new file mode 100644 index 0000000..6bc73be --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/CapnpCodeBehindGenerator.cs @@ -0,0 +1,99 @@ +using CapnpC.CSharp.Generator; +using System; +using System.Collections.Generic; +using System.IO; + +namespace CapnpC.CSharp.MsBuild.Generation +{ + public class CapnpCodeBehindGenerator : IDisposable + { + + public void InitializeProject(string projectPath) + { + } + + + public CsFileGeneratorResult GenerateCodeBehindFile(CapnpGenJob job) + { + string capnpFile = job.CapnpPath; + + // Works around a weird capnp.exe behavior: When the input file is empty, it will spit out an exception dump + // instead of a parse error. But the parse error is nice because it contains a generated ID. We want the parse error! + // Workaround: Generate a temporary file that contains a single line break (such that it is not empty...) + try + { + if (File.Exists(capnpFile) && new FileInfo(capnpFile).Length == 0) + { + string tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".capnp"); + + File.WriteAllText(tempFile, Environment.NewLine); + try + { + var jobCopy = new CapnpGenJob() + { + CapnpPath = tempFile, + WorkingDirectory = job.WorkingDirectory + }; + + jobCopy.AdditionalArguments.AddRange(job.AdditionalArguments); + + return GenerateCodeBehindFile(jobCopy); + } + finally + { + File.Delete(tempFile); + } + } + } + catch + { + } + + var args = new List(); + args.AddRange(job.AdditionalArguments); + args.Add(capnpFile); + + var result = CapnpCompilation.InvokeCapnpAndGenerate(args, job.WorkingDirectory); + + if (result.IsSuccess) + { + if (result.GeneratedFiles.Count == 1) + { + return new CsFileGeneratorResult( + result.GeneratedFiles[0], + capnpFile + ".cs", + result.Messages); + } + else + { + return new CsFileGeneratorResult( + "Code generation produced more than one file. This is not supported.", + result.Messages); + } + } + else + { + switch (result.ErrorCategory) + { + case CapnpProcessFailure.NotFound: + return new CsFileGeneratorResult("Unable to find capnp.exe - please install capnproto on your system first."); + + case CapnpProcessFailure.BadInput: + return new CsFileGeneratorResult("Invalid schema", result.Messages); + + case CapnpProcessFailure.BadOutput: + return new CsFileGeneratorResult( + "Internal error: capnp.exe produced a binary code generation request which was not understood by the backend", + result.Messages); + + default: + throw new NotSupportedException("Invalid error category"); + } + } + } + + public void Dispose() + { + } + } +} \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/CapnpFileCodeBehindGenerator.cs b/CapnpC.CSharp.MsBuild.Generation/CapnpFileCodeBehindGenerator.cs new file mode 100644 index 0000000..26af336 --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/CapnpFileCodeBehindGenerator.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace CapnpC.CSharp.MsBuild.Generation +{ + public class CapnpFileCodeBehindGenerator : ICapnpcCsharpGenerator + { + public CapnpFileCodeBehindGenerator(TaskLoggingHelper log) + { + Log = log ?? throw new ArgumentNullException(nameof(log)); + } + + public TaskLoggingHelper Log { get; } + + public IEnumerable GenerateFilesForProject( + string projectPath, + List capnpFiles, + string projectFolder) + { + using (var capnpCodeBehindGenerator = new CapnpCodeBehindGenerator()) + { + capnpCodeBehindGenerator.InitializeProject(projectPath); + + var codeBehindWriter = new CodeBehindWriter(null); + + if (capnpFiles == null) + { + yield break; + } + + foreach (var genJob in capnpFiles) + { + Log.LogMessage(MessageImportance.Normal, "Generate {0}, working dir = {1}, options = {2}", + genJob.CapnpPath, + genJob.WorkingDirectory, + string.Join(" ", genJob.AdditionalArguments)); + + var generatorResult = capnpCodeBehindGenerator.GenerateCodeBehindFile(genJob); + + if (!generatorResult.Success) + { + if (!string.IsNullOrEmpty(generatorResult.Error)) + { + Log.LogError("{0}", generatorResult.Error); + } + + if (generatorResult.Messages != null) + { + foreach (var message in generatorResult.Messages) + { + if (message.IsParseSuccess) + { + Log.LogError( + subcategory: null, + errorCode: null, + helpKeyword: null, + file: genJob.CapnpPath, + lineNumber: message.Line, + columnNumber: message.Column, + endLineNumber: message.Line, + endColumnNumber: message.EndColumn == 0 ? message.Column : message.EndColumn, + "{0}", + message.MessageText); + } + else + { + Log.LogError("{0}", message.FullMessage); + } + } + } + + continue; + } + + var resultedFile = codeBehindWriter.WriteCodeBehindFile(generatorResult.Filename, generatorResult); + + yield return FileSystemHelper.GetRelativePath(resultedFile, projectFolder); + } + } + + } + } +} diff --git a/CapnpC.CSharp.MsBuild.Generation/CapnpGenJob.cs b/CapnpC.CSharp.MsBuild.Generation/CapnpGenJob.cs new file mode 100644 index 0000000..0ac6201 --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/CapnpGenJob.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace CapnpC.CSharp.MsBuild.Generation +{ + public class CapnpGenJob + { + public string CapnpPath { get; set; } + public string WorkingDirectory { get; set; } + public List AdditionalArguments { get; } = new List(); + } +} \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/CodeBehindWriter.cs b/CapnpC.CSharp.MsBuild.Generation/CodeBehindWriter.cs new file mode 100644 index 0000000..3ff276b --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/CodeBehindWriter.cs @@ -0,0 +1,38 @@ +using System; +using System.IO; +using Microsoft.Build.Utilities; + +namespace CapnpC.CSharp.MsBuild.Generation +{ + public class CodeBehindWriter + { + public CodeBehindWriter(TaskLoggingHelper log) + { + Log = log; + } + + public TaskLoggingHelper Log { get; } + + public string WriteCodeBehindFile(string outputPath, CsFileGeneratorResult testFileGeneratorResult) + { + string directoryPath = Path.GetDirectoryName(outputPath) ?? throw new InvalidOperationException(); + Log?.LogWithNameTag(Log.LogMessage, directoryPath); + + Log?.LogWithNameTag(Log.LogMessage, $"Writing data to {outputPath}; path = {directoryPath}; generatedFilename = {testFileGeneratorResult.Filename}"); + + if (File.Exists(outputPath)) + { + if (!FileSystemHelper.FileCompareContent(outputPath, testFileGeneratorResult.GeneratedCode)) + { + File.WriteAllText(outputPath, testFileGeneratorResult.GeneratedCode); + } + } + else + { + File.WriteAllText(outputPath, testFileGeneratorResult.GeneratedCode); + } + + return outputPath; + } + } +} diff --git a/CapnpC.CSharp.MsBuild.Generation/CsFileGeneratorResult.cs b/CapnpC.CSharp.MsBuild.Generation/CsFileGeneratorResult.cs new file mode 100644 index 0000000..75961ac --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/CsFileGeneratorResult.cs @@ -0,0 +1,51 @@ +using CapnpC.CSharp.Generator; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace CapnpC.CSharp.MsBuild.Generation +{ + public class CsFileGeneratorResult + { + public CsFileGeneratorResult(FileGenerationResult generatorResult, string fileName, IReadOnlyList messages) + { + if (generatorResult == null) + { + throw new ArgumentNullException(nameof(generatorResult)); + } + + Filename = fileName ?? throw new ArgumentNullException(nameof(fileName)); + + Error = generatorResult.Exception?.Message; + GeneratedCode = generatorResult.GeneratedContent; + Messages = messages; + } + + public CsFileGeneratorResult(string error) + { + Error = error; + } + + public CsFileGeneratorResult(string error, IReadOnlyList messages) + { + Error = error; + Messages = messages; + } + + /// + /// The error, if any. + /// + public string Error { get; } + + /// + /// The generated code. + /// + public string GeneratedCode { get; } + + public IReadOnlyList Messages { get; } + + public bool Success => Error == null; + + public string Filename { get; } + } +} \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/FileSystemHelper.cs b/CapnpC.CSharp.MsBuild.Generation/FileSystemHelper.cs new file mode 100644 index 0000000..d538531 --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/FileSystemHelper.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; + +namespace CapnpC.CSharp.MsBuild.Generation +{ + public static class FileSystemHelper + { + public static void CopyFileToFolder(string filePath, string folderName) + { + File.Copy(filePath, Path.Combine(folderName, Path.GetFileName(filePath))); + } + + public static string GetRelativePath(string path, string basePath) + { + path = Path.GetFullPath(path); + basePath = Path.GetFullPath(basePath); + if (String.Equals(path, basePath, StringComparison.OrdinalIgnoreCase)) + return "."; // the "this folder" + + if (path.StartsWith(basePath + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase)) + return path.Substring(basePath.Length + 1); + + //handle different drives + string pathRoot = Path.GetPathRoot(path); + if (!String.Equals(pathRoot, Path.GetPathRoot(basePath), StringComparison.OrdinalIgnoreCase)) + return path; + + //handle ".." pathes + string[] pathParts = path.Substring(pathRoot.Length).Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); + string[] basePathParts = basePath.Substring(pathRoot.Length).Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); + + int commonFolderCount = 0; + while (commonFolderCount < pathParts.Length && commonFolderCount < basePathParts.Length && + String.Equals(pathParts[commonFolderCount], basePathParts[commonFolderCount], StringComparison.OrdinalIgnoreCase)) + commonFolderCount++; + + StringBuilder result = new StringBuilder(); + for (int i = 0; i < basePathParts.Length - commonFolderCount; i++) + { + result.Append(".."); + result.Append(Path.DirectorySeparatorChar); + } + + if (pathParts.Length - commonFolderCount == 0) + return result.ToString().TrimEnd(Path.DirectorySeparatorChar); + + result.Append(String.Join(Path.DirectorySeparatorChar.ToString(), pathParts, commonFolderCount, pathParts.Length - commonFolderCount)); + return result.ToString(); + } + + // This method accepts two strings the represent two files to + // compare. A return value of true indicates that the contents of the files + // are the same. A return value of any other value indicates that the + // files are not the same. + public static bool FileCompare(string filePath1, string filePath2) + { + int file1byte; + int file2byte; + + // Determine if the same file was referenced two times. + if (String.Equals(filePath1, filePath2, StringComparison.CurrentCultureIgnoreCase)) + { + // Return true to indicate that the files are the same. + return true; + } + + // Open the two files. + using (FileStream fs1 = new FileStream(filePath1, FileMode.Open, FileAccess.Read)) + { + using (FileStream fs2 = new FileStream(filePath2, FileMode.Open, FileAccess.Read)) + { + // Check the file sizes. If they are not the same, the files + // are not the same. + if (fs1.Length != fs2.Length) + { + // Return false to indicate files are different + return false; + } + + // Read and compare a byte from each file until either a + // non-matching set of bytes is found or until the end of + // file1 is reached. + do + { + // Read one byte from each file. + file1byte = fs1.ReadByte(); + file2byte = fs2.ReadByte(); + } while ((file1byte == file2byte) && (file1byte != -1)); + } + } + // Return the success of the comparison. "file1byte" is + // equal to "file2byte" at this point only if the files are + // the same. + return ((file1byte - file2byte) == 0); + } + + // This method accepts two strings the represent two files to + // compare. A return value of true indicates that the contents of the files + // are the same. A return value of any other value indicates that the + // files are not the same. + public static bool FileCompareContent(string filePath1, string fileContent) + { + var currentFileContent = File.ReadAllText(filePath1); + + return string.CompareOrdinal(currentFileContent, fileContent) == 0; + + } + } +} diff --git a/CapnpC.CSharp.MsBuild.Generation/GenerateCapnpFileCodeBehindTask.cs b/CapnpC.CSharp.MsBuild.Generation/GenerateCapnpFileCodeBehindTask.cs new file mode 100644 index 0000000..459af9b --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/GenerateCapnpFileCodeBehindTask.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Resources; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace CapnpC.CSharp.MsBuild.Generation +{ + public class GenerateCapnpFileCodeBehindTask : Task + { + public GenerateCapnpFileCodeBehindTask() + { + CodeBehindGenerator = new CapnpFileCodeBehindGenerator(Log); + } + + public ICapnpcCsharpGenerator CodeBehindGenerator { get; set; } + + [Required] + public string ProjectPath { get; set; } + + public string ProjectFolder => Path.GetDirectoryName(ProjectPath); + + public ITaskItem[] CapnpFiles { get; set; } + + [Output] + public ITaskItem[] GeneratedFiles { get; private set; } + + static CapnpGenJob ToGenJob(ITaskItem item) + { + var job = new CapnpGenJob() + { + CapnpPath = item.GetMetadata("FullPath"), + WorkingDirectory = item.GetMetadata("WorkingDirectory") + }; + + string importPaths = item.GetMetadata("ImportPaths"); + + if (!string.IsNullOrWhiteSpace(importPaths)) + { + job.AdditionalArguments.AddRange(importPaths.Split(new char[] { ';' }, + StringSplitOptions.RemoveEmptyEntries).Select(p => $"-I\"{p.TrimEnd('\\')}\"")); + } + + string sourcePrefix = item.GetMetadata("SourcePrefix"); + + if (!string.IsNullOrWhiteSpace(sourcePrefix)) + { + job.AdditionalArguments.Add(sourcePrefix); + } + + + string verbose = item.GetMetadata("Verbose"); + + if ("true".Equals(verbose, StringComparison.OrdinalIgnoreCase)) + { + job.AdditionalArguments.Add("--verbose"); + } + + return job; + } + + public override bool Execute() + { + try + { + try + { + var currentProcess = Process.GetCurrentProcess(); + + Log.LogWithNameTag(Log.LogMessage, $"process: {currentProcess.ProcessName}, pid: {currentProcess.Id}, CD: {Environment.CurrentDirectory}"); + + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + Log.LogWithNameTag(Log.LogMessage, " " + assembly.FullName); + } + } + catch (Exception e) + { + Log.LogWithNameTag(Log.LogMessage, $"Error when dumping process info: {e}"); + } + + AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; + + var generator = CodeBehindGenerator ?? new CapnpFileCodeBehindGenerator(Log); + + Log.LogWithNameTag(Log.LogMessage, "Starting GenerateCapnpFileCodeBehind"); + + var capnpFiles = CapnpFiles?.Select(ToGenJob).ToList() ?? new List(); + + var generatedFiles = generator.GenerateFilesForProject( + ProjectPath, + capnpFiles, + ProjectFolder); + + GeneratedFiles = generatedFiles.Select(file => new TaskItem { ItemSpec = file }).ToArray(); + + return !Log.HasLoggedErrors; + } + catch (Exception e) + { + if (e.InnerException != null) + { + if (e.InnerException is FileLoadException fle) + { + Log?.LogWithNameTag(Log.LogError, $"FileLoadException Filename: {fle.FileName}"); + Log?.LogWithNameTag(Log.LogError, $"FileLoadException FusionLog: {fle.FusionLog}"); + Log?.LogWithNameTag(Log.LogError, $"FileLoadException Message: {fle.Message}"); + } + + Log?.LogWithNameTag(Log.LogError, e.InnerException.ToString()); + } + + Log?.LogWithNameTag(Log.LogError, e.ToString()); + return false; + } + finally + { + AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve; + } + } + + private System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) + { + Log.LogWithNameTag(Log.LogMessage, args.Name); + + + return null; + } + + } + + +} \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/Helper/LogExtensions.cs b/CapnpC.CSharp.MsBuild.Generation/Helper/LogExtensions.cs new file mode 100644 index 0000000..3203bea --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/Helper/LogExtensions.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Build.Utilities; + +namespace CapnpC.CSharp.MsBuild.Generation +{ + public static class LogExtensions + { + public static void LogWithNameTag( + this TaskLoggingHelper loggingHelper, + Action loggingMethod, + string message, + params object[] messageArgs) + { + string fullMessage = $"[Cap'n Proto] {message}"; + loggingMethod?.Invoke(fullMessage, messageArgs); + } + } +} diff --git a/CapnpC.CSharp.MsBuild.Generation/ICapnpCsharpGenerator.cs b/CapnpC.CSharp.MsBuild.Generation/ICapnpCsharpGenerator.cs new file mode 100644 index 0000000..965b0ce --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/ICapnpCsharpGenerator.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace CapnpC.CSharp.MsBuild.Generation +{ + public interface ICapnpcCsharpGenerator + { + IEnumerable GenerateFilesForProject(string projectPath, List jobs, string projectFolder); + } +} \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/build/CPS/Buildsystem/CpsExtension.DesignTime.targets b/CapnpC.CSharp.MsBuild.Generation/build/CPS/Buildsystem/CpsExtension.DesignTime.targets new file mode 100644 index 0000000..4f6883c --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/build/CPS/Buildsystem/CpsExtension.DesignTime.targets @@ -0,0 +1,15 @@ + + + + + $(MSBuildThisFileDirectory)Rules\ + + + + + + + File;BrowseObject + + + \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/build/CPS/Buildsystem/Rules/CapnpFileType.xaml b/CapnpC.CSharp.MsBuild.Generation/build/CPS/Buildsystem/Rules/CapnpFileType.xaml new file mode 100644 index 0000000..c938967 --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/build/CPS/Buildsystem/Rules/CapnpFileType.xaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/build/CPS/Buildsystem/Rules/ProjectItemsSchema.xaml b/CapnpC.CSharp.MsBuild.Generation/build/CPS/Buildsystem/Rules/ProjectItemsSchema.xaml new file mode 100644 index 0000000..1cf7ddb --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/build/CPS/Buildsystem/Rules/ProjectItemsSchema.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/build/CapnpC.CSharp.MsBuild.Generation.props b/CapnpC.CSharp.MsBuild.Generation/build/CapnpC.CSharp.MsBuild.Generation.props new file mode 100644 index 0000000..2d2682c --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/build/CapnpC.CSharp.MsBuild.Generation.props @@ -0,0 +1,78 @@ + + + + $(MSBuildThisFileDirectory)CPS\Buildsystem\CpsExtension.DesignTime.targets + + + + + + + false + $(CapnpcCsharp_UseHostCompilerIfAvailable) + + + + + false + false + + false + true + false + + <_CapnpcCsharpPropsImported Condition="'$(_CapnpcCsharpPropsImported)'==''">true + + + + + + + false + + + true + $(CapnpcCsharp_EnableDefaultCompileItems) + + $(DefaultItemExcludes);**/*.capnp + + + + + %(RelativeDir)%(Filename).capnp.cs + $(UsingMicrosoftNETSdk) + $(ProjectDir) + + + + + + + + + + + + + + + <_CapnpcCsharp_TaskFolder Condition=" '$(MSBuildRuntimeType)' == 'Core' And '$(_CapnpcCsharp_TaskFolder)' == ''">netcoreapp2.1 + <_CapnpcCsharp_TaskFolder Condition=" '$(MSBuildRuntimeType)' != 'Core' And '$(_CapnpcCsharp_TaskFolder)' == ''">net471 + <_CapnpcCsharp_TaskAssembly Condition=" '$(_CapnpcCsharp_TaskAssembly)' == '' ">..\tasks\$(_CapnpcCsharp_TaskFolder)\CapnpC.CSharp.MsBuild.Generation.dll + + + + + diff --git a/CapnpC.CSharp.MsBuild.Generation/build/CapnpC.CSharp.MsBuild.Generation.targets b/CapnpC.CSharp.MsBuild.Generation/build/CapnpC.CSharp.MsBuild.Generation.targets new file mode 100644 index 0000000..718f826 --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/build/CapnpC.CSharp.MsBuild.Generation.targets @@ -0,0 +1,133 @@ + + + + + + false + true + + + <_CapnpcCsharp_EnableDefaultCompileItems Condition="'$(CapnpcCsharp_EnableDefaultCompileItems)' == '' And '$(UsingMicrosoftNETSdk)' == 'true'">true + <_CapnpcCsharp_EnableDefaultCompileItems Condition="'$(CapnpcCsharp_EnableDefaultCompileItems)' == 'true' And '$(UsingMicrosoftNETSdk)' == 'true'">true + + + + + BeforeUpdateCapnpFilesInProject; + UpdateCapnpFilesInProject; + IncludeCodeBehindFilesInProject; + AfterUpdateCapnpFilesInProject; + $(BuildDependsOn) + + + CleanCapnpFilesInProject; + $(CleanDependsOn) + + + SwitchToForceGenerate; + $(RebuildDependsOn) + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/build/CapnpC.CSharp.MsBuild.Generation.tasks b/CapnpC.CSharp.MsBuild.Generation/build/CapnpC.CSharp.MsBuild.Generation.tasks new file mode 100644 index 0000000..9859d7b --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/build/CapnpC.CSharp.MsBuild.Generation.tasks @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/CapnpC.CSharp.MsBuild.Generation/buildMultiTargeting/CapnpC.CSharp.MsBuild.Generation.props b/CapnpC.CSharp.MsBuild.Generation/buildMultiTargeting/CapnpC.CSharp.MsBuild.Generation.props new file mode 100644 index 0000000..62930dd --- /dev/null +++ b/CapnpC.CSharp.MsBuild.Generation/buildMultiTargeting/CapnpC.CSharp.MsBuild.Generation.props @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Licenses/SpecFlow-LICENSE-NewBSD.txt b/Licenses/SpecFlow-LICENSE-NewBSD.txt new file mode 100644 index 0000000..665e1cd --- /dev/null +++ b/Licenses/SpecFlow-LICENSE-NewBSD.txt @@ -0,0 +1,31 @@ +SpecFlow Licence (New BSD License) + +Copyright (c) 2009, TechTalk + +Disclaimer: + * The initial codebase of Specflow was written by TechTalk employees. + No 3rd party code was included. + * No code of customer projects was used to create this project. + * TechTalk had the full rights to publish the initial codebase. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the SpecFlow project nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL TECHTALK OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MsBuildGenerationTest/AddressBook.capnp b/MsBuildGenerationTest/AddressBook.capnp new file mode 100644 index 0000000..6b353e1 --- /dev/null +++ b/MsBuildGenerationTest/AddressBook.capnp @@ -0,0 +1,31 @@ +@0xebf92c49b1687ddb; + +struct Person { + id @0 :UInt32; + name @1 :Text; + email @2 :Text; + phones @3 :List(PhoneNumber); + + struct PhoneNumber { + number @0 :Text; + type @1 :Type; + + enum Type { + mobile @0; + home @1; + work @2; + } + } + + employment :union { + unemployed @4 :Void; + employer @5 :Text; + school @6 :Text; + selfEmployed @7 :Void; + # We assume that a person is only one of these. + } +} + +struct AddressBook { + people @0 :List(Person); +} \ No newline at end of file diff --git a/MsBuildGenerationTest/AddressBook.capnp.cs b/MsBuildGenerationTest/AddressBook.capnp.cs new file mode 100644 index 0000000..ebffe97 --- /dev/null +++ b/MsBuildGenerationTest/AddressBook.capnp.cs @@ -0,0 +1,412 @@ +using Capnp; +using Capnp.Rpc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace CapnpGen +{ + public class Person : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Id = reader.Id; + Name = reader.Name; + Email = reader.Email; + Phones = reader.Phones.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + Employment = CapnpSerializable.Create(reader.Employment); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Id = Id; + writer.Name = Name; + writer.Email = Email; + writer.Phones.Init(Phones, (_s1, _v1) => _v1?.serialize(_s1)); + Employment?.serialize(writer.Employment); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint Id + { + get; + set; + } + + public string Name + { + get; + set; + } + + public string Email + { + get; + set; + } + + public IReadOnlyList Phones + { + get; + set; + } + + public CapnpGen.Person.@employment Employment + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint Id => ctx.ReadDataUInt(0UL, 0U); + public string Name => ctx.ReadText(0, ""); + public string Email => ctx.ReadText(1, ""); + public IReadOnlyList Phones => ctx.ReadList(2).Cast(CapnpGen.Person.PhoneNumber.READER.create); + public @employment.READER Employment => new @employment.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 4); + } + + public uint Id + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public string Name + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public string Email + { + get => this.ReadText(1, ""); + set => this.WriteText(1, value, ""); + } + + public ListOfStructsSerializer Phones + { + get => BuildPointer>(2); + set => Link(2, value); + } + + public @employment.WRITER Employment + { + get => Rewrap<@employment.WRITER>(); + } + } + + public class @employment : ICapnpSerializable + { + public enum WHICH : ushort + { + Unemployed = 0, + Employer = 1, + School = 2, + SelfEmployed = 3, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Unemployed: + which = reader.which; + break; + case WHICH.Employer: + Employer = reader.Employer; + break; + case WHICH.School: + School = reader.School; + break; + case WHICH.SelfEmployed: + which = reader.which; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Unemployed: + break; + case WHICH.Employer: + _content = null; + break; + case WHICH.School: + _content = null; + break; + case WHICH.SelfEmployed: + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Unemployed: + break; + case WHICH.Employer: + writer.Employer = Employer; + break; + case WHICH.School: + writer.School = School; + break; + case WHICH.SelfEmployed: + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Employer + { + get => _which == WHICH.Employer ? (string)_content : null; + set + { + _which = WHICH.Employer; + _content = value; + } + } + + public string School + { + get => _which == WHICH.School ? (string)_content : null; + set + { + _which = WHICH.School; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(32U, (ushort)0); + public string Employer => which == WHICH.Employer ? ctx.ReadText(3, "") : default; + public string School => which == WHICH.School ? ctx.ReadText(3, "") : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(32U, (ushort)0); + set => this.WriteData(32U, (ushort)value, (ushort)0); + } + + public string Employer + { + get => which == WHICH.Employer ? this.ReadText(3, "") : default; + set => this.WriteText(3, value, ""); + } + + public string School + { + get => which == WHICH.School ? this.ReadText(3, "") : default; + set => this.WriteText(3, value, ""); + } + } + } + + public class PhoneNumber : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Number = reader.Number; + TheType = reader.TheType; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Number = Number; + writer.TheType = TheType; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Number + { + get; + set; + } + + public CapnpGen.Person.PhoneNumber.Type TheType + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Number => ctx.ReadText(0, ""); + public CapnpGen.Person.PhoneNumber.Type TheType => (CapnpGen.Person.PhoneNumber.Type)ctx.ReadDataUShort(0UL, (ushort)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public string Number + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public CapnpGen.Person.PhoneNumber.Type TheType + { + get => (CapnpGen.Person.PhoneNumber.Type)this.ReadDataUShort(0UL, (ushort)0); + set => this.WriteData(0UL, (ushort)value, (ushort)0); + } + } + + public enum Type : ushort + { + mobile, + home, + work + } + } + } + + public class AddressBook : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + People = reader.People.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.People.Init(People, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public IReadOnlyList People + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public IReadOnlyList People => ctx.ReadList(0).Cast(CapnpGen.Person.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public ListOfStructsSerializer People + { + get => BuildPointer>(0); + set => Link(0, value); + } + } + } +} \ No newline at end of file diff --git a/MsBuildGenerationTest/MsBuildGenerationTest.csproj b/MsBuildGenerationTest/MsBuildGenerationTest.csproj new file mode 100644 index 0000000..6b1a4a8 --- /dev/null +++ b/MsBuildGenerationTest/MsBuildGenerationTest.csproj @@ -0,0 +1,59 @@ + + + + Exe + netcoreapp2.2 + 1.0-local + Debug;Release + $(Version)* + + + + + + + + + + + + + + $(ProjectDir) + true + + + $(ProjectDir) + $(ProjectDir);%(ImportPaths) + + + $(ProjectDir) + $(ProjectDir);%(ImportPaths) + + + $(ProjectDir) + $(ProjectDir);%(ImportPaths) + + + $(ProjectDir) + $(ProjectDir);%(ImportPaths) + + + $(ProjectDir) + $(ProjectDir);%(ImportPaths) + + + $(ProjectDir) + $(ProjectDir);%(ImportPaths) + + + $(ProjectDir) + $(ProjectDir);%(ImportPaths) + + + $(ProjectDir) + $(ProjectDir);%(ImportPaths) + + + + diff --git a/MsBuildGenerationTest/MsBuildGenerationTest.sln b/MsBuildGenerationTest/MsBuildGenerationTest.sln new file mode 100644 index 0000000..0545a55 --- /dev/null +++ b/MsBuildGenerationTest/MsBuildGenerationTest.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29306.81 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MsBuildGenerationTest", "MsBuildGenerationTest.csproj", "{D2CFBABF-7028-4761-9B24-6054008F41A0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + AppVeyor|Any CPU = AppVeyor|Any CPU + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D2CFBABF-7028-4761-9B24-6054008F41A0}.AppVeyor|Any CPU.ActiveCfg = Release|Any CPU + {D2CFBABF-7028-4761-9B24-6054008F41A0}.AppVeyor|Any CPU.Build.0 = Release|Any CPU + {D2CFBABF-7028-4761-9B24-6054008F41A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2CFBABF-7028-4761-9B24-6054008F41A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2CFBABF-7028-4761-9B24-6054008F41A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2CFBABF-7028-4761-9B24-6054008F41A0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {76182204-2E1A-4AEF-AB7B-13725C36FFF2} + EndGlobalSection +EndGlobal diff --git a/MsBuildGenerationTest/Program.cs b/MsBuildGenerationTest/Program.cs new file mode 100644 index 0000000..bbbb50b --- /dev/null +++ b/MsBuildGenerationTest/Program.cs @@ -0,0 +1,21 @@ +using System; + +namespace MsBuildGenerationTest +{ + class Program + { + static void Main(string[] args) + { + // Instantiate some generated classes ensures that they are really present. + // Note that this code is not supposed to test runtime behavior, we have plenty of other test cases for that purpose. + + var vatId = new Capnp.Rpc.Twoparty.VatId(); + var msg = new Capnp.Rpc.Message(); + var node = new Capnp.Schema.Node(); + var x = Capnproto_test.Capnp.Test.TestEnum.garply; + var imp = new CapnpGen.TestImport(); + var imp2 = new CapnpGen.TestImport2(); + var book = new CapnpGen.AddressBook(); + } + } +} diff --git a/MsBuildGenerationTest/capnp/c++.capnp b/MsBuildGenerationTest/capnp/c++.capnp new file mode 100644 index 0000000..2bda547 --- /dev/null +++ b/MsBuildGenerationTest/capnp/c++.capnp @@ -0,0 +1,26 @@ +# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0xbdf87d7bb8304e81; +$namespace("capnp::annotations"); + +annotation namespace(file): Text; +annotation name(field, enumerant, struct, enum, interface, method, param, group, union): Text; diff --git a/MsBuildGenerationTest/capnp/c++.capnp.cs b/MsBuildGenerationTest/capnp/c++.capnp.cs new file mode 100644 index 0000000..e43c504 --- /dev/null +++ b/MsBuildGenerationTest/capnp/c++.capnp.cs @@ -0,0 +1,10 @@ +using Capnp; +using Capnp.Rpc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Capnp.Annotations +{ +} \ No newline at end of file diff --git a/MsBuildGenerationTest/capnp/compat/json-test.capnp b/MsBuildGenerationTest/capnp/compat/json-test.capnp new file mode 100644 index 0000000..1446f8a --- /dev/null +++ b/MsBuildGenerationTest/capnp/compat/json-test.capnp @@ -0,0 +1,116 @@ +# Copyright (c) 2018 Cloudflare, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0xc9d405cf4333e4c9; + +using Json = import "/capnp/compat/json.capnp"; + +$import "/capnp/c++.capnp".namespace("capnp"); + +struct TestJsonAnnotations { + someField @0 :Text $Json.name("names-can_contain!anything Really"); + + aGroup :group $Json.flatten() { + flatFoo @1 :UInt32; + flatBar @2 :Text; + flatBaz :group $Json.name("renamed-flatBaz") { + hello @3 :Bool; + } + doubleFlat :group $Json.flatten() { + flatQux @4 :Text; + } + } + + prefixedGroup :group $Json.flatten(prefix = "pfx.") { + foo @5 :Text; + bar @6 :UInt32 $Json.name("renamed-bar"); + baz :group { + hello @7 :Bool; + } + morePrefix :group $Json.flatten(prefix = "xfp.") { + qux @8 :Text; + } + } + + aUnion :union $Json.flatten() $Json.discriminator(name = "union-type") { + foo :group $Json.flatten() { + fooMember @9 :Text; + multiMember @10 :UInt32; + } + bar :group $Json.flatten() $Json.name("renamed-bar") { + barMember @11 :UInt32; + multiMember @12 :Text; + } + } + + dependency @13 :TestJsonAnnotations2; + # To test that dependencies are loaded even if not flattened. + + simpleGroup :group { + # To test that group types are loaded even if not flattened. + grault @14 :Text $Json.name("renamed-grault"); + } + + enums @15 :List(TestJsonAnnotatedEnum); + + innerJson @16 :Json.Value; + + customFieldHandler @17 :Text; + + testBase64 @18 :Data $Json.base64; + testHex @19 :Data $Json.hex; + + bUnion :union $Json.flatten() $Json.discriminator(valueName = "bValue") { + foo @20 :Text; + bar @21 :UInt32 $Json.name("renamed-bar"); + } + + externalUnion @22 :TestJsonAnnotations3; + + unionWithVoid :union $Json.discriminator(name = "type") { + intValue @23 :UInt32; + voidValue @24 :Void; + textValue @25 :Text; + } +} + +struct TestJsonAnnotations2 { + foo @0 :Text $Json.name("renamed-foo"); + cycle @1 :TestJsonAnnotations; +} + +struct TestJsonAnnotations3 $Json.discriminator(name = "type") { + union { + foo @0 :UInt32; + bar @1 :TestFlattenedStruct $Json.flatten(); + } +} + +struct TestFlattenedStruct { + value @0 :Text; +} + +enum TestJsonAnnotatedEnum { + foo @0; + bar @1 $Json.name("renamed-bar"); + baz @2 $Json.name("renamed-baz"); + qux @3; +} diff --git a/MsBuildGenerationTest/capnp/compat/json-test.capnp.cs b/MsBuildGenerationTest/capnp/compat/json-test.capnp.cs new file mode 100644 index 0000000..c6366e6 --- /dev/null +++ b/MsBuildGenerationTest/capnp/compat/json-test.capnp.cs @@ -0,0 +1,1559 @@ +using Capnp; +using Capnp.Rpc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Capnp +{ + public class TestJsonAnnotations : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + SomeField = reader.SomeField; + AGroup = CapnpSerializable.Create(reader.AGroup); + PrefixedGroup = CapnpSerializable.Create(reader.PrefixedGroup); + AUnion = CapnpSerializable.Create(reader.AUnion); + Dependency = CapnpSerializable.Create(reader.Dependency); + SimpleGroup = CapnpSerializable.Create(reader.SimpleGroup); + Enums = reader.Enums; + InnerJson = CapnpSerializable.Create(reader.InnerJson); + CustomFieldHandler = reader.CustomFieldHandler; + TestBase64 = reader.TestBase64; + TestHex = reader.TestHex; + BUnion = CapnpSerializable.Create(reader.BUnion); + ExternalUnion = CapnpSerializable.Create(reader.ExternalUnion); + UnionWithVoid = CapnpSerializable.Create(reader.UnionWithVoid); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.SomeField = SomeField; + AGroup?.serialize(writer.AGroup); + PrefixedGroup?.serialize(writer.PrefixedGroup); + AUnion?.serialize(writer.AUnion); + Dependency?.serialize(writer.Dependency); + SimpleGroup?.serialize(writer.SimpleGroup); + writer.Enums.Init(Enums); + InnerJson?.serialize(writer.InnerJson); + writer.CustomFieldHandler = CustomFieldHandler; + writer.TestBase64.Init(TestBase64); + writer.TestHex.Init(TestHex); + BUnion?.serialize(writer.BUnion); + ExternalUnion?.serialize(writer.ExternalUnion); + UnionWithVoid?.serialize(writer.UnionWithVoid); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string SomeField + { + get; + set; + } + + public Capnp.TestJsonAnnotations.@aGroup AGroup + { + get; + set; + } + + public Capnp.TestJsonAnnotations.@prefixedGroup PrefixedGroup + { + get; + set; + } + + public Capnp.TestJsonAnnotations.@aUnion AUnion + { + get; + set; + } + + public Capnp.TestJsonAnnotations2 Dependency + { + get; + set; + } + + public Capnp.TestJsonAnnotations.@simpleGroup SimpleGroup + { + get; + set; + } + + public IReadOnlyList Enums + { + get; + set; + } + + public Capnp.Json.Value InnerJson + { + get; + set; + } + + public string CustomFieldHandler + { + get; + set; + } + + public IReadOnlyList TestBase64 + { + get; + set; + } + + public IReadOnlyList TestHex + { + get; + set; + } + + public Capnp.TestJsonAnnotations.@bUnion BUnion + { + get; + set; + } + + public Capnp.TestJsonAnnotations3 ExternalUnion + { + get; + set; + } + + public Capnp.TestJsonAnnotations.@unionWithVoid UnionWithVoid + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string SomeField => ctx.ReadText(0, ""); + public @aGroup.READER AGroup => new @aGroup.READER(ctx); + public @prefixedGroup.READER PrefixedGroup => new @prefixedGroup.READER(ctx); + public @aUnion.READER AUnion => new @aUnion.READER(ctx); + public Capnp.TestJsonAnnotations2.READER Dependency => ctx.ReadStruct(6, Capnp.TestJsonAnnotations2.READER.create); + public @simpleGroup.READER SimpleGroup => new @simpleGroup.READER(ctx); + public IReadOnlyList Enums => ctx.ReadList(8).CastEnums(_0 => (Capnp.TestJsonAnnotatedEnum)_0); + public Capnp.Json.Value.READER InnerJson => ctx.ReadStruct(9, Capnp.Json.Value.READER.create); + public string CustomFieldHandler => ctx.ReadText(10, ""); + public IReadOnlyList TestBase64 => ctx.ReadList(11).CastByte(); + public IReadOnlyList TestHex => ctx.ReadList(12).CastByte(); + public @bUnion.READER BUnion => new @bUnion.READER(ctx); + public Capnp.TestJsonAnnotations3.READER ExternalUnion => ctx.ReadStruct(14, Capnp.TestJsonAnnotations3.READER.create); + public @unionWithVoid.READER UnionWithVoid => new @unionWithVoid.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(4, 16); + } + + public string SomeField + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public @aGroup.WRITER AGroup + { + get => Rewrap<@aGroup.WRITER>(); + } + + public @prefixedGroup.WRITER PrefixedGroup + { + get => Rewrap<@prefixedGroup.WRITER>(); + } + + public @aUnion.WRITER AUnion + { + get => Rewrap<@aUnion.WRITER>(); + } + + public Capnp.TestJsonAnnotations2.WRITER Dependency + { + get => BuildPointer(6); + set => Link(6, value); + } + + public @simpleGroup.WRITER SimpleGroup + { + get => Rewrap<@simpleGroup.WRITER>(); + } + + public ListOfPrimitivesSerializer Enums + { + get => BuildPointer>(8); + set => Link(8, value); + } + + public Capnp.Json.Value.WRITER InnerJson + { + get => BuildPointer(9); + set => Link(9, value); + } + + public string CustomFieldHandler + { + get => this.ReadText(10, ""); + set => this.WriteText(10, value, ""); + } + + public ListOfPrimitivesSerializer TestBase64 + { + get => BuildPointer>(11); + set => Link(11, value); + } + + public ListOfPrimitivesSerializer TestHex + { + get => BuildPointer>(12); + set => Link(12, value); + } + + public @bUnion.WRITER BUnion + { + get => Rewrap<@bUnion.WRITER>(); + } + + public Capnp.TestJsonAnnotations3.WRITER ExternalUnion + { + get => BuildPointer(14); + set => Link(14, value); + } + + public @unionWithVoid.WRITER UnionWithVoid + { + get => Rewrap<@unionWithVoid.WRITER>(); + } + } + + public class @aGroup : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + FlatFoo = reader.FlatFoo; + FlatBar = reader.FlatBar; + FlatBaz = CapnpSerializable.Create(reader.FlatBaz); + DoubleFlat = CapnpSerializable.Create(reader.DoubleFlat); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.FlatFoo = FlatFoo; + writer.FlatBar = FlatBar; + FlatBaz?.serialize(writer.FlatBaz); + DoubleFlat?.serialize(writer.DoubleFlat); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint FlatFoo + { + get; + set; + } + + public string FlatBar + { + get; + set; + } + + public Capnp.TestJsonAnnotations.@aGroup.@flatBaz FlatBaz + { + get; + set; + } + + public Capnp.TestJsonAnnotations.@aGroup.@doubleFlat DoubleFlat + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint FlatFoo => ctx.ReadDataUInt(0UL, 0U); + public string FlatBar => ctx.ReadText(1, ""); + public @flatBaz.READER FlatBaz => new @flatBaz.READER(ctx); + public @doubleFlat.READER DoubleFlat => new @doubleFlat.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public uint FlatFoo + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public string FlatBar + { + get => this.ReadText(1, ""); + set => this.WriteText(1, value, ""); + } + + public @flatBaz.WRITER FlatBaz + { + get => Rewrap<@flatBaz.WRITER>(); + } + + public @doubleFlat.WRITER DoubleFlat + { + get => Rewrap<@doubleFlat.WRITER>(); + } + } + + public class @flatBaz : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Hello = reader.Hello; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Hello = Hello; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool Hello + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public bool Hello => ctx.ReadDataBool(32UL, false); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public bool Hello + { + get => this.ReadDataBool(32UL, false); + set => this.WriteData(32UL, value, false); + } + } + } + + public class @doubleFlat : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + FlatQux = reader.FlatQux; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.FlatQux = FlatQux; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string FlatQux + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string FlatQux => ctx.ReadText(2, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public string FlatQux + { + get => this.ReadText(2, ""); + set => this.WriteText(2, value, ""); + } + } + } + } + + public class @prefixedGroup : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Foo = reader.Foo; + Bar = reader.Bar; + Baz = CapnpSerializable.Create(reader.Baz); + MorePrefix = CapnpSerializable.Create(reader.MorePrefix); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Foo = Foo; + writer.Bar = Bar; + Baz?.serialize(writer.Baz); + MorePrefix?.serialize(writer.MorePrefix); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Foo + { + get; + set; + } + + public uint Bar + { + get; + set; + } + + public Capnp.TestJsonAnnotations.@prefixedGroup.@baz Baz + { + get; + set; + } + + public Capnp.TestJsonAnnotations.@prefixedGroup.@morePrefix MorePrefix + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Foo => ctx.ReadText(3, ""); + public uint Bar => ctx.ReadDataUInt(64UL, 0U); + public @baz.READER Baz => new @baz.READER(ctx); + public @morePrefix.READER MorePrefix => new @morePrefix.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public string Foo + { + get => this.ReadText(3, ""); + set => this.WriteText(3, value, ""); + } + + public uint Bar + { + get => this.ReadDataUInt(64UL, 0U); + set => this.WriteData(64UL, value, 0U); + } + + public @baz.WRITER Baz + { + get => Rewrap<@baz.WRITER>(); + } + + public @morePrefix.WRITER MorePrefix + { + get => Rewrap<@morePrefix.WRITER>(); + } + } + + public class @baz : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Hello = reader.Hello; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Hello = Hello; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool Hello + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public bool Hello => ctx.ReadDataBool(33UL, false); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public bool Hello + { + get => this.ReadDataBool(33UL, false); + set => this.WriteData(33UL, value, false); + } + } + } + + public class @morePrefix : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Qux = reader.Qux; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Qux = Qux; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Qux + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Qux => ctx.ReadText(4, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public string Qux + { + get => this.ReadText(4, ""); + set => this.WriteText(4, value, ""); + } + } + } + } + + public class @aUnion : ICapnpSerializable + { + public enum WHICH : ushort + { + Foo = 0, + Bar = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Foo: + Foo = CapnpSerializable.Create(reader.Foo); + break; + case WHICH.Bar: + Bar = CapnpSerializable.Create(reader.Bar); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Foo: + _content = null; + break; + case WHICH.Bar: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Foo: + Foo?.serialize(writer.Foo); + break; + case WHICH.Bar: + Bar?.serialize(writer.Bar); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnp.TestJsonAnnotations.@aUnion.@foo Foo + { + get => _which == WHICH.Foo ? (Capnp.TestJsonAnnotations.@aUnion.@foo)_content : null; + set + { + _which = WHICH.Foo; + _content = value; + } + } + + public Capnp.TestJsonAnnotations.@aUnion.@bar Bar + { + get => _which == WHICH.Bar ? (Capnp.TestJsonAnnotations.@aUnion.@bar)_content : null; + set + { + _which = WHICH.Bar; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(48U, (ushort)0); + public @foo.READER Foo => which == WHICH.Foo ? new @foo.READER(ctx) : default; + public @bar.READER Bar => which == WHICH.Bar ? new @bar.READER(ctx) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(48U, (ushort)0); + set => this.WriteData(48U, (ushort)value, (ushort)0); + } + + public @foo.WRITER Foo + { + get => which == WHICH.Foo ? Rewrap<@foo.WRITER>() : default; + } + + public @bar.WRITER Bar + { + get => which == WHICH.Bar ? Rewrap<@bar.WRITER>() : default; + } + } + + public class @foo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + FooMember = reader.FooMember; + MultiMember = reader.MultiMember; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.FooMember = FooMember; + writer.MultiMember = MultiMember; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string FooMember + { + get; + set; + } + + public uint MultiMember + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string FooMember => ctx.ReadText(5, ""); + public uint MultiMember => ctx.ReadDataUInt(96UL, 0U); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public string FooMember + { + get => this.ReadText(5, ""); + set => this.WriteText(5, value, ""); + } + + public uint MultiMember + { + get => this.ReadDataUInt(96UL, 0U); + set => this.WriteData(96UL, value, 0U); + } + } + } + + public class @bar : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + BarMember = reader.BarMember; + MultiMember = reader.MultiMember; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.BarMember = BarMember; + writer.MultiMember = MultiMember; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint BarMember + { + get; + set; + } + + public string MultiMember + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint BarMember => ctx.ReadDataUInt(96UL, 0U); + public string MultiMember => ctx.ReadText(5, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public uint BarMember + { + get => this.ReadDataUInt(96UL, 0U); + set => this.WriteData(96UL, value, 0U); + } + + public string MultiMember + { + get => this.ReadText(5, ""); + set => this.WriteText(5, value, ""); + } + } + } + } + + public class @simpleGroup : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Grault = reader.Grault; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Grault = Grault; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Grault + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Grault => ctx.ReadText(7, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public string Grault + { + get => this.ReadText(7, ""); + set => this.WriteText(7, value, ""); + } + } + } + + public class @bUnion : ICapnpSerializable + { + public enum WHICH : ushort + { + Foo = 0, + Bar = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Foo: + Foo = reader.Foo; + break; + case WHICH.Bar: + Bar = reader.Bar; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Foo: + _content = null; + break; + case WHICH.Bar: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Foo: + writer.Foo = Foo; + break; + case WHICH.Bar: + writer.Bar = Bar.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Foo + { + get => _which == WHICH.Foo ? (string)_content : null; + set + { + _which = WHICH.Foo; + _content = value; + } + } + + public uint? Bar + { + get => _which == WHICH.Bar ? (uint? )_content : null; + set + { + _which = WHICH.Bar; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(128U, (ushort)0); + public string Foo => which == WHICH.Foo ? ctx.ReadText(13, "") : default; + public uint Bar => which == WHICH.Bar ? ctx.ReadDataUInt(160UL, 0U) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(128U, (ushort)0); + set => this.WriteData(128U, (ushort)value, (ushort)0); + } + + public string Foo + { + get => which == WHICH.Foo ? this.ReadText(13, "") : default; + set => this.WriteText(13, value, ""); + } + + public uint Bar + { + get => which == WHICH.Bar ? this.ReadDataUInt(160UL, 0U) : default; + set => this.WriteData(160UL, value, 0U); + } + } + } + + public class @unionWithVoid : ICapnpSerializable + { + public enum WHICH : ushort + { + IntValue = 0, + VoidValue = 1, + TextValue = 2, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.IntValue: + IntValue = reader.IntValue; + break; + case WHICH.VoidValue: + which = reader.which; + break; + case WHICH.TextValue: + TextValue = reader.TextValue; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.IntValue: + _content = 0; + break; + case WHICH.VoidValue: + break; + case WHICH.TextValue: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.IntValue: + writer.IntValue = IntValue.Value; + break; + case WHICH.VoidValue: + break; + case WHICH.TextValue: + writer.TextValue = TextValue; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint? IntValue + { + get => _which == WHICH.IntValue ? (uint? )_content : null; + set + { + _which = WHICH.IntValue; + _content = value; + } + } + + public string TextValue + { + get => _which == WHICH.TextValue ? (string)_content : null; + set + { + _which = WHICH.TextValue; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(144U, (ushort)0); + public uint IntValue => which == WHICH.IntValue ? ctx.ReadDataUInt(192UL, 0U) : default; + public string TextValue => which == WHICH.TextValue ? ctx.ReadText(15, "") : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(144U, (ushort)0); + set => this.WriteData(144U, (ushort)value, (ushort)0); + } + + public uint IntValue + { + get => which == WHICH.IntValue ? this.ReadDataUInt(192UL, 0U) : default; + set => this.WriteData(192UL, value, 0U); + } + + public string TextValue + { + get => which == WHICH.TextValue ? this.ReadText(15, "") : default; + set => this.WriteText(15, value, ""); + } + } + } + } + + public class TestJsonAnnotations2 : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Foo = reader.Foo; + Cycle = CapnpSerializable.Create(reader.Cycle); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Foo = Foo; + Cycle?.serialize(writer.Cycle); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Foo + { + get; + set; + } + + public Capnp.TestJsonAnnotations Cycle + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Foo => ctx.ReadText(0, ""); + public Capnp.TestJsonAnnotations.READER Cycle => ctx.ReadStruct(1, Capnp.TestJsonAnnotations.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public string Foo + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public Capnp.TestJsonAnnotations.WRITER Cycle + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + + public class TestJsonAnnotations3 : ICapnpSerializable + { + public enum WHICH : ushort + { + Foo = 0, + Bar = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Foo: + Foo = reader.Foo; + break; + case WHICH.Bar: + Bar = CapnpSerializable.Create(reader.Bar); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Foo: + _content = 0; + break; + case WHICH.Bar: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Foo: + writer.Foo = Foo.Value; + break; + case WHICH.Bar: + Bar?.serialize(writer.Bar); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint? Foo + { + get => _which == WHICH.Foo ? (uint? )_content : null; + set + { + _which = WHICH.Foo; + _content = value; + } + } + + public Capnp.TestFlattenedStruct Bar + { + get => _which == WHICH.Bar ? (Capnp.TestFlattenedStruct)_content : null; + set + { + _which = WHICH.Bar; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(32U, (ushort)0); + public uint Foo => which == WHICH.Foo ? ctx.ReadDataUInt(0UL, 0U) : default; + public Capnp.TestFlattenedStruct.READER Bar => which == WHICH.Bar ? ctx.ReadStruct(0, Capnp.TestFlattenedStruct.READER.create) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(32U, (ushort)0); + set => this.WriteData(32U, (ushort)value, (ushort)0); + } + + public uint Foo + { + get => which == WHICH.Foo ? this.ReadDataUInt(0UL, 0U) : default; + set => this.WriteData(0UL, value, 0U); + } + + public Capnp.TestFlattenedStruct.WRITER Bar + { + get => which == WHICH.Bar ? BuildPointer(0) : default; + set => Link(0, value); + } + } + } + + public class TestFlattenedStruct : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Value = reader.Value; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Value = Value; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Value + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Value => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string Value + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public enum TestJsonAnnotatedEnum : ushort + { + foo, + bar, + baz, + qux + } +} \ No newline at end of file diff --git a/MsBuildGenerationTest/capnp/compat/json.capnp b/MsBuildGenerationTest/capnp/compat/json.capnp new file mode 100644 index 0000000..ff6e7f9 --- /dev/null +++ b/MsBuildGenerationTest/capnp/compat/json.capnp @@ -0,0 +1,112 @@ +# Copyright (c) 2015 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0x8ef99297a43a5e34; + +$import "/capnp/c++.capnp".namespace("capnp::json"); + +struct Value { + union { + null @0 :Void; + boolean @1 :Bool; + number @2 :Float64; + string @3 :Text; + array @4 :List(Value); + object @5 :List(Field); + # Standard JSON values. + + call @6 :Call; + # Non-standard: A "function call", applying a named function (named by a single identifier) + # to a parameter list. Examples: + # + # BinData(0, "Zm9vCg==") + # ISODate("2015-04-15T08:44:50.218Z") + # + # Mongo DB users will recognize the above as exactly the syntax Mongo uses to represent BSON + # "binary" and "date" types in text, since JSON has no analog of these. This is basically the + # reason this extension exists. We do NOT recommend using `call` unless you specifically need + # to be compatible with some silly format that uses this syntax. + } + + struct Field { + name @0 :Text; + value @1 :Value; + } + + struct Call { + function @0 :Text; + params @1 :List(Value); + } +} + +# ======================================================================================== +# Annotations to control parsing. Typical usage: +# +# using Json = import "/capnp/compat/json.capnp"; +# +# And then later on: +# +# myField @0 :Text $Json.name("my_field"); + +annotation name @0xfa5b1fd61c2e7c3d (field, enumerant, method, group, union): Text; +# Define an alternative name to use when encoding the given item in JSON. This can be used, for +# example, to use snake_case names where needed, even though Cap'n Proto uses strictly camelCase. +# +# (However, because JSON is derived from JavaScript, you *should* use camelCase names when +# defining JSON-based APIs. But, when supporting a pre-existing API you may not have a choice.) + +annotation flatten @0x82d3e852af0336bf (field, group, union): FlattenOptions; +# Specifies that an aggregate field should be flattened into its parent. +# +# In order to flatten a member of a union, the union (or, for an anonymous union, the parent +# struct type) must have the $jsonDiscriminator annotation. +# +# TODO(someday): Maybe support "flattening" a List(Value.Field) as a way to support unknown JSON +# fields? + +struct FlattenOptions { + prefix @0 :Text = ""; + # Optional: Adds the given prefix to flattened field names. +} + +annotation discriminator @0xcfa794e8d19a0162 (struct, union): DiscriminatorOptions; +# Specifies that a union's variant will be decided not by which fields are present, but instead +# by a special discriminator field. The value of the discriminator field is a string naming which +# variant is active. This allows the members of the union to have the $jsonFlatten annotation, or +# to all have the same name. + +struct DiscriminatorOptions { + name @0 :Text; + # The name of the discriminator field. Defaults to matching the name of the union. + + valueName @1 :Text; + # If non-null, specifies that the union's value shall have the given field name, rather than the + # value's name. In this case the union's variant can only be determined by looking at the + # discriminant field, not by inspecting which value field is present. + # + # It is an error to use `valueName` while also declaring some variants as $flatten. +} + +annotation base64 @0xd7d879450a253e4b (field): Void; +# Place on a field of type `Data` to indicate that its JSON representation is a Base64 string. + +annotation hex @0xf061e22f0ae5c7b5 (field): Void; +# Place on a field of type `Data` to indicate that its JSON representation is a hex string. diff --git a/MsBuildGenerationTest/capnp/compat/json.capnp.cs b/MsBuildGenerationTest/capnp/compat/json.capnp.cs new file mode 100644 index 0000000..062257f --- /dev/null +++ b/MsBuildGenerationTest/capnp/compat/json.capnp.cs @@ -0,0 +1,536 @@ +using Capnp; +using Capnp.Rpc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Capnp.Json +{ + public class Value : ICapnpSerializable + { + public enum WHICH : ushort + { + Null = 0, + Boolean = 1, + Number = 2, + String = 3, + Array = 4, + Object = 5, + TheCall = 6, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Null: + which = reader.which; + break; + case WHICH.Boolean: + Boolean = reader.Boolean; + break; + case WHICH.Number: + Number = reader.Number; + break; + case WHICH.String: + String = reader.String; + break; + case WHICH.Array: + Array = reader.Array.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + break; + case WHICH.Object: + Object = reader.Object.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + break; + case WHICH.TheCall: + TheCall = CapnpSerializable.Create(reader.TheCall); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Null: + break; + case WHICH.Boolean: + _content = false; + break; + case WHICH.Number: + _content = 0; + break; + case WHICH.String: + _content = null; + break; + case WHICH.Array: + _content = null; + break; + case WHICH.Object: + _content = null; + break; + case WHICH.TheCall: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Null: + break; + case WHICH.Boolean: + writer.Boolean = Boolean.Value; + break; + case WHICH.Number: + writer.Number = Number.Value; + break; + case WHICH.String: + writer.String = String; + break; + case WHICH.Array: + writer.Array.Init(Array, (_s1, _v1) => _v1?.serialize(_s1)); + break; + case WHICH.Object: + writer.Object.Init(Object, (_s1, _v1) => _v1?.serialize(_s1)); + break; + case WHICH.TheCall: + TheCall?.serialize(writer.TheCall); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool? Boolean + { + get => _which == WHICH.Boolean ? (bool? )_content : null; + set + { + _which = WHICH.Boolean; + _content = value; + } + } + + public double? Number + { + get => _which == WHICH.Number ? (double? )_content : null; + set + { + _which = WHICH.Number; + _content = value; + } + } + + public string String + { + get => _which == WHICH.String ? (string)_content : null; + set + { + _which = WHICH.String; + _content = value; + } + } + + public IReadOnlyList Array + { + get => _which == WHICH.Array ? (IReadOnlyList)_content : null; + set + { + _which = WHICH.Array; + _content = value; + } + } + + public IReadOnlyList Object + { + get => _which == WHICH.Object ? (IReadOnlyList)_content : null; + set + { + _which = WHICH.Object; + _content = value; + } + } + + public Capnp.Json.Value.Call TheCall + { + get => _which == WHICH.TheCall ? (Capnp.Json.Value.Call)_content : null; + set + { + _which = WHICH.TheCall; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public bool Boolean => which == WHICH.Boolean ? ctx.ReadDataBool(16UL, false) : default; + public double Number => which == WHICH.Number ? ctx.ReadDataDouble(64UL, 0) : default; + public string String => which == WHICH.String ? ctx.ReadText(0, "") : default; + public IReadOnlyList Array => which == WHICH.Array ? ctx.ReadList(0).Cast(Capnp.Json.Value.READER.create) : default; + public IReadOnlyList Object => which == WHICH.Object ? ctx.ReadList(0).Cast(Capnp.Json.Value.Field.READER.create) : default; + public Capnp.Json.Value.Call.READER TheCall => which == WHICH.TheCall ? ctx.ReadStruct(0, Capnp.Json.Value.Call.READER.create) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(2, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public bool Boolean + { + get => which == WHICH.Boolean ? this.ReadDataBool(16UL, false) : default; + set => this.WriteData(16UL, value, false); + } + + public double Number + { + get => which == WHICH.Number ? this.ReadDataDouble(64UL, 0) : default; + set => this.WriteData(64UL, value, 0); + } + + public string String + { + get => which == WHICH.String ? this.ReadText(0, "") : default; + set => this.WriteText(0, value, ""); + } + + public ListOfStructsSerializer Array + { + get => which == WHICH.Array ? BuildPointer>(0) : default; + set => Link(0, value); + } + + public ListOfStructsSerializer Object + { + get => which == WHICH.Object ? BuildPointer>(0) : default; + set => Link(0, value); + } + + public Capnp.Json.Value.Call.WRITER TheCall + { + get => which == WHICH.TheCall ? BuildPointer(0) : default; + set => Link(0, value); + } + } + + public class Field : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Name = reader.Name; + Value = CapnpSerializable.Create(reader.Value); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Name = Name; + Value?.serialize(writer.Value); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Name + { + get; + set; + } + + public Capnp.Json.Value Value + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Name => ctx.ReadText(0, ""); + public Capnp.Json.Value.READER Value => ctx.ReadStruct(1, Capnp.Json.Value.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public string Name + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public Capnp.Json.Value.WRITER Value + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + + public class Call : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Function = reader.Function; + Params = reader.Params.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Function = Function; + writer.Params.Init(Params, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Function + { + get; + set; + } + + public IReadOnlyList Params + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Function => ctx.ReadText(0, ""); + public IReadOnlyList Params => ctx.ReadList(1).Cast(Capnp.Json.Value.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public string Function + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public ListOfStructsSerializer Params + { + get => BuildPointer>(1); + set => Link(1, value); + } + } + } + } + + public class FlattenOptions : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Prefix = reader.Prefix; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Prefix = Prefix; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + Prefix = Prefix ?? ""; + } + + public string Prefix + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Prefix => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string Prefix + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class DiscriminatorOptions : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Name = reader.Name; + ValueName = reader.ValueName; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Name = Name; + writer.ValueName = ValueName; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Name + { + get; + set; + } + + public string ValueName + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Name => ctx.ReadText(0, ""); + public string ValueName => ctx.ReadText(1, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public string Name + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public string ValueName + { + get => this.ReadText(1, ""); + set => this.WriteText(1, value, ""); + } + } + } +} \ No newline at end of file diff --git a/MsBuildGenerationTest/capnp/persistent.capnp b/MsBuildGenerationTest/capnp/persistent.capnp new file mode 100644 index 0000000..a13b471 --- /dev/null +++ b/MsBuildGenerationTest/capnp/persistent.capnp @@ -0,0 +1,139 @@ +# Copyright (c) 2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0xb8630836983feed7; + +$import "/capnp/c++.capnp".namespace("capnp"); + +interface Persistent@0xc8cb212fcd9f5691(SturdyRef, Owner) { + # Interface implemented by capabilities that outlive a single connection. A client may save() + # the capability, producing a SturdyRef. The SturdyRef can be stored to disk, then later used to + # obtain a new reference to the capability on a future connection. + # + # The exact format of SturdyRef depends on the "realm" in which the SturdyRef appears. A "realm" + # is an abstract space in which all SturdyRefs have the same format and refer to the same set of + # resources. Every vat is in exactly one realm. All capability clients within that vat must + # produce SturdyRefs of the format appropriate for the realm. + # + # Similarly, every VatNetwork also resides in a particular realm. Usually, a vat's "realm" + # corresponds to the realm of its main VatNetwork. However, a Vat can in fact communicate over + # a VatNetwork in a different realm -- in this case, all SturdyRefs need to be transformed when + # coming or going through said VatNetwork. The RPC system has hooks for registering + # transformation callbacks for this purpose. + # + # Since the format of SturdyRef is realm-dependent, it is not defined here. An application should + # choose an appropriate realm for itself as part of its design. Note that under Sandstorm, every + # application exists in its own realm and is therefore free to define its own SturdyRef format; + # the Sandstorm platform handles translating between realms. + # + # Note that whether a capability is persistent is often orthogonal to its type. In these cases, + # the capability's interface should NOT inherit `Persistent`; instead, just perform a cast at + # runtime. It's not type-safe, but trying to be type-safe in these cases will likely lead to + # tears. In cases where a particular interface only makes sense on persistent capabilities, it + # still should not explicitly inherit Persistent because the `SturdyRef` and `Owner` types will + # vary between realms (they may even be different at the call site than they are on the + # implementation). Instead, mark persistent interfaces with the $persistent annotation (defined + # below). + # + # Sealing + # ------- + # + # As an added security measure, SturdyRefs may be "sealed" to a particular owner, such that + # if the SturdyRef itself leaks to a third party, that party cannot actually restore it because + # they are not the owner. To restore a sealed capability, you must first prove to its host that + # you are the rightful owner. The precise mechanism for this authentication is defined by the + # realm. + # + # Sealing is a defense-in-depth mechanism meant to mitigate damage in the case of catastrophic + # attacks. For example, say an attacker temporarily gains read access to a database full of + # SturdyRefs: it would be unfortunate if it were then necessary to revoke every single reference + # in the database to prevent the attacker from using them. + # + # In general, an "owner" is a course-grained identity. Because capability-based security is still + # the primary mechanism of security, it is not necessary nor desirable to have a separate "owner" + # identity for every single process or object; that is exactly what capabilities are supposed to + # avoid! Instead, it makes sense for an "owner" to literally identify the owner of the machines + # where the capability is stored. If untrusted third parties are able to run arbitrary code on + # said machines, then the sandbox for that code should be designed using Distributed Confinement + # such that the third-party code never sees the bits of the SturdyRefs and cannot directly + # exercise the owner's power to restore refs. See: + # + # http://www.erights.org/elib/capability/dist-confine.html + # + # Resist the urge to represent an Owner as a simple public key. The whole point of sealing is to + # defend against leaked-storage attacks. Such attacks can easily result in the owner's private + # key being stolen as well. A better solution is for `Owner` to contain a simple globally unique + # identifier for the owner, and for everyone to separately maintain a mapping of owner IDs to + # public keys. If an owner's private key is compromised, then humans will need to communicate + # and agree on a replacement public key, then update the mapping. + # + # As a concrete example, an `Owner` could simply contain a domain name, and restoring a SturdyRef + # would require signing a request using the domain's private key. Authenticating this key could + # be accomplished through certificate authorities or web-of-trust techniques. + + save @0 SaveParams -> SaveResults; + # Save a capability persistently so that it can be restored by a future connection. Not all + # capabilities can be saved -- application interfaces should define which capabilities support + # this and which do not. + + struct SaveParams { + sealFor @0 :Owner; + # Seal the SturdyRef so that it can only be restored by the specified Owner. This is meant + # to mitigate damage when a SturdyRef is leaked. See comments above. + # + # Leaving this value null may or may not be allowed; it is up to the realm to decide. If a + # realm does allow a null owner, this should indicate that anyone is allowed to restore the + # ref. + } + struct SaveResults { + sturdyRef @0 :SturdyRef; + } +} + +interface RealmGateway(InternalRef, ExternalRef, InternalOwner, ExternalOwner) { + # Interface invoked when a SturdyRef is about to cross realms. The RPC system supports providing + # a RealmGateway as a callback hook when setting up RPC over some VatNetwork. + + import @0 (cap :Persistent(ExternalRef, ExternalOwner), + params :Persistent(InternalRef, InternalOwner).SaveParams) + -> Persistent(InternalRef, InternalOwner).SaveResults; + # Given an external capability, save it and return an internal reference. Used when someone + # inside the realm tries to save a capability from outside the realm. + + export @1 (cap :Persistent(InternalRef, InternalOwner), + params :Persistent(ExternalRef, ExternalOwner).SaveParams) + -> Persistent(ExternalRef, ExternalOwner).SaveResults; + # Given an internal capability, save it and return an external reference. Used when someone + # outside the realm tries to save a capability from inside the realm. +} + +annotation persistent(interface, field) :Void; +# Apply this annotation to interfaces for objects that will always be persistent, instead of +# extending the Persistent capability, since the correct type parameters to Persistent depend on +# the realm, which is orthogonal to the interface type and therefore should not be defined +# along-side it. +# +# You may also apply this annotation to a capability-typed field which will always contain a +# persistent capability, but where the capability's interface itself is not already marked +# persistent. +# +# Note that absence of the $persistent annotation doesn't mean a capability of that type isn't +# persistent; it just means not *all* such capabilities are persistent. diff --git a/MsBuildGenerationTest/capnp/rpc-twoparty.capnp b/MsBuildGenerationTest/capnp/rpc-twoparty.capnp new file mode 100644 index 0000000..0b670e8 --- /dev/null +++ b/MsBuildGenerationTest/capnp/rpc-twoparty.capnp @@ -0,0 +1,169 @@ +# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0xa184c7885cdaf2a1; +# This file defines the "network-specific parameters" in rpc.capnp to support a network consisting +# of two vats. Each of these vats may in fact be in communication with other vats, but any +# capabilities they forward must be proxied. Thus, to each end of the connection, all capabilities +# received from the other end appear to live in a single vat. +# +# Two notable use cases for this model include: +# - Regular client-server communications, where a remote client machine (perhaps living on an end +# user's personal device) connects to a server. The server may be part of a cluster, and may +# call on other servers in the cluster to help service the user's request. It may even obtain +# capabilities from these other servers which it passes on to the user. To simplify network +# common traversal problems (e.g. if the user is behind a firewall), it is probably desirable to +# multiplex all communications between the server cluster and the client over the original +# connection rather than form new ones. This connection should use the two-party protocol, as +# the client has no interest in knowing about additional servers. +# - Applications running in a sandbox. A supervisor process may execute a confined application +# such that all of the confined app's communications with the outside world must pass through +# the supervisor. In this case, the connection between the confined app and the supervisor might +# as well use the two-party protocol, because the confined app is intentionally prevented from +# talking to any other vat anyway. Any external resources will be proxied through the supervisor, +# and so to the contained app will appear as if they were hosted by the supervisor itself. +# +# Since there are only two vats in this network, there is never a need for three-way introductions, +# so level 3 is free. Moreover, because it is never necessary to form new connections, the +# two-party protocol can be used easily anywhere where a two-way byte stream exists, without regard +# to where that byte stream goes or how it was initiated. This makes the two-party runtime library +# highly reusable. +# +# Joins (level 4) _could_ be needed in cases where one or both vats are participating in other +# networks that use joins. For instance, if Alice and Bob are speaking through the two-party +# protocol, and Bob is also participating on another network, Bob may send Alice two or more +# proxied capabilities which, unbeknownst to Bob at the time, are in fact pointing at the same +# remote object. Alice may then request to join these capabilities, at which point Bob will have +# to forward the join to the other network. Note, however, that if Alice is _not_ participating on +# any other network, then Alice will never need to _receive_ a Join, because Alice would always +# know when two locally-hosted capabilities are the same and would never export a redundant alias +# to Bob. So, Alice can respond to all incoming joins with an error, and only needs to implement +# outgoing joins if she herself desires to use this feature. Also, outgoing joins are relatively +# easy to implement in this scenario. +# +# What all this means is that a level 4 implementation of the confined network is barely more +# complicated than a level 2 implementation. However, such an implementation allows the "client" +# or "confined" app to access the server's/supervisor's network with equal functionality to any +# native participant. In other words, an application which implements only the two-party protocol +# can be paired with a proxy app in order to participate in any network. +# +# So, when implementing Cap'n Proto in a new language, it makes sense to implement only the +# two-party protocol initially, and then pair applications with an appropriate proxy written in +# C++, rather than implement other parameterizations of the RPC protocol directly. + +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("capnp::rpc::twoparty"); + +# Note: SturdyRef is not specified here. It is up to the application to define semantics of +# SturdyRefs if desired. + +enum Side { + server @0; + # The object lives on the "server" or "supervisor" end of the connection. Only the + # server/supervisor knows how to interpret the ref; to the client, it is opaque. + # + # Note that containers intending to implement strong confinement should rewrite SturdyRefs + # received from the external network before passing them on to the confined app. The confined + # app thus does not ever receive the raw bits of the SturdyRef (which it could perhaps + # maliciously leak), but instead receives only a thing that it can pass back to the container + # later to restore the ref. See: + # http://www.erights.org/elib/capability/dist-confine.html + + client @1; + # The object lives on the "client" or "confined app" end of the connection. Only the client + # knows how to interpret the ref; to the server/supervisor, it is opaque. Most clients do not + # actually know how to persist capabilities at all, so use of this is unusual. +} + +struct VatId { + side @0 :Side; +} + +struct ProvisionId { + # Only used for joins, since three-way introductions never happen on a two-party network. + + joinId @0 :UInt32; + # The ID from `JoinKeyPart`. +} + +struct RecipientId {} +# Never used, because there are only two parties. + +struct ThirdPartyCapId {} +# Never used, because there is no third party. + +struct JoinKeyPart { + # Joins in the two-party case are simplified by a few observations. + # + # First, on a two-party network, a Join only ever makes sense if the receiving end is also + # connected to other networks. A vat which is not connected to any other network can safely + # reject all joins. + # + # Second, since a two-party connection bisects the network -- there can be no other connections + # between the networks at either end of the connection -- if one part of a join crosses the + # connection, then _all_ parts must cross it. Therefore, a vat which is receiving a Join request + # off some other network which needs to be forwarded across the two-party connection can + # collect all the parts on its end and only forward them across the two-party connection when all + # have been received. + # + # For example, imagine that Alice and Bob are vats connected over a two-party connection, and + # each is also connected to other networks. At some point, Alice receives one part of a Join + # request off her network. The request is addressed to a capability that Alice received from + # Bob and is proxying to her other network. Alice goes ahead and responds to the Join part as + # if she hosted the capability locally (this is important so that if not all the Join parts end + # up at Alice, the original sender can detect the failed Join without hanging). As other parts + # trickle in, Alice verifies that each part is addressed to a capability from Bob and continues + # to respond to each one. Once the complete set of join parts is received, Alice checks if they + # were all for the exact same capability. If so, she doesn't need to send anything to Bob at + # all. Otherwise, she collects the set of capabilities (from Bob) to which the join parts were + # addressed and essentially initiates a _new_ Join request on those capabilities to Bob. Alice + # does not forward the Join parts she received herself, but essentially forwards the Join as a + # whole. + # + # On Bob's end, since he knows that Alice will always send all parts of a Join together, he + # simply waits until he's received them all, then performs a join on the respective capabilities + # as if it had been requested locally. + + joinId @0 :UInt32; + # A number identifying this join, chosen by the sender. May be reused once `Finish` messages are + # sent corresponding to all of the `Join` messages. + + partCount @1 :UInt16; + # The number of capabilities to be joined. + + partNum @2 :UInt16; + # Which part this request targets -- a number in the range [0, partCount). +} + +struct JoinResult { + joinId @0 :UInt32; + # Matches `JoinKeyPart`. + + succeeded @1 :Bool; + # All JoinResults in the set will have the same value for `succeeded`. The receiver actually + # implements the join by waiting for all the `JoinKeyParts` and then performing its own join on + # them, then going back and answering all the join requests afterwards. + + cap @2 :AnyPointer; + # One of the JoinResults will have a non-null `cap` which is the joined capability. + # + # TODO(cleanup): Change `AnyPointer` to `Capability` when that is supported. +} diff --git a/MsBuildGenerationTest/capnp/rpc-twoparty.capnp.cs b/MsBuildGenerationTest/capnp/rpc-twoparty.capnp.cs new file mode 100644 index 0000000..4d66331 --- /dev/null +++ b/MsBuildGenerationTest/capnp/rpc-twoparty.capnp.cs @@ -0,0 +1,393 @@ +using Capnp; +using Capnp.Rpc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Capnp.Rpc.Twoparty +{ + public enum Side : ushort + { + server, + client + } + + public class VatId : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Side = reader.Side; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Side = Side; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnp.Rpc.Twoparty.Side Side + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnp.Rpc.Twoparty.Side Side => (Capnp.Rpc.Twoparty.Side)ctx.ReadDataUShort(0UL, (ushort)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public Capnp.Rpc.Twoparty.Side Side + { + get => (Capnp.Rpc.Twoparty.Side)this.ReadDataUShort(0UL, (ushort)0); + set => this.WriteData(0UL, (ushort)value, (ushort)0); + } + } + } + + public class ProvisionId : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + JoinId = reader.JoinId; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.JoinId = JoinId; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint JoinId + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint JoinId => ctx.ReadDataUInt(0UL, 0U); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public uint JoinId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + } + } + + public class RecipientId : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class ThirdPartyCapId : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class JoinKeyPart : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + JoinId = reader.JoinId; + PartCount = reader.PartCount; + PartNum = reader.PartNum; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.JoinId = JoinId; + writer.PartCount = PartCount; + writer.PartNum = PartNum; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint JoinId + { + get; + set; + } + + public ushort PartCount + { + get; + set; + } + + public ushort PartNum + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint JoinId => ctx.ReadDataUInt(0UL, 0U); + public ushort PartCount => ctx.ReadDataUShort(32UL, (ushort)0); + public ushort PartNum => ctx.ReadDataUShort(48UL, (ushort)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public uint JoinId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public ushort PartCount + { + get => this.ReadDataUShort(32UL, (ushort)0); + set => this.WriteData(32UL, value, (ushort)0); + } + + public ushort PartNum + { + get => this.ReadDataUShort(48UL, (ushort)0); + set => this.WriteData(48UL, value, (ushort)0); + } + } + } + + public class JoinResult : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + JoinId = reader.JoinId; + Succeeded = reader.Succeeded; + Cap = CapnpSerializable.Create(reader.Cap); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.JoinId = JoinId; + writer.Succeeded = Succeeded; + writer.Cap.SetObject(Cap); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint JoinId + { + get; + set; + } + + public bool Succeeded + { + get; + set; + } + + public AnyPointer Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint JoinId => ctx.ReadDataUInt(0UL, 0U); + public bool Succeeded => ctx.ReadDataBool(32UL, false); + public DeserializerState Cap => ctx.StructReadPointer(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public uint JoinId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public bool Succeeded + { + get => this.ReadDataBool(32UL, false); + set => this.WriteData(32UL, value, false); + } + + public DynamicSerializerState Cap + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } +} \ No newline at end of file diff --git a/MsBuildGenerationTest/capnp/rpc.capnp b/MsBuildGenerationTest/capnp/rpc.capnp new file mode 100644 index 0000000..86e86ea --- /dev/null +++ b/MsBuildGenerationTest/capnp/rpc.capnp @@ -0,0 +1,1409 @@ +# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0xb312981b2552a250; +# Recall that Cap'n Proto RPC allows messages to contain references to remote objects that +# implement interfaces. These references are called "capabilities", because they both designate +# the remote object to use and confer permission to use it. +# +# Recall also that Cap'n Proto RPC has the feature that when a method call itself returns a +# capability, the caller can begin calling methods on that capability _before the first call has +# returned_. The caller essentially sends a message saying "Hey server, as soon as you finish +# that previous call, do this with the result!". Cap'n Proto's RPC protocol makes this possible. +# +# The protocol is significantly more complicated than most RPC protocols. However, this is +# implementation complexity that underlies an easy-to-grasp higher-level model of object oriented +# programming. That is, just like TCP is a surprisingly complicated protocol that implements a +# conceptually-simple byte stream abstraction, Cap'n Proto is a surprisingly complicated protocol +# that implements a conceptually-simple object abstraction. +# +# Cap'n Proto RPC is based heavily on CapTP, the object-capability protocol used by the E +# programming language: +# http://www.erights.org/elib/distrib/captp/index.html +# +# Cap'n Proto RPC takes place between "vats". A vat hosts some set of objects and talks to other +# vats through direct bilateral connections. Typically, there is a 1:1 correspondence between vats +# and processes (in the unix sense of the word), although this is not strictly always true (one +# process could run multiple vats, or a distributed virtual vat might live across many processes). +# +# Cap'n Proto does not distinguish between "clients" and "servers" -- this is up to the application. +# Either end of any connection can potentially hold capabilities pointing to the other end, and +# can call methods on those capabilities. In the doc comments below, we use the words "sender" +# and "receiver". These refer to the sender and receiver of an instance of the struct or field +# being documented. Sometimes we refer to a "third-party" that is neither the sender nor the +# receiver. Documentation is generally written from the point of view of the sender. +# +# It is generally up to the vat network implementation to securely verify that connections are made +# to the intended vat as well as to encrypt transmitted data for privacy and integrity. See the +# `VatNetwork` example interface near the end of this file. +# +# When a new connection is formed, the only interesting things that can be done are to send a +# `Bootstrap` (level 0) or `Accept` (level 3) message. +# +# Unless otherwise specified, messages must be delivered to the receiving application in the same +# order in which they were initiated by the sending application. The goal is to support "E-Order", +# which states that two calls made on the same reference must be delivered in the order which they +# were made: +# http://erights.org/elib/concurrency/partial-order.html +# +# Since the full protocol is complicated, we define multiple levels of support that an +# implementation may target. For many applications, level 1 support will be sufficient. +# Comments in this file indicate which level requires the corresponding feature to be +# implemented. +# +# * **Level 0:** The implementation does not support object references. Only the bootstrap interface +# can be called. At this level, the implementation does not support object-oriented protocols and +# is similar in complexity to JSON-RPC or Protobuf services. This level should be considered only +# a temporary stepping-stone toward level 1 as the lack of object references drastically changes +# how protocols are designed. Applications _should not_ attempt to design their protocols around +# the limitations of level 0 implementations. +# +# * **Level 1:** The implementation supports simple bilateral interaction with object references +# and promise pipelining, but interactions between three or more parties are supported only via +# proxying of objects. E.g. if Alice (in Vat A) wants to send Bob (in Vat B) a capability +# pointing to Carol (in Vat C), Alice must create a proxy of Carol within Vat A and send Bob a +# reference to that; Bob cannot form a direct connection to Carol. Level 1 implementations do +# not support checking if two capabilities received from different vats actually point to the +# same object ("join"), although they should be able to do this check on capabilities received +# from the same vat. +# +# * **Level 2:** The implementation supports saving persistent capabilities -- i.e. capabilities +# that remain valid even after disconnect, and can be restored on a future connection. When a +# capability is saved, the requester receives a `SturdyRef`, which is a token that can be used +# to restore the capability later. +# +# * **Level 3:** The implementation supports three-way interactions. That is, if Alice (in Vat A) +# sends Bob (in Vat B) a capability pointing to Carol (in Vat C), then Vat B will automatically +# form a direct connection to Vat C rather than have requests be proxied through Vat A. +# +# * **Level 4:** The entire protocol is implemented, including joins (checking if two capabilities +# are equivalent). +# +# Note that an implementation must also support specific networks (transports), as described in +# the "Network-specific Parameters" section below. An implementation might have different levels +# depending on the network used. +# +# New implementations of Cap'n Proto should start out targeting the simplistic two-party network +# type as defined in `rpc-twoparty.capnp`. With this network type, level 3 is irrelevant and +# levels 2 and 4 are much easier than usual to implement. When such an implementation is paired +# with a container proxy, the contained app effectively gets to make full use of the proxy's +# network at level 4. And since Cap'n Proto IPC is extremely fast, it may never make sense to +# bother implementing any other vat network protocol -- just use the correct container type and get +# it for free. + +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("capnp::rpc"); + +# ======================================================================================== +# The Four Tables +# +# Cap'n Proto RPC connections are stateful (although an application built on Cap'n Proto could +# export a stateless interface). As in CapTP, for each open connection, a vat maintains four state +# tables: questions, answers, imports, and exports. See the diagram at: +# http://www.erights.org/elib/distrib/captp/4tables.html +# +# The question table corresponds to the other end's answer table, and the imports table corresponds +# to the other end's exports table. +# +# The entries in each table are identified by ID numbers (defined below as 32-bit integers). These +# numbers are always specific to the connection; a newly-established connection starts with no +# valid IDs. Since low-numbered IDs will pack better, it is suggested that IDs be assigned like +# Unix file descriptors -- prefer the lowest-number ID that is currently available. +# +# IDs in the questions/answers tables are chosen by the questioner and generally represent method +# calls that are in progress. +# +# IDs in the imports/exports tables are chosen by the exporter and generally represent objects on +# which methods may be called. Exports may be "settled", meaning the exported object is an actual +# object living in the exporter's vat, or they may be "promises", meaning the exported object is +# the as-yet-unknown result of an ongoing operation and will eventually be resolved to some other +# object once that operation completes. Calls made to a promise will be forwarded to the eventual +# target once it is known. The eventual replacement object does *not* get the same ID as the +# promise, as it may turn out to be an object that is already exported (so already has an ID) or +# may even live in a completely different vat (and so won't get an ID on the same export table +# at all). +# +# IDs can be reused over time. To make this safe, we carefully define the lifetime of IDs. Since +# messages using the ID could be traveling in both directions simultaneously, we must define the +# end of life of each ID _in each direction_. The ID is only safe to reuse once it has been +# released by both sides. +# +# When a Cap'n Proto connection is lost, everything on the four tables is lost. All questions are +# canceled and throw exceptions. All imports become broken (all future calls to them throw +# exceptions). All exports and answers are implicitly released. The only things not lost are +# persistent capabilities (`SturdyRef`s). The application must plan for this and should respond by +# establishing a new connection and restoring from these persistent capabilities. + +using QuestionId = UInt32; +# **(level 0)** +# +# Identifies a question in the sender's question table (which corresponds to the receiver's answer +# table). The questioner (caller) chooses an ID when making a call. The ID remains valid in +# caller -> callee messages until a Finish message is sent, and remains valid in callee -> caller +# messages until a Return message is sent. + +using AnswerId = QuestionId; +# **(level 0)** +# +# Identifies an answer in the sender's answer table (which corresponds to the receiver's question +# table). +# +# AnswerId is physically equivalent to QuestionId, since the question and answer tables correspond, +# but we define a separate type for documentation purposes: we always use the type representing +# the sender's point of view. + +using ExportId = UInt32; +# **(level 1)** +# +# Identifies an exported capability or promise in the sender's export table (which corresponds +# to the receiver's import table). The exporter chooses an ID before sending a capability over the +# wire. If the capability is already in the table, the exporter should reuse the same ID. If the +# ID is a promise (as opposed to a settled capability), this must be indicated at the time the ID +# is introduced (e.g. by using `senderPromise` instead of `senderHosted` in `CapDescriptor`); in +# this case, the importer shall expect a later `Resolve` message that replaces the promise. +# +# ExportId/ImportIds are subject to reference counting. Whenever an `ExportId` is sent over the +# wire (from the exporter to the importer), the export's reference count is incremented (unless +# otherwise specified). The reference count is later decremented by a `Release` message. Since +# the `Release` message can specify an arbitrary number by which to reduce the reference count, the +# importer should usually batch reference decrements and only send a `Release` when it believes the +# reference count has hit zero. Of course, it is possible that a new reference to the export is +# in-flight at the time that the `Release` message is sent, so it is necessary for the exporter to +# keep track of the reference count on its end as well to avoid race conditions. +# +# When a connection is lost, all exports are implicitly released. It is not possible to restore +# a connection state after disconnect (although a transport layer could implement a concept of +# persistent connections if it is transparent to the RPC layer). + +using ImportId = ExportId; +# **(level 1)** +# +# Identifies an imported capability or promise in the sender's import table (which corresponds to +# the receiver's export table). +# +# ImportId is physically equivalent to ExportId, since the export and import tables correspond, +# but we define a separate type for documentation purposes: we always use the type representing +# the sender's point of view. +# +# An `ImportId` remains valid in importer -> exporter messages until the importer has sent +# `Release` messages that (it believes) have reduced the reference count to zero. + +# ======================================================================================== +# Messages + +struct Message { + # An RPC connection is a bi-directional stream of Messages. + + union { + unimplemented @0 :Message; + # The sender previously received this message from the peer but didn't understand it or doesn't + # yet implement the functionality that was requested. So, the sender is echoing the message + # back. In some cases, the receiver may be able to recover from this by pretending the sender + # had taken some appropriate "null" action. + # + # For example, say `resolve` is received by a level 0 implementation (because a previous call + # or return happened to contain a promise). The level 0 implementation will echo it back as + # `unimplemented`. The original sender can then simply release the cap to which the promise + # had resolved, thus avoiding a leak. + # + # For any message type that introduces a question, if the message comes back unimplemented, + # the original sender may simply treat it as if the question failed with an exception. + # + # In cases where there is no sensible way to react to an `unimplemented` message (without + # resource leaks or other serious problems), the connection may need to be aborted. This is + # a gray area; different implementations may take different approaches. + + abort @1 :Exception; + # Sent when a connection is being aborted due to an unrecoverable error. This could be e.g. + # because the sender received an invalid or nonsensical message or because the sender had an + # internal error. The sender will shut down the outgoing half of the connection after `abort` + # and will completely close the connection shortly thereafter (it's up to the sender how much + # of a time buffer they want to offer for the client to receive the `abort` before the + # connection is reset). + + # Level 0 features ----------------------------------------------- + + bootstrap @8 :Bootstrap; # Request the peer's bootstrap interface. + call @2 :Call; # Begin a method call. + return @3 :Return; # Complete a method call. + finish @4 :Finish; # Release a returned answer / cancel a call. + + # Level 1 features ----------------------------------------------- + + resolve @5 :Resolve; # Resolve a previously-sent promise. + release @6 :Release; # Release a capability so that the remote object can be deallocated. + disembargo @13 :Disembargo; # Lift an embargo used to enforce E-order over promise resolution. + + # Level 2 features ----------------------------------------------- + + obsoleteSave @7 :AnyPointer; + # Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced + # by the `Persistent` interface defined in `persistent.capnp`. This operation was never + # implemented. + + obsoleteDelete @9 :AnyPointer; + # Obsolete way to delete a SturdyRef. This operation was never implemented. + + # Level 3 features ----------------------------------------------- + + provide @10 :Provide; # Provide a capability to a third party. + accept @11 :Accept; # Accept a capability provided by a third party. + + # Level 4 features ----------------------------------------------- + + join @12 :Join; # Directly connect to the common root of two or more proxied caps. + } +} + +# Level 0 message types ---------------------------------------------- + +struct Bootstrap { + # **(level 0)** + # + # Get the "bootstrap" interface exported by the remote vat. + # + # For level 0, 1, and 2 implementations, the "bootstrap" interface is simply the main interface + # exported by a vat. If the vat acts as a server fielding connections from clients, then the + # bootstrap interface defines the basic functionality available to a client when it connects. + # The exact interface definition obviously depends on the application. + # + # We call this a "bootstrap" because in an ideal Cap'n Proto world, bootstrap interfaces would + # never be used. In such a world, any time you connect to a new vat, you do so because you + # received an introduction from some other vat (see `ThirdPartyCapId`). Thus, the first message + # you send is `Accept`, and further communications derive from there. `Bootstrap` is not used. + # + # In such an ideal world, DNS itself would support Cap'n Proto -- performing a DNS lookup would + # actually return a new Cap'n Proto capability, thus introducing you to the target system via + # level 3 RPC. Applications would receive the capability to talk to DNS in the first place as + # an initial endowment or part of a Powerbox interaction. Therefore, an app can form arbitrary + # connections without ever using `Bootstrap`. + # + # Of course, in the real world, DNS is not Cap'n-Proto-based, and we don't want Cap'n Proto to + # require a whole new internet infrastructure to be useful. Therefore, we offer bootstrap + # interfaces as a way to get up and running without a level 3 introduction. Thus, bootstrap + # interfaces are used to "bootstrap" from other, non-Cap'n-Proto-based means of service discovery, + # such as legacy DNS. + # + # Note that a vat need not provide a bootstrap interface, and in fact many vats (especially those + # acting as clients) do not. In this case, the vat should either reply to `Bootstrap` with a + # `Return` indicating an exception, or should return a dummy capability with no methods. + + questionId @0 :QuestionId; + # A new question ID identifying this request, which will eventually receive a Return message + # containing the restored capability. + + deprecatedObjectId @1 :AnyPointer; + # ** DEPRECATED ** + # + # A Vat may export multiple bootstrap interfaces. In this case, `deprecatedObjectId` specifies + # which one to return. If this pointer is null, then the default bootstrap interface is returned. + # + # As of verison 0.5, use of this field is deprecated. If a service wants to export multiple + # bootstrap interfaces, it should instead define a single bootstrap interface that has methods + # that return each of the other interfaces. + # + # **History** + # + # In the first version of Cap'n Proto RPC (0.4.x) the `Bootstrap` message was called `Restore`. + # At the time, it was thought that this would eventually serve as the way to restore SturdyRefs + # (level 2). Meanwhile, an application could offer its "main" interface on a well-known + # (non-secret) SturdyRef. + # + # Since level 2 RPC was not implemented at the time, the `Restore` message was in practice only + # used to obtain the main interface. Since most applications had only one main interface that + # they wanted to restore, they tended to designate this with a null `objectId`. + # + # Unfortunately, the earliest version of the EZ RPC interfaces set a precedent of exporting + # multiple main interfaces by allowing them to be exported under string names. In this case, + # `objectId` was a Text value specifying the name. + # + # All of this proved problematic for several reasons: + # + # - The arrangement assumed that a client wishing to restore a SturdyRef would know exactly what + # machine to connect to and would be able to immediately restore a SturdyRef on connection. + # However, in practice, the ability to restore SturdyRefs is itself a capability that may + # require going through an authentication process to obtain. Thus, it makes more sense to + # define a "restorer service" as a full Cap'n Proto interface. If this restorer interface is + # offered as the vat's bootstrap interface, then this is equivalent to the old arrangement. + # + # - Overloading "Restore" for the purpose of obtaining well-known capabilities encouraged the + # practice of exporting singleton services with string names. If singleton services are desired, + # it is better to have one main interface that has methods that can be used to obtain each + # service, in order to get all the usual benefits of schemas and type checking. + # + # - Overloading "Restore" also had a security problem: Often, "main" or "well-known" + # capabilities exported by a vat are in fact not public: they are intended to be accessed only + # by clients who are capable of forming a connection to the vat. This can lead to trouble if + # the client itself has other clients and wishes to foward some `Restore` requests from those + # external clients -- it has to be very careful not to allow through `Restore` requests + # addressing the default capability. + # + # For example, consider the case of a sandboxed Sandstorm application and its supervisor. The + # application exports a default capability to its supervisor that provides access to + # functionality that only the supervisor is supposed to access. Meanwhile, though, applications + # may publish other capabilities that may be persistent, in which case the application needs + # to field `Restore` requests that could come from anywhere. These requests of course have to + # pass through the supervisor, as all communications with the outside world must. But, the + # supervisor has to be careful not to honor an external request addressing the application's + # default capability, since this capability is privileged. Unfortunately, the default + # capability cannot be given an unguessable name, because then the supervisor itself would not + # be able to address it! + # + # As of Cap'n Proto 0.5, `Restore` has been renamed to `Bootstrap` and is no longer planned for + # use in restoring SturdyRefs. + # + # Note that 0.4 also defined a message type called `Delete` that, like `Restore`, addressed a + # SturdyRef, but indicated that the client would not restore the ref again in the future. This + # operation was never implemented, so it was removed entirely. If a "delete" operation is desired, + # it should exist as a method on the same interface that handles restoring SturdyRefs. However, + # the utility of such an operation is questionable. You wouldn't be able to rely on it for + # garbage collection since a client could always disappear permanently without remembering to + # delete all its SturdyRefs, thus leaving them dangling forever. Therefore, it is advisable to + # design systems such that SturdyRefs never represent "owned" pointers. + # + # For example, say a SturdyRef points to an image file hosted on some server. That image file + # should also live inside a collection (a gallery, perhaps) hosted on the same server, owned by + # a user who can delete the image at any time. If the user deletes the image, the SturdyRef + # stops working. On the other hand, if the SturdyRef is discarded, this has no effect on the + # existence of the image in its collection. +} + +struct Call { + # **(level 0)** + # + # Message type initiating a method call on a capability. + + questionId @0 :QuestionId; + # A number, chosen by the caller, that identifies this call in future messages. This number + # must be different from all other calls originating from the same end of the connection (but + # may overlap with question IDs originating from the opposite end). A fine strategy is to use + # sequential question IDs, but the recipient should not assume this. + # + # A question ID can be reused once both: + # - A matching Return has been received from the callee. + # - A matching Finish has been sent from the caller. + + target @1 :MessageTarget; + # The object that should receive this call. + + interfaceId @2 :UInt64; + # The type ID of the interface being called. Each capability may implement multiple interfaces. + + methodId @3 :UInt16; + # The ordinal number of the method to call within the requested interface. + + allowThirdPartyTailCall @8 :Bool = false; + # Indicates whether or not the receiver is allowed to send a `Return` containing + # `acceptFromThirdParty`. Level 3 implementations should set this true. Otherwise, the callee + # will have to proxy the return in the case of a tail call to a third-party vat. + + params @4 :Payload; + # The call parameters. `params.content` is a struct whose fields correspond to the parameters of + # the method. + + sendResultsTo :union { + # Where should the return message be sent? + + caller @5 :Void; + # Send the return message back to the caller (the usual). + + yourself @6 :Void; + # **(level 1)** + # + # Don't actually return the results to the sender. Instead, hold on to them and await + # instructions from the sender regarding what to do with them. In particular, the sender + # may subsequently send a `Return` for some other call (which the receiver had previously made + # to the sender) with `takeFromOtherQuestion` set. The results from this call are then used + # as the results of the other call. + # + # When `yourself` is used, the receiver must still send a `Return` for the call, but sets the + # field `resultsSentElsewhere` in that `Return` rather than including the results. + # + # This feature can be used to implement tail calls in which a call from Vat A to Vat B ends up + # returning the result of a call from Vat B back to Vat A. + # + # In particular, the most common use case for this feature is when Vat A makes a call to a + # promise in Vat B, and then that promise ends up resolving to a capability back in Vat A. + # Vat B must forward all the queued calls on that promise back to Vat A, but can set `yourself` + # in the calls so that the results need not pass back through Vat B. + # + # For example: + # - Alice, in Vat A, calls foo() on Bob in Vat B. + # - Alice makes a pipelined call bar() on the promise returned by foo(). + # - Later on, Bob resolves the promise from foo() to point at Carol, who lives in Vat A (next + # to Alice). + # - Vat B dutifully forwards the bar() call to Carol. Let us call this forwarded call bar'(). + # Notice that bar() and bar'() are travelling in opposite directions on the same network + # link. + # - The `Call` for bar'() has `sendResultsTo` set to `yourself`. + # - Vat B sends a `Return` for bar() with `takeFromOtherQuestion` set in place of the results, + # with the value set to the question ID of bar'(). Vat B does not wait for bar'() to return, + # as doing so would introduce unnecessary round trip latency. + # - Vat A receives bar'() and delivers it to Carol. + # - When bar'() returns, Vat A sends a `Return` for bar'() to Vat B, with `resultsSentElsewhere` + # set in place of results. + # - Vat A sends a `Finish` for the bar() call to Vat B. + # - Vat B receives the `Finish` for bar() and sends a `Finish` for bar'(). + + thirdParty @7 :RecipientId; + # **(level 3)** + # + # The call's result should be returned to a different vat. The receiver (the callee) expects + # to receive an `Accept` message from the indicated vat, and should return the call's result + # to it, rather than to the sender of the `Call`. + # + # This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call` + # messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from + # Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends + # an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C + # also sends a `Return` to Vat B with `resultsSentElsewhere`. + } +} + +struct Return { + # **(level 0)** + # + # Message type sent from callee to caller indicating that the call has completed. + + answerId @0 :AnswerId; + # Equal to the QuestionId of the corresponding `Call` message. + + releaseParamCaps @1 :Bool = true; + # If true, all capabilities that were in the params should be considered released. The sender + # must not send separate `Release` messages for them. Level 0 implementations in particular + # should always set this true. This defaults true because if level 0 implementations forget to + # set it they'll never notice (just silently leak caps), but if level >=1 implementations forget + # to set it to false they'll quickly get errors. + # + # The receiver should act as if the sender had sent a release message with count=1 for each + # CapDescriptor in the original Call message. + + union { + results @2 :Payload; + # The result. + # + # For regular method calls, `results.content` points to the result struct. + # + # For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single + # capability (rather than a struct), and `results.content` is just a capability pointer with + # index 0. A `Finish` is still required in this case. + + exception @3 :Exception; + # Indicates that the call failed and explains why. + + canceled @4 :Void; + # Indicates that the call was canceled due to the caller sending a Finish message + # before the call had completed. + + resultsSentElsewhere @5 :Void; + # This is set when returning from a `Call` that had `sendResultsTo` set to something other + # than `caller`. + # + # It doesn't matter too much when this is sent, as the receiver doesn't need to do anything + # with it, but the C++ implementation appears to wait for the call to finish before sending + # this. + + takeFromOtherQuestion @6 :QuestionId; + # The sender has also sent (before this message) a `Call` with the given question ID and with + # `sendResultsTo.yourself` set, and the results of that other call should be used as the + # results here. `takeFromOtherQuestion` can only used once per question. + + acceptFromThirdParty @7 :ThirdPartyCapId; + # **(level 3)** + # + # The caller should contact a third-party vat to pick up the results. An `Accept` message + # sent to the vat will return the result. This pairs with `Call.sendResultsTo.thirdParty`. + # It should only be used if the corresponding `Call` had `allowThirdPartyTailCall` set. + } +} + +struct Finish { + # **(level 0)** + # + # Message type sent from the caller to the callee to indicate: + # 1) The questionId will no longer be used in any messages sent by the callee (no further + # pipelined requests). + # 2) If the call has not returned yet, the caller no longer cares about the result. If nothing + # else cares about the result either (e.g. there are no other outstanding calls pipelined on + # the result of this one) then the callee may wish to immediately cancel the operation and + # send back a Return message with "canceled" set. However, implementations are not required + # to support premature cancellation -- instead, the implementation may wait until the call + # actually completes and send a normal `Return` message. + # + # TODO(someday): Should we separate (1) and implicitly releasing result capabilities? It would be + # possible and useful to notify the server that it doesn't need to keep around the response to + # service pipeline requests even though the caller still wants to receive it / hasn't yet + # finished processing it. It could also be useful to notify the server that it need not marshal + # the results because the caller doesn't want them anyway, even if the caller is still sending + # pipelined calls, although this seems less useful (just saving some bytes on the wire). + + questionId @0 :QuestionId; + # ID of the call whose result is to be released. + + releaseResultCaps @1 :Bool = true; + # If true, all capabilities that were in the results should be considered released. The sender + # must not send separate `Release` messages for them. Level 0 implementations in particular + # should always set this true. This defaults true because if level 0 implementations forget to + # set it they'll never notice (just silently leak caps), but if level >=1 implementations forget + # set it false they'll quickly get errors. +} + +# Level 1 message types ---------------------------------------------- + +struct Resolve { + # **(level 1)** + # + # Message type sent to indicate that a previously-sent promise has now been resolved to some other + # object (possibly another promise) -- or broken, or canceled. + # + # Keep in mind that it's possible for a `Resolve` to be sent to a level 0 implementation that + # doesn't implement it. For example, a method call or return might contain a capability in the + # payload. Normally this is fine even if the receiver is level 0, because they will implicitly + # release all such capabilities on return / finish. But if the cap happens to be a promise, then + # a follow-up `Resolve` may be sent regardless of this release. The level 0 receiver will reply + # with an `unimplemented` message, and the sender (of the `Resolve`) can respond to this as if the + # receiver had immediately released any capability to which the promise resolved. + # + # When implementing promise resolution, it's important to understand how embargos work and the + # tricky case of the Tribble 4-way race condition. See the comments for the Disembargo message, + # below. + + promiseId @0 :ExportId; + # The ID of the promise to be resolved. + # + # Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does + # _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver + # will release the export soon after receiving `Resolve`, and the sender will not send this + # `ExportId` again until it has been released and recycled. + # + # When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise, + # this indicates that the sender will follow up at some point with a `Resolve` message. If the + # same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the + # same ID is sent again later _after_ a `Resolve`, it can only be because the export's + # reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore + # this later promise does _not_ correspond to the earlier `Resolve`. + # + # If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve` + # message may or may not still be sent (the `Resolve` may have already been in-flight when + # `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer + # any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which + # the receiver has no knowledge, because it already released it earlier. In this case, the + # receiver should simply release the capability to which the promise resolved. + + union { + cap @1 :CapDescriptor; + # The object to which the promise resolved. + # + # The sender promises that from this point forth, until `promiseId` is released, it shall + # simply forward all messages to the capability designated by `cap`. This is true even if + # `cap` itself happens to desigate another promise, and that other promise later resolves -- + # messages sent to `promiseId` shall still go to that other promise, not to its resolution. + # This is important in the case that the receiver of the `Resolve` ends up sending a + # `Disembargo` message towards `promiseId` in order to control message ordering -- that + # `Disembargo` really needs to reflect back to exactly the object designated by `cap` even + # if that object is itself a promise. + + exception @2 :Exception; + # Indicates that the promise was broken. + } +} + +struct Release { + # **(level 1)** + # + # Message type sent to indicate that the sender is done with the given capability and the receiver + # can free resources allocated to it. + + id @0 :ImportId; + # What to release. + + referenceCount @1 :UInt32; + # The amount by which to decrement the reference count. The export is only actually released + # when the reference count reaches zero. +} + +struct Disembargo { + # **(level 1)** + # + # Message sent to indicate that an embargo on a recently-resolved promise may now be lifted. + # + # Embargos are used to enforce E-order in the presence of promise resolution. That is, if an + # application makes two calls foo() and bar() on the same capability reference, in that order, + # the calls should be delivered in the order in which they were made. But if foo() is called + # on a promise, and that promise happens to resolve before bar() is called, then the two calls + # may travel different paths over the network, and thus could arrive in the wrong order. In + # this case, the call to `bar()` must be embargoed, and a `Disembargo` message must be sent along + # the same path as `foo()` to ensure that the `Disembargo` arrives after `foo()`. Once the + # `Disembargo` arrives, `bar()` can then be delivered. + # + # There are two particular cases where embargos are important. Consider object Alice, in Vat A, + # who holds a promise P, pointing towards Vat B, that eventually resolves to Carol. The two + # cases are: + # - Carol lives in Vat A, i.e. next to Alice. In this case, Vat A needs to send a `Disembargo` + # message that echos through Vat B and back, to ensure that all pipelined calls on the promise + # have been delivered. + # - Carol lives in a different Vat C. When the promise resolves, a three-party handoff occurs + # (see `Provide` and `Accept`, which constitute level 3 of the protocol). In this case, we + # piggyback on the state that has already been set up to handle the handoff: the `Accept` + # message (from Vat A to Vat C) is embargoed, as are all pipelined messages sent to it, while + # a `Disembargo` message is sent from Vat A through Vat B to Vat C. See `Accept.embargo` for + # an example. + # + # Note that in the case where Carol actually lives in Vat B (i.e., the same vat that the promise + # already pointed at), no embargo is needed, because the pipelined calls are delivered over the + # same path as the later direct calls. + # + # Keep in mind that promise resolution happens both in the form of Resolve messages as well as + # Return messages (which resolve PromisedAnswers). Embargos apply in both cases. + # + # An alternative strategy for enforcing E-order over promise resolution could be for Vat A to + # implement the embargo internally. When Vat A is notified of promise resolution, it could + # send a dummy no-op call to promise P and wait for it to complete. Until that call completes, + # all calls to the capability are queued locally. This strategy works, but is pessimistic: + # in the three-party case, it requires an A -> B -> C -> B -> A round trip before calls can start + # being delivered directly to from Vat A to Vat C. The `Disembargo` message allows latency to be + # reduced. (In the two-party loopback case, the `Disembargo` message is just a more explicit way + # of accomplishing the same thing as a no-op call, but isn't any faster.) + # + # *The Tribble 4-way Race Condition* + # + # Any implementation of promise resolution and embargos must be aware of what we call the + # "Tribble 4-way race condition", after Dean Tribble, who explained the problem in a lively + # Friam meeting. + # + # Embargos are designed to work in the case where a two-hop path is being shortened to one hop. + # But sometimes there are more hops. Imagine that Alice has a reference to a remote promise P1 + # that eventually resolves to _another_ remote promise P2 (in a third vat), which _at the same + # time_ happens to resolve to Bob (in a fourth vat). In this case, we're shortening from a 3-hop + # path (with four parties) to a 1-hop path (Alice -> Bob). + # + # Extending the embargo/disembargo protocol to be able to shorted multiple hops at once seems + # difficult. Instead, we make a rule that prevents this case from coming up: + # + # One a promise P has been resolved to a remote object reference R, then all further messages + # received addressed to P will be forwarded strictly to R. Even if it turns out later that R is + # itself a promise, and has resolved to some other object Q, messages sent to P will still be + # forwarded to R, not directly to Q (R will of course further forward the messages to Q). + # + # This rule does not cause a significant performance burden because once P has resolved to R, it + # is expected that people sending messages to P will shortly start sending them to R instead and + # drop P. P is at end-of-life anyway, so it doesn't matter if it ignores chances to further + # optimize its path. + + target @0 :MessageTarget; + # What is to be disembargoed. + + using EmbargoId = UInt32; + # Used in `senderLoopback` and `receiverLoopback`, below. + + context :union { + senderLoopback @1 :EmbargoId; + # The sender is requesting a disembargo on a promise that is known to resolve back to a + # capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls + # on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback` + # set to the same value as `senderLoopback`. This value is chosen by the sender, and since + # it is also consumed be the sender, the sender can use whatever strategy it wants to make sure + # the value is unambiguous. + # + # The receiver must verify that the target capability actually resolves back to the sender's + # vat. Otherwise, the sender has committed a protocol error and should be disconnected. + + receiverLoopback @2 :EmbargoId; + # The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to + # this capability, and that Disembargo is now being echoed back. + + accept @3 :Void; + # **(level 3)** + # + # The sender is requesting a disembargo on a promise that is known to resolve to a third-party + # capability that the sender is currently in the process of accepting (using `Accept`). + # The receiver of this `Disembargo` has an outstanding `Provide` on said capability. The + # receiver should now send a `Disembargo` with `provide` set to the question ID of that + # `Provide` message. + # + # See `Accept.embargo` for an example. + + provide @4 :QuestionId; + # **(level 3)** + # + # The sender is requesting a disembargo on a capability currently being provided to a third + # party. The question ID identifies the `Provide` message previously sent by the sender to + # this capability. On receipt, the receiver (the capability host) shall release the embargo + # on the `Accept` message that it has received from the third party. See `Accept.embargo` for + # an example. + } +} + +# Level 2 message types ---------------------------------------------- + +# See persistent.capnp. + +# Level 3 message types ---------------------------------------------- + +struct Provide { + # **(level 3)** + # + # Message type sent to indicate that the sender wishes to make a particular capability implemented + # by the receiver available to a third party for direct access (without the need for the third + # party to proxy through the sender). + # + # (In CapTP, `Provide` and `Accept` are methods of the global `NonceLocator` object exported by + # every vat. In Cap'n Proto, we bake this into the core protocol.) + + questionId @0 :QuestionId; + # Question ID to be held open until the recipient has received the capability. A result will be + # returned once the third party has successfully received the capability. The sender must at some + # point send a `Finish` message as with any other call, and that message can be used to cancel the + # whole operation. + + target @1 :MessageTarget; + # What is to be provided to the third party. + + recipient @2 :RecipientId; + # Identity of the third party that is expected to pick up the capability. +} + +struct Accept { + # **(level 3)** + # + # Message type sent to pick up a capability hosted by the receiving vat and provided by a third + # party. The third party previously designated the capability using `Provide`. + # + # This message is also used to pick up a redirected return -- see `Return.acceptFromThirdParty`. + + questionId @0 :QuestionId; + # A new question ID identifying this accept message, which will eventually receive a Return + # message containing the provided capability (or the call result in the case of a redirected + # return). + + provision @1 :ProvisionId; + # Identifies the provided object to be picked up. + + embargo @2 :Bool; + # If true, this accept shall be temporarily embargoed. The resulting `Return` will not be sent, + # and any pipelined calls will not be delivered, until the embargo is released. The receiver + # (the capability host) will expect the provider (the vat that sent the `Provide` message) to + # eventually send a `Disembargo` message with the field `context.provide` set to the question ID + # of the original `Provide` message. At that point, the embargo is released and the queued + # messages are delivered. + # + # For example: + # - Alice, in Vat A, holds a promise P, which currently points toward Vat B. + # - Alice calls foo() on P. The `Call` message is sent to Vat B. + # - The promise P in Vat B ends up resolving to Carol, in Vat C. + # - Vat B sends a `Provide` message to Vat C, identifying Vat A as the recipient. + # - Vat B sends a `Resolve` message to Vat A, indicating that the promise has resolved to a + # `ThirdPartyCapId` identifying Carol in Vat C. + # - Vat A sends an `Accept` message to Vat C to pick up the capability. Since Vat A knows that + # it has an outstanding call to the promise, it sets `embargo` to `true` in the `Accept` + # message. + # - Vat A sends a `Disembargo` message to Vat B on promise P, with `context.accept` set. + # - Alice makes a call bar() to promise P, which is now pointing towards Vat C. Alice doesn't + # know anything about the mechanics of promise resolution happening under the hood, but she + # expects that bar() will be delivered after foo() because that is the order in which she + # initiated the calls. + # - Vat A sends the bar() call to Vat C, as a pipelined call on the result of the `Accept` (which + # hasn't returned yet, due to the embargo). Since calls to the newly-accepted capability + # are embargoed, Vat C does not deliver the call yet. + # - At some point, Vat B forwards the foo() call from the beginning of this example on to Vat C. + # - Vat B forwards the `Disembargo` from Vat A on to vat C. It sets `context.provide` to the + # question ID of the `Provide` message it had sent previously. + # - Vat C receives foo() before `Disembargo`, thus allowing it to correctly deliver foo() + # before delivering bar(). + # - Vat C receives `Disembargo` from Vat B. It can now send a `Return` for the `Accept` from + # Vat A, as well as deliver bar(). +} + +# Level 4 message types ---------------------------------------------- + +struct Join { + # **(level 4)** + # + # Message type sent to implement E.join(), which, given a number of capabilities that are + # expected to be equivalent, finds the underlying object upon which they all agree and forms a + # direct connection to it, skipping any proxies that may have been constructed by other vats + # while transmitting the capability. See: + # http://erights.org/elib/equality/index.html + # + # Note that this should only serve to bypass fully-transparent proxies -- proxies that were + # created merely for convenience, without any intention of hiding the underlying object. + # + # For example, say Bob holds two capabilities hosted by Alice and Carol, but he expects that both + # are simply proxies for a capability hosted elsewhere. He then issues a join request, which + # operates as follows: + # - Bob issues Join requests on both Alice and Carol. Each request contains a different piece + # of the JoinKey. + # - Alice is proxying a capability hosted by Dana, so forwards the request to Dana's cap. + # - Dana receives the first request and sees that the JoinKeyPart is one of two. She notes that + # she doesn't have the other part yet, so she records the request and responds with a + # JoinResult. + # - Alice relays the JoinAswer back to Bob. + # - Carol is also proxying a capability from Dana, and so forwards her Join request to Dana as + # well. + # - Dana receives Carol's request and notes that she now has both parts of a JoinKey. She + # combines them in order to form information needed to form a secure connection to Bob. She + # also responds with another JoinResult. + # - Bob receives the responses from Alice and Carol. He uses the returned JoinResults to + # determine how to connect to Dana and attempts to form the connection. Since Bob and Dana now + # agree on a secret key that neither Alice nor Carol ever saw, this connection can be made + # securely even if Alice or Carol is conspiring against the other. (If Alice and Carol are + # conspiring _together_, they can obviously reproduce the key, but this doesn't matter because + # the whole point of the join is to verify that Alice and Carol agree on what capability they + # are proxying.) + # + # If the two capabilities aren't actually proxies of the same object, then the join requests + # will come back with conflicting `hostId`s and the join will fail before attempting to form any + # connection. + + questionId @0 :QuestionId; + # Question ID used to respond to this Join. (Note that this ID only identifies one part of the + # request for one hop; each part has a different ID and relayed copies of the request have + # (probably) different IDs still.) + # + # The receiver will reply with a `Return` whose `results` is a JoinResult. This `JoinResult` + # is relayed from the joined object's host, possibly with transformation applied as needed + # by the network. + # + # Like any return, the result must be released using a `Finish`. However, this release + # should not occur until the joiner has either successfully connected to the joined object. + # Vats relaying a `Join` message similarly must not release the result they receive until the + # return they relayed back towards the joiner has itself been released. This allows the + # joined object's host to detect when the Join operation is canceled before completing -- if + # it receives a `Finish` for one of the join results before the joiner successfully + # connects. It can then free any resources it had allocated as part of the join. + + target @1 :MessageTarget; + # The capability to join. + + keyPart @2 :JoinKeyPart; + # A part of the join key. These combine to form the complete join key, which is used to establish + # a direct connection. + + # TODO(before implementing): Change this so that multiple parts can be sent in a single Join + # message, so that if multiple join parts are going to cross the same connection they can be sent + # together, so that the receive can potentially optimize its handling of them. In the case where + # all parts are bundled together, should the recipient be expected to simply return a cap, so + # that the caller can immediately start pipelining to it? +} + +# ======================================================================================== +# Common structures used in messages + +struct MessageTarget { + # The target of a `Call` or other messages that target a capability. + + union { + importedCap @0 :ImportId; + # This message is to a capability or promise previously imported by the caller (exported by + # the receiver). + + promisedAnswer @1 :PromisedAnswer; + # This message is to a capability that is expected to be returned by another call that has not + # yet been completed. + # + # At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so + # that initial startup doesn't require a round trip. + } +} + +struct Payload { + # Represents some data structure that might contain capabilities. + + content @0 :AnyPointer; + # Some Cap'n Proto data structure. Capability pointers embedded in this structure index into + # `capTable`. + + capTable @1 :List(CapDescriptor); + # Descriptors corresponding to the cap pointers in `content`. +} + +struct CapDescriptor { + # **(level 1)** + # + # When an application-defined type contains an interface pointer, that pointer contains an index + # into the message's capability table -- i.e. the `capTable` part of the `Payload`. Each + # capability in the table is represented as a `CapDescriptor`. The runtime API should not reveal + # the CapDescriptor directly to the application, but should instead wrap it in some kind of + # callable object with methods corresponding to the interface that the capability implements. + # + # Keep in mind that `ExportIds` in a `CapDescriptor` are subject to reference counting. See the + # description of `ExportId`. + # + # Note that it is currently not possible to include a broken capability in the CapDescriptor + # table. Instead, create a new export (`senderPromise`) for each broken capability and then + # immediately follow the payload-bearing Call or Return message with one Resolve message for each + # broken capability, resolving it to an exception. + + union { + none @0 :Void; + # There is no capability here. This `CapDescriptor` should not appear in the payload content. + # A `none` CapDescriptor can be generated when an application inserts a capability into a + # message and then later changes its mind and removes it -- rewriting all of the other + # capability pointers may be hard, so instead a tombstone is left, similar to the way a removed + # struct or list instance is zeroed out of the message but the space is not reclaimed. + # Hopefully this is unusual. + + senderHosted @1 :ExportId; + # The ID of a capability in the sender's export table (receiver's import table). It may be a + # newly allocated table entry, or an existing entry (increments the reference count). + + senderPromise @2 :ExportId; + # A promise that the sender will resolve later. The sender will send exactly one Resolve + # message at a future point in time to replace this promise. Note that even if the same + # `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of + # them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this + # `CapDescriptor`) may choose not to send the `Resolve` at all. + + receiverHosted @3 :ImportId; + # A capability (or promise) previously exported by the receiver (imported by the sender). + + receiverAnswer @4 :PromisedAnswer; + # A capability expected to be returned in the results of a currently-outstanding call posed + # by the sender. + + thirdPartyHosted @5 :ThirdPartyCapDescriptor; + # **(level 3)** + # + # A capability that lives in neither the sender's nor the receiver's vat. The sender needs + # to form a direct connection to a third party to pick up the capability. + # + # Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its + # `vine` instead. + } +} + +struct PromisedAnswer { + # **(mostly level 1)** + # + # Specifies how to derive a promise from an unanswered question, by specifying the path of fields + # to follow from the root of the eventual result struct to get to the desired capability. Used + # to address method calls to a not-yet-returned capability or to pass such a capability as an + # input to some other method call. + # + # Level 0 implementations must support `PromisedAnswer` only for the case where the answer is + # to a `Bootstrap` message. In this case, `path` is always empty since `Bootstrap` always returns + # a raw capability. + + questionId @0 :QuestionId; + # ID of the question (in the sender's question table / receiver's answer table) whose answer is + # expected to contain the capability. + + transform @1 :List(Op); + # Operations / transformations to apply to the result in order to get the capability actually + # being addressed. E.g. if the result is a struct and you want to call a method on a capability + # pointed to by a field of the struct, you need a `getPointerField` op. + + struct Op { + union { + noop @0 :Void; + # Does nothing. This member is mostly defined so that we can make `Op` a union even + # though (as of this writing) only one real operation is defined. + + getPointerField @1 :UInt16; + # Get a pointer field within a struct. The number is an index into the pointer section, NOT + # a field ordinal, so that the receiver does not need to understand the schema. + + # TODO(someday): We could add: + # - For lists, the ability to address every member of the list, or a slice of the list, the + # result of which would be another list. This is useful for implementing the equivalent of + # a SQL table join (not to be confused with the `Join` message type). + # - Maybe some ability to test a union. + # - Probably not a good idea: the ability to specify an arbitrary script to run on the + # result. We could define a little stack-based language where `Op` specifies one + # "instruction" or transformation to apply. Although this is not a good idea + # (over-engineered), any narrower additions to `Op` should be designed as if this + # were the eventual goal. + } + } +} + +struct ThirdPartyCapDescriptor { + # **(level 3)** + # + # Identifies a capability in a third-party vat that the sender wants the receiver to pick up. + + id @0 :ThirdPartyCapId; + # Identifies the third-party host and the specific capability to accept from it. + + vineId @1 :ExportId; + # A proxy for the third-party object exported by the sender. In CapTP terminology this is called + # a "vine", because it is an indirect reference to the third-party object that snakes through the + # sender vat. This serves two purposes: + # + # * Level 1 and 2 implementations that don't understand how to connect to a third party may + # simply send calls to the vine. Such calls will be forwarded to the third-party by the + # sender. + # + # * Level 3 implementations must release the vine only once they have successfully picked up the + # object from the third party. This ensures that the capability is not released by the sender + # prematurely. + # + # The sender will close the `Provide` request that it has sent to the third party as soon as + # it receives either a `Call` or a `Release` message directed at the vine. +} + +struct Exception { + # **(level 0)** + # + # Describes an arbitrary error that prevented an operation (e.g. a call) from completing. + # + # Cap'n Proto exceptions always indicate that something went wrong. In other words, in a fantasy + # world where everything always works as expected, no exceptions would ever be thrown. Clients + # should only ever catch exceptions as a means to implement fault-tolerance, where "fault" can + # mean: + # - Bugs. + # - Invalid input. + # - Configuration errors. + # - Network problems. + # - Insufficient resources. + # - Version skew (unimplemented functionality). + # - Other logistical problems. + # + # Exceptions should NOT be used to flag application-specific conditions that a client is expected + # to handle in an application-specific way. Put another way, in the Cap'n Proto world, + # "checked exceptions" (where an interface explicitly defines the exceptions it throws and + # clients are forced by the type system to handle those exceptions) do NOT make sense. + + reason @0 :Text; + # Human-readable failure description. + + type @3 :Type; + # The type of the error. The purpose of this enum is not to describe the error itself, but + # rather to describe how the client might want to respond to the error. + + enum Type { + failed @0; + # A generic problem occurred, and it is believed that if the operation were repeated without + # any change in the state of the world, the problem would occur again. + # + # A client might respond to this error by logging it for investigation by the developer and/or + # displaying it to the user. + + overloaded @1; + # The request was rejected due to a temporary lack of resources. + # + # Examples include: + # - There's not enough CPU time to keep up with incoming requests, so some are rejected. + # - The server ran out of RAM or disk space during the request. + # - The operation timed out (took significantly longer than it should have). + # + # A client might respond to this error by scheduling to retry the operation much later. The + # client should NOT retry again immediately since this would likely exacerbate the problem. + + disconnected @2; + # The method failed because a connection to some necessary capability was lost. + # + # Examples include: + # - The client introduced the server to a third-party capability, the connection to that third + # party was subsequently lost, and then the client requested that the server use the dead + # capability for something. + # - The client previously requested that the server obtain a capability from some third party. + # The server returned a capability to an object wrapping the third-party capability. Later, + # the server's connection to the third party was lost. + # - The capability has been revoked. Revocation does not necessarily mean that the client is + # no longer authorized to use the capability; it is often used simply as a way to force the + # client to repeat the setup process, perhaps to efficiently move them to a new back-end or + # get them to recognize some other change that has occurred. + # + # A client should normally respond to this error by releasing all capabilities it is currently + # holding related to the one it called and then re-creating them by restoring SturdyRefs and/or + # repeating the method calls used to create them originally. In other words, disconnect and + # start over. This should in turn cause the server to obtain a new copy of the capability that + # it lost, thus making everything work. + # + # If the client receives another `disconnencted` error in the process of rebuilding the + # capability and retrying the call, it should treat this as an `overloaded` error: the network + # is currently unreliable, possibly due to load or other temporary issues. + + unimplemented @3; + # The server doesn't implement the requested method. If there is some other method that the + # client could call (perhaps an older and/or slower interface), it should try that instead. + # Otherwise, this should be treated like `failed`. + } + + obsoleteIsCallersFault @1 :Bool; + # OBSOLETE. Ignore. + + obsoleteDurability @2 :UInt16; + # OBSOLETE. See `type` instead. +} + +# ======================================================================================== +# Network-specific Parameters +# +# Some parts of the Cap'n Proto RPC protocol are not specified here because different vat networks +# may wish to use different approaches to solving them. For example, on the public internet, you +# may want to authenticate vats using public-key cryptography, but on a local intranet with trusted +# infrastructure, you may be happy to authenticate based on network address only, or some other +# lightweight mechanism. +# +# To accommodate this, we specify several "parameter" types. Each type is defined here as an +# alias for `AnyPointer`, but a specific network will want to define a specific set of types to use. +# All vats in a vat network must agree on these parameters in order to be able to communicate. +# Inter-network communication can be accomplished through "gateways" that perform translation +# between the primitives used on each network; these gateways may need to be deeply stateful, +# depending on the translations they perform. +# +# For interaction over the global internet between parties with no other prior arrangement, a +# particular set of bindings for these types is defined elsewhere. (TODO(someday): Specify where +# these common definitions live.) +# +# Another common network type is the two-party network, in which one of the parties typically +# interacts with the outside world entirely through the other party. In such a connection between +# Alice and Bob, all objects that exist on Bob's other networks appear to Alice as if they were +# hosted by Bob himself, and similarly all objects on Alice's network (if she even has one) appear +# to Bob as if they were hosted by Alice. This network type is interesting because from the point +# of view of a simple application that communicates with only one other party via the two-party +# protocol, there are no three-party interactions at all, and joins are unusually simple to +# implement, so implementing at level 4 is barely more complicated than implementing at level 1. +# Moreover, if you pair an app implementing the two-party network with a container that implements +# some other network, the app can then participate on the container's network just as if it +# implemented that network directly. The types used by the two-party network are defined in +# `rpc-twoparty.capnp`. +# +# The things that we need to parameterize are: +# - How to store capabilities long-term without holding a connection open (mostly level 2). +# - How to authenticate vats in three-party introductions (level 3). +# - How to implement `Join` (level 4). +# +# Persistent references +# --------------------- +# +# **(mostly level 2)** +# +# We want to allow some capabilities to be stored long-term, even if a connection is lost and later +# recreated. ExportId is a short-term identifier that is specific to a connection, so it doesn't +# help here. We need a way to specify long-term identifiers, as well as a strategy for +# reconnecting to a referenced capability later. +# +# Three-party interactions +# ------------------------ +# +# **(level 3)** +# +# In cases where more than two vats are interacting, we have situations where VatA holds a +# capability hosted by VatB and wants to send that capability to VatC. This can be accomplished +# by VatA proxying requests on the new capability, but doing so has two big problems: +# - It's inefficient, requiring an extra network hop. +# - If VatC receives another capability to the same object from VatD, it is difficult for VatC to +# detect that the two capabilities are really the same and to implement the E "join" operation, +# which is necessary for certain four-or-more-party interactions, such as the escrow pattern. +# See: http://www.erights.org/elib/equality/grant-matcher/index.html +# +# Instead, we want a way for VatC to form a direct, authenticated connection to VatB. +# +# Join +# ---- +# +# **(level 4)** +# +# The `Join` message type and corresponding operation arranges for a direct connection to be formed +# between the joiner and the host of the joined object, and this connection must be authenticated. +# Thus, the details are network-dependent. + +using SturdyRef = AnyPointer; +# **(level 2)** +# +# Identifies a persisted capability that can be restored in the future. How exactly a SturdyRef +# is restored to a live object is specified along with the SturdyRef definition (i.e. not by +# rpc.capnp). +# +# Generally a SturdyRef needs to specify three things: +# - How to reach the vat that can restore the ref (e.g. a hostname or IP address). +# - How to authenticate the vat after connecting (e.g. a public key fingerprint). +# - The identity of a specific object hosted by the vat. Generally, this is an opaque pointer whose +# format is defined by the specific vat -- the client has no need to inspect the object ID. +# It is important that the objec ID be unguessable if the object is not public (and objects +# should almost never be public). +# +# The above are only suggestions. Some networks might work differently. For example, a private +# network might employ a special restorer service whose sole purpose is to restore SturdyRefs. +# In this case, the entire contents of SturdyRef might be opaque, because they are intended only +# to be forwarded to the restorer service. + +using ProvisionId = AnyPointer; +# **(level 3)** +# +# The information that must be sent in an `Accept` message to identify the object being accepted. +# +# In a network where each vat has a public/private key pair, this could simply be the public key +# fingerprint of the provider vat along with a nonce matching the one in the `RecipientId` used +# in the `Provide` message sent from that provider. + +using RecipientId = AnyPointer; +# **(level 3)** +# +# The information that must be sent in a `Provide` message to identify the recipient of the +# capability. +# +# In a network where each vat has a public/private key pair, this could simply be the public key +# fingerprint of the recipient along with a nonce matching the one in the `ProvisionId`. + +using ThirdPartyCapId = AnyPointer; +# **(level 3)** +# +# The information needed to connect to a third party and accept a capability from it. +# +# In a network where each vat has a public/private key pair, this could be a combination of the +# third party's public key fingerprint, hints on how to connect to the third party (e.g. an IP +# address), and the nonce used in the corresponding `Provide` message's `RecipientId` as sent +# to that third party (used to identify which capability to pick up). + +using JoinKeyPart = AnyPointer; +# **(level 4)** +# +# A piece of a secret key. One piece is sent along each path that is expected to lead to the same +# place. Once the pieces are combined, a direct connection may be formed between the sender and +# the receiver, bypassing any men-in-the-middle along the paths. See the `Join` message type. +# +# The motivation for Joins is discussed under "Supporting Equality" in the "Unibus" protocol +# sketch: http://www.erights.org/elib/distrib/captp/unibus.html +# +# In a network where each vat has a public/private key pair and each vat forms no more than one +# connection to each other vat, Joins will rarely -- perhaps never -- be needed, as objects never +# need to be transparently proxied and references to the same object sent over the same connection +# have the same export ID. Thus, a successful join requires only checking that the two objects +# come from the same connection and have the same ID, and then completes immediately. +# +# However, in networks where two vats may form more than one connection between each other, or +# where proxying of objects occurs, joins are necessary. +# +# Typically, each JoinKeyPart would include a fixed-length data value such that all value parts +# XOR'd together forms a shared secret that can be used to form an encrypted connection between +# the joiner and the joined object's host. Each JoinKeyPart should also include an indication of +# how many parts to expect and a hash of the shared secret (used to match up parts). + +using JoinResult = AnyPointer; +# **(level 4)** +# +# Information returned as the result to a `Join` message, needed by the joiner in order to form a +# direct connection to a joined object. This might simply be the address of the joined object's +# host vat, since the `JoinKey` has already been communicated so the two vats already have a shared +# secret to use to authenticate each other. +# +# The `JoinResult` should also contain information that can be used to detect when the Join +# requests ended up reaching different objects, so that this situation can be detected easily. +# This could be a simple matter of including a sequence number -- if the joiner receives two +# `JoinResult`s with sequence number 0, then they must have come from different objects and the +# whole join is a failure. + +# ======================================================================================== +# Network interface sketch +# +# The interfaces below are meant to be pseudo-code to illustrate how the details of a particular +# vat network might be abstracted away. They are written like Cap'n Proto interfaces, but in +# practice you'd probably define these interfaces manually in the target programming language. A +# Cap'n Proto RPC implementation should be able to use these interfaces without knowing the +# definitions of the various network-specific parameters defined above. + +# interface VatNetwork { +# # Represents a vat network, with the ability to connect to particular vats and receive +# # connections from vats. +# # +# # Note that methods returning a `Connection` may return a pre-existing `Connection`, and the +# # caller is expected to find and share state with existing users of the connection. +# +# # Level 0 features ----------------------------------------------- +# +# connect(vatId :VatId) :Connection; +# # Connect to the given vat. The transport should return a promise that does not +# # resolve until authentication has completed, but allows messages to be pipelined in before +# # that; the transport either queues these messages until authenticated, or sends them encrypted +# # such that only the authentic vat would be able to decrypt them. The latter approach avoids a +# # round trip for authentication. +# +# accept() :Connection; +# # Wait for the next incoming connection and return it. Only connections formed by +# # connect() are returned by this method. +# +# # Level 4 features ----------------------------------------------- +# +# newJoiner(count :UInt32) :NewJoinerResponse; +# # Prepare a new Join operation, which will eventually lead to forming a new direct connection +# # to the host of the joined capability. `count` is the number of capabilities to join. +# +# struct NewJoinerResponse { +# joinKeyParts :List(JoinKeyPart); +# # Key parts to send in Join messages to each capability. +# +# joiner :Joiner; +# # Used to establish the final connection. +# } +# +# interface Joiner { +# addJoinResult(result :JoinResult) :Void; +# # Add a JoinResult received in response to one of the `Join` messages. All `JoinResult`s +# # returned from all paths must be added before trying to connect. +# +# connect() :ConnectionAndProvisionId; +# # Try to form a connection to the joined capability's host, verifying that it has received +# # all of the JoinKeyParts. Once the connection is formed, the caller should send an `Accept` +# # message on it with the specified `ProvisionId` in order to receive the final capability. +# } +# +# acceptConnectionFromJoiner(parts :List(JoinKeyPart), paths :List(VatPath)) +# :ConnectionAndProvisionId; +# # Called on a joined capability's host to receive the connection from the joiner, once all +# # key parts have arrived. The caller should expect to receive an `Accept` message over the +# # connection with the given ProvisionId. +# } +# +# interface Connection { +# # Level 0 features ----------------------------------------------- +# +# send(message :Message) :Void; +# # Send the message. Returns successfully when the message (and all preceding messages) has +# # been acknowledged by the recipient. +# +# receive() :Message; +# # Receive the next message, and acknowledges receipt to the sender. Messages are received in +# # the order in which they are sent. +# +# # Level 3 features ----------------------------------------------- +# +# introduceTo(recipient :Connection) :IntroductionInfo; +# # Call before starting a three-way introduction, assuming a `Provide` message is to be sent on +# # this connection and a `ThirdPartyCapId` is to be sent to `recipient`. +# +# struct IntroductionInfo { +# sendToRecipient :ThirdPartyCapId; +# sendToTarget :RecipientId; +# } +# +# connectToIntroduced(capId :ThirdPartyCapId) :ConnectionAndProvisionId; +# # Given a ThirdPartyCapId received over this connection, connect to the third party. The +# # caller should then send an `Accept` message over the new connection. +# +# acceptIntroducedConnection(recipientId :RecipientId) :Connection; +# # Given a RecipientId received in a `Provide` message on this `Connection`, wait for the +# # recipient to connect, and return the connection formed. Usually, the first message received +# # on the new connection will be an `Accept` message. +# } +# +# struct ConnectionAndProvisionId { +# # **(level 3)** +# +# connection :Connection; +# # Connection on which to issue `Accept` message. +# +# provision :ProvisionId; +# # `ProvisionId` to send in the `Accept` message. +# } diff --git a/MsBuildGenerationTest/capnp/rpc.capnp.cs b/MsBuildGenerationTest/capnp/rpc.capnp.cs new file mode 100644 index 0000000..35b0269 --- /dev/null +++ b/MsBuildGenerationTest/capnp/rpc.capnp.cs @@ -0,0 +1,2641 @@ +using Capnp; +using Capnp.Rpc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Capnp.Rpc +{ + public class Message : ICapnpSerializable + { + public enum WHICH : ushort + { + Unimplemented = 0, + Abort = 1, + Call = 2, + Return = 3, + Finish = 4, + Resolve = 5, + Release = 6, + ObsoleteSave = 7, + Bootstrap = 8, + ObsoleteDelete = 9, + Provide = 10, + Accept = 11, + Join = 12, + Disembargo = 13, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Unimplemented: + Unimplemented = CapnpSerializable.Create(reader.Unimplemented); + break; + case WHICH.Abort: + Abort = CapnpSerializable.Create(reader.Abort); + break; + case WHICH.Call: + Call = CapnpSerializable.Create(reader.Call); + break; + case WHICH.Return: + Return = CapnpSerializable.Create(reader.Return); + break; + case WHICH.Finish: + Finish = CapnpSerializable.Create(reader.Finish); + break; + case WHICH.Resolve: + Resolve = CapnpSerializable.Create(reader.Resolve); + break; + case WHICH.Release: + Release = CapnpSerializable.Create(reader.Release); + break; + case WHICH.ObsoleteSave: + ObsoleteSave = CapnpSerializable.Create(reader.ObsoleteSave); + break; + case WHICH.Bootstrap: + Bootstrap = CapnpSerializable.Create(reader.Bootstrap); + break; + case WHICH.ObsoleteDelete: + ObsoleteDelete = CapnpSerializable.Create(reader.ObsoleteDelete); + break; + case WHICH.Provide: + Provide = CapnpSerializable.Create(reader.Provide); + break; + case WHICH.Accept: + Accept = CapnpSerializable.Create(reader.Accept); + break; + case WHICH.Join: + Join = CapnpSerializable.Create(reader.Join); + break; + case WHICH.Disembargo: + Disembargo = CapnpSerializable.Create(reader.Disembargo); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Unimplemented: + _content = null; + break; + case WHICH.Abort: + _content = null; + break; + case WHICH.Call: + _content = null; + break; + case WHICH.Return: + _content = null; + break; + case WHICH.Finish: + _content = null; + break; + case WHICH.Resolve: + _content = null; + break; + case WHICH.Release: + _content = null; + break; + case WHICH.ObsoleteSave: + _content = null; + break; + case WHICH.Bootstrap: + _content = null; + break; + case WHICH.ObsoleteDelete: + _content = null; + break; + case WHICH.Provide: + _content = null; + break; + case WHICH.Accept: + _content = null; + break; + case WHICH.Join: + _content = null; + break; + case WHICH.Disembargo: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Unimplemented: + Unimplemented?.serialize(writer.Unimplemented); + break; + case WHICH.Abort: + Abort?.serialize(writer.Abort); + break; + case WHICH.Call: + Call?.serialize(writer.Call); + break; + case WHICH.Return: + Return?.serialize(writer.Return); + break; + case WHICH.Finish: + Finish?.serialize(writer.Finish); + break; + case WHICH.Resolve: + Resolve?.serialize(writer.Resolve); + break; + case WHICH.Release: + Release?.serialize(writer.Release); + break; + case WHICH.ObsoleteSave: + writer.ObsoleteSave.SetObject(ObsoleteSave); + break; + case WHICH.Bootstrap: + Bootstrap?.serialize(writer.Bootstrap); + break; + case WHICH.ObsoleteDelete: + writer.ObsoleteDelete.SetObject(ObsoleteDelete); + break; + case WHICH.Provide: + Provide?.serialize(writer.Provide); + break; + case WHICH.Accept: + Accept?.serialize(writer.Accept); + break; + case WHICH.Join: + Join?.serialize(writer.Join); + break; + case WHICH.Disembargo: + Disembargo?.serialize(writer.Disembargo); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnp.Rpc.Message Unimplemented + { + get => _which == WHICH.Unimplemented ? (Capnp.Rpc.Message)_content : null; + set + { + _which = WHICH.Unimplemented; + _content = value; + } + } + + public Capnp.Rpc.Exception Abort + { + get => _which == WHICH.Abort ? (Capnp.Rpc.Exception)_content : null; + set + { + _which = WHICH.Abort; + _content = value; + } + } + + public Capnp.Rpc.Call Call + { + get => _which == WHICH.Call ? (Capnp.Rpc.Call)_content : null; + set + { + _which = WHICH.Call; + _content = value; + } + } + + public Capnp.Rpc.Return Return + { + get => _which == WHICH.Return ? (Capnp.Rpc.Return)_content : null; + set + { + _which = WHICH.Return; + _content = value; + } + } + + public Capnp.Rpc.Finish Finish + { + get => _which == WHICH.Finish ? (Capnp.Rpc.Finish)_content : null; + set + { + _which = WHICH.Finish; + _content = value; + } + } + + public Capnp.Rpc.Resolve Resolve + { + get => _which == WHICH.Resolve ? (Capnp.Rpc.Resolve)_content : null; + set + { + _which = WHICH.Resolve; + _content = value; + } + } + + public Capnp.Rpc.Release Release + { + get => _which == WHICH.Release ? (Capnp.Rpc.Release)_content : null; + set + { + _which = WHICH.Release; + _content = value; + } + } + + public AnyPointer ObsoleteSave + { + get => _which == WHICH.ObsoleteSave ? (AnyPointer)_content : null; + set + { + _which = WHICH.ObsoleteSave; + _content = value; + } + } + + public Capnp.Rpc.Bootstrap Bootstrap + { + get => _which == WHICH.Bootstrap ? (Capnp.Rpc.Bootstrap)_content : null; + set + { + _which = WHICH.Bootstrap; + _content = value; + } + } + + public AnyPointer ObsoleteDelete + { + get => _which == WHICH.ObsoleteDelete ? (AnyPointer)_content : null; + set + { + _which = WHICH.ObsoleteDelete; + _content = value; + } + } + + public Capnp.Rpc.Provide Provide + { + get => _which == WHICH.Provide ? (Capnp.Rpc.Provide)_content : null; + set + { + _which = WHICH.Provide; + _content = value; + } + } + + public Capnp.Rpc.Accept Accept + { + get => _which == WHICH.Accept ? (Capnp.Rpc.Accept)_content : null; + set + { + _which = WHICH.Accept; + _content = value; + } + } + + public Capnp.Rpc.Join Join + { + get => _which == WHICH.Join ? (Capnp.Rpc.Join)_content : null; + set + { + _which = WHICH.Join; + _content = value; + } + } + + public Capnp.Rpc.Disembargo Disembargo + { + get => _which == WHICH.Disembargo ? (Capnp.Rpc.Disembargo)_content : null; + set + { + _which = WHICH.Disembargo; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public Capnp.Rpc.Message.READER Unimplemented => which == WHICH.Unimplemented ? ctx.ReadStruct(0, Capnp.Rpc.Message.READER.create) : default; + public Capnp.Rpc.Exception.READER Abort => which == WHICH.Abort ? ctx.ReadStruct(0, Capnp.Rpc.Exception.READER.create) : default; + public Capnp.Rpc.Call.READER Call => which == WHICH.Call ? ctx.ReadStruct(0, Capnp.Rpc.Call.READER.create) : default; + public Capnp.Rpc.Return.READER Return => which == WHICH.Return ? ctx.ReadStruct(0, Capnp.Rpc.Return.READER.create) : default; + public Capnp.Rpc.Finish.READER Finish => which == WHICH.Finish ? ctx.ReadStruct(0, Capnp.Rpc.Finish.READER.create) : default; + public Capnp.Rpc.Resolve.READER Resolve => which == WHICH.Resolve ? ctx.ReadStruct(0, Capnp.Rpc.Resolve.READER.create) : default; + public Capnp.Rpc.Release.READER Release => which == WHICH.Release ? ctx.ReadStruct(0, Capnp.Rpc.Release.READER.create) : default; + public DeserializerState ObsoleteSave => which == WHICH.ObsoleteSave ? ctx.StructReadPointer(0) : default; + public Capnp.Rpc.Bootstrap.READER Bootstrap => which == WHICH.Bootstrap ? ctx.ReadStruct(0, Capnp.Rpc.Bootstrap.READER.create) : default; + public DeserializerState ObsoleteDelete => which == WHICH.ObsoleteDelete ? ctx.StructReadPointer(0) : default; + public Capnp.Rpc.Provide.READER Provide => which == WHICH.Provide ? ctx.ReadStruct(0, Capnp.Rpc.Provide.READER.create) : default; + public Capnp.Rpc.Accept.READER Accept => which == WHICH.Accept ? ctx.ReadStruct(0, Capnp.Rpc.Accept.READER.create) : default; + public Capnp.Rpc.Join.READER Join => which == WHICH.Join ? ctx.ReadStruct(0, Capnp.Rpc.Join.READER.create) : default; + public Capnp.Rpc.Disembargo.READER Disembargo => which == WHICH.Disembargo ? ctx.ReadStruct(0, Capnp.Rpc.Disembargo.READER.create) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public Capnp.Rpc.Message.WRITER Unimplemented + { + get => which == WHICH.Unimplemented ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Exception.WRITER Abort + { + get => which == WHICH.Abort ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Call.WRITER Call + { + get => which == WHICH.Call ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Return.WRITER Return + { + get => which == WHICH.Return ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Finish.WRITER Finish + { + get => which == WHICH.Finish ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Resolve.WRITER Resolve + { + get => which == WHICH.Resolve ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Release.WRITER Release + { + get => which == WHICH.Release ? BuildPointer(0) : default; + set => Link(0, value); + } + + public DynamicSerializerState ObsoleteSave + { + get => which == WHICH.ObsoleteSave ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Bootstrap.WRITER Bootstrap + { + get => which == WHICH.Bootstrap ? BuildPointer(0) : default; + set => Link(0, value); + } + + public DynamicSerializerState ObsoleteDelete + { + get => which == WHICH.ObsoleteDelete ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Provide.WRITER Provide + { + get => which == WHICH.Provide ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Accept.WRITER Accept + { + get => which == WHICH.Accept ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Join.WRITER Join + { + get => which == WHICH.Join ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Disembargo.WRITER Disembargo + { + get => which == WHICH.Disembargo ? BuildPointer(0) : default; + set => Link(0, value); + } + } + } + + public class Bootstrap : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + QuestionId = reader.QuestionId; + DeprecatedObjectId = CapnpSerializable.Create(reader.DeprecatedObjectId); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.QuestionId = QuestionId; + writer.DeprecatedObjectId.SetObject(DeprecatedObjectId); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint QuestionId + { + get; + set; + } + + public AnyPointer DeprecatedObjectId + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint QuestionId => ctx.ReadDataUInt(0UL, 0U); + public DeserializerState DeprecatedObjectId => ctx.StructReadPointer(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public uint QuestionId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public DynamicSerializerState DeprecatedObjectId + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } + + public class Call : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + QuestionId = reader.QuestionId; + Target = CapnpSerializable.Create(reader.Target); + InterfaceId = reader.InterfaceId; + MethodId = reader.MethodId; + Params = CapnpSerializable.Create(reader.Params); + SendResultsTo = CapnpSerializable.Create(reader.SendResultsTo); + AllowThirdPartyTailCall = reader.AllowThirdPartyTailCall; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.QuestionId = QuestionId; + Target?.serialize(writer.Target); + writer.InterfaceId = InterfaceId; + writer.MethodId = MethodId; + Params?.serialize(writer.Params); + SendResultsTo?.serialize(writer.SendResultsTo); + writer.AllowThirdPartyTailCall = AllowThirdPartyTailCall; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint QuestionId + { + get; + set; + } + + public Capnp.Rpc.MessageTarget Target + { + get; + set; + } + + public ulong InterfaceId + { + get; + set; + } + + public ushort MethodId + { + get; + set; + } + + public Capnp.Rpc.Payload Params + { + get; + set; + } + + public Capnp.Rpc.Call.@sendResultsTo SendResultsTo + { + get; + set; + } + + public bool AllowThirdPartyTailCall + { + get; + set; + } + + = false; + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint QuestionId => ctx.ReadDataUInt(0UL, 0U); + public Capnp.Rpc.MessageTarget.READER Target => ctx.ReadStruct(0, Capnp.Rpc.MessageTarget.READER.create); + public ulong InterfaceId => ctx.ReadDataULong(64UL, 0UL); + public ushort MethodId => ctx.ReadDataUShort(32UL, (ushort)0); + public Capnp.Rpc.Payload.READER Params => ctx.ReadStruct(1, Capnp.Rpc.Payload.READER.create); + public @sendResultsTo.READER SendResultsTo => new @sendResultsTo.READER(ctx); + public bool AllowThirdPartyTailCall => ctx.ReadDataBool(128UL, false); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(3, 3); + } + + public uint QuestionId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public Capnp.Rpc.MessageTarget.WRITER Target + { + get => BuildPointer(0); + set => Link(0, value); + } + + public ulong InterfaceId + { + get => this.ReadDataULong(64UL, 0UL); + set => this.WriteData(64UL, value, 0UL); + } + + public ushort MethodId + { + get => this.ReadDataUShort(32UL, (ushort)0); + set => this.WriteData(32UL, value, (ushort)0); + } + + public Capnp.Rpc.Payload.WRITER Params + { + get => BuildPointer(1); + set => Link(1, value); + } + + public @sendResultsTo.WRITER SendResultsTo + { + get => Rewrap<@sendResultsTo.WRITER>(); + } + + public bool AllowThirdPartyTailCall + { + get => this.ReadDataBool(128UL, false); + set => this.WriteData(128UL, value, false); + } + } + + public class @sendResultsTo : ICapnpSerializable + { + public enum WHICH : ushort + { + Caller = 0, + Yourself = 1, + ThirdParty = 2, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Caller: + which = reader.which; + break; + case WHICH.Yourself: + which = reader.which; + break; + case WHICH.ThirdParty: + ThirdParty = CapnpSerializable.Create(reader.ThirdParty); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Caller: + break; + case WHICH.Yourself: + break; + case WHICH.ThirdParty: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Caller: + break; + case WHICH.Yourself: + break; + case WHICH.ThirdParty: + writer.ThirdParty.SetObject(ThirdParty); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public AnyPointer ThirdParty + { + get => _which == WHICH.ThirdParty ? (AnyPointer)_content : null; + set + { + _which = WHICH.ThirdParty; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(48U, (ushort)0); + public DeserializerState ThirdParty => which == WHICH.ThirdParty ? ctx.StructReadPointer(2) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(48U, (ushort)0); + set => this.WriteData(48U, (ushort)value, (ushort)0); + } + + public DynamicSerializerState ThirdParty + { + get => which == WHICH.ThirdParty ? BuildPointer(2) : default; + set => Link(2, value); + } + } + } + } + + public class Return : ICapnpSerializable + { + public enum WHICH : ushort + { + Results = 0, + Exception = 1, + Canceled = 2, + ResultsSentElsewhere = 3, + TakeFromOtherQuestion = 4, + AcceptFromThirdParty = 5, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Results: + Results = CapnpSerializable.Create(reader.Results); + break; + case WHICH.Exception: + Exception = CapnpSerializable.Create(reader.Exception); + break; + case WHICH.Canceled: + which = reader.which; + break; + case WHICH.ResultsSentElsewhere: + which = reader.which; + break; + case WHICH.TakeFromOtherQuestion: + TakeFromOtherQuestion = reader.TakeFromOtherQuestion; + break; + case WHICH.AcceptFromThirdParty: + AcceptFromThirdParty = CapnpSerializable.Create(reader.AcceptFromThirdParty); + break; + } + + AnswerId = reader.AnswerId; + ReleaseParamCaps = reader.ReleaseParamCaps; + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Results: + _content = null; + break; + case WHICH.Exception: + _content = null; + break; + case WHICH.Canceled: + break; + case WHICH.ResultsSentElsewhere: + break; + case WHICH.TakeFromOtherQuestion: + _content = 0; + break; + case WHICH.AcceptFromThirdParty: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Results: + Results?.serialize(writer.Results); + break; + case WHICH.Exception: + Exception?.serialize(writer.Exception); + break; + case WHICH.Canceled: + break; + case WHICH.ResultsSentElsewhere: + break; + case WHICH.TakeFromOtherQuestion: + writer.TakeFromOtherQuestion = TakeFromOtherQuestion.Value; + break; + case WHICH.AcceptFromThirdParty: + writer.AcceptFromThirdParty.SetObject(AcceptFromThirdParty); + break; + } + + writer.AnswerId = AnswerId; + writer.ReleaseParamCaps = ReleaseParamCaps; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint AnswerId + { + get; + set; + } + + public bool ReleaseParamCaps + { + get; + set; + } + + = true; + public Capnp.Rpc.Payload Results + { + get => _which == WHICH.Results ? (Capnp.Rpc.Payload)_content : null; + set + { + _which = WHICH.Results; + _content = value; + } + } + + public Capnp.Rpc.Exception Exception + { + get => _which == WHICH.Exception ? (Capnp.Rpc.Exception)_content : null; + set + { + _which = WHICH.Exception; + _content = value; + } + } + + public uint? TakeFromOtherQuestion + { + get => _which == WHICH.TakeFromOtherQuestion ? (uint? )_content : null; + set + { + _which = WHICH.TakeFromOtherQuestion; + _content = value; + } + } + + public AnyPointer AcceptFromThirdParty + { + get => _which == WHICH.AcceptFromThirdParty ? (AnyPointer)_content : null; + set + { + _which = WHICH.AcceptFromThirdParty; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(48U, (ushort)0); + public uint AnswerId => ctx.ReadDataUInt(0UL, 0U); + public bool ReleaseParamCaps => ctx.ReadDataBool(32UL, true); + public Capnp.Rpc.Payload.READER Results => which == WHICH.Results ? ctx.ReadStruct(0, Capnp.Rpc.Payload.READER.create) : default; + public Capnp.Rpc.Exception.READER Exception => which == WHICH.Exception ? ctx.ReadStruct(0, Capnp.Rpc.Exception.READER.create) : default; + public uint TakeFromOtherQuestion => which == WHICH.TakeFromOtherQuestion ? ctx.ReadDataUInt(64UL, 0U) : default; + public DeserializerState AcceptFromThirdParty => which == WHICH.AcceptFromThirdParty ? ctx.StructReadPointer(0) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(2, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(48U, (ushort)0); + set => this.WriteData(48U, (ushort)value, (ushort)0); + } + + public uint AnswerId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public bool ReleaseParamCaps + { + get => this.ReadDataBool(32UL, true); + set => this.WriteData(32UL, value, true); + } + + public Capnp.Rpc.Payload.WRITER Results + { + get => which == WHICH.Results ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Exception.WRITER Exception + { + get => which == WHICH.Exception ? BuildPointer(0) : default; + set => Link(0, value); + } + + public uint TakeFromOtherQuestion + { + get => which == WHICH.TakeFromOtherQuestion ? this.ReadDataUInt(64UL, 0U) : default; + set => this.WriteData(64UL, value, 0U); + } + + public DynamicSerializerState AcceptFromThirdParty + { + get => which == WHICH.AcceptFromThirdParty ? BuildPointer(0) : default; + set => Link(0, value); + } + } + } + + public class Finish : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + QuestionId = reader.QuestionId; + ReleaseResultCaps = reader.ReleaseResultCaps; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.QuestionId = QuestionId; + writer.ReleaseResultCaps = ReleaseResultCaps; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint QuestionId + { + get; + set; + } + + public bool ReleaseResultCaps + { + get; + set; + } + + = true; + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint QuestionId => ctx.ReadDataUInt(0UL, 0U); + public bool ReleaseResultCaps => ctx.ReadDataBool(32UL, true); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public uint QuestionId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public bool ReleaseResultCaps + { + get => this.ReadDataBool(32UL, true); + set => this.WriteData(32UL, value, true); + } + } + } + + public class Resolve : ICapnpSerializable + { + public enum WHICH : ushort + { + Cap = 0, + Exception = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Cap: + Cap = CapnpSerializable.Create(reader.Cap); + break; + case WHICH.Exception: + Exception = CapnpSerializable.Create(reader.Exception); + break; + } + + PromiseId = reader.PromiseId; + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Cap: + _content = null; + break; + case WHICH.Exception: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Cap: + Cap?.serialize(writer.Cap); + break; + case WHICH.Exception: + Exception?.serialize(writer.Exception); + break; + } + + writer.PromiseId = PromiseId; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint PromiseId + { + get; + set; + } + + public Capnp.Rpc.CapDescriptor Cap + { + get => _which == WHICH.Cap ? (Capnp.Rpc.CapDescriptor)_content : null; + set + { + _which = WHICH.Cap; + _content = value; + } + } + + public Capnp.Rpc.Exception Exception + { + get => _which == WHICH.Exception ? (Capnp.Rpc.Exception)_content : null; + set + { + _which = WHICH.Exception; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(32U, (ushort)0); + public uint PromiseId => ctx.ReadDataUInt(0UL, 0U); + public Capnp.Rpc.CapDescriptor.READER Cap => which == WHICH.Cap ? ctx.ReadStruct(0, Capnp.Rpc.CapDescriptor.READER.create) : default; + public Capnp.Rpc.Exception.READER Exception => which == WHICH.Exception ? ctx.ReadStruct(0, Capnp.Rpc.Exception.READER.create) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(32U, (ushort)0); + set => this.WriteData(32U, (ushort)value, (ushort)0); + } + + public uint PromiseId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public Capnp.Rpc.CapDescriptor.WRITER Cap + { + get => which == WHICH.Cap ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.Exception.WRITER Exception + { + get => which == WHICH.Exception ? BuildPointer(0) : default; + set => Link(0, value); + } + } + } + + public class Release : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Id = reader.Id; + ReferenceCount = reader.ReferenceCount; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Id = Id; + writer.ReferenceCount = ReferenceCount; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint Id + { + get; + set; + } + + public uint ReferenceCount + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint Id => ctx.ReadDataUInt(0UL, 0U); + public uint ReferenceCount => ctx.ReadDataUInt(32UL, 0U); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public uint Id + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public uint ReferenceCount + { + get => this.ReadDataUInt(32UL, 0U); + set => this.WriteData(32UL, value, 0U); + } + } + } + + public class Disembargo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Target = CapnpSerializable.Create(reader.Target); + Context = CapnpSerializable.Create(reader.Context); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Target?.serialize(writer.Target); + Context?.serialize(writer.Context); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnp.Rpc.MessageTarget Target + { + get; + set; + } + + public Capnp.Rpc.Disembargo.@context Context + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnp.Rpc.MessageTarget.READER Target => ctx.ReadStruct(0, Capnp.Rpc.MessageTarget.READER.create); + public @context.READER Context => new @context.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public Capnp.Rpc.MessageTarget.WRITER Target + { + get => BuildPointer(0); + set => Link(0, value); + } + + public @context.WRITER Context + { + get => Rewrap<@context.WRITER>(); + } + } + + public class @context : ICapnpSerializable + { + public enum WHICH : ushort + { + SenderLoopback = 0, + ReceiverLoopback = 1, + Accept = 2, + Provide = 3, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.SenderLoopback: + SenderLoopback = reader.SenderLoopback; + break; + case WHICH.ReceiverLoopback: + ReceiverLoopback = reader.ReceiverLoopback; + break; + case WHICH.Accept: + which = reader.which; + break; + case WHICH.Provide: + Provide = reader.Provide; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.SenderLoopback: + _content = 0; + break; + case WHICH.ReceiverLoopback: + _content = 0; + break; + case WHICH.Accept: + break; + case WHICH.Provide: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.SenderLoopback: + writer.SenderLoopback = SenderLoopback.Value; + break; + case WHICH.ReceiverLoopback: + writer.ReceiverLoopback = ReceiverLoopback.Value; + break; + case WHICH.Accept: + break; + case WHICH.Provide: + writer.Provide = Provide.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint? SenderLoopback + { + get => _which == WHICH.SenderLoopback ? (uint? )_content : null; + set + { + _which = WHICH.SenderLoopback; + _content = value; + } + } + + public uint? ReceiverLoopback + { + get => _which == WHICH.ReceiverLoopback ? (uint? )_content : null; + set + { + _which = WHICH.ReceiverLoopback; + _content = value; + } + } + + public uint? Provide + { + get => _which == WHICH.Provide ? (uint? )_content : null; + set + { + _which = WHICH.Provide; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(32U, (ushort)0); + public uint SenderLoopback => which == WHICH.SenderLoopback ? ctx.ReadDataUInt(0UL, 0U) : default; + public uint ReceiverLoopback => which == WHICH.ReceiverLoopback ? ctx.ReadDataUInt(0UL, 0U) : default; + public uint Provide => which == WHICH.Provide ? ctx.ReadDataUInt(0UL, 0U) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(32U, (ushort)0); + set => this.WriteData(32U, (ushort)value, (ushort)0); + } + + public uint SenderLoopback + { + get => which == WHICH.SenderLoopback ? this.ReadDataUInt(0UL, 0U) : default; + set => this.WriteData(0UL, value, 0U); + } + + public uint ReceiverLoopback + { + get => which == WHICH.ReceiverLoopback ? this.ReadDataUInt(0UL, 0U) : default; + set => this.WriteData(0UL, value, 0U); + } + + public uint Provide + { + get => which == WHICH.Provide ? this.ReadDataUInt(0UL, 0U) : default; + set => this.WriteData(0UL, value, 0U); + } + } + } + } + + public class Provide : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + QuestionId = reader.QuestionId; + Target = CapnpSerializable.Create(reader.Target); + Recipient = CapnpSerializable.Create(reader.Recipient); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.QuestionId = QuestionId; + Target?.serialize(writer.Target); + writer.Recipient.SetObject(Recipient); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint QuestionId + { + get; + set; + } + + public Capnp.Rpc.MessageTarget Target + { + get; + set; + } + + public AnyPointer Recipient + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint QuestionId => ctx.ReadDataUInt(0UL, 0U); + public Capnp.Rpc.MessageTarget.READER Target => ctx.ReadStruct(0, Capnp.Rpc.MessageTarget.READER.create); + public DeserializerState Recipient => ctx.StructReadPointer(1); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 2); + } + + public uint QuestionId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public Capnp.Rpc.MessageTarget.WRITER Target + { + get => BuildPointer(0); + set => Link(0, value); + } + + public DynamicSerializerState Recipient + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + + public class Accept : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + QuestionId = reader.QuestionId; + Provision = CapnpSerializable.Create(reader.Provision); + Embargo = reader.Embargo; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.QuestionId = QuestionId; + writer.Provision.SetObject(Provision); + writer.Embargo = Embargo; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint QuestionId + { + get; + set; + } + + public AnyPointer Provision + { + get; + set; + } + + public bool Embargo + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint QuestionId => ctx.ReadDataUInt(0UL, 0U); + public DeserializerState Provision => ctx.StructReadPointer(0); + public bool Embargo => ctx.ReadDataBool(32UL, false); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public uint QuestionId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public DynamicSerializerState Provision + { + get => BuildPointer(0); + set => Link(0, value); + } + + public bool Embargo + { + get => this.ReadDataBool(32UL, false); + set => this.WriteData(32UL, value, false); + } + } + } + + public class Join : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + QuestionId = reader.QuestionId; + Target = CapnpSerializable.Create(reader.Target); + KeyPart = CapnpSerializable.Create(reader.KeyPart); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.QuestionId = QuestionId; + Target?.serialize(writer.Target); + writer.KeyPart.SetObject(KeyPart); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint QuestionId + { + get; + set; + } + + public Capnp.Rpc.MessageTarget Target + { + get; + set; + } + + public AnyPointer KeyPart + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint QuestionId => ctx.ReadDataUInt(0UL, 0U); + public Capnp.Rpc.MessageTarget.READER Target => ctx.ReadStruct(0, Capnp.Rpc.MessageTarget.READER.create); + public DeserializerState KeyPart => ctx.StructReadPointer(1); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 2); + } + + public uint QuestionId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public Capnp.Rpc.MessageTarget.WRITER Target + { + get => BuildPointer(0); + set => Link(0, value); + } + + public DynamicSerializerState KeyPart + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + + public class MessageTarget : ICapnpSerializable + { + public enum WHICH : ushort + { + ImportedCap = 0, + PromisedAnswer = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.ImportedCap: + ImportedCap = reader.ImportedCap; + break; + case WHICH.PromisedAnswer: + PromisedAnswer = CapnpSerializable.Create(reader.PromisedAnswer); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.ImportedCap: + _content = 0; + break; + case WHICH.PromisedAnswer: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.ImportedCap: + writer.ImportedCap = ImportedCap.Value; + break; + case WHICH.PromisedAnswer: + PromisedAnswer?.serialize(writer.PromisedAnswer); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint? ImportedCap + { + get => _which == WHICH.ImportedCap ? (uint? )_content : null; + set + { + _which = WHICH.ImportedCap; + _content = value; + } + } + + public Capnp.Rpc.PromisedAnswer PromisedAnswer + { + get => _which == WHICH.PromisedAnswer ? (Capnp.Rpc.PromisedAnswer)_content : null; + set + { + _which = WHICH.PromisedAnswer; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(32U, (ushort)0); + public uint ImportedCap => which == WHICH.ImportedCap ? ctx.ReadDataUInt(0UL, 0U) : default; + public Capnp.Rpc.PromisedAnswer.READER PromisedAnswer => which == WHICH.PromisedAnswer ? ctx.ReadStruct(0, Capnp.Rpc.PromisedAnswer.READER.create) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(32U, (ushort)0); + set => this.WriteData(32U, (ushort)value, (ushort)0); + } + + public uint ImportedCap + { + get => which == WHICH.ImportedCap ? this.ReadDataUInt(0UL, 0U) : default; + set => this.WriteData(0UL, value, 0U); + } + + public Capnp.Rpc.PromisedAnswer.WRITER PromisedAnswer + { + get => which == WHICH.PromisedAnswer ? BuildPointer(0) : default; + set => Link(0, value); + } + } + } + + public class Payload : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Content = CapnpSerializable.Create(reader.Content); + CapTable = reader.CapTable.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Content.SetObject(Content); + writer.CapTable.Init(CapTable, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public AnyPointer Content + { + get; + set; + } + + public IReadOnlyList CapTable + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState Content => ctx.StructReadPointer(0); + public IReadOnlyList CapTable => ctx.ReadList(1).Cast(Capnp.Rpc.CapDescriptor.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public DynamicSerializerState Content + { + get => BuildPointer(0); + set => Link(0, value); + } + + public ListOfStructsSerializer CapTable + { + get => BuildPointer>(1); + set => Link(1, value); + } + } + } + + public class CapDescriptor : ICapnpSerializable + { + public enum WHICH : ushort + { + None = 0, + SenderHosted = 1, + SenderPromise = 2, + ReceiverHosted = 3, + ReceiverAnswer = 4, + ThirdPartyHosted = 5, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.None: + which = reader.which; + break; + case WHICH.SenderHosted: + SenderHosted = reader.SenderHosted; + break; + case WHICH.SenderPromise: + SenderPromise = reader.SenderPromise; + break; + case WHICH.ReceiverHosted: + ReceiverHosted = reader.ReceiverHosted; + break; + case WHICH.ReceiverAnswer: + ReceiverAnswer = CapnpSerializable.Create(reader.ReceiverAnswer); + break; + case WHICH.ThirdPartyHosted: + ThirdPartyHosted = CapnpSerializable.Create(reader.ThirdPartyHosted); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.None: + break; + case WHICH.SenderHosted: + _content = 0; + break; + case WHICH.SenderPromise: + _content = 0; + break; + case WHICH.ReceiverHosted: + _content = 0; + break; + case WHICH.ReceiverAnswer: + _content = null; + break; + case WHICH.ThirdPartyHosted: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.None: + break; + case WHICH.SenderHosted: + writer.SenderHosted = SenderHosted.Value; + break; + case WHICH.SenderPromise: + writer.SenderPromise = SenderPromise.Value; + break; + case WHICH.ReceiverHosted: + writer.ReceiverHosted = ReceiverHosted.Value; + break; + case WHICH.ReceiverAnswer: + ReceiverAnswer?.serialize(writer.ReceiverAnswer); + break; + case WHICH.ThirdPartyHosted: + ThirdPartyHosted?.serialize(writer.ThirdPartyHosted); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint? SenderHosted + { + get => _which == WHICH.SenderHosted ? (uint? )_content : null; + set + { + _which = WHICH.SenderHosted; + _content = value; + } + } + + public uint? SenderPromise + { + get => _which == WHICH.SenderPromise ? (uint? )_content : null; + set + { + _which = WHICH.SenderPromise; + _content = value; + } + } + + public uint? ReceiverHosted + { + get => _which == WHICH.ReceiverHosted ? (uint? )_content : null; + set + { + _which = WHICH.ReceiverHosted; + _content = value; + } + } + + public Capnp.Rpc.PromisedAnswer ReceiverAnswer + { + get => _which == WHICH.ReceiverAnswer ? (Capnp.Rpc.PromisedAnswer)_content : null; + set + { + _which = WHICH.ReceiverAnswer; + _content = value; + } + } + + public Capnp.Rpc.ThirdPartyCapDescriptor ThirdPartyHosted + { + get => _which == WHICH.ThirdPartyHosted ? (Capnp.Rpc.ThirdPartyCapDescriptor)_content : null; + set + { + _which = WHICH.ThirdPartyHosted; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public uint SenderHosted => which == WHICH.SenderHosted ? ctx.ReadDataUInt(32UL, 0U) : default; + public uint SenderPromise => which == WHICH.SenderPromise ? ctx.ReadDataUInt(32UL, 0U) : default; + public uint ReceiverHosted => which == WHICH.ReceiverHosted ? ctx.ReadDataUInt(32UL, 0U) : default; + public Capnp.Rpc.PromisedAnswer.READER ReceiverAnswer => which == WHICH.ReceiverAnswer ? ctx.ReadStruct(0, Capnp.Rpc.PromisedAnswer.READER.create) : default; + public Capnp.Rpc.ThirdPartyCapDescriptor.READER ThirdPartyHosted => which == WHICH.ThirdPartyHosted ? ctx.ReadStruct(0, Capnp.Rpc.ThirdPartyCapDescriptor.READER.create) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public uint SenderHosted + { + get => which == WHICH.SenderHosted ? this.ReadDataUInt(32UL, 0U) : default; + set => this.WriteData(32UL, value, 0U); + } + + public uint SenderPromise + { + get => which == WHICH.SenderPromise ? this.ReadDataUInt(32UL, 0U) : default; + set => this.WriteData(32UL, value, 0U); + } + + public uint ReceiverHosted + { + get => which == WHICH.ReceiverHosted ? this.ReadDataUInt(32UL, 0U) : default; + set => this.WriteData(32UL, value, 0U); + } + + public Capnp.Rpc.PromisedAnswer.WRITER ReceiverAnswer + { + get => which == WHICH.ReceiverAnswer ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnp.Rpc.ThirdPartyCapDescriptor.WRITER ThirdPartyHosted + { + get => which == WHICH.ThirdPartyHosted ? BuildPointer(0) : default; + set => Link(0, value); + } + } + } + + public class PromisedAnswer : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + QuestionId = reader.QuestionId; + Transform = reader.Transform.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.QuestionId = QuestionId; + writer.Transform.Init(Transform, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint QuestionId + { + get; + set; + } + + public IReadOnlyList Transform + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint QuestionId => ctx.ReadDataUInt(0UL, 0U); + public IReadOnlyList Transform => ctx.ReadList(0).Cast(Capnp.Rpc.PromisedAnswer.Op.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public uint QuestionId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public ListOfStructsSerializer Transform + { + get => BuildPointer>(0); + set => Link(0, value); + } + } + + public class Op : ICapnpSerializable + { + public enum WHICH : ushort + { + Noop = 0, + GetPointerField = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Noop: + which = reader.which; + break; + case WHICH.GetPointerField: + GetPointerField = reader.GetPointerField; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Noop: + break; + case WHICH.GetPointerField: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Noop: + break; + case WHICH.GetPointerField: + writer.GetPointerField = GetPointerField.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ushort? GetPointerField + { + get => _which == WHICH.GetPointerField ? (ushort? )_content : null; + set + { + _which = WHICH.GetPointerField; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public ushort GetPointerField => which == WHICH.GetPointerField ? ctx.ReadDataUShort(16UL, (ushort)0) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public ushort GetPointerField + { + get => which == WHICH.GetPointerField ? this.ReadDataUShort(16UL, (ushort)0) : default; + set => this.WriteData(16UL, value, (ushort)0); + } + } + } + } + + public class ThirdPartyCapDescriptor : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Id = CapnpSerializable.Create(reader.Id); + VineId = reader.VineId; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Id.SetObject(Id); + writer.VineId = VineId; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public AnyPointer Id + { + get; + set; + } + + public uint VineId + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState Id => ctx.StructReadPointer(0); + public uint VineId => ctx.ReadDataUInt(0UL, 0U); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public DynamicSerializerState Id + { + get => BuildPointer(0); + set => Link(0, value); + } + + public uint VineId + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + } + } + + public class Exception : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Reason = reader.Reason; + ObsoleteIsCallersFault = reader.ObsoleteIsCallersFault; + ObsoleteDurability = reader.ObsoleteDurability; + TheType = reader.TheType; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Reason = Reason; + writer.ObsoleteIsCallersFault = ObsoleteIsCallersFault; + writer.ObsoleteDurability = ObsoleteDurability; + writer.TheType = TheType; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Reason + { + get; + set; + } + + public bool ObsoleteIsCallersFault + { + get; + set; + } + + public ushort ObsoleteDurability + { + get; + set; + } + + public Capnp.Rpc.Exception.Type TheType + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Reason => ctx.ReadText(0, ""); + public bool ObsoleteIsCallersFault => ctx.ReadDataBool(0UL, false); + public ushort ObsoleteDurability => ctx.ReadDataUShort(16UL, (ushort)0); + public Capnp.Rpc.Exception.Type TheType => (Capnp.Rpc.Exception.Type)ctx.ReadDataUShort(32UL, (ushort)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public string Reason + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public bool ObsoleteIsCallersFault + { + get => this.ReadDataBool(0UL, false); + set => this.WriteData(0UL, value, false); + } + + public ushort ObsoleteDurability + { + get => this.ReadDataUShort(16UL, (ushort)0); + set => this.WriteData(16UL, value, (ushort)0); + } + + public Capnp.Rpc.Exception.Type TheType + { + get => (Capnp.Rpc.Exception.Type)this.ReadDataUShort(32UL, (ushort)0); + set => this.WriteData(32UL, (ushort)value, (ushort)0); + } + } + + public enum Type : ushort + { + failed, + overloaded, + disconnected, + unimplemented + } + } +} \ No newline at end of file diff --git a/MsBuildGenerationTest/capnp/schema.capnp b/MsBuildGenerationTest/capnp/schema.capnp new file mode 100644 index 0000000..f9fbe61 --- /dev/null +++ b/MsBuildGenerationTest/capnp/schema.capnp @@ -0,0 +1,529 @@ +# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +using Cxx = import "/capnp/c++.capnp"; + +@0xa93fc509624c72d9; +$Cxx.namespace("capnp::schema"); + +using Id = UInt64; +# The globally-unique ID of a file, type, or annotation. + +struct Node { + id @0 :Id; + + displayName @1 :Text; + # Name to present to humans to identify this Node. You should not attempt to parse this. Its + # format could change. It is not guaranteed to be unique. + # + # (On Zooko's triangle, this is the node's nickname.) + + displayNamePrefixLength @2 :UInt32; + # If you want a shorter version of `displayName` (just naming this node, without its surrounding + # scope), chop off this many characters from the beginning of `displayName`. + + scopeId @3 :Id; + # ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back + # at this node, but robust code should avoid relying on this (and, in fact, group nodes are not + # listed in the outer struct's nestedNodes, since they are listed in the fields). `scopeId` is + # zero if the node has no parent, which is normally only the case with files, but should be + # allowed for any kind of node (in order to make runtime type generation easier). + + parameters @32 :List(Parameter); + # If this node is parameterized (generic), the list of parameters. Empty for non-generic types. + + isGeneric @33 :Bool; + # True if this node is generic, meaning that it or one of its parent scopes has a non-empty + # `parameters`. + + struct Parameter { + # Information about one of the node's parameters. + + name @0 :Text; + } + + nestedNodes @4 :List(NestedNode); + # List of nodes nested within this node, along with the names under which they were declared. + + struct NestedNode { + name @0 :Text; + # Unqualified symbol name. Unlike Node.displayName, this *can* be used programmatically. + # + # (On Zooko's triangle, this is the node's petname according to its parent scope.) + + id @1 :Id; + # ID of the nested node. Typically, the target node's scopeId points back to this node, but + # robust code should avoid relying on this. + } + + annotations @5 :List(Annotation); + # Annotations applied to this node. + + union { + # Info specific to each kind of node. + + file @6 :Void; + + struct :group { + dataWordCount @7 :UInt16; + # Size of the data section, in words. + + pointerCount @8 :UInt16; + # Size of the pointer section, in pointers (which are one word each). + + preferredListEncoding @9 :ElementSize; + # The preferred element size to use when encoding a list of this struct. If this is anything + # other than `inlineComposite` then the struct is one word or less in size and is a candidate + # for list packing optimization. + + isGroup @10 :Bool; + # If true, then this "struct" node is actually not an independent node, but merely represents + # some named union or group within a particular parent struct. This node's scopeId refers + # to the parent struct, which may itself be a union/group in yet another struct. + # + # All group nodes share the same dataWordCount and pointerCount as the top-level + # struct, and their fields live in the same ordinal and offset spaces as all other fields in + # the struct. + # + # Note that a named union is considered a special kind of group -- in fact, a named union + # is exactly equivalent to a group that contains nothing but an unnamed union. + + discriminantCount @11 :UInt16; + # Number of fields in this struct which are members of an anonymous union, and thus may + # overlap. If this is non-zero, then a 16-bit discriminant is present indicating which + # of the overlapping fields is active. This can never be 1 -- if it is non-zero, it must be + # two or more. + # + # Note that the fields of an unnamed union are considered fields of the scope containing the + # union -- an unnamed union is not its own group. So, a top-level struct may contain a + # non-zero discriminant count. Named unions, on the other hand, are equivalent to groups + # containing unnamed unions. So, a named union has its own independent schema node, with + # `isGroup` = true. + + discriminantOffset @12 :UInt32; + # If `discriminantCount` is non-zero, this is the offset of the union discriminant, in + # multiples of 16 bits. + + fields @13 :List(Field); + # Fields defined within this scope (either the struct's top-level fields, or the fields of + # a particular group; see `isGroup`). + # + # The fields are sorted by ordinal number, but note that because groups share the same + # ordinal space, the field's index in this list is not necessarily exactly its ordinal. + # On the other hand, the field's position in this list does remain the same even as the + # protocol evolves, since it is not possible to insert or remove an earlier ordinal. + # Therefore, for most use cases, if you want to identify a field by number, it may make the + # most sense to use the field's index in this list rather than its ordinal. + } + + enum :group { + enumerants@14 :List(Enumerant); + # Enumerants ordered by numeric value (ordinal). + } + + interface :group { + methods @15 :List(Method); + # Methods ordered by ordinal. + + superclasses @31 :List(Superclass); + # Superclasses of this interface. + } + + const :group { + type @16 :Type; + value @17 :Value; + } + + annotation :group { + type @18 :Type; + + targetsFile @19 :Bool; + targetsConst @20 :Bool; + targetsEnum @21 :Bool; + targetsEnumerant @22 :Bool; + targetsStruct @23 :Bool; + targetsField @24 :Bool; + targetsUnion @25 :Bool; + targetsGroup @26 :Bool; + targetsInterface @27 :Bool; + targetsMethod @28 :Bool; + targetsParam @29 :Bool; + targetsAnnotation @30 :Bool; + } + } + + struct SourceInfo { + # Additional information about a node which is not needed at runtime, but may be useful for + # documentation or debugging purposes. This is kept in a separate struct to make sure it + # doesn't accidentally get included in contexts where it is not needed. The + # `CodeGeneratorRequest` includes this information in a separate array. + + id @0 :Id; + # ID of the Node which this info describes. + + docComment @1 :Text; + # The top-level doc comment for the Node. + + members @2 :List(Member); + # Information about each member -- i.e. fields (for structs), enumerants (for enums), or + # methods (for interfaces). + # + # This list is the same length and order as the corresponding list in the Node, i.e. + # Node.struct.fields, Node.enum.enumerants, or Node.interface.methods. + + struct Member { + docComment @0 :Text; + # Doc comment on the member. + } + + # TODO(someday): Record location of the declaration in the original source code. + } +} + +struct Field { + # Schema for a field of a struct. + + name @0 :Text; + + codeOrder @1 :UInt16; + # Indicates where this member appeared in the code, relative to other members. + # Code ordering may have semantic relevance -- programmers tend to place related fields + # together. So, using code ordering makes sense in human-readable formats where ordering is + # otherwise irrelevant, like JSON. The values of codeOrder are tightly-packed, so the maximum + # value is count(members) - 1. Fields that are members of a union are only ordered relative to + # the other members of that union, so the maximum value there is count(union.members). + + annotations @2 :List(Annotation); + + const noDiscriminant :UInt16 = 0xffff; + + discriminantValue @3 :UInt16 = Field.noDiscriminant; + # If the field is in a union, this is the value which the union's discriminant should take when + # the field is active. If the field is not in a union, this is 0xffff. + + union { + slot :group { + # A regular, non-group, non-fixed-list field. + + offset @4 :UInt32; + # Offset, in units of the field's size, from the beginning of the section in which the field + # resides. E.g. for a UInt32 field, multiply this by 4 to get the byte offset from the + # beginning of the data section. + + type @5 :Type; + defaultValue @6 :Value; + + hadExplicitDefault @10 :Bool; + # Whether the default value was specified explicitly. Non-explicit default values are always + # zero or empty values. Usually, whether the default value was explicit shouldn't matter. + # The main use case for this flag is for structs representing method parameters: + # explicitly-defaulted parameters may be allowed to be omitted when calling the method. + } + + group :group { + # A group. + + typeId @7 :Id; + # The ID of the group's node. + } + } + + ordinal :union { + implicit @8 :Void; + explicit @9 :UInt16; + # The original ordinal number given to the field. You probably should NOT use this; if you need + # a numeric identifier for a field, use its position within the field array for its scope. + # The ordinal is given here mainly just so that the original schema text can be reproduced given + # the compiled version -- i.e. so that `capnp compile -ocapnp` can do its job. + } +} + +struct Enumerant { + # Schema for member of an enum. + + name @0 :Text; + + codeOrder @1 :UInt16; + # Specifies order in which the enumerants were declared in the code. + # Like Struct.Field.codeOrder. + + annotations @2 :List(Annotation); +} + +struct Superclass { + id @0 :Id; + brand @1 :Brand; +} + +struct Method { + # Schema for method of an interface. + + name @0 :Text; + + codeOrder @1 :UInt16; + # Specifies order in which the methods were declared in the code. + # Like Struct.Field.codeOrder. + + implicitParameters @7 :List(Node.Parameter); + # The parameters listed in [] (typically, type / generic parameters), whose bindings are intended + # to be inferred rather than specified explicitly, although not all languages support this. + + paramStructType @2 :Id; + # ID of the parameter struct type. If a named parameter list was specified in the method + # declaration (rather than a single struct parameter type) then a corresponding struct type is + # auto-generated. Such an auto-generated type will not be listed in the interface's + # `nestedNodes` and its `scopeId` will be zero -- it is completely detached from the namespace. + # (Awkwardly, it does of course inherit generic parameters from the method's scope, which makes + # this a situation where you can't just climb the scope chain to find where a particular + # generic parameter was introduced. Making the `scopeId` zero was a mistake.) + + paramBrand @5 :Brand; + # Brand of param struct type. + + resultStructType @3 :Id; + # ID of the return struct type; similar to `paramStructType`. + + resultBrand @6 :Brand; + # Brand of result struct type. + + annotations @4 :List(Annotation); +} + +struct Type { + # Represents a type expression. + + union { + # The ordinals intentionally match those of Value. + + void @0 :Void; + bool @1 :Void; + int8 @2 :Void; + int16 @3 :Void; + int32 @4 :Void; + int64 @5 :Void; + uint8 @6 :Void; + uint16 @7 :Void; + uint32 @8 :Void; + uint64 @9 :Void; + float32 @10 :Void; + float64 @11 :Void; + text @12 :Void; + data @13 :Void; + + list :group { + elementType @14 :Type; + } + + enum :group { + typeId @15 :Id; + brand @21 :Brand; + } + struct :group { + typeId @16 :Id; + brand @22 :Brand; + } + interface :group { + typeId @17 :Id; + brand @23 :Brand; + } + + anyPointer :union { + unconstrained :union { + # A regular AnyPointer. + # + # The name "unconstrained" means as opposed to constraining it to match a type parameter. + # In retrospect this name is probably a poor choice given that it may still be constrained + # to be a struct, list, or capability. + + anyKind @18 :Void; # truly AnyPointer + struct @25 :Void; # AnyStruct + list @26 :Void; # AnyList + capability @27 :Void; # Capability + } + + parameter :group { + # This is actually a reference to a type parameter defined within this scope. + + scopeId @19 :Id; + # ID of the generic type whose parameter we're referencing. This should be a parent of the + # current scope. + + parameterIndex @20 :UInt16; + # Index of the parameter within the generic type's parameter list. + } + + implicitMethodParameter :group { + # This is actually a reference to an implicit (generic) parameter of a method. The only + # legal context for this type to appear is inside Method.paramBrand or Method.resultBrand. + + parameterIndex @24 :UInt16; + } + } + } +} + +struct Brand { + # Specifies bindings for parameters of generics. Since these bindings turn a generic into a + # non-generic, we call it the "brand". + + scopes @0 :List(Scope); + # For each of the target type and each of its parent scopes, a parameterization may be included + # in this list. If no parameterization is included for a particular relevant scope, then either + # that scope has no parameters or all parameters should be considered to be `AnyPointer`. + + struct Scope { + scopeId @0 :Id; + # ID of the scope to which these params apply. + + union { + bind @1 :List(Binding); + # List of parameter bindings. + + inherit @2 :Void; + # The place where this Brand appears is actually within this scope or a sub-scope, + # and the bindings for this scope should be inherited from the reference point. + } + } + + struct Binding { + union { + unbound @0 :Void; + type @1 :Type; + + # TODO(someday): Allow non-type parameters? Unsure if useful. + } + } +} + +struct Value { + # Represents a value, e.g. a field default value, constant value, or annotation value. + + union { + # The ordinals intentionally match those of Type. + + void @0 :Void; + bool @1 :Bool; + int8 @2 :Int8; + int16 @3 :Int16; + int32 @4 :Int32; + int64 @5 :Int64; + uint8 @6 :UInt8; + uint16 @7 :UInt16; + uint32 @8 :UInt32; + uint64 @9 :UInt64; + float32 @10 :Float32; + float64 @11 :Float64; + text @12 :Text; + data @13 :Data; + + list @14 :AnyPointer; + + enum @15 :UInt16; + struct @16 :AnyPointer; + + interface @17 :Void; + # The only interface value that can be represented statically is "null", whose methods always + # throw exceptions. + + anyPointer @18 :AnyPointer; + } +} + +struct Annotation { + # Describes an annotation applied to a declaration. Note AnnotationNode describes the + # annotation's declaration, while this describes a use of the annotation. + + id @0 :Id; + # ID of the annotation node. + + brand @2 :Brand; + # Brand of the annotation. + # + # Note that the annotation itself is not allowed to be parameterized, but its scope might be. + + value @1 :Value; +} + +enum ElementSize { + # Possible element sizes for encoded lists. These correspond exactly to the possible values of + # the 3-bit element size component of a list pointer. + + empty @0; # aka "void", but that's a keyword. + bit @1; + byte @2; + twoBytes @3; + fourBytes @4; + eightBytes @5; + pointer @6; + inlineComposite @7; +} + +struct CapnpVersion { + major @0 :UInt16; + minor @1 :UInt8; + micro @2 :UInt8; +} + +struct CodeGeneratorRequest { + capnpVersion @2 :CapnpVersion; + # Version of the `capnp` executable. Generally, code generators should ignore this, but the code + # generators that ship with `capnp` itself will print a warning if this mismatches since that + # probably indicates something is misconfigured. + # + # The first version of 'capnp' to set this was 0.6.0. So, if it's missing, the compiler version + # is older than that. + + nodes @0 :List(Node); + # All nodes parsed by the compiler, including for the files on the command line and their + # imports. + + sourceInfo @3 :List(Node.SourceInfo); + # Information about the original source code for each node, where available. This array may be + # omitted or may be missing some nodes if no info is available for them. + + requestedFiles @1 :List(RequestedFile); + # Files which were listed on the command line. + + struct RequestedFile { + id @0 :Id; + # ID of the file. + + filename @1 :Text; + # Name of the file as it appeared on the command-line (minus the src-prefix). You may use + # this to decide where to write the output. + + imports @2 :List(Import); + # List of all imported paths seen in this file. + + struct Import { + id @0 :Id; + # ID of the imported file. + + name @1 :Text; + # Name which *this* file used to refer to the foreign file. This may be a relative name. + # This information is provided because it might be useful for code generation, e.g. to + # generate #include directives in C++. We don't put this in Node.file because this + # information is only meaningful at compile time anyway. + # + # (On Zooko's triangle, this is the import's petname according to the importing file.) + } + } +} diff --git a/MsBuildGenerationTest/capnp/schema.capnp.cs b/MsBuildGenerationTest/capnp/schema.capnp.cs new file mode 100644 index 0000000..63d6b35 --- /dev/null +++ b/MsBuildGenerationTest/capnp/schema.capnp.cs @@ -0,0 +1,4309 @@ +using Capnp; +using Capnp.Rpc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Capnp.Schema +{ + public class Node : ICapnpSerializable + { + public enum WHICH : ushort + { + File = 0, + Struct = 1, + Enum = 2, + Interface = 3, + Const = 4, + Annotation = 5, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.File: + which = reader.which; + break; + case WHICH.Struct: + Struct = CapnpSerializable.Create(reader.Struct); + break; + case WHICH.Enum: + Enum = CapnpSerializable.Create(reader.Enum); + break; + case WHICH.Interface: + Interface = CapnpSerializable.Create(reader.Interface); + break; + case WHICH.Const: + Const = CapnpSerializable.Create(reader.Const); + break; + case WHICH.Annotation: + Annotation = CapnpSerializable.Create(reader.Annotation); + break; + } + + Id = reader.Id; + DisplayName = reader.DisplayName; + DisplayNamePrefixLength = reader.DisplayNamePrefixLength; + ScopeId = reader.ScopeId; + NestedNodes = reader.NestedNodes.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + Annotations = reader.Annotations.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + Parameters = reader.Parameters.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + IsGeneric = reader.IsGeneric; + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.File: + break; + case WHICH.Struct: + _content = null; + break; + case WHICH.Enum: + _content = null; + break; + case WHICH.Interface: + _content = null; + break; + case WHICH.Const: + _content = null; + break; + case WHICH.Annotation: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.File: + break; + case WHICH.Struct: + Struct?.serialize(writer.Struct); + break; + case WHICH.Enum: + Enum?.serialize(writer.Enum); + break; + case WHICH.Interface: + Interface?.serialize(writer.Interface); + break; + case WHICH.Const: + Const?.serialize(writer.Const); + break; + case WHICH.Annotation: + Annotation?.serialize(writer.Annotation); + break; + } + + writer.Id = Id; + writer.DisplayName = DisplayName; + writer.DisplayNamePrefixLength = DisplayNamePrefixLength; + writer.ScopeId = ScopeId; + writer.NestedNodes.Init(NestedNodes, (_s1, _v1) => _v1?.serialize(_s1)); + writer.Annotations.Init(Annotations, (_s1, _v1) => _v1?.serialize(_s1)); + writer.Parameters.Init(Parameters, (_s1, _v1) => _v1?.serialize(_s1)); + writer.IsGeneric = IsGeneric; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong Id + { + get; + set; + } + + public string DisplayName + { + get; + set; + } + + public uint DisplayNamePrefixLength + { + get; + set; + } + + public ulong ScopeId + { + get; + set; + } + + public IReadOnlyList NestedNodes + { + get; + set; + } + + public IReadOnlyList Annotations + { + get; + set; + } + + public Capnp.Schema.Node.@struct Struct + { + get => _which == WHICH.Struct ? (Capnp.Schema.Node.@struct)_content : null; + set + { + _which = WHICH.Struct; + _content = value; + } + } + + public Capnp.Schema.Node.@enum Enum + { + get => _which == WHICH.Enum ? (Capnp.Schema.Node.@enum)_content : null; + set + { + _which = WHICH.Enum; + _content = value; + } + } + + public Capnp.Schema.Node.@interface Interface + { + get => _which == WHICH.Interface ? (Capnp.Schema.Node.@interface)_content : null; + set + { + _which = WHICH.Interface; + _content = value; + } + } + + public Capnp.Schema.Node.@const Const + { + get => _which == WHICH.Const ? (Capnp.Schema.Node.@const)_content : null; + set + { + _which = WHICH.Const; + _content = value; + } + } + + public Capnp.Schema.Node.@annotation Annotation + { + get => _which == WHICH.Annotation ? (Capnp.Schema.Node.@annotation)_content : null; + set + { + _which = WHICH.Annotation; + _content = value; + } + } + + public IReadOnlyList Parameters + { + get; + set; + } + + public bool IsGeneric + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(96U, (ushort)0); + public ulong Id => ctx.ReadDataULong(0UL, 0UL); + public string DisplayName => ctx.ReadText(0, ""); + public uint DisplayNamePrefixLength => ctx.ReadDataUInt(64UL, 0U); + public ulong ScopeId => ctx.ReadDataULong(128UL, 0UL); + public IReadOnlyList NestedNodes => ctx.ReadList(1).Cast(Capnp.Schema.Node.NestedNode.READER.create); + public IReadOnlyList Annotations => ctx.ReadList(2).Cast(Capnp.Schema.Annotation.READER.create); + public @struct.READER Struct => which == WHICH.Struct ? new @struct.READER(ctx) : default; + public @enum.READER Enum => which == WHICH.Enum ? new @enum.READER(ctx) : default; + public @interface.READER Interface => which == WHICH.Interface ? new @interface.READER(ctx) : default; + public @const.READER Const => which == WHICH.Const ? new @const.READER(ctx) : default; + public @annotation.READER Annotation => which == WHICH.Annotation ? new @annotation.READER(ctx) : default; + public IReadOnlyList Parameters => ctx.ReadList(5).Cast(Capnp.Schema.Node.Parameter.READER.create); + public bool IsGeneric => ctx.ReadDataBool(288UL, false); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(5, 6); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(96U, (ushort)0); + set => this.WriteData(96U, (ushort)value, (ushort)0); + } + + public ulong Id + { + get => this.ReadDataULong(0UL, 0UL); + set => this.WriteData(0UL, value, 0UL); + } + + public string DisplayName + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public uint DisplayNamePrefixLength + { + get => this.ReadDataUInt(64UL, 0U); + set => this.WriteData(64UL, value, 0U); + } + + public ulong ScopeId + { + get => this.ReadDataULong(128UL, 0UL); + set => this.WriteData(128UL, value, 0UL); + } + + public ListOfStructsSerializer NestedNodes + { + get => BuildPointer>(1); + set => Link(1, value); + } + + public ListOfStructsSerializer Annotations + { + get => BuildPointer>(2); + set => Link(2, value); + } + + public @struct.WRITER Struct + { + get => which == WHICH.Struct ? Rewrap<@struct.WRITER>() : default; + } + + public @enum.WRITER Enum + { + get => which == WHICH.Enum ? Rewrap<@enum.WRITER>() : default; + } + + public @interface.WRITER Interface + { + get => which == WHICH.Interface ? Rewrap<@interface.WRITER>() : default; + } + + public @const.WRITER Const + { + get => which == WHICH.Const ? Rewrap<@const.WRITER>() : default; + } + + public @annotation.WRITER Annotation + { + get => which == WHICH.Annotation ? Rewrap<@annotation.WRITER>() : default; + } + + public ListOfStructsSerializer Parameters + { + get => BuildPointer>(5); + set => Link(5, value); + } + + public bool IsGeneric + { + get => this.ReadDataBool(288UL, false); + set => this.WriteData(288UL, value, false); + } + } + + public class @struct : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + DataWordCount = reader.DataWordCount; + PointerCount = reader.PointerCount; + PreferredListEncoding = reader.PreferredListEncoding; + IsGroup = reader.IsGroup; + DiscriminantCount = reader.DiscriminantCount; + DiscriminantOffset = reader.DiscriminantOffset; + Fields = reader.Fields.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.DataWordCount = DataWordCount; + writer.PointerCount = PointerCount; + writer.PreferredListEncoding = PreferredListEncoding; + writer.IsGroup = IsGroup; + writer.DiscriminantCount = DiscriminantCount; + writer.DiscriminantOffset = DiscriminantOffset; + writer.Fields.Init(Fields, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ushort DataWordCount + { + get; + set; + } + + public ushort PointerCount + { + get; + set; + } + + public Capnp.Schema.ElementSize PreferredListEncoding + { + get; + set; + } + + public bool IsGroup + { + get; + set; + } + + public ushort DiscriminantCount + { + get; + set; + } + + public uint DiscriminantOffset + { + get; + set; + } + + public IReadOnlyList Fields + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ushort DataWordCount => ctx.ReadDataUShort(112UL, (ushort)0); + public ushort PointerCount => ctx.ReadDataUShort(192UL, (ushort)0); + public Capnp.Schema.ElementSize PreferredListEncoding => (Capnp.Schema.ElementSize)ctx.ReadDataUShort(208UL, (ushort)0); + public bool IsGroup => ctx.ReadDataBool(224UL, false); + public ushort DiscriminantCount => ctx.ReadDataUShort(240UL, (ushort)0); + public uint DiscriminantOffset => ctx.ReadDataUInt(256UL, 0U); + public IReadOnlyList Fields => ctx.ReadList(3).Cast(Capnp.Schema.Field.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public ushort DataWordCount + { + get => this.ReadDataUShort(112UL, (ushort)0); + set => this.WriteData(112UL, value, (ushort)0); + } + + public ushort PointerCount + { + get => this.ReadDataUShort(192UL, (ushort)0); + set => this.WriteData(192UL, value, (ushort)0); + } + + public Capnp.Schema.ElementSize PreferredListEncoding + { + get => (Capnp.Schema.ElementSize)this.ReadDataUShort(208UL, (ushort)0); + set => this.WriteData(208UL, (ushort)value, (ushort)0); + } + + public bool IsGroup + { + get => this.ReadDataBool(224UL, false); + set => this.WriteData(224UL, value, false); + } + + public ushort DiscriminantCount + { + get => this.ReadDataUShort(240UL, (ushort)0); + set => this.WriteData(240UL, value, (ushort)0); + } + + public uint DiscriminantOffset + { + get => this.ReadDataUInt(256UL, 0U); + set => this.WriteData(256UL, value, 0U); + } + + public ListOfStructsSerializer Fields + { + get => BuildPointer>(3); + set => Link(3, value); + } + } + } + + public class @enum : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Enumerants = reader.Enumerants.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Enumerants.Init(Enumerants, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public IReadOnlyList Enumerants + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public IReadOnlyList Enumerants => ctx.ReadList(3).Cast(Capnp.Schema.Enumerant.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public ListOfStructsSerializer Enumerants + { + get => BuildPointer>(3); + set => Link(3, value); + } + } + } + + public class @interface : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Methods = reader.Methods.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + Superclasses = reader.Superclasses.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Methods.Init(Methods, (_s1, _v1) => _v1?.serialize(_s1)); + writer.Superclasses.Init(Superclasses, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public IReadOnlyList Methods + { + get; + set; + } + + public IReadOnlyList Superclasses + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public IReadOnlyList Methods => ctx.ReadList(3).Cast(Capnp.Schema.Method.READER.create); + public IReadOnlyList Superclasses => ctx.ReadList(4).Cast(Capnp.Schema.Superclass.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public ListOfStructsSerializer Methods + { + get => BuildPointer>(3); + set => Link(3, value); + } + + public ListOfStructsSerializer Superclasses + { + get => BuildPointer>(4); + set => Link(4, value); + } + } + } + + public class @const : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Type = CapnpSerializable.Create(reader.Type); + Value = CapnpSerializable.Create(reader.Value); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Type?.serialize(writer.Type); + Value?.serialize(writer.Value); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnp.Schema.Type Type + { + get; + set; + } + + public Capnp.Schema.Value Value + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnp.Schema.Type.READER Type => ctx.ReadStruct(3, Capnp.Schema.Type.READER.create); + public Capnp.Schema.Value.READER Value => ctx.ReadStruct(4, Capnp.Schema.Value.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public Capnp.Schema.Type.WRITER Type + { + get => BuildPointer(3); + set => Link(3, value); + } + + public Capnp.Schema.Value.WRITER Value + { + get => BuildPointer(4); + set => Link(4, value); + } + } + } + + public class @annotation : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Type = CapnpSerializable.Create(reader.Type); + TargetsFile = reader.TargetsFile; + TargetsConst = reader.TargetsConst; + TargetsEnum = reader.TargetsEnum; + TargetsEnumerant = reader.TargetsEnumerant; + TargetsStruct = reader.TargetsStruct; + TargetsField = reader.TargetsField; + TargetsUnion = reader.TargetsUnion; + TargetsGroup = reader.TargetsGroup; + TargetsInterface = reader.TargetsInterface; + TargetsMethod = reader.TargetsMethod; + TargetsParam = reader.TargetsParam; + TargetsAnnotation = reader.TargetsAnnotation; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Type?.serialize(writer.Type); + writer.TargetsFile = TargetsFile; + writer.TargetsConst = TargetsConst; + writer.TargetsEnum = TargetsEnum; + writer.TargetsEnumerant = TargetsEnumerant; + writer.TargetsStruct = TargetsStruct; + writer.TargetsField = TargetsField; + writer.TargetsUnion = TargetsUnion; + writer.TargetsGroup = TargetsGroup; + writer.TargetsInterface = TargetsInterface; + writer.TargetsMethod = TargetsMethod; + writer.TargetsParam = TargetsParam; + writer.TargetsAnnotation = TargetsAnnotation; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnp.Schema.Type Type + { + get; + set; + } + + public bool TargetsFile + { + get; + set; + } + + public bool TargetsConst + { + get; + set; + } + + public bool TargetsEnum + { + get; + set; + } + + public bool TargetsEnumerant + { + get; + set; + } + + public bool TargetsStruct + { + get; + set; + } + + public bool TargetsField + { + get; + set; + } + + public bool TargetsUnion + { + get; + set; + } + + public bool TargetsGroup + { + get; + set; + } + + public bool TargetsInterface + { + get; + set; + } + + public bool TargetsMethod + { + get; + set; + } + + public bool TargetsParam + { + get; + set; + } + + public bool TargetsAnnotation + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnp.Schema.Type.READER Type => ctx.ReadStruct(3, Capnp.Schema.Type.READER.create); + public bool TargetsFile => ctx.ReadDataBool(112UL, false); + public bool TargetsConst => ctx.ReadDataBool(113UL, false); + public bool TargetsEnum => ctx.ReadDataBool(114UL, false); + public bool TargetsEnumerant => ctx.ReadDataBool(115UL, false); + public bool TargetsStruct => ctx.ReadDataBool(116UL, false); + public bool TargetsField => ctx.ReadDataBool(117UL, false); + public bool TargetsUnion => ctx.ReadDataBool(118UL, false); + public bool TargetsGroup => ctx.ReadDataBool(119UL, false); + public bool TargetsInterface => ctx.ReadDataBool(120UL, false); + public bool TargetsMethod => ctx.ReadDataBool(121UL, false); + public bool TargetsParam => ctx.ReadDataBool(122UL, false); + public bool TargetsAnnotation => ctx.ReadDataBool(123UL, false); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public Capnp.Schema.Type.WRITER Type + { + get => BuildPointer(3); + set => Link(3, value); + } + + public bool TargetsFile + { + get => this.ReadDataBool(112UL, false); + set => this.WriteData(112UL, value, false); + } + + public bool TargetsConst + { + get => this.ReadDataBool(113UL, false); + set => this.WriteData(113UL, value, false); + } + + public bool TargetsEnum + { + get => this.ReadDataBool(114UL, false); + set => this.WriteData(114UL, value, false); + } + + public bool TargetsEnumerant + { + get => this.ReadDataBool(115UL, false); + set => this.WriteData(115UL, value, false); + } + + public bool TargetsStruct + { + get => this.ReadDataBool(116UL, false); + set => this.WriteData(116UL, value, false); + } + + public bool TargetsField + { + get => this.ReadDataBool(117UL, false); + set => this.WriteData(117UL, value, false); + } + + public bool TargetsUnion + { + get => this.ReadDataBool(118UL, false); + set => this.WriteData(118UL, value, false); + } + + public bool TargetsGroup + { + get => this.ReadDataBool(119UL, false); + set => this.WriteData(119UL, value, false); + } + + public bool TargetsInterface + { + get => this.ReadDataBool(120UL, false); + set => this.WriteData(120UL, value, false); + } + + public bool TargetsMethod + { + get => this.ReadDataBool(121UL, false); + set => this.WriteData(121UL, value, false); + } + + public bool TargetsParam + { + get => this.ReadDataBool(122UL, false); + set => this.WriteData(122UL, value, false); + } + + public bool TargetsAnnotation + { + get => this.ReadDataBool(123UL, false); + set => this.WriteData(123UL, value, false); + } + } + } + + public class Parameter : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Name = reader.Name; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Name = Name; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Name + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Name => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string Name + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class NestedNode : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Name = reader.Name; + Id = reader.Id; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Name = Name; + writer.Id = Id; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Name + { + get; + set; + } + + public ulong Id + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Name => ctx.ReadText(0, ""); + public ulong Id => ctx.ReadDataULong(0UL, 0UL); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public string Name + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public ulong Id + { + get => this.ReadDataULong(0UL, 0UL); + set => this.WriteData(0UL, value, 0UL); + } + } + } + + public class SourceInfo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Id = reader.Id; + DocComment = reader.DocComment; + Members = reader.Members.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Id = Id; + writer.DocComment = DocComment; + writer.Members.Init(Members, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong Id + { + get; + set; + } + + public string DocComment + { + get; + set; + } + + public IReadOnlyList Members + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong Id => ctx.ReadDataULong(0UL, 0UL); + public string DocComment => ctx.ReadText(0, ""); + public IReadOnlyList Members => ctx.ReadList(1).Cast(Capnp.Schema.Node.SourceInfo.Member.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 2); + } + + public ulong Id + { + get => this.ReadDataULong(0UL, 0UL); + set => this.WriteData(0UL, value, 0UL); + } + + public string DocComment + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public ListOfStructsSerializer Members + { + get => BuildPointer>(1); + set => Link(1, value); + } + } + + public class Member : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + DocComment = reader.DocComment; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.DocComment = DocComment; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string DocComment + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string DocComment => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string DocComment + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + } + } + + public class Field : ICapnpSerializable + { + public enum WHICH : ushort + { + Slot = 0, + Group = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Slot: + Slot = CapnpSerializable.Create(reader.Slot); + break; + case WHICH.Group: + Group = CapnpSerializable.Create(reader.Group); + break; + } + + Name = reader.Name; + CodeOrder = reader.CodeOrder; + Annotations = reader.Annotations.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + DiscriminantValue = reader.DiscriminantValue; + Ordinal = CapnpSerializable.Create(reader.Ordinal); + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Slot: + _content = null; + break; + case WHICH.Group: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Slot: + Slot?.serialize(writer.Slot); + break; + case WHICH.Group: + Group?.serialize(writer.Group); + break; + } + + writer.Name = Name; + writer.CodeOrder = CodeOrder; + writer.Annotations.Init(Annotations, (_s1, _v1) => _v1?.serialize(_s1)); + writer.DiscriminantValue = DiscriminantValue; + Ordinal?.serialize(writer.Ordinal); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Name + { + get; + set; + } + + public ushort CodeOrder + { + get; + set; + } + + public IReadOnlyList Annotations + { + get; + set; + } + + public ushort DiscriminantValue + { + get; + set; + } + + = 65535; + public Capnp.Schema.Field.@slot Slot + { + get => _which == WHICH.Slot ? (Capnp.Schema.Field.@slot)_content : null; + set + { + _which = WHICH.Slot; + _content = value; + } + } + + public Capnp.Schema.Field.@group Group + { + get => _which == WHICH.Group ? (Capnp.Schema.Field.@group)_content : null; + set + { + _which = WHICH.Group; + _content = value; + } + } + + public Capnp.Schema.Field.@ordinal Ordinal + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(64U, (ushort)0); + public string Name => ctx.ReadText(0, ""); + public ushort CodeOrder => ctx.ReadDataUShort(0UL, (ushort)0); + public IReadOnlyList Annotations => ctx.ReadList(1).Cast(Capnp.Schema.Annotation.READER.create); + public ushort DiscriminantValue => ctx.ReadDataUShort(16UL, (ushort)65535); + public @slot.READER Slot => which == WHICH.Slot ? new @slot.READER(ctx) : default; + public @group.READER Group => which == WHICH.Group ? new @group.READER(ctx) : default; + public @ordinal.READER Ordinal => new @ordinal.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(3, 4); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(64U, (ushort)0); + set => this.WriteData(64U, (ushort)value, (ushort)0); + } + + public string Name + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public ushort CodeOrder + { + get => this.ReadDataUShort(0UL, (ushort)0); + set => this.WriteData(0UL, value, (ushort)0); + } + + public ListOfStructsSerializer Annotations + { + get => BuildPointer>(1); + set => Link(1, value); + } + + public ushort DiscriminantValue + { + get => this.ReadDataUShort(16UL, (ushort)65535); + set => this.WriteData(16UL, value, (ushort)65535); + } + + public @slot.WRITER Slot + { + get => which == WHICH.Slot ? Rewrap<@slot.WRITER>() : default; + } + + public @group.WRITER Group + { + get => which == WHICH.Group ? Rewrap<@group.WRITER>() : default; + } + + public @ordinal.WRITER Ordinal + { + get => Rewrap<@ordinal.WRITER>(); + } + } + + public class @slot : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Offset = reader.Offset; + Type = CapnpSerializable.Create(reader.Type); + DefaultValue = CapnpSerializable.Create(reader.DefaultValue); + HadExplicitDefault = reader.HadExplicitDefault; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Offset = Offset; + Type?.serialize(writer.Type); + DefaultValue?.serialize(writer.DefaultValue); + writer.HadExplicitDefault = HadExplicitDefault; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint Offset + { + get; + set; + } + + public Capnp.Schema.Type Type + { + get; + set; + } + + public Capnp.Schema.Value DefaultValue + { + get; + set; + } + + public bool HadExplicitDefault + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint Offset => ctx.ReadDataUInt(32UL, 0U); + public Capnp.Schema.Type.READER Type => ctx.ReadStruct(2, Capnp.Schema.Type.READER.create); + public Capnp.Schema.Value.READER DefaultValue => ctx.ReadStruct(3, Capnp.Schema.Value.READER.create); + public bool HadExplicitDefault => ctx.ReadDataBool(128UL, false); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public uint Offset + { + get => this.ReadDataUInt(32UL, 0U); + set => this.WriteData(32UL, value, 0U); + } + + public Capnp.Schema.Type.WRITER Type + { + get => BuildPointer(2); + set => Link(2, value); + } + + public Capnp.Schema.Value.WRITER DefaultValue + { + get => BuildPointer(3); + set => Link(3, value); + } + + public bool HadExplicitDefault + { + get => this.ReadDataBool(128UL, false); + set => this.WriteData(128UL, value, false); + } + } + } + + public class @group : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + TypeId = reader.TypeId; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.TypeId = TypeId; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong TypeId + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong TypeId => ctx.ReadDataULong(128UL, 0UL); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public ulong TypeId + { + get => this.ReadDataULong(128UL, 0UL); + set => this.WriteData(128UL, value, 0UL); + } + } + } + + public class @ordinal : ICapnpSerializable + { + public enum WHICH : ushort + { + Implicit = 0, + Explicit = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Implicit: + which = reader.which; + break; + case WHICH.Explicit: + Explicit = reader.Explicit; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Implicit: + break; + case WHICH.Explicit: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Implicit: + break; + case WHICH.Explicit: + writer.Explicit = Explicit.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ushort? Explicit + { + get => _which == WHICH.Explicit ? (ushort? )_content : null; + set + { + _which = WHICH.Explicit; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(80U, (ushort)0); + public ushort Explicit => which == WHICH.Explicit ? ctx.ReadDataUShort(96UL, (ushort)0) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(80U, (ushort)0); + set => this.WriteData(80U, (ushort)value, (ushort)0); + } + + public ushort Explicit + { + get => which == WHICH.Explicit ? this.ReadDataUShort(96UL, (ushort)0) : default; + set => this.WriteData(96UL, value, (ushort)0); + } + } + } + } + + public class Enumerant : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Name = reader.Name; + CodeOrder = reader.CodeOrder; + Annotations = reader.Annotations.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Name = Name; + writer.CodeOrder = CodeOrder; + writer.Annotations.Init(Annotations, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Name + { + get; + set; + } + + public ushort CodeOrder + { + get; + set; + } + + public IReadOnlyList Annotations + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Name => ctx.ReadText(0, ""); + public ushort CodeOrder => ctx.ReadDataUShort(0UL, (ushort)0); + public IReadOnlyList Annotations => ctx.ReadList(1).Cast(Capnp.Schema.Annotation.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 2); + } + + public string Name + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public ushort CodeOrder + { + get => this.ReadDataUShort(0UL, (ushort)0); + set => this.WriteData(0UL, value, (ushort)0); + } + + public ListOfStructsSerializer Annotations + { + get => BuildPointer>(1); + set => Link(1, value); + } + } + } + + public class Superclass : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Id = reader.Id; + Brand = CapnpSerializable.Create(reader.Brand); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Id = Id; + Brand?.serialize(writer.Brand); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong Id + { + get; + set; + } + + public Capnp.Schema.Brand Brand + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong Id => ctx.ReadDataULong(0UL, 0UL); + public Capnp.Schema.Brand.READER Brand => ctx.ReadStruct(0, Capnp.Schema.Brand.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public ulong Id + { + get => this.ReadDataULong(0UL, 0UL); + set => this.WriteData(0UL, value, 0UL); + } + + public Capnp.Schema.Brand.WRITER Brand + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } + + public class Method : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Name = reader.Name; + CodeOrder = reader.CodeOrder; + ParamStructType = reader.ParamStructType; + ResultStructType = reader.ResultStructType; + Annotations = reader.Annotations.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + ParamBrand = CapnpSerializable.Create(reader.ParamBrand); + ResultBrand = CapnpSerializable.Create(reader.ResultBrand); + ImplicitParameters = reader.ImplicitParameters.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Name = Name; + writer.CodeOrder = CodeOrder; + writer.ParamStructType = ParamStructType; + writer.ResultStructType = ResultStructType; + writer.Annotations.Init(Annotations, (_s1, _v1) => _v1?.serialize(_s1)); + ParamBrand?.serialize(writer.ParamBrand); + ResultBrand?.serialize(writer.ResultBrand); + writer.ImplicitParameters.Init(ImplicitParameters, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Name + { + get; + set; + } + + public ushort CodeOrder + { + get; + set; + } + + public ulong ParamStructType + { + get; + set; + } + + public ulong ResultStructType + { + get; + set; + } + + public IReadOnlyList Annotations + { + get; + set; + } + + public Capnp.Schema.Brand ParamBrand + { + get; + set; + } + + public Capnp.Schema.Brand ResultBrand + { + get; + set; + } + + public IReadOnlyList ImplicitParameters + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Name => ctx.ReadText(0, ""); + public ushort CodeOrder => ctx.ReadDataUShort(0UL, (ushort)0); + public ulong ParamStructType => ctx.ReadDataULong(64UL, 0UL); + public ulong ResultStructType => ctx.ReadDataULong(128UL, 0UL); + public IReadOnlyList Annotations => ctx.ReadList(1).Cast(Capnp.Schema.Annotation.READER.create); + public Capnp.Schema.Brand.READER ParamBrand => ctx.ReadStruct(2, Capnp.Schema.Brand.READER.create); + public Capnp.Schema.Brand.READER ResultBrand => ctx.ReadStruct(3, Capnp.Schema.Brand.READER.create); + public IReadOnlyList ImplicitParameters => ctx.ReadList(4).Cast(Capnp.Schema.Node.Parameter.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(3, 5); + } + + public string Name + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public ushort CodeOrder + { + get => this.ReadDataUShort(0UL, (ushort)0); + set => this.WriteData(0UL, value, (ushort)0); + } + + public ulong ParamStructType + { + get => this.ReadDataULong(64UL, 0UL); + set => this.WriteData(64UL, value, 0UL); + } + + public ulong ResultStructType + { + get => this.ReadDataULong(128UL, 0UL); + set => this.WriteData(128UL, value, 0UL); + } + + public ListOfStructsSerializer Annotations + { + get => BuildPointer>(1); + set => Link(1, value); + } + + public Capnp.Schema.Brand.WRITER ParamBrand + { + get => BuildPointer(2); + set => Link(2, value); + } + + public Capnp.Schema.Brand.WRITER ResultBrand + { + get => BuildPointer(3); + set => Link(3, value); + } + + public ListOfStructsSerializer ImplicitParameters + { + get => BuildPointer>(4); + set => Link(4, value); + } + } + } + + public class Type : ICapnpSerializable + { + public enum WHICH : ushort + { + Void = 0, + Bool = 1, + Int8 = 2, + Int16 = 3, + Int32 = 4, + Int64 = 5, + Uint8 = 6, + Uint16 = 7, + Uint32 = 8, + Uint64 = 9, + Float32 = 10, + Float64 = 11, + Text = 12, + Data = 13, + List = 14, + Enum = 15, + Struct = 16, + Interface = 17, + AnyPointer = 18, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Void: + which = reader.which; + break; + case WHICH.Bool: + which = reader.which; + break; + case WHICH.Int8: + which = reader.which; + break; + case WHICH.Int16: + which = reader.which; + break; + case WHICH.Int32: + which = reader.which; + break; + case WHICH.Int64: + which = reader.which; + break; + case WHICH.Uint8: + which = reader.which; + break; + case WHICH.Uint16: + which = reader.which; + break; + case WHICH.Uint32: + which = reader.which; + break; + case WHICH.Uint64: + which = reader.which; + break; + case WHICH.Float32: + which = reader.which; + break; + case WHICH.Float64: + which = reader.which; + break; + case WHICH.Text: + which = reader.which; + break; + case WHICH.Data: + which = reader.which; + break; + case WHICH.List: + List = CapnpSerializable.Create(reader.List); + break; + case WHICH.Enum: + Enum = CapnpSerializable.Create(reader.Enum); + break; + case WHICH.Struct: + Struct = CapnpSerializable.Create(reader.Struct); + break; + case WHICH.Interface: + Interface = CapnpSerializable.Create(reader.Interface); + break; + case WHICH.AnyPointer: + AnyPointer = CapnpSerializable.Create(reader.AnyPointer); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Void: + break; + case WHICH.Bool: + break; + case WHICH.Int8: + break; + case WHICH.Int16: + break; + case WHICH.Int32: + break; + case WHICH.Int64: + break; + case WHICH.Uint8: + break; + case WHICH.Uint16: + break; + case WHICH.Uint32: + break; + case WHICH.Uint64: + break; + case WHICH.Float32: + break; + case WHICH.Float64: + break; + case WHICH.Text: + break; + case WHICH.Data: + break; + case WHICH.List: + _content = null; + break; + case WHICH.Enum: + _content = null; + break; + case WHICH.Struct: + _content = null; + break; + case WHICH.Interface: + _content = null; + break; + case WHICH.AnyPointer: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Void: + break; + case WHICH.Bool: + break; + case WHICH.Int8: + break; + case WHICH.Int16: + break; + case WHICH.Int32: + break; + case WHICH.Int64: + break; + case WHICH.Uint8: + break; + case WHICH.Uint16: + break; + case WHICH.Uint32: + break; + case WHICH.Uint64: + break; + case WHICH.Float32: + break; + case WHICH.Float64: + break; + case WHICH.Text: + break; + case WHICH.Data: + break; + case WHICH.List: + List?.serialize(writer.List); + break; + case WHICH.Enum: + Enum?.serialize(writer.Enum); + break; + case WHICH.Struct: + Struct?.serialize(writer.Struct); + break; + case WHICH.Interface: + Interface?.serialize(writer.Interface); + break; + case WHICH.AnyPointer: + AnyPointer?.serialize(writer.AnyPointer); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnp.Schema.Type.@list List + { + get => _which == WHICH.List ? (Capnp.Schema.Type.@list)_content : null; + set + { + _which = WHICH.List; + _content = value; + } + } + + public Capnp.Schema.Type.@enum Enum + { + get => _which == WHICH.Enum ? (Capnp.Schema.Type.@enum)_content : null; + set + { + _which = WHICH.Enum; + _content = value; + } + } + + public Capnp.Schema.Type.@struct Struct + { + get => _which == WHICH.Struct ? (Capnp.Schema.Type.@struct)_content : null; + set + { + _which = WHICH.Struct; + _content = value; + } + } + + public Capnp.Schema.Type.@interface Interface + { + get => _which == WHICH.Interface ? (Capnp.Schema.Type.@interface)_content : null; + set + { + _which = WHICH.Interface; + _content = value; + } + } + + public Capnp.Schema.Type.@anyPointer AnyPointer + { + get => _which == WHICH.AnyPointer ? (Capnp.Schema.Type.@anyPointer)_content : null; + set + { + _which = WHICH.AnyPointer; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public @list.READER List => which == WHICH.List ? new @list.READER(ctx) : default; + public @enum.READER Enum => which == WHICH.Enum ? new @enum.READER(ctx) : default; + public @struct.READER Struct => which == WHICH.Struct ? new @struct.READER(ctx) : default; + public @interface.READER Interface => which == WHICH.Interface ? new @interface.READER(ctx) : default; + public @anyPointer.READER AnyPointer => which == WHICH.AnyPointer ? new @anyPointer.READER(ctx) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(3, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public @list.WRITER List + { + get => which == WHICH.List ? Rewrap<@list.WRITER>() : default; + } + + public @enum.WRITER Enum + { + get => which == WHICH.Enum ? Rewrap<@enum.WRITER>() : default; + } + + public @struct.WRITER Struct + { + get => which == WHICH.Struct ? Rewrap<@struct.WRITER>() : default; + } + + public @interface.WRITER Interface + { + get => which == WHICH.Interface ? Rewrap<@interface.WRITER>() : default; + } + + public @anyPointer.WRITER AnyPointer + { + get => which == WHICH.AnyPointer ? Rewrap<@anyPointer.WRITER>() : default; + } + } + + public class @list : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + ElementType = CapnpSerializable.Create(reader.ElementType); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + ElementType?.serialize(writer.ElementType); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnp.Schema.Type ElementType + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnp.Schema.Type.READER ElementType => ctx.ReadStruct(0, Capnp.Schema.Type.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public Capnp.Schema.Type.WRITER ElementType + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } + + public class @enum : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + TypeId = reader.TypeId; + Brand = CapnpSerializable.Create(reader.Brand); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.TypeId = TypeId; + Brand?.serialize(writer.Brand); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong TypeId + { + get; + set; + } + + public Capnp.Schema.Brand Brand + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong TypeId => ctx.ReadDataULong(64UL, 0UL); + public Capnp.Schema.Brand.READER Brand => ctx.ReadStruct(0, Capnp.Schema.Brand.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public ulong TypeId + { + get => this.ReadDataULong(64UL, 0UL); + set => this.WriteData(64UL, value, 0UL); + } + + public Capnp.Schema.Brand.WRITER Brand + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } + + public class @struct : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + TypeId = reader.TypeId; + Brand = CapnpSerializable.Create(reader.Brand); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.TypeId = TypeId; + Brand?.serialize(writer.Brand); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong TypeId + { + get; + set; + } + + public Capnp.Schema.Brand Brand + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong TypeId => ctx.ReadDataULong(64UL, 0UL); + public Capnp.Schema.Brand.READER Brand => ctx.ReadStruct(0, Capnp.Schema.Brand.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public ulong TypeId + { + get => this.ReadDataULong(64UL, 0UL); + set => this.WriteData(64UL, value, 0UL); + } + + public Capnp.Schema.Brand.WRITER Brand + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } + + public class @interface : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + TypeId = reader.TypeId; + Brand = CapnpSerializable.Create(reader.Brand); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.TypeId = TypeId; + Brand?.serialize(writer.Brand); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong TypeId + { + get; + set; + } + + public Capnp.Schema.Brand Brand + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong TypeId => ctx.ReadDataULong(64UL, 0UL); + public Capnp.Schema.Brand.READER Brand => ctx.ReadStruct(0, Capnp.Schema.Brand.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public ulong TypeId + { + get => this.ReadDataULong(64UL, 0UL); + set => this.WriteData(64UL, value, 0UL); + } + + public Capnp.Schema.Brand.WRITER Brand + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } + + public class @anyPointer : ICapnpSerializable + { + public enum WHICH : ushort + { + Unconstrained = 0, + Parameter = 1, + ImplicitMethodParameter = 2, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Unconstrained: + Unconstrained = CapnpSerializable.Create(reader.Unconstrained); + break; + case WHICH.Parameter: + Parameter = CapnpSerializable.Create(reader.Parameter); + break; + case WHICH.ImplicitMethodParameter: + ImplicitMethodParameter = CapnpSerializable.Create(reader.ImplicitMethodParameter); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Unconstrained: + _content = null; + break; + case WHICH.Parameter: + _content = null; + break; + case WHICH.ImplicitMethodParameter: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Unconstrained: + Unconstrained?.serialize(writer.Unconstrained); + break; + case WHICH.Parameter: + Parameter?.serialize(writer.Parameter); + break; + case WHICH.ImplicitMethodParameter: + ImplicitMethodParameter?.serialize(writer.ImplicitMethodParameter); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnp.Schema.Type.@anyPointer.@unconstrained Unconstrained + { + get => _which == WHICH.Unconstrained ? (Capnp.Schema.Type.@anyPointer.@unconstrained)_content : null; + set + { + _which = WHICH.Unconstrained; + _content = value; + } + } + + public Capnp.Schema.Type.@anyPointer.@parameter Parameter + { + get => _which == WHICH.Parameter ? (Capnp.Schema.Type.@anyPointer.@parameter)_content : null; + set + { + _which = WHICH.Parameter; + _content = value; + } + } + + public Capnp.Schema.Type.@anyPointer.@implicitMethodParameter ImplicitMethodParameter + { + get => _which == WHICH.ImplicitMethodParameter ? (Capnp.Schema.Type.@anyPointer.@implicitMethodParameter)_content : null; + set + { + _which = WHICH.ImplicitMethodParameter; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(64U, (ushort)0); + public @unconstrained.READER Unconstrained => which == WHICH.Unconstrained ? new @unconstrained.READER(ctx) : default; + public @parameter.READER Parameter => which == WHICH.Parameter ? new @parameter.READER(ctx) : default; + public @implicitMethodParameter.READER ImplicitMethodParameter => which == WHICH.ImplicitMethodParameter ? new @implicitMethodParameter.READER(ctx) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(64U, (ushort)0); + set => this.WriteData(64U, (ushort)value, (ushort)0); + } + + public @unconstrained.WRITER Unconstrained + { + get => which == WHICH.Unconstrained ? Rewrap<@unconstrained.WRITER>() : default; + } + + public @parameter.WRITER Parameter + { + get => which == WHICH.Parameter ? Rewrap<@parameter.WRITER>() : default; + } + + public @implicitMethodParameter.WRITER ImplicitMethodParameter + { + get => which == WHICH.ImplicitMethodParameter ? Rewrap<@implicitMethodParameter.WRITER>() : default; + } + } + + public class @unconstrained : ICapnpSerializable + { + public enum WHICH : ushort + { + AnyKind = 0, + Struct = 1, + List = 2, + Capability = 3, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.AnyKind: + which = reader.which; + break; + case WHICH.Struct: + which = reader.which; + break; + case WHICH.List: + which = reader.which; + break; + case WHICH.Capability: + which = reader.which; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.AnyKind: + break; + case WHICH.Struct: + break; + case WHICH.List: + break; + case WHICH.Capability: + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.AnyKind: + break; + case WHICH.Struct: + break; + case WHICH.List: + break; + case WHICH.Capability: + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(80U, (ushort)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(80U, (ushort)0); + set => this.WriteData(80U, (ushort)value, (ushort)0); + } + } + } + + public class @parameter : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + ScopeId = reader.ScopeId; + ParameterIndex = reader.ParameterIndex; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.ScopeId = ScopeId; + writer.ParameterIndex = ParameterIndex; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong ScopeId + { + get; + set; + } + + public ushort ParameterIndex + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong ScopeId => ctx.ReadDataULong(128UL, 0UL); + public ushort ParameterIndex => ctx.ReadDataUShort(80UL, (ushort)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public ulong ScopeId + { + get => this.ReadDataULong(128UL, 0UL); + set => this.WriteData(128UL, value, 0UL); + } + + public ushort ParameterIndex + { + get => this.ReadDataUShort(80UL, (ushort)0); + set => this.WriteData(80UL, value, (ushort)0); + } + } + } + + public class @implicitMethodParameter : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + ParameterIndex = reader.ParameterIndex; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.ParameterIndex = ParameterIndex; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ushort ParameterIndex + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ushort ParameterIndex => ctx.ReadDataUShort(80UL, (ushort)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public ushort ParameterIndex + { + get => this.ReadDataUShort(80UL, (ushort)0); + set => this.WriteData(80UL, value, (ushort)0); + } + } + } + } + } + + public class Brand : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Scopes = reader.Scopes.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Scopes.Init(Scopes, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public IReadOnlyList Scopes + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public IReadOnlyList Scopes => ctx.ReadList(0).Cast(Capnp.Schema.Brand.Scope.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public ListOfStructsSerializer Scopes + { + get => BuildPointer>(0); + set => Link(0, value); + } + } + + public class Scope : ICapnpSerializable + { + public enum WHICH : ushort + { + Bind = 0, + Inherit = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Bind: + Bind = reader.Bind.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + break; + case WHICH.Inherit: + which = reader.which; + break; + } + + ScopeId = reader.ScopeId; + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Bind: + _content = null; + break; + case WHICH.Inherit: + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Bind: + writer.Bind.Init(Bind, (_s1, _v1) => _v1?.serialize(_s1)); + break; + case WHICH.Inherit: + break; + } + + writer.ScopeId = ScopeId; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong ScopeId + { + get; + set; + } + + public IReadOnlyList Bind + { + get => _which == WHICH.Bind ? (IReadOnlyList)_content : null; + set + { + _which = WHICH.Bind; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(64U, (ushort)0); + public ulong ScopeId => ctx.ReadDataULong(0UL, 0UL); + public IReadOnlyList Bind => which == WHICH.Bind ? ctx.ReadList(0).Cast(Capnp.Schema.Brand.Binding.READER.create) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(2, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(64U, (ushort)0); + set => this.WriteData(64U, (ushort)value, (ushort)0); + } + + public ulong ScopeId + { + get => this.ReadDataULong(0UL, 0UL); + set => this.WriteData(0UL, value, 0UL); + } + + public ListOfStructsSerializer Bind + { + get => which == WHICH.Bind ? BuildPointer>(0) : default; + set => Link(0, value); + } + } + } + + public class Binding : ICapnpSerializable + { + public enum WHICH : ushort + { + Unbound = 0, + Type = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Unbound: + which = reader.which; + break; + case WHICH.Type: + Type = CapnpSerializable.Create(reader.Type); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Unbound: + break; + case WHICH.Type: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Unbound: + break; + case WHICH.Type: + Type?.serialize(writer.Type); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnp.Schema.Type Type + { + get => _which == WHICH.Type ? (Capnp.Schema.Type)_content : null; + set + { + _which = WHICH.Type; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public Capnp.Schema.Type.READER Type => which == WHICH.Type ? ctx.ReadStruct(0, Capnp.Schema.Type.READER.create) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public Capnp.Schema.Type.WRITER Type + { + get => which == WHICH.Type ? BuildPointer(0) : default; + set => Link(0, value); + } + } + } + } + + public class Value : ICapnpSerializable + { + public enum WHICH : ushort + { + Void = 0, + Bool = 1, + Int8 = 2, + Int16 = 3, + Int32 = 4, + Int64 = 5, + Uint8 = 6, + Uint16 = 7, + Uint32 = 8, + Uint64 = 9, + Float32 = 10, + Float64 = 11, + Text = 12, + Data = 13, + List = 14, + Enum = 15, + Struct = 16, + Interface = 17, + AnyPointer = 18, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Void: + which = reader.which; + break; + case WHICH.Bool: + Bool = reader.Bool; + break; + case WHICH.Int8: + Int8 = reader.Int8; + break; + case WHICH.Int16: + Int16 = reader.Int16; + break; + case WHICH.Int32: + Int32 = reader.Int32; + break; + case WHICH.Int64: + Int64 = reader.Int64; + break; + case WHICH.Uint8: + Uint8 = reader.Uint8; + break; + case WHICH.Uint16: + Uint16 = reader.Uint16; + break; + case WHICH.Uint32: + Uint32 = reader.Uint32; + break; + case WHICH.Uint64: + Uint64 = reader.Uint64; + break; + case WHICH.Float32: + Float32 = reader.Float32; + break; + case WHICH.Float64: + Float64 = reader.Float64; + break; + case WHICH.Text: + Text = reader.Text; + break; + case WHICH.Data: + Data = reader.Data; + break; + case WHICH.List: + List = CapnpSerializable.Create(reader.List); + break; + case WHICH.Enum: + Enum = reader.Enum; + break; + case WHICH.Struct: + Struct = CapnpSerializable.Create(reader.Struct); + break; + case WHICH.Interface: + which = reader.which; + break; + case WHICH.AnyPointer: + AnyPointer = CapnpSerializable.Create(reader.AnyPointer); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Void: + break; + case WHICH.Bool: + _content = false; + break; + case WHICH.Int8: + _content = 0; + break; + case WHICH.Int16: + _content = 0; + break; + case WHICH.Int32: + _content = 0; + break; + case WHICH.Int64: + _content = 0; + break; + case WHICH.Uint8: + _content = 0; + break; + case WHICH.Uint16: + _content = 0; + break; + case WHICH.Uint32: + _content = 0; + break; + case WHICH.Uint64: + _content = 0; + break; + case WHICH.Float32: + _content = 0F; + break; + case WHICH.Float64: + _content = 0; + break; + case WHICH.Text: + _content = null; + break; + case WHICH.Data: + _content = null; + break; + case WHICH.List: + _content = null; + break; + case WHICH.Enum: + _content = 0; + break; + case WHICH.Struct: + _content = null; + break; + case WHICH.Interface: + break; + case WHICH.AnyPointer: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Void: + break; + case WHICH.Bool: + writer.Bool = Bool.Value; + break; + case WHICH.Int8: + writer.Int8 = Int8.Value; + break; + case WHICH.Int16: + writer.Int16 = Int16.Value; + break; + case WHICH.Int32: + writer.Int32 = Int32.Value; + break; + case WHICH.Int64: + writer.Int64 = Int64.Value; + break; + case WHICH.Uint8: + writer.Uint8 = Uint8.Value; + break; + case WHICH.Uint16: + writer.Uint16 = Uint16.Value; + break; + case WHICH.Uint32: + writer.Uint32 = Uint32.Value; + break; + case WHICH.Uint64: + writer.Uint64 = Uint64.Value; + break; + case WHICH.Float32: + writer.Float32 = Float32.Value; + break; + case WHICH.Float64: + writer.Float64 = Float64.Value; + break; + case WHICH.Text: + writer.Text = Text; + break; + case WHICH.Data: + writer.Data.Init(Data); + break; + case WHICH.List: + writer.List.SetObject(List); + break; + case WHICH.Enum: + writer.Enum = Enum.Value; + break; + case WHICH.Struct: + writer.Struct.SetObject(Struct); + break; + case WHICH.Interface: + break; + case WHICH.AnyPointer: + writer.AnyPointer.SetObject(AnyPointer); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool? Bool + { + get => _which == WHICH.Bool ? (bool? )_content : null; + set + { + _which = WHICH.Bool; + _content = value; + } + } + + public sbyte? Int8 + { + get => _which == WHICH.Int8 ? (sbyte? )_content : null; + set + { + _which = WHICH.Int8; + _content = value; + } + } + + public short? Int16 + { + get => _which == WHICH.Int16 ? (short? )_content : null; + set + { + _which = WHICH.Int16; + _content = value; + } + } + + public int? Int32 + { + get => _which == WHICH.Int32 ? (int? )_content : null; + set + { + _which = WHICH.Int32; + _content = value; + } + } + + public long? Int64 + { + get => _which == WHICH.Int64 ? (long? )_content : null; + set + { + _which = WHICH.Int64; + _content = value; + } + } + + public byte? Uint8 + { + get => _which == WHICH.Uint8 ? (byte? )_content : null; + set + { + _which = WHICH.Uint8; + _content = value; + } + } + + public ushort? Uint16 + { + get => _which == WHICH.Uint16 ? (ushort? )_content : null; + set + { + _which = WHICH.Uint16; + _content = value; + } + } + + public uint? Uint32 + { + get => _which == WHICH.Uint32 ? (uint? )_content : null; + set + { + _which = WHICH.Uint32; + _content = value; + } + } + + public ulong? Uint64 + { + get => _which == WHICH.Uint64 ? (ulong? )_content : null; + set + { + _which = WHICH.Uint64; + _content = value; + } + } + + public float? Float32 + { + get => _which == WHICH.Float32 ? (float? )_content : null; + set + { + _which = WHICH.Float32; + _content = value; + } + } + + public double? Float64 + { + get => _which == WHICH.Float64 ? (double? )_content : null; + set + { + _which = WHICH.Float64; + _content = value; + } + } + + public string Text + { + get => _which == WHICH.Text ? (string)_content : null; + set + { + _which = WHICH.Text; + _content = value; + } + } + + public IReadOnlyList Data + { + get => _which == WHICH.Data ? (IReadOnlyList)_content : null; + set + { + _which = WHICH.Data; + _content = value; + } + } + + public AnyPointer List + { + get => _which == WHICH.List ? (AnyPointer)_content : null; + set + { + _which = WHICH.List; + _content = value; + } + } + + public ushort? Enum + { + get => _which == WHICH.Enum ? (ushort? )_content : null; + set + { + _which = WHICH.Enum; + _content = value; + } + } + + public AnyPointer Struct + { + get => _which == WHICH.Struct ? (AnyPointer)_content : null; + set + { + _which = WHICH.Struct; + _content = value; + } + } + + public AnyPointer AnyPointer + { + get => _which == WHICH.AnyPointer ? (AnyPointer)_content : null; + set + { + _which = WHICH.AnyPointer; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public bool Bool => which == WHICH.Bool ? ctx.ReadDataBool(16UL, false) : default; + public sbyte Int8 => which == WHICH.Int8 ? ctx.ReadDataSByte(16UL, (sbyte)0) : default; + public short Int16 => which == WHICH.Int16 ? ctx.ReadDataShort(16UL, (short)0) : default; + public int Int32 => which == WHICH.Int32 ? ctx.ReadDataInt(32UL, 0) : default; + public long Int64 => which == WHICH.Int64 ? ctx.ReadDataLong(64UL, 0L) : default; + public byte Uint8 => which == WHICH.Uint8 ? ctx.ReadDataByte(16UL, (byte)0) : default; + public ushort Uint16 => which == WHICH.Uint16 ? ctx.ReadDataUShort(16UL, (ushort)0) : default; + public uint Uint32 => which == WHICH.Uint32 ? ctx.ReadDataUInt(32UL, 0U) : default; + public ulong Uint64 => which == WHICH.Uint64 ? ctx.ReadDataULong(64UL, 0UL) : default; + public float Float32 => which == WHICH.Float32 ? ctx.ReadDataFloat(32UL, 0F) : default; + public double Float64 => which == WHICH.Float64 ? ctx.ReadDataDouble(64UL, 0) : default; + public string Text => which == WHICH.Text ? ctx.ReadText(0, "") : default; + public IReadOnlyList Data => which == WHICH.Data ? ctx.ReadList(0).CastByte() : default; + public DeserializerState List => which == WHICH.List ? ctx.StructReadPointer(0) : default; + public ushort Enum => which == WHICH.Enum ? ctx.ReadDataUShort(16UL, (ushort)0) : default; + public DeserializerState Struct => which == WHICH.Struct ? ctx.StructReadPointer(0) : default; + public DeserializerState AnyPointer => which == WHICH.AnyPointer ? ctx.StructReadPointer(0) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(2, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public bool Bool + { + get => which == WHICH.Bool ? this.ReadDataBool(16UL, false) : default; + set => this.WriteData(16UL, value, false); + } + + public sbyte Int8 + { + get => which == WHICH.Int8 ? this.ReadDataSByte(16UL, (sbyte)0) : default; + set => this.WriteData(16UL, value, (sbyte)0); + } + + public short Int16 + { + get => which == WHICH.Int16 ? this.ReadDataShort(16UL, (short)0) : default; + set => this.WriteData(16UL, value, (short)0); + } + + public int Int32 + { + get => which == WHICH.Int32 ? this.ReadDataInt(32UL, 0) : default; + set => this.WriteData(32UL, value, 0); + } + + public long Int64 + { + get => which == WHICH.Int64 ? this.ReadDataLong(64UL, 0L) : default; + set => this.WriteData(64UL, value, 0L); + } + + public byte Uint8 + { + get => which == WHICH.Uint8 ? this.ReadDataByte(16UL, (byte)0) : default; + set => this.WriteData(16UL, value, (byte)0); + } + + public ushort Uint16 + { + get => which == WHICH.Uint16 ? this.ReadDataUShort(16UL, (ushort)0) : default; + set => this.WriteData(16UL, value, (ushort)0); + } + + public uint Uint32 + { + get => which == WHICH.Uint32 ? this.ReadDataUInt(32UL, 0U) : default; + set => this.WriteData(32UL, value, 0U); + } + + public ulong Uint64 + { + get => which == WHICH.Uint64 ? this.ReadDataULong(64UL, 0UL) : default; + set => this.WriteData(64UL, value, 0UL); + } + + public float Float32 + { + get => which == WHICH.Float32 ? this.ReadDataFloat(32UL, 0F) : default; + set => this.WriteData(32UL, value, 0F); + } + + public double Float64 + { + get => which == WHICH.Float64 ? this.ReadDataDouble(64UL, 0) : default; + set => this.WriteData(64UL, value, 0); + } + + public string Text + { + get => which == WHICH.Text ? this.ReadText(0, "") : default; + set => this.WriteText(0, value, ""); + } + + public ListOfPrimitivesSerializer Data + { + get => which == WHICH.Data ? BuildPointer>(0) : default; + set => Link(0, value); + } + + public DynamicSerializerState List + { + get => which == WHICH.List ? BuildPointer(0) : default; + set => Link(0, value); + } + + public ushort Enum + { + get => which == WHICH.Enum ? this.ReadDataUShort(16UL, (ushort)0) : default; + set => this.WriteData(16UL, value, (ushort)0); + } + + public DynamicSerializerState Struct + { + get => which == WHICH.Struct ? BuildPointer(0) : default; + set => Link(0, value); + } + + public DynamicSerializerState AnyPointer + { + get => which == WHICH.AnyPointer ? BuildPointer(0) : default; + set => Link(0, value); + } + } + } + + public class Annotation : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Id = reader.Id; + Value = CapnpSerializable.Create(reader.Value); + Brand = CapnpSerializable.Create(reader.Brand); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Id = Id; + Value?.serialize(writer.Value); + Brand?.serialize(writer.Brand); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong Id + { + get; + set; + } + + public Capnp.Schema.Value Value + { + get; + set; + } + + public Capnp.Schema.Brand Brand + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong Id => ctx.ReadDataULong(0UL, 0UL); + public Capnp.Schema.Value.READER Value => ctx.ReadStruct(0, Capnp.Schema.Value.READER.create); + public Capnp.Schema.Brand.READER Brand => ctx.ReadStruct(1, Capnp.Schema.Brand.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 2); + } + + public ulong Id + { + get => this.ReadDataULong(0UL, 0UL); + set => this.WriteData(0UL, value, 0UL); + } + + public Capnp.Schema.Value.WRITER Value + { + get => BuildPointer(0); + set => Link(0, value); + } + + public Capnp.Schema.Brand.WRITER Brand + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + + public enum ElementSize : ushort + { + empty, + bit, + @byte, + twoBytes, + fourBytes, + eightBytes, + pointer, + inlineComposite + } + + public class CapnpVersion : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Major = reader.Major; + Minor = reader.Minor; + Micro = reader.Micro; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Major = Major; + writer.Minor = Minor; + writer.Micro = Micro; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ushort Major + { + get; + set; + } + + public byte Minor + { + get; + set; + } + + public byte Micro + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ushort Major => ctx.ReadDataUShort(0UL, (ushort)0); + public byte Minor => ctx.ReadDataByte(16UL, (byte)0); + public byte Micro => ctx.ReadDataByte(24UL, (byte)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public ushort Major + { + get => this.ReadDataUShort(0UL, (ushort)0); + set => this.WriteData(0UL, value, (ushort)0); + } + + public byte Minor + { + get => this.ReadDataByte(16UL, (byte)0); + set => this.WriteData(16UL, value, (byte)0); + } + + public byte Micro + { + get => this.ReadDataByte(24UL, (byte)0); + set => this.WriteData(24UL, value, (byte)0); + } + } + } + + public class CodeGeneratorRequest : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Nodes = reader.Nodes.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + RequestedFiles = reader.RequestedFiles.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + CapnpVersion = CapnpSerializable.Create(reader.CapnpVersion); + SourceInfo = reader.SourceInfo.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Nodes.Init(Nodes, (_s1, _v1) => _v1?.serialize(_s1)); + writer.RequestedFiles.Init(RequestedFiles, (_s1, _v1) => _v1?.serialize(_s1)); + CapnpVersion?.serialize(writer.CapnpVersion); + writer.SourceInfo.Init(SourceInfo, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public IReadOnlyList Nodes + { + get; + set; + } + + public IReadOnlyList RequestedFiles + { + get; + set; + } + + public Capnp.Schema.CapnpVersion CapnpVersion + { + get; + set; + } + + public IReadOnlyList SourceInfo + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public IReadOnlyList Nodes => ctx.ReadList(0).Cast(Capnp.Schema.Node.READER.create); + public IReadOnlyList RequestedFiles => ctx.ReadList(1).Cast(Capnp.Schema.CodeGeneratorRequest.RequestedFile.READER.create); + public Capnp.Schema.CapnpVersion.READER CapnpVersion => ctx.ReadStruct(2, Capnp.Schema.CapnpVersion.READER.create); + public IReadOnlyList SourceInfo => ctx.ReadList(3).Cast(Capnp.Schema.Node.SourceInfo.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 4); + } + + public ListOfStructsSerializer Nodes + { + get => BuildPointer>(0); + set => Link(0, value); + } + + public ListOfStructsSerializer RequestedFiles + { + get => BuildPointer>(1); + set => Link(1, value); + } + + public Capnp.Schema.CapnpVersion.WRITER CapnpVersion + { + get => BuildPointer(2); + set => Link(2, value); + } + + public ListOfStructsSerializer SourceInfo + { + get => BuildPointer>(3); + set => Link(3, value); + } + } + + public class RequestedFile : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Id = reader.Id; + Filename = reader.Filename; + Imports = reader.Imports.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Id = Id; + writer.Filename = Filename; + writer.Imports.Init(Imports, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong Id + { + get; + set; + } + + public string Filename + { + get; + set; + } + + public IReadOnlyList Imports + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong Id => ctx.ReadDataULong(0UL, 0UL); + public string Filename => ctx.ReadText(0, ""); + public IReadOnlyList Imports => ctx.ReadList(1).Cast(Capnp.Schema.CodeGeneratorRequest.RequestedFile.Import.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 2); + } + + public ulong Id + { + get => this.ReadDataULong(0UL, 0UL); + set => this.WriteData(0UL, value, 0UL); + } + + public string Filename + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public ListOfStructsSerializer Imports + { + get => BuildPointer>(1); + set => Link(1, value); + } + } + + public class Import : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Id = reader.Id; + Name = reader.Name; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Id = Id; + writer.Name = Name; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong Id + { + get; + set; + } + + public string Name + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong Id => ctx.ReadDataULong(0UL, 0UL); + public string Name => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public ulong Id + { + get => this.ReadDataULong(0UL, 0UL); + set => this.WriteData(0UL, value, 0UL); + } + + public string Name + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + } + } +} \ No newline at end of file diff --git a/MsBuildGenerationTest/capnp/test-import.capnp b/MsBuildGenerationTest/capnp/test-import.capnp new file mode 100644 index 0000000..dbaa4bd --- /dev/null +++ b/MsBuildGenerationTest/capnp/test-import.capnp @@ -0,0 +1,28 @@ +# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0xf36d7b330303c66e; + +using Test = import "test.capnp"; + +struct TestImport { + field @0 :Test.TestAllTypes; +} diff --git a/MsBuildGenerationTest/capnp/test-import.capnp.cs b/MsBuildGenerationTest/capnp/test-import.capnp.cs new file mode 100644 index 0000000..3fc5b54 --- /dev/null +++ b/MsBuildGenerationTest/capnp/test-import.capnp.cs @@ -0,0 +1,67 @@ +using Capnp; +using Capnp.Rpc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace CapnpGen +{ + public class TestImport : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Field = CapnpSerializable.Create(reader.Field); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Field?.serialize(writer.Field); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestAllTypes Field + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestAllTypes.READER Field => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestAllTypes.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.TestAllTypes.WRITER Field + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } +} \ No newline at end of file diff --git a/MsBuildGenerationTest/capnp/test-import2.capnp b/MsBuildGenerationTest/capnp/test-import2.capnp new file mode 100644 index 0000000..23eb600 --- /dev/null +++ b/MsBuildGenerationTest/capnp/test-import2.capnp @@ -0,0 +1,32 @@ +# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0xc64a3bf0338a124a; + +using Import1 = import "/capnp/schema.capnp"; +using Import2 = import "test-import.capnp"; +using Import3 = import "test.capnp"; + +struct TestImport2 { + foo @0 :Import3.TestAllTypes; + bar @1 :Import1.Node; + baz @2 :Import2.TestImport; +} diff --git a/MsBuildGenerationTest/capnp/test-import2.capnp.cs b/MsBuildGenerationTest/capnp/test-import2.capnp.cs new file mode 100644 index 0000000..534bba9 --- /dev/null +++ b/MsBuildGenerationTest/capnp/test-import2.capnp.cs @@ -0,0 +1,97 @@ +using Capnp; +using Capnp.Rpc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace CapnpGen +{ + public class TestImport2 : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Foo = CapnpSerializable.Create(reader.Foo); + Bar = CapnpSerializable.Create(reader.Bar); + Baz = CapnpSerializable.Create(reader.Baz); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Foo?.serialize(writer.Foo); + Bar?.serialize(writer.Bar); + Baz?.serialize(writer.Baz); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestAllTypes Foo + { + get; + set; + } + + public Capnp.Schema.Node Bar + { + get; + set; + } + + public CapnpGen.TestImport Baz + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestAllTypes.READER Foo => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestAllTypes.READER.create); + public Capnp.Schema.Node.READER Bar => ctx.ReadStruct(1, Capnp.Schema.Node.READER.create); + public CapnpGen.TestImport.READER Baz => ctx.ReadStruct(2, CapnpGen.TestImport.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 3); + } + + public Capnproto_test.Capnp.Test.TestAllTypes.WRITER Foo + { + get => BuildPointer(0); + set => Link(0, value); + } + + public Capnp.Schema.Node.WRITER Bar + { + get => BuildPointer(1); + set => Link(1, value); + } + + public CapnpGen.TestImport.WRITER Baz + { + get => BuildPointer(2); + set => Link(2, value); + } + } + } +} \ No newline at end of file diff --git a/MsBuildGenerationTest/capnp/test.capnp b/MsBuildGenerationTest/capnp/test.capnp new file mode 100644 index 0000000..0a4a507 --- /dev/null +++ b/MsBuildGenerationTest/capnp/test.capnp @@ -0,0 +1,969 @@ +# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0xd508eebdc2dc42b8; + +using Cxx = import "c++.capnp"; + +# Use a namespace likely to cause trouble if the generated code doesn't use fully-qualified +# names for stuff in the capnproto namespace. +$Cxx.namespace("capnproto_test::capnp::test"); + +enum TestEnum { + foo @0; + bar @1; + baz @2; + qux @3; + quux @4; + corge @5; + grault @6; + garply @7; +} + +struct TestAllTypes { + voidField @0 : Void; + boolField @1 : Bool; + int8Field @2 : Int8; + int16Field @3 : Int16; + int32Field @4 : Int32; + int64Field @5 : Int64; + uInt8Field @6 : UInt8; + uInt16Field @7 : UInt16; + uInt32Field @8 : UInt32; + uInt64Field @9 : UInt64; + float32Field @10 : Float32; + float64Field @11 : Float64; + textField @12 : Text; + dataField @13 : Data; + structField @14 : TestAllTypes; + enumField @15 : TestEnum; + interfaceField @16 : Void; # TODO + + voidList @17 : List(Void); + boolList @18 : List(Bool); + int8List @19 : List(Int8); + int16List @20 : List(Int16); + int32List @21 : List(Int32); + int64List @22 : List(Int64); + uInt8List @23 : List(UInt8); + uInt16List @24 : List(UInt16); + uInt32List @25 : List(UInt32); + uInt64List @26 : List(UInt64); + float32List @27 : List(Float32); + float64List @28 : List(Float64); + textList @29 : List(Text); + dataList @30 : List(Data); + structList @31 : List(TestAllTypes); + enumList @32 : List(TestEnum); + interfaceList @33 : List(Void); # TODO +} + +struct TestDefaults { + voidField @0 : Void = void; + boolField @1 : Bool = true; + int8Field @2 : Int8 = -123; + int16Field @3 : Int16 = -12345; + int32Field @4 : Int32 = -12345678; + int64Field @5 : Int64 = -123456789012345; + uInt8Field @6 : UInt8 = 234; + uInt16Field @7 : UInt16 = 45678; + uInt32Field @8 : UInt32 = 3456789012; + uInt64Field @9 : UInt64 = 12345678901234567890; + float32Field @10 : Float32 = 1234.5; + float64Field @11 : Float64 = -123e45; + textField @12 : Text = "foo"; + dataField @13 : Data = 0x"62 61 72"; # "bar" + structField @14 : TestAllTypes = ( + voidField = void, + boolField = true, + int8Field = -12, + int16Field = 3456, + int32Field = -78901234, + int64Field = 56789012345678, + uInt8Field = 90, + uInt16Field = 1234, + uInt32Field = 56789012, + uInt64Field = 345678901234567890, + float32Field = -1.25e-10, + float64Field = 345, + textField = "baz", + dataField = "qux", + structField = ( + textField = "nested", + structField = (textField = "really nested")), + enumField = baz, + # interfaceField can't have a default + + voidList = [void, void, void], + boolList = [false, true, false, true, true], + int8List = [12, -34, -0x80, 0x7f], + int16List = [1234, -5678, -0x8000, 0x7fff], + int32List = [12345678, -90123456, -0x80000000, 0x7fffffff], + int64List = [123456789012345, -678901234567890, -0x8000000000000000, 0x7fffffffffffffff], + uInt8List = [12, 34, 0, 0xff], + uInt16List = [1234, 5678, 0, 0xffff], + uInt32List = [12345678, 90123456, 0, 0xffffffff], + uInt64List = [123456789012345, 678901234567890, 0, 0xffffffffffffffff], + float32List = [0, 1234567, 1e37, -1e37, 1e-37, -1e-37], + float64List = [0, 123456789012345, 1e306, -1e306, 1e-306, -1e-306], + textList = ["quux", "corge", "grault"], + dataList = ["garply", "waldo", "fred"], + structList = [ + (textField = "x " "structlist" + " 1"), + (textField = "x structlist 2"), + (textField = "x structlist 3")], + enumList = [qux, bar, grault] + # interfaceList can't have a default + ); + enumField @15 : TestEnum = corge; + interfaceField @16 : Void; # TODO + + voidList @17 : List(Void) = [void, void, void, void, void, void]; + boolList @18 : List(Bool) = [true, false, false, true]; + int8List @19 : List(Int8) = [111, -111]; + int16List @20 : List(Int16) = [11111, -11111]; + int32List @21 : List(Int32) = [111111111, -111111111]; + int64List @22 : List(Int64) = [1111111111111111111, -1111111111111111111]; + uInt8List @23 : List(UInt8) = [111, 222] ; + uInt16List @24 : List(UInt16) = [33333, 44444]; + uInt32List @25 : List(UInt32) = [3333333333]; + uInt64List @26 : List(UInt64) = [11111111111111111111]; + float32List @27 : List(Float32) = [5555.5, inf, -inf, nan]; + float64List @28 : List(Float64) = [7777.75, inf, -inf, nan]; + textList @29 : List(Text) = ["plugh", "xyzzy", "thud"]; + dataList @30 : List(Data) = ["oops", "exhausted", "rfc3092"]; + structList @31 : List(TestAllTypes) = [ + (textField = "structlist 1"), + (textField = "structlist 2"), + (textField = "structlist 3")]; + enumList @32 : List(TestEnum) = [foo, garply]; + interfaceList @33 : List(Void); # TODO +} + +struct TestAnyPointer { + anyPointerField @0 :AnyPointer; + + # Do not add any other fields here! Some tests rely on anyPointerField being the last pointer + # in the struct. +} + +struct TestAnyOthers { + anyStructField @0 :AnyStruct; + anyListField @1 :AnyList; + capabilityField @2 :Capability; +} + +struct TestOutOfOrder { + foo @3 :Text; + bar @2 :Text; + baz @8 :Text; + qux @0 :Text; + quux @6 :Text; + corge @4 :Text; + grault @1 :Text; + garply @7 :Text; + waldo @5 :Text; +} + +struct TestUnion { + union0 @0! :union { + # Pack union 0 under ideal conditions: there is no unused padding space prior to it. + u0f0s0 @4: Void; + u0f0s1 @5: Bool; + u0f0s8 @6: Int8; + u0f0s16 @7: Int16; + u0f0s32 @8: Int32; + u0f0s64 @9: Int64; + u0f0sp @10: Text; + + # Pack more stuff into union0 -- should go in same space. + u0f1s0 @11: Void; + u0f1s1 @12: Bool; + u0f1s8 @13: Int8; + u0f1s16 @14: Int16; + u0f1s32 @15: Int32; + u0f1s64 @16: Int64; + u0f1sp @17: Text; + } + + # Pack one bit in order to make pathological situation for union1. + bit0 @18: Bool; + + union1 @1! :union { + # Pack pathologically bad case. Each field takes up new space. + u1f0s0 @19: Void; + u1f0s1 @20: Bool; + u1f1s1 @21: Bool; + u1f0s8 @22: Int8; + u1f1s8 @23: Int8; + u1f0s16 @24: Int16; + u1f1s16 @25: Int16; + u1f0s32 @26: Int32; + u1f1s32 @27: Int32; + u1f0s64 @28: Int64; + u1f1s64 @29: Int64; + u1f0sp @30: Text; + u1f1sp @31: Text; + + # Pack more stuff into union1 -- each should go into the same space as corresponding u1f0s*. + u1f2s0 @32: Void; + u1f2s1 @33: Bool; + u1f2s8 @34: Int8; + u1f2s16 @35: Int16; + u1f2s32 @36: Int32; + u1f2s64 @37: Int64; + u1f2sp @38: Text; + } + + # Fill in the rest of that bitfield from earlier. + bit2 @39: Bool; + bit3 @40: Bool; + bit4 @41: Bool; + bit5 @42: Bool; + bit6 @43: Bool; + bit7 @44: Bool; + + # Interleave two unions to be really annoying. + # Also declare in reverse order to make sure union discriminant values are sorted by field number + # and not by declaration order. + union2 @2! :union { + u2f0s64 @54: Int64; + u2f0s32 @52: Int32; + u2f0s16 @50: Int16; + u2f0s8 @47: Int8; + u2f0s1 @45: Bool; + } + + union3 @3! :union { + u3f0s64 @55: Int64; + u3f0s32 @53: Int32; + u3f0s16 @51: Int16; + u3f0s8 @48: Int8; + u3f0s1 @46: Bool; + } + + byte0 @49: UInt8; +} + +struct TestUnnamedUnion { + before @0 :Text; + + union { + foo @1 :UInt16; + bar @3 :UInt32; + } + + middle @2 :UInt16; + + after @4 :Text; +} + +struct TestUnionInUnion { + # There is no reason to ever do this. + outer :union { + inner :union { + foo @0 :Int32; + bar @1 :Int32; + } + baz @2 :Int32; + } +} + +struct TestGroups { + groups :union { + foo :group { + corge @0 :Int32; + grault @2 :Int64; + garply @8 :Text; + } + bar :group { + corge @3 :Int32; + grault @4 :Text; + garply @5 :Int64; + } + baz :group { + corge @1 :Int32; + grault @6 :Text; + garply @7 :Text; + } + } +} + +struct TestInterleavedGroups { + group1 :group { + foo @0 :UInt32; + bar @2 :UInt64; + union { + qux @4 :UInt16; + corge :group { + grault @6 :UInt64; + garply @8 :UInt16; + plugh @14 :Text; + xyzzy @16 :Text; + } + + fred @12 :Text; + } + + waldo @10 :Text; + } + + group2 :group { + foo @1 :UInt32; + bar @3 :UInt64; + union { + qux @5 :UInt16; + corge :group { + grault @7 :UInt64; + garply @9 :UInt16; + plugh @15 :Text; + xyzzy @17 :Text; + } + + fred @13 :Text; + } + + waldo @11 :Text; + } +} + +struct TestUnionDefaults { + s16s8s64s8Set @0 :TestUnion = + (union0 = (u0f0s16 = 321), union1 = (u1f0s8 = 123), union2 = (u2f0s64 = 12345678901234567), + union3 = (u3f0s8 = 55)); + s0sps1s32Set @1 :TestUnion = + (union0 = (u0f1s0 = void), union1 = (u1f0sp = "foo"), union2 = (u2f0s1 = true), + union3 = (u3f0s32 = 12345678)); + + unnamed1 @2 :TestUnnamedUnion = (foo = 123); + unnamed2 @3 :TestUnnamedUnion = (bar = 321, before = "foo", after = "bar"); +} + +struct TestNestedTypes { + enum NestedEnum { + foo @0; + bar @1; + } + + struct NestedStruct { + enum NestedEnum { + baz @0; + qux @1; + quux @2; + } + + outerNestedEnum @0 :TestNestedTypes.NestedEnum = bar; + innerNestedEnum @1 :NestedEnum = quux; + } + + nestedStruct @0 :NestedStruct; + + outerNestedEnum @1 :NestedEnum = bar; + innerNestedEnum @2 :NestedStruct.NestedEnum = quux; +} + +struct TestUsing { + using OuterNestedEnum = TestNestedTypes.NestedEnum; + using TestNestedTypes.NestedStruct.NestedEnum; + + outerNestedEnum @1 :OuterNestedEnum = bar; + innerNestedEnum @0 :NestedEnum = quux; +} + +struct TestLists { + # Small structs, when encoded as list, will be encoded as primitive lists rather than struct + # lists, to save space. + struct Struct0 { f @0 :Void; } + struct Struct1 { f @0 :Bool; } + struct Struct8 { f @0 :UInt8; } + struct Struct16 { f @0 :UInt16; } + struct Struct32 { f @0 :UInt32; } + struct Struct64 { f @0 :UInt64; } + struct StructP { f @0 :Text; } + + # Versions of the above which cannot be encoded as primitive lists. + struct Struct0c { f @0 :Void; pad @1 :Text; } + struct Struct1c { f @0 :Bool; pad @1 :Text; } + struct Struct8c { f @0 :UInt8; pad @1 :Text; } + struct Struct16c { f @0 :UInt16; pad @1 :Text; } + struct Struct32c { f @0 :UInt32; pad @1 :Text; } + struct Struct64c { f @0 :UInt64; pad @1 :Text; } + struct StructPc { f @0 :Text; pad @1 :UInt64; } + + list0 @0 :List(Struct0); + list1 @1 :List(Struct1); + list8 @2 :List(Struct8); + list16 @3 :List(Struct16); + list32 @4 :List(Struct32); + list64 @5 :List(Struct64); + listP @6 :List(StructP); + + int32ListList @7 :List(List(Int32)); + textListList @8 :List(List(Text)); + structListList @9 :List(List(TestAllTypes)); +} + +struct TestFieldZeroIsBit { + bit @0 :Bool; + secondBit @1 :Bool = true; + thirdField @2 :UInt8 = 123; +} + +struct TestListDefaults { + lists @0 :TestLists = ( + list0 = [(f = void), (f = void)], + list1 = [(f = true), (f = false), (f = true), (f = true)], + list8 = [(f = 123), (f = 45)], + list16 = [(f = 12345), (f = 6789)], + list32 = [(f = 123456789), (f = 234567890)], + list64 = [(f = 1234567890123456), (f = 2345678901234567)], + listP = [(f = "foo"), (f = "bar")], + int32ListList = [[1, 2, 3], [4, 5], [12341234]], + textListList = [["foo", "bar"], ["baz"], ["qux", "corge"]], + structListList = [[(int32Field = 123), (int32Field = 456)], [(int32Field = 789)]]); +} + +struct TestLateUnion { + # Test what happens if the unions are not the first ordinals in the struct. At one point this + # was broken for the dynamic API. + + foo @0 :Int32; + bar @1 :Text; + baz @2 :Int16; + + theUnion @3! :union { + qux @4 :Text; + corge @5 :List(Int32); + grault @6 :Float32; + } + + anotherUnion @7! :union { + qux @8 :Text; + corge @9 :List(Int32); + grault @10 :Float32; + } +} + +struct TestOldVersion { + # A subset of TestNewVersion. + old1 @0 :Int64; + old2 @1 :Text; + old3 @2 :TestOldVersion; +} + +struct TestNewVersion { + # A superset of TestOldVersion. + old1 @0 :Int64; + old2 @1 :Text; + old3 @2 :TestNewVersion; + new1 @3 :Int64 = 987; + new2 @4 :Text = "baz"; +} + +struct TestOldUnionVersion { + union { + a @0 :Void; + b @1 :UInt64; + } +} + +struct TestNewUnionVersion { + union { + a :union { + a0 @0 :Void; + a1 @2 :UInt64; + } + b @1 :UInt64; + } +} + +struct TestStructUnion { + un @0! :union { + struct @1 :SomeStruct; + object @2 :TestAnyPointer; + } + + struct SomeStruct { + someText @0 :Text; + moreText @1 :Text; + } +} + +struct TestPrintInlineStructs { + someText @0 :Text; + + structList @1 :List(InlineStruct); + struct InlineStruct { + int32Field @0 :Int32; + textField @1 :Text; + } +} + +struct TestWholeFloatDefault { + # At one point, these failed to compile in C++ because it would produce literals like "123f", + # which is not valid; it needs to be "123.0f". + field @0 :Float32 = 123; + bigField @1 :Float32 = 2e30; + const constant :Float32 = 456; + const bigConstant :Float32 = 4e30; +} + +struct TestGenerics(Foo, Bar) { + foo @0 :Foo; + rev @1 :TestGenerics(Bar, Foo); + + union { + uv @2:Void; + ug :group { + ugfoo @3:Int32; + } + } + + list @4 :List(Inner); + # At one time this failed to compile with MSVC due to poor expression SFINAE support. + + struct Inner { + foo @0 :Foo; + bar @1 :Bar; + } + + struct Inner2(Baz) { + bar @0 :Bar; + baz @1 :Baz; + innerBound @2 :Inner; + innerUnbound @3 :TestGenerics.Inner; + + struct DeepNest(Qux) { + foo @0 :Foo; + bar @1 :Bar; + baz @2 :Baz; + qux @3 :Qux; + + interface DeepNestInterface(Quux) { + # At one time this failed to compile. + call @0 () -> (); + } + } + } + + interface Interface(Qux) { + call @0 Inner2(Text) -> (qux :Qux, gen :TestGenerics(TestAllTypes, TestAnyPointer)); + } + + annotation ann(struct) :Foo; + + using AliasFoo = Foo; + using AliasInner = Inner; + using AliasInner2 = Inner2; + using AliasInner2Text = Inner2(Text); + using AliasRev = TestGenerics(Bar, Foo); + + struct UseAliases { + foo @0 :AliasFoo; + inner @1 :AliasInner; + inner2 @2 :AliasInner2; + inner2Bind @3 :AliasInner2(Text); + inner2Text @4 :AliasInner2Text; + revFoo @5 :AliasRev.AliasFoo; + } +} + +struct TestGenericsWrapper(Foo, Bar) { + value @0 :TestGenerics(Foo, Bar); +} + +struct TestGenericsWrapper2 { + value @0 :TestGenericsWrapper(Text, TestAllTypes); +} + +interface TestImplicitMethodParams { + call @0 [T, U] (foo :T, bar :U) -> TestGenerics(T, U); +} + +interface TestImplicitMethodParamsInGeneric(V) { + call @0 [T, U] (foo :T, bar :U) -> TestGenerics(T, U); +} + +struct TestGenericsUnion(Foo, Bar) { + # At one point this failed to compile. + + union { + foo @0 :Foo; + bar @1 :Bar; + } +} + +struct TestUseGenerics $TestGenerics(Text, Data).ann("foo") { + basic @0 :TestGenerics(TestAllTypes, TestAnyPointer); + inner @1 :TestGenerics(TestAllTypes, TestAnyPointer).Inner; + inner2 @2 :TestGenerics(TestAllTypes, TestAnyPointer).Inner2(Text); + unspecified @3 :TestGenerics; + unspecifiedInner @4 :TestGenerics.Inner2(Text); + wrapper @8 :TestGenericsWrapper(TestAllTypes, TestAnyPointer); + cap @18 :TestGenerics(TestInterface, Text); + genericCap @19 :TestGenerics(TestAllTypes, List(UInt32)).Interface(Data); + + default @5 :TestGenerics(TestAllTypes, Text) = + (foo = (int16Field = 123), rev = (foo = "text", rev = (foo = (int16Field = 321)))); + defaultInner @6 :TestGenerics(TestAllTypes, Text).Inner = + (foo = (int16Field = 123), bar = "text"); + defaultUser @7 :TestUseGenerics = (basic = (foo = (int16Field = 123))); + defaultWrapper @9 :TestGenericsWrapper(Text, TestAllTypes) = + (value = (foo = "text", rev = (foo = (int16Field = 321)))); + defaultWrapper2 @10 :TestGenericsWrapper2 = + (value = (value = (foo = "text", rev = (foo = (int16Field = 321))))); + + aliasFoo @11 :TestGenerics(TestAllTypes, TestAnyPointer).AliasFoo = (int16Field = 123); + aliasInner @12 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner + = (foo = (int16Field = 123)); + aliasInner2 @13 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2 + = (innerBound = (foo = (int16Field = 123))); + aliasInner2Bind @14 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2(List(UInt32)) + = (baz = [12, 34], innerBound = (foo = (int16Field = 123))); + aliasInner2Text @15 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2Text + = (baz = "text", innerBound = (foo = (int16Field = 123))); + aliasRev @16 :TestGenerics(TestAnyPointer, Text).AliasRev.AliasFoo = "text"; + + useAliases @17 :TestGenerics(TestAllTypes, List(UInt32)).UseAliases = ( + foo = (int16Field = 123), + inner = (foo = (int16Field = 123)), + inner2 = (innerBound = (foo = (int16Field = 123))), + inner2Bind = (baz = "text", innerBound = (foo = (int16Field = 123))), + inner2Text = (baz = "text", innerBound = (foo = (int16Field = 123))), + revFoo = [12, 34, 56]); +} + +struct TestEmptyStruct {} + +struct TestConstants { + const voidConst :Void = void; + const boolConst :Bool = true; + const int8Const :Int8 = -123; + const int16Const :Int16 = -12345; + const int32Const :Int32 = -12345678; + const int64Const :Int64 = -123456789012345; + const uint8Const :UInt8 = 234; + const uint16Const :UInt16 = 45678; + const uint32Const :UInt32 = 3456789012; + const uint64Const :UInt64 = 12345678901234567890; + const float32Const :Float32 = 1234.5; + const float64Const :Float64 = -123e45; + const textConst :Text = "foo"; + const dataConst :Data = "bar"; + const structConst :TestAllTypes = ( + voidField = void, + boolField = true, + int8Field = -12, + int16Field = 3456, + int32Field = -78901234, + int64Field = 56789012345678, + uInt8Field = 90, + uInt16Field = 1234, + uInt32Field = 56789012, + uInt64Field = 345678901234567890, + float32Field = -1.25e-10, + float64Field = 345, + textField = "baz", + dataField = "qux", + structField = ( + textField = "nested", + structField = (textField = "really nested")), + enumField = baz, + # interfaceField can't have a default + + voidList = [void, void, void], + boolList = [false, true, false, true, true], + int8List = [12, -34, -0x80, 0x7f], + int16List = [1234, -5678, -0x8000, 0x7fff], + int32List = [12345678, -90123456, -0x80000000, 0x7fffffff], + int64List = [123456789012345, -678901234567890, -0x8000000000000000, 0x7fffffffffffffff], + uInt8List = [12, 34, 0, 0xff], + uInt16List = [1234, 5678, 0, 0xffff], + uInt32List = [12345678, 90123456, 0, 0xffffffff], + uInt64List = [123456789012345, 678901234567890, 0, 0xffffffffffffffff], + float32List = [0, 1234567, 1e37, -1e37, 1e-37, -1e-37], + float64List = [0, 123456789012345, 1e306, -1e306, 1e-306, -1e-306], + textList = ["quux", "corge", "grault"], + dataList = ["garply", "waldo", "fred"], + structList = [ + (textField = "x " "structlist" + " 1"), + (textField = "x structlist 2"), + (textField = "x structlist 3")], + enumList = [qux, bar, grault] + # interfaceList can't have a default + ); + const enumConst :TestEnum = corge; + + const voidListConst :List(Void) = [void, void, void, void, void, void]; + const boolListConst :List(Bool) = [true, false, false, true]; + const int8ListConst :List(Int8) = [111, -111]; + const int16ListConst :List(Int16) = [11111, -11111]; + const int32ListConst :List(Int32) = [111111111, -111111111]; + const int64ListConst :List(Int64) = [1111111111111111111, -1111111111111111111]; + const uint8ListConst :List(UInt8) = [111, 222] ; + const uint16ListConst :List(UInt16) = [33333, 44444]; + const uint32ListConst :List(UInt32) = [3333333333]; + const uint64ListConst :List(UInt64) = [11111111111111111111]; + const float32ListConst :List(Float32) = [5555.5, inf, -inf, nan]; + const float64ListConst :List(Float64) = [7777.75, inf, -inf, nan]; + const textListConst :List(Text) = ["plugh", "xyzzy", "thud"]; + const dataListConst :List(Data) = ["oops", "exhausted", "rfc3092"]; + const structListConst :List(TestAllTypes) = [ + (textField = "structlist 1"), + (textField = "structlist 2"), + (textField = "structlist 3")]; + const enumListConst :List(TestEnum) = [foo, garply]; +} + +const globalInt :UInt32 = 12345; +const globalText :Text = "foobar"; +const globalStruct :TestAllTypes = (int32Field = 54321); +const globalPrintableStruct :TestPrintInlineStructs = (someText = "foo"); +const derivedConstant :TestAllTypes = ( + uInt32Field = .globalInt, + textField = TestConstants.textConst, + structField = TestConstants.structConst, + int16List = TestConstants.int16ListConst, + structList = TestConstants.structListConst); + +const genericConstant :TestGenerics(TestAllTypes, Text) = + (foo = (int16Field = 123), rev = (foo = "text", rev = (foo = (int16Field = 321)))); + +const embeddedData :Data = embed "testdata/packed"; +const embeddedText :Text = embed "testdata/short.txt"; +const embeddedStruct :TestAllTypes = embed "testdata/binary"; + +const nonAsciiText :Text = "♫ é ✓"; + +struct TestAnyPointerConstants { + anyKindAsStruct @0 :AnyPointer; + anyStructAsStruct @1 :AnyStruct; + anyKindAsList @2 :AnyPointer; + anyListAsList @3 :AnyList; + +} + +const anyPointerConstants :TestAnyPointerConstants = ( + anyKindAsStruct = TestConstants.structConst, + anyStructAsStruct = TestConstants.structConst, + anyKindAsList = TestConstants.int32ListConst, + anyListAsList = TestConstants.int32ListConst, +); + +interface TestInterface { + foo @0 (i :UInt32, j :Bool) -> (x :Text); + bar @1 () -> (); + baz @2 (s: TestAllTypes); +} + +interface TestExtends extends(TestInterface) { + qux @0 (); + corge @1 TestAllTypes -> (); + grault @2 () -> TestAllTypes; +} + +interface TestExtends2 extends(TestExtends) {} + +interface TestPipeline { + getCap @0 (n: UInt32, inCap :TestInterface) -> (s: Text, outBox :Box); + testPointers @1 (cap :TestInterface, obj :AnyPointer, list :List(TestInterface)) -> (); + getAnyCap @2 (n: UInt32, inCap :Capability) -> (s: Text, outBox :AnyBox); + + struct Box { + cap @0 :TestInterface; + } + struct AnyBox { + cap @0 :Capability; + } +} + +interface TestCallOrder { + getCallSequence @0 (expected: UInt32) -> (n: UInt32); + # First call returns 0, next returns 1, ... + # + # The input `expected` is ignored but useful for disambiguating debug logs. +} + +interface TestTailCallee { + struct TailResult { + i @0 :UInt32; + t @1 :Text; + c @2 :TestCallOrder; + } + + foo @0 (i :Int32, t :Text) -> TailResult; +} + +interface TestTailCaller { + foo @0 (i :Int32, callee :TestTailCallee) -> TestTailCallee.TailResult; +} + +interface TestHandle {} + +interface TestMoreStuff extends(TestCallOrder) { + # Catch-all type that contains lots of testing methods. + + callFoo @0 (cap :TestInterface) -> (s: Text); + # Call `cap.foo()`, check the result, and return "bar". + + callFooWhenResolved @1 (cap :TestInterface) -> (s: Text); + # Like callFoo but waits for `cap` to resolve first. + + neverReturn @2 (cap :TestInterface) -> (capCopy :TestInterface); + # Doesn't return. You should cancel it. + + hold @3 (cap :TestInterface) -> (); + # Returns immediately but holds on to the capability. + + callHeld @4 () -> (s: Text); + # Calls the capability previously held using `hold` (and keeps holding it). + + getHeld @5 () -> (cap :TestInterface); + # Returns the capability previously held using `hold` (and keeps holding it). + + echo @6 (cap :TestCallOrder) -> (cap :TestCallOrder); + # Just returns the input cap. + + expectCancel @7 (cap :TestInterface) -> (); + # evalLater()-loops forever, holding `cap`. Must be canceled. + + methodWithDefaults @8 (a :Text, b :UInt32 = 123, c :Text = "foo") -> (d :Text, e :Text = "bar"); + + methodWithNullDefault @12 (a :Text, b :TestInterface = null); + + getHandle @9 () -> (handle :TestHandle); + # Get a new handle. Tests have an out-of-band way to check the current number of live handles, so + # this can be used to test garbage collection. + + getNull @10 () -> (nullCap :TestMoreStuff); + # Always returns a null capability. + + getEnormousString @11 () -> (str :Text); + # Attempts to return an 100MB string. Should always fail. +} + +interface TestMembrane { + makeThing @0 () -> (thing :Thing); + callPassThrough @1 (thing :Thing, tailCall :Bool) -> Result; + callIntercept @2 (thing :Thing, tailCall :Bool) -> Result; + loopback @3 (thing :Thing) -> (thing :Thing); + + waitForever @4 (); + + interface Thing { + passThrough @0 () -> Result; + intercept @1 () -> Result; + } + + struct Result { + text @0 :Text; + } +} + +struct TestContainMembrane { + cap @0 :TestMembrane.Thing; + list @1 :List(TestMembrane.Thing); +} + +struct TestTransferCap { + list @0 :List(Element); + struct Element { + text @0 :Text; + cap @1 :TestInterface; + } +} + +interface TestKeywordMethods { + delete @0 (); + class @1 (); + void @2 (); + return @3 (); +} + +interface TestAuthenticatedBootstrap(VatId) { + getCallerId @0 () -> (caller :VatId); +} + +struct TestSturdyRef { + hostId @0 :TestSturdyRefHostId; + objectId @1 :AnyPointer; +} + +struct TestSturdyRefHostId { + host @0 :Text; +} + +struct TestSturdyRefObjectId { + tag @0 :Tag; + enum Tag { + testInterface @0; + testExtends @1; + testPipeline @2; + testTailCallee @3; + testTailCaller @4; + testMoreStuff @5; + } +} + +struct TestProvisionId {} +struct TestRecipientId {} +struct TestThirdPartyCapId {} +struct TestJoinResult {} + +struct TestNameAnnotation $Cxx.name("RenamedStruct") { + union { + badFieldName @0 :Bool $Cxx.name("goodFieldName"); + bar @1 :Int8; + } + + enum BadlyNamedEnum $Cxx.name("RenamedEnum") { + foo @0; + bar @1; + baz @2 $Cxx.name("qux"); + } + + anotherBadFieldName @2 :BadlyNamedEnum $Cxx.name("anotherGoodFieldName"); + + struct NestedStruct $Cxx.name("RenamedNestedStruct") { + badNestedFieldName @0 :Bool $Cxx.name("goodNestedFieldName"); + anotherBadNestedFieldName @1 :NestedStruct $Cxx.name("anotherGoodNestedFieldName"); + + enum DeeplyNestedEnum $Cxx.name("RenamedDeeplyNestedEnum") { + quux @0; + corge @1; + grault @2 $Cxx.name("garply"); + } + } + + badlyNamedUnion :union $Cxx.name("renamedUnion") { + badlyNamedGroup :group $Cxx.name("renamedGroup") { + foo @3 :Void; + bar @4 :Void; + } + baz @5 :NestedStruct $Cxx.name("qux"); + } +} + +interface TestNameAnnotationInterface $Cxx.name("RenamedInterface") { + badlyNamedMethod @0 (badlyNamedParam :UInt8 $Cxx.name("renamedParam")) $Cxx.name("renamedMethod"); +} diff --git a/MsBuildGenerationTest/capnp/test.capnp.cs b/MsBuildGenerationTest/capnp/test.capnp.cs new file mode 100644 index 0000000..d20da0b --- /dev/null +++ b/MsBuildGenerationTest/capnp/test.capnp.cs @@ -0,0 +1,16200 @@ +using Capnp; +using Capnp.Rpc; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Capnproto_test.Capnp.Test +{ + public enum TestEnum : ushort + { + foo, + bar, + baz, + qux, + quux, + corge, + grault, + garply + } + + public class TestAllTypes : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + BoolField = reader.BoolField; + Int8Field = reader.Int8Field; + Int16Field = reader.Int16Field; + Int32Field = reader.Int32Field; + Int64Field = reader.Int64Field; + UInt8Field = reader.UInt8Field; + UInt16Field = reader.UInt16Field; + UInt32Field = reader.UInt32Field; + UInt64Field = reader.UInt64Field; + Float32Field = reader.Float32Field; + Float64Field = reader.Float64Field; + TextField = reader.TextField; + DataField = reader.DataField; + StructField = CapnpSerializable.Create(reader.StructField); + EnumField = reader.EnumField; + VoidList = reader.VoidList; + BoolList = reader.BoolList; + Int8List = reader.Int8List; + Int16List = reader.Int16List; + Int32List = reader.Int32List; + Int64List = reader.Int64List; + UInt8List = reader.UInt8List; + UInt16List = reader.UInt16List; + UInt32List = reader.UInt32List; + UInt64List = reader.UInt64List; + Float32List = reader.Float32List; + Float64List = reader.Float64List; + TextList = reader.TextList; + DataList = reader.DataList; + StructList = reader.StructList.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + EnumList = reader.EnumList; + InterfaceList = reader.InterfaceList; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.BoolField = BoolField; + writer.Int8Field = Int8Field; + writer.Int16Field = Int16Field; + writer.Int32Field = Int32Field; + writer.Int64Field = Int64Field; + writer.UInt8Field = UInt8Field; + writer.UInt16Field = UInt16Field; + writer.UInt32Field = UInt32Field; + writer.UInt64Field = UInt64Field; + writer.Float32Field = Float32Field; + writer.Float64Field = Float64Field; + writer.TextField = TextField; + writer.DataField.Init(DataField); + StructField?.serialize(writer.StructField); + writer.EnumField = EnumField; + writer.VoidList.Init(VoidList); + writer.BoolList.Init(BoolList); + writer.Int8List.Init(Int8List); + writer.Int16List.Init(Int16List); + writer.Int32List.Init(Int32List); + writer.Int64List.Init(Int64List); + writer.UInt8List.Init(UInt8List); + writer.UInt16List.Init(UInt16List); + writer.UInt32List.Init(UInt32List); + writer.UInt64List.Init(UInt64List); + writer.Float32List.Init(Float32List); + writer.Float64List.Init(Float64List); + writer.TextList.Init(TextList); + writer.DataList.Init(DataList, (_s1, _v1) => _s1.Init(_v1)); + writer.StructList.Init(StructList, (_s1, _v1) => _v1?.serialize(_s1)); + writer.EnumList.Init(EnumList); + writer.InterfaceList.Init(InterfaceList); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool BoolField + { + get; + set; + } + + public sbyte Int8Field + { + get; + set; + } + + public short Int16Field + { + get; + set; + } + + public int Int32Field + { + get; + set; + } + + public long Int64Field + { + get; + set; + } + + public byte UInt8Field + { + get; + set; + } + + public ushort UInt16Field + { + get; + set; + } + + public uint UInt32Field + { + get; + set; + } + + public ulong UInt64Field + { + get; + set; + } + + public float Float32Field + { + get; + set; + } + + public double Float64Field + { + get; + set; + } + + public string TextField + { + get; + set; + } + + public IReadOnlyList DataField + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestAllTypes StructField + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestEnum EnumField + { + get; + set; + } + + public int VoidList + { + get; + set; + } + + public IReadOnlyList BoolList + { + get; + set; + } + + public IReadOnlyList Int8List + { + get; + set; + } + + public IReadOnlyList Int16List + { + get; + set; + } + + public IReadOnlyList Int32List + { + get; + set; + } + + public IReadOnlyList Int64List + { + get; + set; + } + + public IReadOnlyList UInt8List + { + get; + set; + } + + public IReadOnlyList UInt16List + { + get; + set; + } + + public IReadOnlyList UInt32List + { + get; + set; + } + + public IReadOnlyList UInt64List + { + get; + set; + } + + public IReadOnlyList Float32List + { + get; + set; + } + + public IReadOnlyList Float64List + { + get; + set; + } + + public IReadOnlyList TextList + { + get; + set; + } + + public IReadOnlyList> DataList + { + get; + set; + } + + public IReadOnlyList StructList + { + get; + set; + } + + public IReadOnlyList EnumList + { + get; + set; + } + + public int InterfaceList + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public bool BoolField => ctx.ReadDataBool(0UL, false); + public sbyte Int8Field => ctx.ReadDataSByte(8UL, (sbyte)0); + public short Int16Field => ctx.ReadDataShort(16UL, (short)0); + public int Int32Field => ctx.ReadDataInt(32UL, 0); + public long Int64Field => ctx.ReadDataLong(64UL, 0L); + public byte UInt8Field => ctx.ReadDataByte(128UL, (byte)0); + public ushort UInt16Field => ctx.ReadDataUShort(144UL, (ushort)0); + public uint UInt32Field => ctx.ReadDataUInt(160UL, 0U); + public ulong UInt64Field => ctx.ReadDataULong(192UL, 0UL); + public float Float32Field => ctx.ReadDataFloat(256UL, 0F); + public double Float64Field => ctx.ReadDataDouble(320UL, 0); + public string TextField => ctx.ReadText(0, ""); + public IReadOnlyList DataField => ctx.ReadList(1).CastByte(); + public Capnproto_test.Capnp.Test.TestAllTypes.READER StructField => ctx.ReadStruct(2, Capnproto_test.Capnp.Test.TestAllTypes.READER.create); + public Capnproto_test.Capnp.Test.TestEnum EnumField => (Capnproto_test.Capnp.Test.TestEnum)ctx.ReadDataUShort(288UL, (ushort)0); + public int VoidList => ctx.ReadList(3).Count; + public IReadOnlyList BoolList => ctx.ReadList(4).CastBool(); + public IReadOnlyList Int8List => ctx.ReadList(5).CastSByte(); + public IReadOnlyList Int16List => ctx.ReadList(6).CastShort(); + public IReadOnlyList Int32List => ctx.ReadList(7).CastInt(); + public IReadOnlyList Int64List => ctx.ReadList(8).CastLong(); + public IReadOnlyList UInt8List => ctx.ReadList(9).CastByte(); + public IReadOnlyList UInt16List => ctx.ReadList(10).CastUShort(); + public IReadOnlyList UInt32List => ctx.ReadList(11).CastUInt(); + public IReadOnlyList UInt64List => ctx.ReadList(12).CastULong(); + public IReadOnlyList Float32List => ctx.ReadList(13).CastFloat(); + public IReadOnlyList Float64List => ctx.ReadList(14).CastDouble(); + public IReadOnlyList TextList => ctx.ReadList(15).CastText2(); + public IReadOnlyList> DataList => ctx.ReadList(16).CastData(); + public IReadOnlyList StructList => ctx.ReadList(17).Cast(Capnproto_test.Capnp.Test.TestAllTypes.READER.create); + public IReadOnlyList EnumList => ctx.ReadList(18).CastEnums(_0 => (Capnproto_test.Capnp.Test.TestEnum)_0); + public int InterfaceList => ctx.ReadList(19).Count; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(6, 20); + } + + public bool BoolField + { + get => this.ReadDataBool(0UL, false); + set => this.WriteData(0UL, value, false); + } + + public sbyte Int8Field + { + get => this.ReadDataSByte(8UL, (sbyte)0); + set => this.WriteData(8UL, value, (sbyte)0); + } + + public short Int16Field + { + get => this.ReadDataShort(16UL, (short)0); + set => this.WriteData(16UL, value, (short)0); + } + + public int Int32Field + { + get => this.ReadDataInt(32UL, 0); + set => this.WriteData(32UL, value, 0); + } + + public long Int64Field + { + get => this.ReadDataLong(64UL, 0L); + set => this.WriteData(64UL, value, 0L); + } + + public byte UInt8Field + { + get => this.ReadDataByte(128UL, (byte)0); + set => this.WriteData(128UL, value, (byte)0); + } + + public ushort UInt16Field + { + get => this.ReadDataUShort(144UL, (ushort)0); + set => this.WriteData(144UL, value, (ushort)0); + } + + public uint UInt32Field + { + get => this.ReadDataUInt(160UL, 0U); + set => this.WriteData(160UL, value, 0U); + } + + public ulong UInt64Field + { + get => this.ReadDataULong(192UL, 0UL); + set => this.WriteData(192UL, value, 0UL); + } + + public float Float32Field + { + get => this.ReadDataFloat(256UL, 0F); + set => this.WriteData(256UL, value, 0F); + } + + public double Float64Field + { + get => this.ReadDataDouble(320UL, 0); + set => this.WriteData(320UL, value, 0); + } + + public string TextField + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public ListOfPrimitivesSerializer DataField + { + get => BuildPointer>(1); + set => Link(1, value); + } + + public Capnproto_test.Capnp.Test.TestAllTypes.WRITER StructField + { + get => BuildPointer(2); + set => Link(2, value); + } + + public Capnproto_test.Capnp.Test.TestEnum EnumField + { + get => (Capnproto_test.Capnp.Test.TestEnum)this.ReadDataUShort(288UL, (ushort)0); + set => this.WriteData(288UL, (ushort)value, (ushort)0); + } + + public ListOfEmptySerializer VoidList + { + get => BuildPointer(3); + set => Link(3, value); + } + + public ListOfBitsSerializer BoolList + { + get => BuildPointer(4); + set => Link(4, value); + } + + public ListOfPrimitivesSerializer Int8List + { + get => BuildPointer>(5); + set => Link(5, value); + } + + public ListOfPrimitivesSerializer Int16List + { + get => BuildPointer>(6); + set => Link(6, value); + } + + public ListOfPrimitivesSerializer Int32List + { + get => BuildPointer>(7); + set => Link(7, value); + } + + public ListOfPrimitivesSerializer Int64List + { + get => BuildPointer>(8); + set => Link(8, value); + } + + public ListOfPrimitivesSerializer UInt8List + { + get => BuildPointer>(9); + set => Link(9, value); + } + + public ListOfPrimitivesSerializer UInt16List + { + get => BuildPointer>(10); + set => Link(10, value); + } + + public ListOfPrimitivesSerializer UInt32List + { + get => BuildPointer>(11); + set => Link(11, value); + } + + public ListOfPrimitivesSerializer UInt64List + { + get => BuildPointer>(12); + set => Link(12, value); + } + + public ListOfPrimitivesSerializer Float32List + { + get => BuildPointer>(13); + set => Link(13, value); + } + + public ListOfPrimitivesSerializer Float64List + { + get => BuildPointer>(14); + set => Link(14, value); + } + + public ListOfTextSerializer TextList + { + get => BuildPointer(15); + set => Link(15, value); + } + + public ListOfPointersSerializer> DataList + { + get => BuildPointer>>(16); + set => Link(16, value); + } + + public ListOfStructsSerializer StructList + { + get => BuildPointer>(17); + set => Link(17, value); + } + + public ListOfPrimitivesSerializer EnumList + { + get => BuildPointer>(18); + set => Link(18, value); + } + + public ListOfEmptySerializer InterfaceList + { + get => BuildPointer(19); + set => Link(19, value); + } + } + } + + public class TestDefaults : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + BoolField = reader.BoolField; + Int8Field = reader.Int8Field; + Int16Field = reader.Int16Field; + Int32Field = reader.Int32Field; + Int64Field = reader.Int64Field; + UInt8Field = reader.UInt8Field; + UInt16Field = reader.UInt16Field; + UInt32Field = reader.UInt32Field; + UInt64Field = reader.UInt64Field; + Float32Field = reader.Float32Field; + Float64Field = reader.Float64Field; + TextField = reader.TextField; + DataField = reader.DataField; + StructField = CapnpSerializable.Create(reader.StructField); + EnumField = reader.EnumField; + VoidList = reader.VoidList; + BoolList = reader.BoolList; + Int8List = reader.Int8List; + Int16List = reader.Int16List; + Int32List = reader.Int32List; + Int64List = reader.Int64List; + UInt8List = reader.UInt8List; + UInt16List = reader.UInt16List; + UInt32List = reader.UInt32List; + UInt64List = reader.UInt64List; + Float32List = reader.Float32List; + Float64List = reader.Float64List; + TextList = reader.TextList; + DataList = reader.DataList; + StructList = reader.StructList.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + EnumList = reader.EnumList; + InterfaceList = reader.InterfaceList; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.BoolField = BoolField; + writer.Int8Field = Int8Field; + writer.Int16Field = Int16Field; + writer.Int32Field = Int32Field; + writer.Int64Field = Int64Field; + writer.UInt8Field = UInt8Field; + writer.UInt16Field = UInt16Field; + writer.UInt32Field = UInt32Field; + writer.UInt64Field = UInt64Field; + writer.Float32Field = Float32Field; + writer.Float64Field = Float64Field; + writer.TextField = TextField; + writer.DataField.Init(DataField); + StructField?.serialize(writer.StructField); + writer.EnumField = EnumField; + writer.VoidList.Init(VoidList); + writer.BoolList.Init(BoolList); + writer.Int8List.Init(Int8List); + writer.Int16List.Init(Int16List); + writer.Int32List.Init(Int32List); + writer.Int64List.Init(Int64List); + writer.UInt8List.Init(UInt8List); + writer.UInt16List.Init(UInt16List); + writer.UInt32List.Init(UInt32List); + writer.UInt64List.Init(UInt64List); + writer.Float32List.Init(Float32List); + writer.Float64List.Init(Float64List); + writer.TextList.Init(TextList); + writer.DataList.Init(DataList, (_s1, _v1) => _s1.Init(_v1)); + writer.StructList.Init(StructList, (_s1, _v1) => _v1?.serialize(_s1)); + writer.EnumList.Init(EnumList); + writer.InterfaceList.Init(InterfaceList); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + TextField = TextField ?? "foo"; + DataField = DataField ?? new byte[]{98, 97, 114}; + StructField = StructField ?? new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = true, Int8Field = -12, Int16Field = 3456, Int32Field = -78901234, Int64Field = 56789012345678L, UInt8Field = 90, UInt16Field = 1234, UInt32Field = 56789012U, UInt64Field = 345678901234567890UL, Float32Field = -1.25E-10F, Float64Field = 345, TextField = "baz", DataField = new byte[]{113, 117, 120}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 0, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = "nested", DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 0, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = "really nested", DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 3, BoolList = new bool[]{false, true, false, true, true}, Int8List = new sbyte[]{12, -34, -128, 127}, Int16List = new short[]{1234, -5678, -32768, 32767}, Int32List = new int[]{12345678, -90123456, -2147483648, 2147483647}, Int64List = new long[]{123456789012345L, -678901234567890L, -9223372036854775808L, 9223372036854775807L}, UInt8List = new byte[]{12, 34, 0, 255}, UInt16List = new ushort[]{1234, 5678, 0, 65535}, UInt32List = new uint[]{12345678U, 90123456U, 0U, 4294967295U}, UInt64List = new ulong[]{123456789012345UL, 678901234567890UL, 0UL, 18446744073709551615UL}, Float32List = new float[]{0F, 1234567F, 1E+37F, -1E+37F, 1E-37F, -1E-37F}, Float64List = new double[]{0, 123456789012345, 1E+306, -1E+306, 1E-306, -1E-306}, TextList = new string[]{"quux", "corge", "grault"}, DataList = new IReadOnlyList[]{new byte[]{103, 97, 114, 112, 108, 121}, new byte[]{119, 97, 108, 100, 111}, new byte[]{102, 114, 101, 100}}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 0, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = "x structlist 1", DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 0, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = "x structlist 2", DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 0, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = "x structlist 3", DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{Capnproto_test.Capnp.Test.TestEnum.qux, Capnproto_test.Capnp.Test.TestEnum.bar, Capnproto_test.Capnp.Test.TestEnum.grault}, InterfaceList = 0}; + BoolList = BoolList ?? new bool[]{true, false, false, true}; + Int8List = Int8List ?? new sbyte[]{111, -111}; + Int16List = Int16List ?? new short[]{11111, -11111}; + Int32List = Int32List ?? new int[]{111111111, -111111111}; + Int64List = Int64List ?? new long[]{1111111111111111111L, -1111111111111111111L}; + UInt8List = UInt8List ?? new byte[]{111, 222}; + UInt16List = UInt16List ?? new ushort[]{33333, 44444}; + UInt32List = UInt32List ?? new uint[]{3333333333U}; + UInt64List = UInt64List ?? new ulong[]{11111111111111111111UL}; + Float32List = Float32List ?? new float[]{5555.5F, float.PositiveInfinity, float.NegativeInfinity, float.NaN}; + Float64List = Float64List ?? new double[]{7777.75, double.PositiveInfinity, double.NegativeInfinity, double.NaN}; + TextList = TextList ?? new string[]{"plugh", "xyzzy", "thud"}; + DataList = DataList ?? new IReadOnlyList[]{new byte[]{111, 111, 112, 115}, new byte[]{101, 120, 104, 97, 117, 115, 116, 101, 100}, new byte[]{114, 102, 99, 51, 48, 57, 50}}; + StructList = StructList ?? new Capnproto_test.Capnp.Test.TestAllTypes[]{new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 0, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = "structlist 1", DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 0, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = "structlist 2", DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 0, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = "structlist 3", DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}}; + EnumList = EnumList ?? new Capnproto_test.Capnp.Test.TestEnum[]{Capnproto_test.Capnp.Test.TestEnum.foo, Capnproto_test.Capnp.Test.TestEnum.garply}; + } + + public bool BoolField + { + get; + set; + } + + = true; + public sbyte Int8Field + { + get; + set; + } + + = -123; + public short Int16Field + { + get; + set; + } + + = -12345; + public int Int32Field + { + get; + set; + } + + = -12345678; + public long Int64Field + { + get; + set; + } + + = -123456789012345L; + public byte UInt8Field + { + get; + set; + } + + = 234; + public ushort UInt16Field + { + get; + set; + } + + = 45678; + public uint UInt32Field + { + get; + set; + } + + = 3456789012U; + public ulong UInt64Field + { + get; + set; + } + + = 12345678901234567890UL; + public float Float32Field + { + get; + set; + } + + = 1234.5F; + public double Float64Field + { + get; + set; + } + + = -1.23E+47; + public string TextField + { + get; + set; + } + + public IReadOnlyList DataField + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestAllTypes StructField + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestEnum EnumField + { + get; + set; + } + + = Capnproto_test.Capnp.Test.TestEnum.corge; + public int VoidList + { + get; + set; + } + + = 6; + public IReadOnlyList BoolList + { + get; + set; + } + + public IReadOnlyList Int8List + { + get; + set; + } + + public IReadOnlyList Int16List + { + get; + set; + } + + public IReadOnlyList Int32List + { + get; + set; + } + + public IReadOnlyList Int64List + { + get; + set; + } + + public IReadOnlyList UInt8List + { + get; + set; + } + + public IReadOnlyList UInt16List + { + get; + set; + } + + public IReadOnlyList UInt32List + { + get; + set; + } + + public IReadOnlyList UInt64List + { + get; + set; + } + + public IReadOnlyList Float32List + { + get; + set; + } + + public IReadOnlyList Float64List + { + get; + set; + } + + public IReadOnlyList TextList + { + get; + set; + } + + public IReadOnlyList> DataList + { + get; + set; + } + + public IReadOnlyList StructList + { + get; + set; + } + + public IReadOnlyList EnumList + { + get; + set; + } + + public int InterfaceList + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public bool BoolField => ctx.ReadDataBool(0UL, true); + public sbyte Int8Field => ctx.ReadDataSByte(8UL, (sbyte)-123); + public short Int16Field => ctx.ReadDataShort(16UL, (short)-12345); + public int Int32Field => ctx.ReadDataInt(32UL, -12345678); + public long Int64Field => ctx.ReadDataLong(64UL, -123456789012345L); + public byte UInt8Field => ctx.ReadDataByte(128UL, (byte)234); + public ushort UInt16Field => ctx.ReadDataUShort(144UL, (ushort)45678); + public uint UInt32Field => ctx.ReadDataUInt(160UL, 3456789012U); + public ulong UInt64Field => ctx.ReadDataULong(192UL, 12345678901234567890UL); + public float Float32Field => ctx.ReadDataFloat(256UL, 1234.5F); + public double Float64Field => ctx.ReadDataDouble(320UL, -1.23E+47); + public string TextField => ctx.ReadText(0, "foo"); + public IReadOnlyList DataField => ctx.ReadList(1).CastByte(); + public Capnproto_test.Capnp.Test.TestAllTypes.READER StructField => ctx.ReadStruct(2, Capnproto_test.Capnp.Test.TestAllTypes.READER.create); + public Capnproto_test.Capnp.Test.TestEnum EnumField => (Capnproto_test.Capnp.Test.TestEnum)ctx.ReadDataUShort(288UL, (ushort)5); + public int VoidList => ctx.ReadList(3).Count; + public IReadOnlyList BoolList => ctx.ReadList(4).CastBool(); + public IReadOnlyList Int8List => ctx.ReadList(5).CastSByte(); + public IReadOnlyList Int16List => ctx.ReadList(6).CastShort(); + public IReadOnlyList Int32List => ctx.ReadList(7).CastInt(); + public IReadOnlyList Int64List => ctx.ReadList(8).CastLong(); + public IReadOnlyList UInt8List => ctx.ReadList(9).CastByte(); + public IReadOnlyList UInt16List => ctx.ReadList(10).CastUShort(); + public IReadOnlyList UInt32List => ctx.ReadList(11).CastUInt(); + public IReadOnlyList UInt64List => ctx.ReadList(12).CastULong(); + public IReadOnlyList Float32List => ctx.ReadList(13).CastFloat(); + public IReadOnlyList Float64List => ctx.ReadList(14).CastDouble(); + public IReadOnlyList TextList => ctx.ReadList(15).CastText2(); + public IReadOnlyList> DataList => ctx.ReadList(16).CastData(); + public IReadOnlyList StructList => ctx.ReadList(17).Cast(Capnproto_test.Capnp.Test.TestAllTypes.READER.create); + public IReadOnlyList EnumList => ctx.ReadList(18).CastEnums(_0 => (Capnproto_test.Capnp.Test.TestEnum)_0); + public int InterfaceList => ctx.ReadList(19).Count; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(6, 20); + } + + public bool BoolField + { + get => this.ReadDataBool(0UL, true); + set => this.WriteData(0UL, value, true); + } + + public sbyte Int8Field + { + get => this.ReadDataSByte(8UL, (sbyte)-123); + set => this.WriteData(8UL, value, (sbyte)-123); + } + + public short Int16Field + { + get => this.ReadDataShort(16UL, (short)-12345); + set => this.WriteData(16UL, value, (short)-12345); + } + + public int Int32Field + { + get => this.ReadDataInt(32UL, -12345678); + set => this.WriteData(32UL, value, -12345678); + } + + public long Int64Field + { + get => this.ReadDataLong(64UL, -123456789012345L); + set => this.WriteData(64UL, value, -123456789012345L); + } + + public byte UInt8Field + { + get => this.ReadDataByte(128UL, (byte)234); + set => this.WriteData(128UL, value, (byte)234); + } + + public ushort UInt16Field + { + get => this.ReadDataUShort(144UL, (ushort)45678); + set => this.WriteData(144UL, value, (ushort)45678); + } + + public uint UInt32Field + { + get => this.ReadDataUInt(160UL, 3456789012U); + set => this.WriteData(160UL, value, 3456789012U); + } + + public ulong UInt64Field + { + get => this.ReadDataULong(192UL, 12345678901234567890UL); + set => this.WriteData(192UL, value, 12345678901234567890UL); + } + + public float Float32Field + { + get => this.ReadDataFloat(256UL, 1234.5F); + set => this.WriteData(256UL, value, 1234.5F); + } + + public double Float64Field + { + get => this.ReadDataDouble(320UL, -1.23E+47); + set => this.WriteData(320UL, value, -1.23E+47); + } + + public string TextField + { + get => this.ReadText(0, "foo"); + set => this.WriteText(0, value, "foo"); + } + + public ListOfPrimitivesSerializer DataField + { + get => BuildPointer>(1); + set => Link(1, value); + } + + public Capnproto_test.Capnp.Test.TestAllTypes.WRITER StructField + { + get => BuildPointer(2); + set => Link(2, value); + } + + public Capnproto_test.Capnp.Test.TestEnum EnumField + { + get => (Capnproto_test.Capnp.Test.TestEnum)this.ReadDataUShort(288UL, (ushort)5); + set => this.WriteData(288UL, (ushort)value, (ushort)5); + } + + public ListOfEmptySerializer VoidList + { + get => BuildPointer(3); + set => Link(3, value); + } + + public ListOfBitsSerializer BoolList + { + get => BuildPointer(4); + set => Link(4, value); + } + + public ListOfPrimitivesSerializer Int8List + { + get => BuildPointer>(5); + set => Link(5, value); + } + + public ListOfPrimitivesSerializer Int16List + { + get => BuildPointer>(6); + set => Link(6, value); + } + + public ListOfPrimitivesSerializer Int32List + { + get => BuildPointer>(7); + set => Link(7, value); + } + + public ListOfPrimitivesSerializer Int64List + { + get => BuildPointer>(8); + set => Link(8, value); + } + + public ListOfPrimitivesSerializer UInt8List + { + get => BuildPointer>(9); + set => Link(9, value); + } + + public ListOfPrimitivesSerializer UInt16List + { + get => BuildPointer>(10); + set => Link(10, value); + } + + public ListOfPrimitivesSerializer UInt32List + { + get => BuildPointer>(11); + set => Link(11, value); + } + + public ListOfPrimitivesSerializer UInt64List + { + get => BuildPointer>(12); + set => Link(12, value); + } + + public ListOfPrimitivesSerializer Float32List + { + get => BuildPointer>(13); + set => Link(13, value); + } + + public ListOfPrimitivesSerializer Float64List + { + get => BuildPointer>(14); + set => Link(14, value); + } + + public ListOfTextSerializer TextList + { + get => BuildPointer(15); + set => Link(15, value); + } + + public ListOfPointersSerializer> DataList + { + get => BuildPointer>>(16); + set => Link(16, value); + } + + public ListOfStructsSerializer StructList + { + get => BuildPointer>(17); + set => Link(17, value); + } + + public ListOfPrimitivesSerializer EnumList + { + get => BuildPointer>(18); + set => Link(18, value); + } + + public ListOfEmptySerializer InterfaceList + { + get => BuildPointer(19); + set => Link(19, value); + } + } + } + + public class TestAnyPointer : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + AnyPointerField = CapnpSerializable.Create(reader.AnyPointerField); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.AnyPointerField.SetObject(AnyPointerField); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public AnyPointer AnyPointerField + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState AnyPointerField => ctx.StructReadPointer(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public DynamicSerializerState AnyPointerField + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } + + public class TestAnyOthers : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + AnyStructField = CapnpSerializable.Create(reader.AnyStructField); + AnyListField = reader.AnyListField.ToReadOnlyList(_ => (object)_); + CapabilityField = reader.CapabilityField; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.AnyStructField.SetObject(AnyStructField); + writer.AnyListField.SetObject(AnyListField); + writer.CapabilityField = CapabilityField; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public AnyPointer AnyStructField + { + get; + set; + } + + public IReadOnlyList AnyListField + { + get; + set; + } + + public BareProxy CapabilityField + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState AnyStructField => ctx.StructReadPointer(0); + public IReadOnlyList AnyListField => (IReadOnlyList)ctx.ReadList(1); + public BareProxy CapabilityField => ctx.ReadCap(2); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 3); + } + + public DynamicSerializerState AnyStructField + { + get => BuildPointer(0); + set => Link(0, value); + } + + public DynamicSerializerState AnyListField + { + get => BuildPointer(1); + set => Link(1, value); + } + + public BareProxy CapabilityField + { + get => ReadCap(2); + set => LinkObject(2, value); + } + } + } + + public class TestOutOfOrder : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Qux = reader.Qux; + Grault = reader.Grault; + Bar = reader.Bar; + Foo = reader.Foo; + Corge = reader.Corge; + Waldo = reader.Waldo; + Quux = reader.Quux; + Garply = reader.Garply; + Baz = reader.Baz; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Qux = Qux; + writer.Grault = Grault; + writer.Bar = Bar; + writer.Foo = Foo; + writer.Corge = Corge; + writer.Waldo = Waldo; + writer.Quux = Quux; + writer.Garply = Garply; + writer.Baz = Baz; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Qux + { + get; + set; + } + + public string Grault + { + get; + set; + } + + public string Bar + { + get; + set; + } + + public string Foo + { + get; + set; + } + + public string Corge + { + get; + set; + } + + public string Waldo + { + get; + set; + } + + public string Quux + { + get; + set; + } + + public string Garply + { + get; + set; + } + + public string Baz + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Qux => ctx.ReadText(0, ""); + public string Grault => ctx.ReadText(1, ""); + public string Bar => ctx.ReadText(2, ""); + public string Foo => ctx.ReadText(3, ""); + public string Corge => ctx.ReadText(4, ""); + public string Waldo => ctx.ReadText(5, ""); + public string Quux => ctx.ReadText(6, ""); + public string Garply => ctx.ReadText(7, ""); + public string Baz => ctx.ReadText(8, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 9); + } + + public string Qux + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public string Grault + { + get => this.ReadText(1, ""); + set => this.WriteText(1, value, ""); + } + + public string Bar + { + get => this.ReadText(2, ""); + set => this.WriteText(2, value, ""); + } + + public string Foo + { + get => this.ReadText(3, ""); + set => this.WriteText(3, value, ""); + } + + public string Corge + { + get => this.ReadText(4, ""); + set => this.WriteText(4, value, ""); + } + + public string Waldo + { + get => this.ReadText(5, ""); + set => this.WriteText(5, value, ""); + } + + public string Quux + { + get => this.ReadText(6, ""); + set => this.WriteText(6, value, ""); + } + + public string Garply + { + get => this.ReadText(7, ""); + set => this.WriteText(7, value, ""); + } + + public string Baz + { + get => this.ReadText(8, ""); + set => this.WriteText(8, value, ""); + } + } + } + + public class TestUnion : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Union0 = CapnpSerializable.Create(reader.Union0); + Union1 = CapnpSerializable.Create(reader.Union1); + Union2 = CapnpSerializable.Create(reader.Union2); + Union3 = CapnpSerializable.Create(reader.Union3); + Bit0 = reader.Bit0; + Bit2 = reader.Bit2; + Bit3 = reader.Bit3; + Bit4 = reader.Bit4; + Bit5 = reader.Bit5; + Bit6 = reader.Bit6; + Bit7 = reader.Bit7; + Byte0 = reader.Byte0; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Union0?.serialize(writer.Union0); + Union1?.serialize(writer.Union1); + Union2?.serialize(writer.Union2); + Union3?.serialize(writer.Union3); + writer.Bit0 = Bit0; + writer.Bit2 = Bit2; + writer.Bit3 = Bit3; + writer.Bit4 = Bit4; + writer.Bit5 = Bit5; + writer.Bit6 = Bit6; + writer.Bit7 = Bit7; + writer.Byte0 = Byte0; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestUnion.@union0 Union0 + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestUnion.@union1 Union1 + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestUnion.@union2 Union2 + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestUnion.@union3 Union3 + { + get; + set; + } + + public bool Bit0 + { + get; + set; + } + + public bool Bit2 + { + get; + set; + } + + public bool Bit3 + { + get; + set; + } + + public bool Bit4 + { + get; + set; + } + + public bool Bit5 + { + get; + set; + } + + public bool Bit6 + { + get; + set; + } + + public bool Bit7 + { + get; + set; + } + + public byte Byte0 + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public @union0.READER Union0 => new @union0.READER(ctx); + public @union1.READER Union1 => new @union1.READER(ctx); + public @union2.READER Union2 => new @union2.READER(ctx); + public @union3.READER Union3 => new @union3.READER(ctx); + public bool Bit0 => ctx.ReadDataBool(128UL, false); + public bool Bit2 => ctx.ReadDataBool(130UL, false); + public bool Bit3 => ctx.ReadDataBool(131UL, false); + public bool Bit4 => ctx.ReadDataBool(132UL, false); + public bool Bit5 => ctx.ReadDataBool(133UL, false); + public bool Bit6 => ctx.ReadDataBool(134UL, false); + public bool Bit7 => ctx.ReadDataBool(135UL, false); + public byte Byte0 => ctx.ReadDataByte(280UL, (byte)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(8, 2); + } + + public @union0.WRITER Union0 + { + get => Rewrap<@union0.WRITER>(); + } + + public @union1.WRITER Union1 + { + get => Rewrap<@union1.WRITER>(); + } + + public @union2.WRITER Union2 + { + get => Rewrap<@union2.WRITER>(); + } + + public @union3.WRITER Union3 + { + get => Rewrap<@union3.WRITER>(); + } + + public bool Bit0 + { + get => this.ReadDataBool(128UL, false); + set => this.WriteData(128UL, value, false); + } + + public bool Bit2 + { + get => this.ReadDataBool(130UL, false); + set => this.WriteData(130UL, value, false); + } + + public bool Bit3 + { + get => this.ReadDataBool(131UL, false); + set => this.WriteData(131UL, value, false); + } + + public bool Bit4 + { + get => this.ReadDataBool(132UL, false); + set => this.WriteData(132UL, value, false); + } + + public bool Bit5 + { + get => this.ReadDataBool(133UL, false); + set => this.WriteData(133UL, value, false); + } + + public bool Bit6 + { + get => this.ReadDataBool(134UL, false); + set => this.WriteData(134UL, value, false); + } + + public bool Bit7 + { + get => this.ReadDataBool(135UL, false); + set => this.WriteData(135UL, value, false); + } + + public byte Byte0 + { + get => this.ReadDataByte(280UL, (byte)0); + set => this.WriteData(280UL, value, (byte)0); + } + } + + public class @union0 : ICapnpSerializable + { + public enum WHICH : ushort + { + U0f0s0 = 0, + U0f0s1 = 1, + U0f0s8 = 2, + U0f0s16 = 3, + U0f0s32 = 4, + U0f0s64 = 5, + U0f0sp = 6, + U0f1s0 = 7, + U0f1s1 = 8, + U0f1s8 = 9, + U0f1s16 = 10, + U0f1s32 = 11, + U0f1s64 = 12, + U0f1sp = 13, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.U0f0s0: + which = reader.which; + break; + case WHICH.U0f0s1: + U0f0s1 = reader.U0f0s1; + break; + case WHICH.U0f0s8: + U0f0s8 = reader.U0f0s8; + break; + case WHICH.U0f0s16: + U0f0s16 = reader.U0f0s16; + break; + case WHICH.U0f0s32: + U0f0s32 = reader.U0f0s32; + break; + case WHICH.U0f0s64: + U0f0s64 = reader.U0f0s64; + break; + case WHICH.U0f0sp: + U0f0sp = reader.U0f0sp; + break; + case WHICH.U0f1s0: + which = reader.which; + break; + case WHICH.U0f1s1: + U0f1s1 = reader.U0f1s1; + break; + case WHICH.U0f1s8: + U0f1s8 = reader.U0f1s8; + break; + case WHICH.U0f1s16: + U0f1s16 = reader.U0f1s16; + break; + case WHICH.U0f1s32: + U0f1s32 = reader.U0f1s32; + break; + case WHICH.U0f1s64: + U0f1s64 = reader.U0f1s64; + break; + case WHICH.U0f1sp: + U0f1sp = reader.U0f1sp; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.U0f0s0: + break; + case WHICH.U0f0s1: + _content = false; + break; + case WHICH.U0f0s8: + _content = 0; + break; + case WHICH.U0f0s16: + _content = 0; + break; + case WHICH.U0f0s32: + _content = 0; + break; + case WHICH.U0f0s64: + _content = 0; + break; + case WHICH.U0f0sp: + _content = null; + break; + case WHICH.U0f1s0: + break; + case WHICH.U0f1s1: + _content = false; + break; + case WHICH.U0f1s8: + _content = 0; + break; + case WHICH.U0f1s16: + _content = 0; + break; + case WHICH.U0f1s32: + _content = 0; + break; + case WHICH.U0f1s64: + _content = 0; + break; + case WHICH.U0f1sp: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.U0f0s0: + break; + case WHICH.U0f0s1: + writer.U0f0s1 = U0f0s1.Value; + break; + case WHICH.U0f0s8: + writer.U0f0s8 = U0f0s8.Value; + break; + case WHICH.U0f0s16: + writer.U0f0s16 = U0f0s16.Value; + break; + case WHICH.U0f0s32: + writer.U0f0s32 = U0f0s32.Value; + break; + case WHICH.U0f0s64: + writer.U0f0s64 = U0f0s64.Value; + break; + case WHICH.U0f0sp: + writer.U0f0sp = U0f0sp; + break; + case WHICH.U0f1s0: + break; + case WHICH.U0f1s1: + writer.U0f1s1 = U0f1s1.Value; + break; + case WHICH.U0f1s8: + writer.U0f1s8 = U0f1s8.Value; + break; + case WHICH.U0f1s16: + writer.U0f1s16 = U0f1s16.Value; + break; + case WHICH.U0f1s32: + writer.U0f1s32 = U0f1s32.Value; + break; + case WHICH.U0f1s64: + writer.U0f1s64 = U0f1s64.Value; + break; + case WHICH.U0f1sp: + writer.U0f1sp = U0f1sp; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool? U0f0s1 + { + get => _which == WHICH.U0f0s1 ? (bool? )_content : null; + set + { + _which = WHICH.U0f0s1; + _content = value; + } + } + + public sbyte? U0f0s8 + { + get => _which == WHICH.U0f0s8 ? (sbyte? )_content : null; + set + { + _which = WHICH.U0f0s8; + _content = value; + } + } + + public short? U0f0s16 + { + get => _which == WHICH.U0f0s16 ? (short? )_content : null; + set + { + _which = WHICH.U0f0s16; + _content = value; + } + } + + public int? U0f0s32 + { + get => _which == WHICH.U0f0s32 ? (int? )_content : null; + set + { + _which = WHICH.U0f0s32; + _content = value; + } + } + + public long? U0f0s64 + { + get => _which == WHICH.U0f0s64 ? (long? )_content : null; + set + { + _which = WHICH.U0f0s64; + _content = value; + } + } + + public string U0f0sp + { + get => _which == WHICH.U0f0sp ? (string)_content : null; + set + { + _which = WHICH.U0f0sp; + _content = value; + } + } + + public bool? U0f1s1 + { + get => _which == WHICH.U0f1s1 ? (bool? )_content : null; + set + { + _which = WHICH.U0f1s1; + _content = value; + } + } + + public sbyte? U0f1s8 + { + get => _which == WHICH.U0f1s8 ? (sbyte? )_content : null; + set + { + _which = WHICH.U0f1s8; + _content = value; + } + } + + public short? U0f1s16 + { + get => _which == WHICH.U0f1s16 ? (short? )_content : null; + set + { + _which = WHICH.U0f1s16; + _content = value; + } + } + + public int? U0f1s32 + { + get => _which == WHICH.U0f1s32 ? (int? )_content : null; + set + { + _which = WHICH.U0f1s32; + _content = value; + } + } + + public long? U0f1s64 + { + get => _which == WHICH.U0f1s64 ? (long? )_content : null; + set + { + _which = WHICH.U0f1s64; + _content = value; + } + } + + public string U0f1sp + { + get => _which == WHICH.U0f1sp ? (string)_content : null; + set + { + _which = WHICH.U0f1sp; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public bool U0f0s1 => which == WHICH.U0f0s1 ? ctx.ReadDataBool(64UL, false) : default; + public sbyte U0f0s8 => which == WHICH.U0f0s8 ? ctx.ReadDataSByte(64UL, (sbyte)0) : default; + public short U0f0s16 => which == WHICH.U0f0s16 ? ctx.ReadDataShort(64UL, (short)0) : default; + public int U0f0s32 => which == WHICH.U0f0s32 ? ctx.ReadDataInt(64UL, 0) : default; + public long U0f0s64 => which == WHICH.U0f0s64 ? ctx.ReadDataLong(64UL, 0L) : default; + public string U0f0sp => which == WHICH.U0f0sp ? ctx.ReadText(0, "") : default; + public bool U0f1s1 => which == WHICH.U0f1s1 ? ctx.ReadDataBool(64UL, false) : default; + public sbyte U0f1s8 => which == WHICH.U0f1s8 ? ctx.ReadDataSByte(64UL, (sbyte)0) : default; + public short U0f1s16 => which == WHICH.U0f1s16 ? ctx.ReadDataShort(64UL, (short)0) : default; + public int U0f1s32 => which == WHICH.U0f1s32 ? ctx.ReadDataInt(64UL, 0) : default; + public long U0f1s64 => which == WHICH.U0f1s64 ? ctx.ReadDataLong(64UL, 0L) : default; + public string U0f1sp => which == WHICH.U0f1sp ? ctx.ReadText(0, "") : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public bool U0f0s1 + { + get => which == WHICH.U0f0s1 ? this.ReadDataBool(64UL, false) : default; + set => this.WriteData(64UL, value, false); + } + + public sbyte U0f0s8 + { + get => which == WHICH.U0f0s8 ? this.ReadDataSByte(64UL, (sbyte)0) : default; + set => this.WriteData(64UL, value, (sbyte)0); + } + + public short U0f0s16 + { + get => which == WHICH.U0f0s16 ? this.ReadDataShort(64UL, (short)0) : default; + set => this.WriteData(64UL, value, (short)0); + } + + public int U0f0s32 + { + get => which == WHICH.U0f0s32 ? this.ReadDataInt(64UL, 0) : default; + set => this.WriteData(64UL, value, 0); + } + + public long U0f0s64 + { + get => which == WHICH.U0f0s64 ? this.ReadDataLong(64UL, 0L) : default; + set => this.WriteData(64UL, value, 0L); + } + + public string U0f0sp + { + get => which == WHICH.U0f0sp ? this.ReadText(0, "") : default; + set => this.WriteText(0, value, ""); + } + + public bool U0f1s1 + { + get => which == WHICH.U0f1s1 ? this.ReadDataBool(64UL, false) : default; + set => this.WriteData(64UL, value, false); + } + + public sbyte U0f1s8 + { + get => which == WHICH.U0f1s8 ? this.ReadDataSByte(64UL, (sbyte)0) : default; + set => this.WriteData(64UL, value, (sbyte)0); + } + + public short U0f1s16 + { + get => which == WHICH.U0f1s16 ? this.ReadDataShort(64UL, (short)0) : default; + set => this.WriteData(64UL, value, (short)0); + } + + public int U0f1s32 + { + get => which == WHICH.U0f1s32 ? this.ReadDataInt(64UL, 0) : default; + set => this.WriteData(64UL, value, 0); + } + + public long U0f1s64 + { + get => which == WHICH.U0f1s64 ? this.ReadDataLong(64UL, 0L) : default; + set => this.WriteData(64UL, value, 0L); + } + + public string U0f1sp + { + get => which == WHICH.U0f1sp ? this.ReadText(0, "") : default; + set => this.WriteText(0, value, ""); + } + } + } + + public class @union1 : ICapnpSerializable + { + public enum WHICH : ushort + { + U1f0s0 = 0, + U1f0s1 = 1, + U1f1s1 = 2, + U1f0s8 = 3, + U1f1s8 = 4, + U1f0s16 = 5, + U1f1s16 = 6, + U1f0s32 = 7, + U1f1s32 = 8, + U1f0s64 = 9, + U1f1s64 = 10, + U1f0sp = 11, + U1f1sp = 12, + U1f2s0 = 13, + U1f2s1 = 14, + U1f2s8 = 15, + U1f2s16 = 16, + U1f2s32 = 17, + U1f2s64 = 18, + U1f2sp = 19, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.U1f0s0: + which = reader.which; + break; + case WHICH.U1f0s1: + U1f0s1 = reader.U1f0s1; + break; + case WHICH.U1f1s1: + U1f1s1 = reader.U1f1s1; + break; + case WHICH.U1f0s8: + U1f0s8 = reader.U1f0s8; + break; + case WHICH.U1f1s8: + U1f1s8 = reader.U1f1s8; + break; + case WHICH.U1f0s16: + U1f0s16 = reader.U1f0s16; + break; + case WHICH.U1f1s16: + U1f1s16 = reader.U1f1s16; + break; + case WHICH.U1f0s32: + U1f0s32 = reader.U1f0s32; + break; + case WHICH.U1f1s32: + U1f1s32 = reader.U1f1s32; + break; + case WHICH.U1f0s64: + U1f0s64 = reader.U1f0s64; + break; + case WHICH.U1f1s64: + U1f1s64 = reader.U1f1s64; + break; + case WHICH.U1f0sp: + U1f0sp = reader.U1f0sp; + break; + case WHICH.U1f1sp: + U1f1sp = reader.U1f1sp; + break; + case WHICH.U1f2s0: + which = reader.which; + break; + case WHICH.U1f2s1: + U1f2s1 = reader.U1f2s1; + break; + case WHICH.U1f2s8: + U1f2s8 = reader.U1f2s8; + break; + case WHICH.U1f2s16: + U1f2s16 = reader.U1f2s16; + break; + case WHICH.U1f2s32: + U1f2s32 = reader.U1f2s32; + break; + case WHICH.U1f2s64: + U1f2s64 = reader.U1f2s64; + break; + case WHICH.U1f2sp: + U1f2sp = reader.U1f2sp; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.U1f0s0: + break; + case WHICH.U1f0s1: + _content = false; + break; + case WHICH.U1f1s1: + _content = false; + break; + case WHICH.U1f0s8: + _content = 0; + break; + case WHICH.U1f1s8: + _content = 0; + break; + case WHICH.U1f0s16: + _content = 0; + break; + case WHICH.U1f1s16: + _content = 0; + break; + case WHICH.U1f0s32: + _content = 0; + break; + case WHICH.U1f1s32: + _content = 0; + break; + case WHICH.U1f0s64: + _content = 0; + break; + case WHICH.U1f1s64: + _content = 0; + break; + case WHICH.U1f0sp: + _content = null; + break; + case WHICH.U1f1sp: + _content = null; + break; + case WHICH.U1f2s0: + break; + case WHICH.U1f2s1: + _content = false; + break; + case WHICH.U1f2s8: + _content = 0; + break; + case WHICH.U1f2s16: + _content = 0; + break; + case WHICH.U1f2s32: + _content = 0; + break; + case WHICH.U1f2s64: + _content = 0; + break; + case WHICH.U1f2sp: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.U1f0s0: + break; + case WHICH.U1f0s1: + writer.U1f0s1 = U1f0s1.Value; + break; + case WHICH.U1f1s1: + writer.U1f1s1 = U1f1s1.Value; + break; + case WHICH.U1f0s8: + writer.U1f0s8 = U1f0s8.Value; + break; + case WHICH.U1f1s8: + writer.U1f1s8 = U1f1s8.Value; + break; + case WHICH.U1f0s16: + writer.U1f0s16 = U1f0s16.Value; + break; + case WHICH.U1f1s16: + writer.U1f1s16 = U1f1s16.Value; + break; + case WHICH.U1f0s32: + writer.U1f0s32 = U1f0s32.Value; + break; + case WHICH.U1f1s32: + writer.U1f1s32 = U1f1s32.Value; + break; + case WHICH.U1f0s64: + writer.U1f0s64 = U1f0s64.Value; + break; + case WHICH.U1f1s64: + writer.U1f1s64 = U1f1s64.Value; + break; + case WHICH.U1f0sp: + writer.U1f0sp = U1f0sp; + break; + case WHICH.U1f1sp: + writer.U1f1sp = U1f1sp; + break; + case WHICH.U1f2s0: + break; + case WHICH.U1f2s1: + writer.U1f2s1 = U1f2s1.Value; + break; + case WHICH.U1f2s8: + writer.U1f2s8 = U1f2s8.Value; + break; + case WHICH.U1f2s16: + writer.U1f2s16 = U1f2s16.Value; + break; + case WHICH.U1f2s32: + writer.U1f2s32 = U1f2s32.Value; + break; + case WHICH.U1f2s64: + writer.U1f2s64 = U1f2s64.Value; + break; + case WHICH.U1f2sp: + writer.U1f2sp = U1f2sp; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool? U1f0s1 + { + get => _which == WHICH.U1f0s1 ? (bool? )_content : null; + set + { + _which = WHICH.U1f0s1; + _content = value; + } + } + + public bool? U1f1s1 + { + get => _which == WHICH.U1f1s1 ? (bool? )_content : null; + set + { + _which = WHICH.U1f1s1; + _content = value; + } + } + + public sbyte? U1f0s8 + { + get => _which == WHICH.U1f0s8 ? (sbyte? )_content : null; + set + { + _which = WHICH.U1f0s8; + _content = value; + } + } + + public sbyte? U1f1s8 + { + get => _which == WHICH.U1f1s8 ? (sbyte? )_content : null; + set + { + _which = WHICH.U1f1s8; + _content = value; + } + } + + public short? U1f0s16 + { + get => _which == WHICH.U1f0s16 ? (short? )_content : null; + set + { + _which = WHICH.U1f0s16; + _content = value; + } + } + + public short? U1f1s16 + { + get => _which == WHICH.U1f1s16 ? (short? )_content : null; + set + { + _which = WHICH.U1f1s16; + _content = value; + } + } + + public int? U1f0s32 + { + get => _which == WHICH.U1f0s32 ? (int? )_content : null; + set + { + _which = WHICH.U1f0s32; + _content = value; + } + } + + public int? U1f1s32 + { + get => _which == WHICH.U1f1s32 ? (int? )_content : null; + set + { + _which = WHICH.U1f1s32; + _content = value; + } + } + + public long? U1f0s64 + { + get => _which == WHICH.U1f0s64 ? (long? )_content : null; + set + { + _which = WHICH.U1f0s64; + _content = value; + } + } + + public long? U1f1s64 + { + get => _which == WHICH.U1f1s64 ? (long? )_content : null; + set + { + _which = WHICH.U1f1s64; + _content = value; + } + } + + public string U1f0sp + { + get => _which == WHICH.U1f0sp ? (string)_content : null; + set + { + _which = WHICH.U1f0sp; + _content = value; + } + } + + public string U1f1sp + { + get => _which == WHICH.U1f1sp ? (string)_content : null; + set + { + _which = WHICH.U1f1sp; + _content = value; + } + } + + public bool? U1f2s1 + { + get => _which == WHICH.U1f2s1 ? (bool? )_content : null; + set + { + _which = WHICH.U1f2s1; + _content = value; + } + } + + public sbyte? U1f2s8 + { + get => _which == WHICH.U1f2s8 ? (sbyte? )_content : null; + set + { + _which = WHICH.U1f2s8; + _content = value; + } + } + + public short? U1f2s16 + { + get => _which == WHICH.U1f2s16 ? (short? )_content : null; + set + { + _which = WHICH.U1f2s16; + _content = value; + } + } + + public int? U1f2s32 + { + get => _which == WHICH.U1f2s32 ? (int? )_content : null; + set + { + _which = WHICH.U1f2s32; + _content = value; + } + } + + public long? U1f2s64 + { + get => _which == WHICH.U1f2s64 ? (long? )_content : null; + set + { + _which = WHICH.U1f2s64; + _content = value; + } + } + + public string U1f2sp + { + get => _which == WHICH.U1f2sp ? (string)_content : null; + set + { + _which = WHICH.U1f2sp; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(16U, (ushort)0); + public bool U1f0s1 => which == WHICH.U1f0s1 ? ctx.ReadDataBool(129UL, false) : default; + public bool U1f1s1 => which == WHICH.U1f1s1 ? ctx.ReadDataBool(129UL, false) : default; + public sbyte U1f0s8 => which == WHICH.U1f0s8 ? ctx.ReadDataSByte(136UL, (sbyte)0) : default; + public sbyte U1f1s8 => which == WHICH.U1f1s8 ? ctx.ReadDataSByte(136UL, (sbyte)0) : default; + public short U1f0s16 => which == WHICH.U1f0s16 ? ctx.ReadDataShort(144UL, (short)0) : default; + public short U1f1s16 => which == WHICH.U1f1s16 ? ctx.ReadDataShort(144UL, (short)0) : default; + public int U1f0s32 => which == WHICH.U1f0s32 ? ctx.ReadDataInt(160UL, 0) : default; + public int U1f1s32 => which == WHICH.U1f1s32 ? ctx.ReadDataInt(160UL, 0) : default; + public long U1f0s64 => which == WHICH.U1f0s64 ? ctx.ReadDataLong(192UL, 0L) : default; + public long U1f1s64 => which == WHICH.U1f1s64 ? ctx.ReadDataLong(192UL, 0L) : default; + public string U1f0sp => which == WHICH.U1f0sp ? ctx.ReadText(1, "") : default; + public string U1f1sp => which == WHICH.U1f1sp ? ctx.ReadText(1, "") : default; + public bool U1f2s1 => which == WHICH.U1f2s1 ? ctx.ReadDataBool(129UL, false) : default; + public sbyte U1f2s8 => which == WHICH.U1f2s8 ? ctx.ReadDataSByte(136UL, (sbyte)0) : default; + public short U1f2s16 => which == WHICH.U1f2s16 ? ctx.ReadDataShort(144UL, (short)0) : default; + public int U1f2s32 => which == WHICH.U1f2s32 ? ctx.ReadDataInt(160UL, 0) : default; + public long U1f2s64 => which == WHICH.U1f2s64 ? ctx.ReadDataLong(192UL, 0L) : default; + public string U1f2sp => which == WHICH.U1f2sp ? ctx.ReadText(1, "") : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(16U, (ushort)0); + set => this.WriteData(16U, (ushort)value, (ushort)0); + } + + public bool U1f0s1 + { + get => which == WHICH.U1f0s1 ? this.ReadDataBool(129UL, false) : default; + set => this.WriteData(129UL, value, false); + } + + public bool U1f1s1 + { + get => which == WHICH.U1f1s1 ? this.ReadDataBool(129UL, false) : default; + set => this.WriteData(129UL, value, false); + } + + public sbyte U1f0s8 + { + get => which == WHICH.U1f0s8 ? this.ReadDataSByte(136UL, (sbyte)0) : default; + set => this.WriteData(136UL, value, (sbyte)0); + } + + public sbyte U1f1s8 + { + get => which == WHICH.U1f1s8 ? this.ReadDataSByte(136UL, (sbyte)0) : default; + set => this.WriteData(136UL, value, (sbyte)0); + } + + public short U1f0s16 + { + get => which == WHICH.U1f0s16 ? this.ReadDataShort(144UL, (short)0) : default; + set => this.WriteData(144UL, value, (short)0); + } + + public short U1f1s16 + { + get => which == WHICH.U1f1s16 ? this.ReadDataShort(144UL, (short)0) : default; + set => this.WriteData(144UL, value, (short)0); + } + + public int U1f0s32 + { + get => which == WHICH.U1f0s32 ? this.ReadDataInt(160UL, 0) : default; + set => this.WriteData(160UL, value, 0); + } + + public int U1f1s32 + { + get => which == WHICH.U1f1s32 ? this.ReadDataInt(160UL, 0) : default; + set => this.WriteData(160UL, value, 0); + } + + public long U1f0s64 + { + get => which == WHICH.U1f0s64 ? this.ReadDataLong(192UL, 0L) : default; + set => this.WriteData(192UL, value, 0L); + } + + public long U1f1s64 + { + get => which == WHICH.U1f1s64 ? this.ReadDataLong(192UL, 0L) : default; + set => this.WriteData(192UL, value, 0L); + } + + public string U1f0sp + { + get => which == WHICH.U1f0sp ? this.ReadText(1, "") : default; + set => this.WriteText(1, value, ""); + } + + public string U1f1sp + { + get => which == WHICH.U1f1sp ? this.ReadText(1, "") : default; + set => this.WriteText(1, value, ""); + } + + public bool U1f2s1 + { + get => which == WHICH.U1f2s1 ? this.ReadDataBool(129UL, false) : default; + set => this.WriteData(129UL, value, false); + } + + public sbyte U1f2s8 + { + get => which == WHICH.U1f2s8 ? this.ReadDataSByte(136UL, (sbyte)0) : default; + set => this.WriteData(136UL, value, (sbyte)0); + } + + public short U1f2s16 + { + get => which == WHICH.U1f2s16 ? this.ReadDataShort(144UL, (short)0) : default; + set => this.WriteData(144UL, value, (short)0); + } + + public int U1f2s32 + { + get => which == WHICH.U1f2s32 ? this.ReadDataInt(160UL, 0) : default; + set => this.WriteData(160UL, value, 0); + } + + public long U1f2s64 + { + get => which == WHICH.U1f2s64 ? this.ReadDataLong(192UL, 0L) : default; + set => this.WriteData(192UL, value, 0L); + } + + public string U1f2sp + { + get => which == WHICH.U1f2sp ? this.ReadText(1, "") : default; + set => this.WriteText(1, value, ""); + } + } + } + + public class @union2 : ICapnpSerializable + { + public enum WHICH : ushort + { + U2f0s1 = 0, + U2f0s8 = 1, + U2f0s16 = 2, + U2f0s32 = 3, + U2f0s64 = 4, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.U2f0s1: + U2f0s1 = reader.U2f0s1; + break; + case WHICH.U2f0s8: + U2f0s8 = reader.U2f0s8; + break; + case WHICH.U2f0s16: + U2f0s16 = reader.U2f0s16; + break; + case WHICH.U2f0s32: + U2f0s32 = reader.U2f0s32; + break; + case WHICH.U2f0s64: + U2f0s64 = reader.U2f0s64; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.U2f0s1: + _content = false; + break; + case WHICH.U2f0s8: + _content = 0; + break; + case WHICH.U2f0s16: + _content = 0; + break; + case WHICH.U2f0s32: + _content = 0; + break; + case WHICH.U2f0s64: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.U2f0s1: + writer.U2f0s1 = U2f0s1.Value; + break; + case WHICH.U2f0s8: + writer.U2f0s8 = U2f0s8.Value; + break; + case WHICH.U2f0s16: + writer.U2f0s16 = U2f0s16.Value; + break; + case WHICH.U2f0s32: + writer.U2f0s32 = U2f0s32.Value; + break; + case WHICH.U2f0s64: + writer.U2f0s64 = U2f0s64.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool? U2f0s1 + { + get => _which == WHICH.U2f0s1 ? (bool? )_content : null; + set + { + _which = WHICH.U2f0s1; + _content = value; + } + } + + public sbyte? U2f0s8 + { + get => _which == WHICH.U2f0s8 ? (sbyte? )_content : null; + set + { + _which = WHICH.U2f0s8; + _content = value; + } + } + + public short? U2f0s16 + { + get => _which == WHICH.U2f0s16 ? (short? )_content : null; + set + { + _which = WHICH.U2f0s16; + _content = value; + } + } + + public int? U2f0s32 + { + get => _which == WHICH.U2f0s32 ? (int? )_content : null; + set + { + _which = WHICH.U2f0s32; + _content = value; + } + } + + public long? U2f0s64 + { + get => _which == WHICH.U2f0s64 ? (long? )_content : null; + set + { + _which = WHICH.U2f0s64; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(32U, (ushort)0); + public bool U2f0s1 => which == WHICH.U2f0s1 ? ctx.ReadDataBool(256UL, false) : default; + public sbyte U2f0s8 => which == WHICH.U2f0s8 ? ctx.ReadDataSByte(264UL, (sbyte)0) : default; + public short U2f0s16 => which == WHICH.U2f0s16 ? ctx.ReadDataShort(288UL, (short)0) : default; + public int U2f0s32 => which == WHICH.U2f0s32 ? ctx.ReadDataInt(320UL, 0) : default; + public long U2f0s64 => which == WHICH.U2f0s64 ? ctx.ReadDataLong(384UL, 0L) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(32U, (ushort)0); + set => this.WriteData(32U, (ushort)value, (ushort)0); + } + + public bool U2f0s1 + { + get => which == WHICH.U2f0s1 ? this.ReadDataBool(256UL, false) : default; + set => this.WriteData(256UL, value, false); + } + + public sbyte U2f0s8 + { + get => which == WHICH.U2f0s8 ? this.ReadDataSByte(264UL, (sbyte)0) : default; + set => this.WriteData(264UL, value, (sbyte)0); + } + + public short U2f0s16 + { + get => which == WHICH.U2f0s16 ? this.ReadDataShort(288UL, (short)0) : default; + set => this.WriteData(288UL, value, (short)0); + } + + public int U2f0s32 + { + get => which == WHICH.U2f0s32 ? this.ReadDataInt(320UL, 0) : default; + set => this.WriteData(320UL, value, 0); + } + + public long U2f0s64 + { + get => which == WHICH.U2f0s64 ? this.ReadDataLong(384UL, 0L) : default; + set => this.WriteData(384UL, value, 0L); + } + } + } + + public class @union3 : ICapnpSerializable + { + public enum WHICH : ushort + { + U3f0s1 = 0, + U3f0s8 = 1, + U3f0s16 = 2, + U3f0s32 = 3, + U3f0s64 = 4, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.U3f0s1: + U3f0s1 = reader.U3f0s1; + break; + case WHICH.U3f0s8: + U3f0s8 = reader.U3f0s8; + break; + case WHICH.U3f0s16: + U3f0s16 = reader.U3f0s16; + break; + case WHICH.U3f0s32: + U3f0s32 = reader.U3f0s32; + break; + case WHICH.U3f0s64: + U3f0s64 = reader.U3f0s64; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.U3f0s1: + _content = false; + break; + case WHICH.U3f0s8: + _content = 0; + break; + case WHICH.U3f0s16: + _content = 0; + break; + case WHICH.U3f0s32: + _content = 0; + break; + case WHICH.U3f0s64: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.U3f0s1: + writer.U3f0s1 = U3f0s1.Value; + break; + case WHICH.U3f0s8: + writer.U3f0s8 = U3f0s8.Value; + break; + case WHICH.U3f0s16: + writer.U3f0s16 = U3f0s16.Value; + break; + case WHICH.U3f0s32: + writer.U3f0s32 = U3f0s32.Value; + break; + case WHICH.U3f0s64: + writer.U3f0s64 = U3f0s64.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool? U3f0s1 + { + get => _which == WHICH.U3f0s1 ? (bool? )_content : null; + set + { + _which = WHICH.U3f0s1; + _content = value; + } + } + + public sbyte? U3f0s8 + { + get => _which == WHICH.U3f0s8 ? (sbyte? )_content : null; + set + { + _which = WHICH.U3f0s8; + _content = value; + } + } + + public short? U3f0s16 + { + get => _which == WHICH.U3f0s16 ? (short? )_content : null; + set + { + _which = WHICH.U3f0s16; + _content = value; + } + } + + public int? U3f0s32 + { + get => _which == WHICH.U3f0s32 ? (int? )_content : null; + set + { + _which = WHICH.U3f0s32; + _content = value; + } + } + + public long? U3f0s64 + { + get => _which == WHICH.U3f0s64 ? (long? )_content : null; + set + { + _which = WHICH.U3f0s64; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(48U, (ushort)0); + public bool U3f0s1 => which == WHICH.U3f0s1 ? ctx.ReadDataBool(257UL, false) : default; + public sbyte U3f0s8 => which == WHICH.U3f0s8 ? ctx.ReadDataSByte(272UL, (sbyte)0) : default; + public short U3f0s16 => which == WHICH.U3f0s16 ? ctx.ReadDataShort(304UL, (short)0) : default; + public int U3f0s32 => which == WHICH.U3f0s32 ? ctx.ReadDataInt(352UL, 0) : default; + public long U3f0s64 => which == WHICH.U3f0s64 ? ctx.ReadDataLong(448UL, 0L) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(48U, (ushort)0); + set => this.WriteData(48U, (ushort)value, (ushort)0); + } + + public bool U3f0s1 + { + get => which == WHICH.U3f0s1 ? this.ReadDataBool(257UL, false) : default; + set => this.WriteData(257UL, value, false); + } + + public sbyte U3f0s8 + { + get => which == WHICH.U3f0s8 ? this.ReadDataSByte(272UL, (sbyte)0) : default; + set => this.WriteData(272UL, value, (sbyte)0); + } + + public short U3f0s16 + { + get => which == WHICH.U3f0s16 ? this.ReadDataShort(304UL, (short)0) : default; + set => this.WriteData(304UL, value, (short)0); + } + + public int U3f0s32 + { + get => which == WHICH.U3f0s32 ? this.ReadDataInt(352UL, 0) : default; + set => this.WriteData(352UL, value, 0); + } + + public long U3f0s64 + { + get => which == WHICH.U3f0s64 ? this.ReadDataLong(448UL, 0L) : default; + set => this.WriteData(448UL, value, 0L); + } + } + } + } + + public class TestUnnamedUnion : ICapnpSerializable + { + public enum WHICH : ushort + { + Foo = 0, + Bar = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Foo: + Foo = reader.Foo; + break; + case WHICH.Bar: + Bar = reader.Bar; + break; + } + + Before = reader.Before; + Middle = reader.Middle; + After = reader.After; + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Foo: + _content = 0; + break; + case WHICH.Bar: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Foo: + writer.Foo = Foo.Value; + break; + case WHICH.Bar: + writer.Bar = Bar.Value; + break; + } + + writer.Before = Before; + writer.Middle = Middle; + writer.After = After; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Before + { + get; + set; + } + + public ushort? Foo + { + get => _which == WHICH.Foo ? (ushort? )_content : null; + set + { + _which = WHICH.Foo; + _content = value; + } + } + + public ushort Middle + { + get; + set; + } + + public uint? Bar + { + get => _which == WHICH.Bar ? (uint? )_content : null; + set + { + _which = WHICH.Bar; + _content = value; + } + } + + public string After + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(32U, (ushort)0); + public string Before => ctx.ReadText(0, ""); + public ushort Foo => which == WHICH.Foo ? ctx.ReadDataUShort(0UL, (ushort)0) : default; + public ushort Middle => ctx.ReadDataUShort(16UL, (ushort)0); + public uint Bar => which == WHICH.Bar ? ctx.ReadDataUInt(64UL, 0U) : default; + public string After => ctx.ReadText(1, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(2, 2); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(32U, (ushort)0); + set => this.WriteData(32U, (ushort)value, (ushort)0); + } + + public string Before + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public ushort Foo + { + get => which == WHICH.Foo ? this.ReadDataUShort(0UL, (ushort)0) : default; + set => this.WriteData(0UL, value, (ushort)0); + } + + public ushort Middle + { + get => this.ReadDataUShort(16UL, (ushort)0); + set => this.WriteData(16UL, value, (ushort)0); + } + + public uint Bar + { + get => which == WHICH.Bar ? this.ReadDataUInt(64UL, 0U) : default; + set => this.WriteData(64UL, value, 0U); + } + + public string After + { + get => this.ReadText(1, ""); + set => this.WriteText(1, value, ""); + } + } + } + + public class TestUnionInUnion : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Outer = CapnpSerializable.Create(reader.Outer); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Outer?.serialize(writer.Outer); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestUnionInUnion.@outer Outer + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public @outer.READER Outer => new @outer.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(2, 0); + } + + public @outer.WRITER Outer + { + get => Rewrap<@outer.WRITER>(); + } + } + + public class @outer : ICapnpSerializable + { + public enum WHICH : ushort + { + Inner = 0, + Baz = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Inner: + Inner = CapnpSerializable.Create(reader.Inner); + break; + case WHICH.Baz: + Baz = reader.Baz; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Inner: + _content = null; + break; + case WHICH.Baz: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Inner: + Inner?.serialize(writer.Inner); + break; + case WHICH.Baz: + writer.Baz = Baz.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestUnionInUnion.@outer.@inner Inner + { + get => _which == WHICH.Inner ? (Capnproto_test.Capnp.Test.TestUnionInUnion.@outer.@inner)_content : null; + set + { + _which = WHICH.Inner; + _content = value; + } + } + + public int? Baz + { + get => _which == WHICH.Baz ? (int? )_content : null; + set + { + _which = WHICH.Baz; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(64U, (ushort)0); + public @inner.READER Inner => which == WHICH.Inner ? new @inner.READER(ctx) : default; + public int Baz => which == WHICH.Baz ? ctx.ReadDataInt(0UL, 0) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(64U, (ushort)0); + set => this.WriteData(64U, (ushort)value, (ushort)0); + } + + public @inner.WRITER Inner + { + get => which == WHICH.Inner ? Rewrap<@inner.WRITER>() : default; + } + + public int Baz + { + get => which == WHICH.Baz ? this.ReadDataInt(0UL, 0) : default; + set => this.WriteData(0UL, value, 0); + } + } + + public class @inner : ICapnpSerializable + { + public enum WHICH : ushort + { + Foo = 0, + Bar = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Foo: + Foo = reader.Foo; + break; + case WHICH.Bar: + Bar = reader.Bar; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Foo: + _content = 0; + break; + case WHICH.Bar: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Foo: + writer.Foo = Foo.Value; + break; + case WHICH.Bar: + writer.Bar = Bar.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public int? Foo + { + get => _which == WHICH.Foo ? (int? )_content : null; + set + { + _which = WHICH.Foo; + _content = value; + } + } + + public int? Bar + { + get => _which == WHICH.Bar ? (int? )_content : null; + set + { + _which = WHICH.Bar; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(32U, (ushort)0); + public int Foo => which == WHICH.Foo ? ctx.ReadDataInt(0UL, 0) : default; + public int Bar => which == WHICH.Bar ? ctx.ReadDataInt(0UL, 0) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(32U, (ushort)0); + set => this.WriteData(32U, (ushort)value, (ushort)0); + } + + public int Foo + { + get => which == WHICH.Foo ? this.ReadDataInt(0UL, 0) : default; + set => this.WriteData(0UL, value, 0); + } + + public int Bar + { + get => which == WHICH.Bar ? this.ReadDataInt(0UL, 0) : default; + set => this.WriteData(0UL, value, 0); + } + } + } + } + } + + public class TestGroups : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Groups = CapnpSerializable.Create(reader.Groups); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Groups?.serialize(writer.Groups); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestGroups.@groups Groups + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public @groups.READER Groups => new @groups.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(2, 2); + } + + public @groups.WRITER Groups + { + get => Rewrap<@groups.WRITER>(); + } + } + + public class @groups : ICapnpSerializable + { + public enum WHICH : ushort + { + Foo = 0, + Baz = 1, + Bar = 2, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Foo: + Foo = CapnpSerializable.Create(reader.Foo); + break; + case WHICH.Baz: + Baz = CapnpSerializable.Create(reader.Baz); + break; + case WHICH.Bar: + Bar = CapnpSerializable.Create(reader.Bar); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Foo: + _content = null; + break; + case WHICH.Baz: + _content = null; + break; + case WHICH.Bar: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Foo: + Foo?.serialize(writer.Foo); + break; + case WHICH.Baz: + Baz?.serialize(writer.Baz); + break; + case WHICH.Bar: + Bar?.serialize(writer.Bar); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestGroups.@groups.@foo Foo + { + get => _which == WHICH.Foo ? (Capnproto_test.Capnp.Test.TestGroups.@groups.@foo)_content : null; + set + { + _which = WHICH.Foo; + _content = value; + } + } + + public Capnproto_test.Capnp.Test.TestGroups.@groups.@baz Baz + { + get => _which == WHICH.Baz ? (Capnproto_test.Capnp.Test.TestGroups.@groups.@baz)_content : null; + set + { + _which = WHICH.Baz; + _content = value; + } + } + + public Capnproto_test.Capnp.Test.TestGroups.@groups.@bar Bar + { + get => _which == WHICH.Bar ? (Capnproto_test.Capnp.Test.TestGroups.@groups.@bar)_content : null; + set + { + _which = WHICH.Bar; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(32U, (ushort)0); + public @foo.READER Foo => which == WHICH.Foo ? new @foo.READER(ctx) : default; + public @baz.READER Baz => which == WHICH.Baz ? new @baz.READER(ctx) : default; + public @bar.READER Bar => which == WHICH.Bar ? new @bar.READER(ctx) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(32U, (ushort)0); + set => this.WriteData(32U, (ushort)value, (ushort)0); + } + + public @foo.WRITER Foo + { + get => which == WHICH.Foo ? Rewrap<@foo.WRITER>() : default; + } + + public @baz.WRITER Baz + { + get => which == WHICH.Baz ? Rewrap<@baz.WRITER>() : default; + } + + public @bar.WRITER Bar + { + get => which == WHICH.Bar ? Rewrap<@bar.WRITER>() : default; + } + } + + public class @foo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Corge = reader.Corge; + Grault = reader.Grault; + Garply = reader.Garply; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Corge = Corge; + writer.Grault = Grault; + writer.Garply = Garply; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public int Corge + { + get; + set; + } + + public long Grault + { + get; + set; + } + + public string Garply + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public int Corge => ctx.ReadDataInt(0UL, 0); + public long Grault => ctx.ReadDataLong(64UL, 0L); + public string Garply => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public int Corge + { + get => this.ReadDataInt(0UL, 0); + set => this.WriteData(0UL, value, 0); + } + + public long Grault + { + get => this.ReadDataLong(64UL, 0L); + set => this.WriteData(64UL, value, 0L); + } + + public string Garply + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class @baz : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Corge = reader.Corge; + Grault = reader.Grault; + Garply = reader.Garply; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Corge = Corge; + writer.Grault = Grault; + writer.Garply = Garply; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public int Corge + { + get; + set; + } + + public string Grault + { + get; + set; + } + + public string Garply + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public int Corge => ctx.ReadDataInt(0UL, 0); + public string Grault => ctx.ReadText(0, ""); + public string Garply => ctx.ReadText(1, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public int Corge + { + get => this.ReadDataInt(0UL, 0); + set => this.WriteData(0UL, value, 0); + } + + public string Grault + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public string Garply + { + get => this.ReadText(1, ""); + set => this.WriteText(1, value, ""); + } + } + } + + public class @bar : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Corge = reader.Corge; + Grault = reader.Grault; + Garply = reader.Garply; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Corge = Corge; + writer.Grault = Grault; + writer.Garply = Garply; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public int Corge + { + get; + set; + } + + public string Grault + { + get; + set; + } + + public long Garply + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public int Corge => ctx.ReadDataInt(0UL, 0); + public string Grault => ctx.ReadText(0, ""); + public long Garply => ctx.ReadDataLong(64UL, 0L); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public int Corge + { + get => this.ReadDataInt(0UL, 0); + set => this.WriteData(0UL, value, 0); + } + + public string Grault + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public long Garply + { + get => this.ReadDataLong(64UL, 0L); + set => this.WriteData(64UL, value, 0L); + } + } + } + } + } + + public class TestInterleavedGroups : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Group1 = CapnpSerializable.Create(reader.Group1); + Group2 = CapnpSerializable.Create(reader.Group2); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Group1?.serialize(writer.Group1); + Group2?.serialize(writer.Group2); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestInterleavedGroups.@group1 Group1 + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestInterleavedGroups.@group2 Group2 + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public @group1.READER Group1 => new @group1.READER(ctx); + public @group2.READER Group2 => new @group2.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(6, 6); + } + + public @group1.WRITER Group1 + { + get => Rewrap<@group1.WRITER>(); + } + + public @group2.WRITER Group2 + { + get => Rewrap<@group2.WRITER>(); + } + } + + public class @group1 : ICapnpSerializable + { + public enum WHICH : ushort + { + Qux = 0, + Corge = 1, + Fred = 2, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Qux: + Qux = reader.Qux; + break; + case WHICH.Corge: + Corge = CapnpSerializable.Create(reader.Corge); + break; + case WHICH.Fred: + Fred = reader.Fred; + break; + } + + Foo = reader.Foo; + Bar = reader.Bar; + Waldo = reader.Waldo; + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Qux: + _content = 0; + break; + case WHICH.Corge: + _content = null; + break; + case WHICH.Fred: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Qux: + writer.Qux = Qux.Value; + break; + case WHICH.Corge: + Corge?.serialize(writer.Corge); + break; + case WHICH.Fred: + writer.Fred = Fred; + break; + } + + writer.Foo = Foo; + writer.Bar = Bar; + writer.Waldo = Waldo; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint Foo + { + get; + set; + } + + public ulong Bar + { + get; + set; + } + + public ushort? Qux + { + get => _which == WHICH.Qux ? (ushort? )_content : null; + set + { + _which = WHICH.Qux; + _content = value; + } + } + + public Capnproto_test.Capnp.Test.TestInterleavedGroups.@group1.@corge Corge + { + get => _which == WHICH.Corge ? (Capnproto_test.Capnp.Test.TestInterleavedGroups.@group1.@corge)_content : null; + set + { + _which = WHICH.Corge; + _content = value; + } + } + + public string Waldo + { + get; + set; + } + + public string Fred + { + get => _which == WHICH.Fred ? (string)_content : null; + set + { + _which = WHICH.Fred; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(224U, (ushort)0); + public uint Foo => ctx.ReadDataUInt(0UL, 0U); + public ulong Bar => ctx.ReadDataULong(64UL, 0UL); + public ushort Qux => which == WHICH.Qux ? ctx.ReadDataUShort(192UL, (ushort)0) : default; + public @corge.READER Corge => which == WHICH.Corge ? new @corge.READER(ctx) : default; + public string Waldo => ctx.ReadText(0, ""); + public string Fred => which == WHICH.Fred ? ctx.ReadText(2, "") : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(224U, (ushort)0); + set => this.WriteData(224U, (ushort)value, (ushort)0); + } + + public uint Foo + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public ulong Bar + { + get => this.ReadDataULong(64UL, 0UL); + set => this.WriteData(64UL, value, 0UL); + } + + public ushort Qux + { + get => which == WHICH.Qux ? this.ReadDataUShort(192UL, (ushort)0) : default; + set => this.WriteData(192UL, value, (ushort)0); + } + + public @corge.WRITER Corge + { + get => which == WHICH.Corge ? Rewrap<@corge.WRITER>() : default; + } + + public string Waldo + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public string Fred + { + get => which == WHICH.Fred ? this.ReadText(2, "") : default; + set => this.WriteText(2, value, ""); + } + } + + public class @corge : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Grault = reader.Grault; + Garply = reader.Garply; + Plugh = reader.Plugh; + Xyzzy = reader.Xyzzy; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Grault = Grault; + writer.Garply = Garply; + writer.Plugh = Plugh; + writer.Xyzzy = Xyzzy; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong Grault + { + get; + set; + } + + public ushort Garply + { + get; + set; + } + + public string Plugh + { + get; + set; + } + + public string Xyzzy + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong Grault => ctx.ReadDataULong(256UL, 0UL); + public ushort Garply => ctx.ReadDataUShort(192UL, (ushort)0); + public string Plugh => ctx.ReadText(2, ""); + public string Xyzzy => ctx.ReadText(4, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public ulong Grault + { + get => this.ReadDataULong(256UL, 0UL); + set => this.WriteData(256UL, value, 0UL); + } + + public ushort Garply + { + get => this.ReadDataUShort(192UL, (ushort)0); + set => this.WriteData(192UL, value, (ushort)0); + } + + public string Plugh + { + get => this.ReadText(2, ""); + set => this.WriteText(2, value, ""); + } + + public string Xyzzy + { + get => this.ReadText(4, ""); + set => this.WriteText(4, value, ""); + } + } + } + } + + public class @group2 : ICapnpSerializable + { + public enum WHICH : ushort + { + Qux = 0, + Corge = 1, + Fred = 2, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Qux: + Qux = reader.Qux; + break; + case WHICH.Corge: + Corge = CapnpSerializable.Create(reader.Corge); + break; + case WHICH.Fred: + Fred = reader.Fred; + break; + } + + Foo = reader.Foo; + Bar = reader.Bar; + Waldo = reader.Waldo; + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Qux: + _content = 0; + break; + case WHICH.Corge: + _content = null; + break; + case WHICH.Fred: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Qux: + writer.Qux = Qux.Value; + break; + case WHICH.Corge: + Corge?.serialize(writer.Corge); + break; + case WHICH.Fred: + writer.Fred = Fred; + break; + } + + writer.Foo = Foo; + writer.Bar = Bar; + writer.Waldo = Waldo; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint Foo + { + get; + set; + } + + public ulong Bar + { + get; + set; + } + + public ushort? Qux + { + get => _which == WHICH.Qux ? (ushort? )_content : null; + set + { + _which = WHICH.Qux; + _content = value; + } + } + + public Capnproto_test.Capnp.Test.TestInterleavedGroups.@group2.@corge Corge + { + get => _which == WHICH.Corge ? (Capnproto_test.Capnp.Test.TestInterleavedGroups.@group2.@corge)_content : null; + set + { + _which = WHICH.Corge; + _content = value; + } + } + + public string Waldo + { + get; + set; + } + + public string Fred + { + get => _which == WHICH.Fred ? (string)_content : null; + set + { + _which = WHICH.Fred; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(240U, (ushort)0); + public uint Foo => ctx.ReadDataUInt(32UL, 0U); + public ulong Bar => ctx.ReadDataULong(128UL, 0UL); + public ushort Qux => which == WHICH.Qux ? ctx.ReadDataUShort(208UL, (ushort)0) : default; + public @corge.READER Corge => which == WHICH.Corge ? new @corge.READER(ctx) : default; + public string Waldo => ctx.ReadText(1, ""); + public string Fred => which == WHICH.Fred ? ctx.ReadText(3, "") : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(240U, (ushort)0); + set => this.WriteData(240U, (ushort)value, (ushort)0); + } + + public uint Foo + { + get => this.ReadDataUInt(32UL, 0U); + set => this.WriteData(32UL, value, 0U); + } + + public ulong Bar + { + get => this.ReadDataULong(128UL, 0UL); + set => this.WriteData(128UL, value, 0UL); + } + + public ushort Qux + { + get => which == WHICH.Qux ? this.ReadDataUShort(208UL, (ushort)0) : default; + set => this.WriteData(208UL, value, (ushort)0); + } + + public @corge.WRITER Corge + { + get => which == WHICH.Corge ? Rewrap<@corge.WRITER>() : default; + } + + public string Waldo + { + get => this.ReadText(1, ""); + set => this.WriteText(1, value, ""); + } + + public string Fred + { + get => which == WHICH.Fred ? this.ReadText(3, "") : default; + set => this.WriteText(3, value, ""); + } + } + + public class @corge : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Grault = reader.Grault; + Garply = reader.Garply; + Plugh = reader.Plugh; + Xyzzy = reader.Xyzzy; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Grault = Grault; + writer.Garply = Garply; + writer.Plugh = Plugh; + writer.Xyzzy = Xyzzy; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong Grault + { + get; + set; + } + + public ushort Garply + { + get; + set; + } + + public string Plugh + { + get; + set; + } + + public string Xyzzy + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong Grault => ctx.ReadDataULong(320UL, 0UL); + public ushort Garply => ctx.ReadDataUShort(208UL, (ushort)0); + public string Plugh => ctx.ReadText(3, ""); + public string Xyzzy => ctx.ReadText(5, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public ulong Grault + { + get => this.ReadDataULong(320UL, 0UL); + set => this.WriteData(320UL, value, 0UL); + } + + public ushort Garply + { + get => this.ReadDataUShort(208UL, (ushort)0); + set => this.WriteData(208UL, value, (ushort)0); + } + + public string Plugh + { + get => this.ReadText(3, ""); + set => this.WriteText(3, value, ""); + } + + public string Xyzzy + { + get => this.ReadText(5, ""); + set => this.WriteText(5, value, ""); + } + } + } + } + } + + public class TestUnionDefaults : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + S16s8s64s8Set = CapnpSerializable.Create(reader.S16s8s64s8Set); + S0sps1s32Set = CapnpSerializable.Create(reader.S0sps1s32Set); + Unnamed1 = CapnpSerializable.Create(reader.Unnamed1); + Unnamed2 = CapnpSerializable.Create(reader.Unnamed2); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + S16s8s64s8Set?.serialize(writer.S16s8s64s8Set); + S0sps1s32Set?.serialize(writer.S0sps1s32Set); + Unnamed1?.serialize(writer.Unnamed1); + Unnamed2?.serialize(writer.Unnamed2); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + S16s8s64s8Set = S16s8s64s8Set ?? new Capnproto_test.Capnp.Test.TestUnion() + {Union0 = new Capnproto_test.Capnp.Test.TestUnion.@union0() + {}, Union1 = new Capnproto_test.Capnp.Test.TestUnion.@union1() + {}, Union2 = new Capnproto_test.Capnp.Test.TestUnion.@union2() + {}, Union3 = new Capnproto_test.Capnp.Test.TestUnion.@union3() + {}, Bit0 = false, Bit2 = false, Bit3 = false, Bit4 = false, Bit5 = false, Bit6 = false, Bit7 = false, Byte0 = 0}; + S0sps1s32Set = S0sps1s32Set ?? new Capnproto_test.Capnp.Test.TestUnion() + {Union0 = new Capnproto_test.Capnp.Test.TestUnion.@union0() + {}, Union1 = new Capnproto_test.Capnp.Test.TestUnion.@union1() + {}, Union2 = new Capnproto_test.Capnp.Test.TestUnion.@union2() + {}, Union3 = new Capnproto_test.Capnp.Test.TestUnion.@union3() + {}, Bit0 = false, Bit2 = false, Bit3 = false, Bit4 = false, Bit5 = false, Bit6 = false, Bit7 = false, Byte0 = 0}; + Unnamed1 = Unnamed1 ?? new Capnproto_test.Capnp.Test.TestUnnamedUnion() + {Before = null, Middle = 0, After = null}; + Unnamed2 = Unnamed2 ?? new Capnproto_test.Capnp.Test.TestUnnamedUnion() + {Before = "foo", Middle = 0, After = "bar"}; + } + + public Capnproto_test.Capnp.Test.TestUnion S16s8s64s8Set + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestUnion S0sps1s32Set + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestUnnamedUnion Unnamed1 + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestUnnamedUnion Unnamed2 + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestUnion.READER S16s8s64s8Set => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestUnion.READER.create); + public Capnproto_test.Capnp.Test.TestUnion.READER S0sps1s32Set => ctx.ReadStruct(1, Capnproto_test.Capnp.Test.TestUnion.READER.create); + public Capnproto_test.Capnp.Test.TestUnnamedUnion.READER Unnamed1 => ctx.ReadStruct(2, Capnproto_test.Capnp.Test.TestUnnamedUnion.READER.create); + public Capnproto_test.Capnp.Test.TestUnnamedUnion.READER Unnamed2 => ctx.ReadStruct(3, Capnproto_test.Capnp.Test.TestUnnamedUnion.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 4); + } + + public Capnproto_test.Capnp.Test.TestUnion.WRITER S16s8s64s8Set + { + get => BuildPointer(0); + set => Link(0, value); + } + + public Capnproto_test.Capnp.Test.TestUnion.WRITER S0sps1s32Set + { + get => BuildPointer(1); + set => Link(1, value); + } + + public Capnproto_test.Capnp.Test.TestUnnamedUnion.WRITER Unnamed1 + { + get => BuildPointer(2); + set => Link(2, value); + } + + public Capnproto_test.Capnp.Test.TestUnnamedUnion.WRITER Unnamed2 + { + get => BuildPointer(3); + set => Link(3, value); + } + } + } + + public class TestNestedTypes : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + TheNestedStruct = CapnpSerializable.Create(reader.TheNestedStruct); + OuterNestedEnum = reader.OuterNestedEnum; + InnerNestedEnum = reader.InnerNestedEnum; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + TheNestedStruct?.serialize(writer.TheNestedStruct); + writer.OuterNestedEnum = OuterNestedEnum; + writer.InnerNestedEnum = InnerNestedEnum; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct TheNestedStruct + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum OuterNestedEnum + { + get; + set; + } + + = Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum.bar; + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum InnerNestedEnum + { + get; + set; + } + + = Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum.quux; + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.READER TheNestedStruct => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.READER.create); + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum OuterNestedEnum => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum)ctx.ReadDataUShort(0UL, (ushort)1); + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum InnerNestedEnum => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum)ctx.ReadDataUShort(16UL, (ushort)2); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.WRITER TheNestedStruct + { + get => BuildPointer(0); + set => Link(0, value); + } + + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum OuterNestedEnum + { + get => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum)this.ReadDataUShort(0UL, (ushort)1); + set => this.WriteData(0UL, (ushort)value, (ushort)1); + } + + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum InnerNestedEnum + { + get => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum)this.ReadDataUShort(16UL, (ushort)2); + set => this.WriteData(16UL, (ushort)value, (ushort)2); + } + } + + public enum NestedEnum : ushort + { + foo, + bar + } + + public class NestedStruct : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + OuterNestedEnum = reader.OuterNestedEnum; + InnerNestedEnum = reader.InnerNestedEnum; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.OuterNestedEnum = OuterNestedEnum; + writer.InnerNestedEnum = InnerNestedEnum; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum OuterNestedEnum + { + get; + set; + } + + = Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum.bar; + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum InnerNestedEnum + { + get; + set; + } + + = Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum.quux; + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum OuterNestedEnum => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum)ctx.ReadDataUShort(0UL, (ushort)1); + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum InnerNestedEnum => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum)ctx.ReadDataUShort(16UL, (ushort)2); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum OuterNestedEnum + { + get => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum)this.ReadDataUShort(0UL, (ushort)1); + set => this.WriteData(0UL, (ushort)value, (ushort)1); + } + + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum InnerNestedEnum + { + get => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum)this.ReadDataUShort(16UL, (ushort)2); + set => this.WriteData(16UL, (ushort)value, (ushort)2); + } + } + + public enum NestedEnum : ushort + { + baz, + qux, + quux + } + } + } + + public class TestUsing : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + InnerNestedEnum = reader.InnerNestedEnum; + OuterNestedEnum = reader.OuterNestedEnum; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.InnerNestedEnum = InnerNestedEnum; + writer.OuterNestedEnum = OuterNestedEnum; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum InnerNestedEnum + { + get; + set; + } + + = Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum.quux; + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum OuterNestedEnum + { + get; + set; + } + + = Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum.bar; + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum InnerNestedEnum => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum)ctx.ReadDataUShort(0UL, (ushort)2); + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum OuterNestedEnum => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum)ctx.ReadDataUShort(16UL, (ushort)1); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum InnerNestedEnum + { + get => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedStruct.NestedEnum)this.ReadDataUShort(0UL, (ushort)2); + set => this.WriteData(0UL, (ushort)value, (ushort)2); + } + + public Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum OuterNestedEnum + { + get => (Capnproto_test.Capnp.Test.TestNestedTypes.NestedEnum)this.ReadDataUShort(16UL, (ushort)1); + set => this.WriteData(16UL, (ushort)value, (ushort)1); + } + } + } + + public class TestLists : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + List0 = reader.List0.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + List1 = reader.List1.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + List8 = reader.List8.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + List16 = reader.List16.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + List32 = reader.List32.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + List64 = reader.List64.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + ListP = reader.ListP.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + Int32ListList = reader.Int32ListList; + TextListList = reader.TextListList; + StructListList = reader.StructListList.ToReadOnlyList(_2 => _2.ToReadOnlyList(_ => CapnpSerializable.Create(_))); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.List0.Init(List0, (_s1, _v1) => _v1?.serialize(_s1)); + writer.List1.Init(List1, (_s1, _v1) => _v1?.serialize(_s1)); + writer.List8.Init(List8, (_s1, _v1) => _v1?.serialize(_s1)); + writer.List16.Init(List16, (_s1, _v1) => _v1?.serialize(_s1)); + writer.List32.Init(List32, (_s1, _v1) => _v1?.serialize(_s1)); + writer.List64.Init(List64, (_s1, _v1) => _v1?.serialize(_s1)); + writer.ListP.Init(ListP, (_s1, _v1) => _v1?.serialize(_s1)); + writer.Int32ListList.Init(Int32ListList, (_s2, _v2) => _s2.Init(_v2)); + writer.TextListList.Init(TextListList, (_s2, _v2) => _s2.Init(_v2)); + writer.StructListList.Init(StructListList, (_s2, _v2) => _s2.Init(_v2, (_s1, _v1) => _v1?.serialize(_s1))); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public IReadOnlyList List0 + { + get; + set; + } + + public IReadOnlyList List1 + { + get; + set; + } + + public IReadOnlyList List8 + { + get; + set; + } + + public IReadOnlyList List16 + { + get; + set; + } + + public IReadOnlyList List32 + { + get; + set; + } + + public IReadOnlyList List64 + { + get; + set; + } + + public IReadOnlyList ListP + { + get; + set; + } + + public IReadOnlyList> Int32ListList + { + get; + set; + } + + public IReadOnlyList> TextListList + { + get; + set; + } + + public IReadOnlyList> StructListList + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public IReadOnlyList List0 => ctx.ReadList(0).Cast(Capnproto_test.Capnp.Test.TestLists.Struct0.READER.create); + public IReadOnlyList List1 => ctx.ReadList(1).Cast(Capnproto_test.Capnp.Test.TestLists.Struct1.READER.create); + public IReadOnlyList List8 => ctx.ReadList(2).Cast(Capnproto_test.Capnp.Test.TestLists.Struct8.READER.create); + public IReadOnlyList List16 => ctx.ReadList(3).Cast(Capnproto_test.Capnp.Test.TestLists.Struct16.READER.create); + public IReadOnlyList List32 => ctx.ReadList(4).Cast(Capnproto_test.Capnp.Test.TestLists.Struct32.READER.create); + public IReadOnlyList List64 => ctx.ReadList(5).Cast(Capnproto_test.Capnp.Test.TestLists.Struct64.READER.create); + public IReadOnlyList ListP => ctx.ReadList(6).Cast(Capnproto_test.Capnp.Test.TestLists.StructP.READER.create); + public IReadOnlyList> Int32ListList => ctx.ReadList(7).Cast(_0 => _0.RequireList().CastInt()); + public IReadOnlyList> TextListList => ctx.ReadList(8).Cast(_0 => _0.RequireList().CastText2()); + public IReadOnlyList> StructListList => ctx.ReadList(9).Cast(_0 => _0.RequireList().Cast(Capnproto_test.Capnp.Test.TestAllTypes.READER.create)); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 10); + } + + public ListOfStructsSerializer List0 + { + get => BuildPointer>(0); + set => Link(0, value); + } + + public ListOfStructsSerializer List1 + { + get => BuildPointer>(1); + set => Link(1, value); + } + + public ListOfStructsSerializer List8 + { + get => BuildPointer>(2); + set => Link(2, value); + } + + public ListOfStructsSerializer List16 + { + get => BuildPointer>(3); + set => Link(3, value); + } + + public ListOfStructsSerializer List32 + { + get => BuildPointer>(4); + set => Link(4, value); + } + + public ListOfStructsSerializer List64 + { + get => BuildPointer>(5); + set => Link(5, value); + } + + public ListOfStructsSerializer ListP + { + get => BuildPointer>(6); + set => Link(6, value); + } + + public ListOfPointersSerializer> Int32ListList + { + get => BuildPointer>>(7); + set => Link(7, value); + } + + public ListOfPointersSerializer TextListList + { + get => BuildPointer>(8); + set => Link(8, value); + } + + public ListOfPointersSerializer> StructListList + { + get => BuildPointer>>(9); + set => Link(9, value); + } + } + + public class Struct0 : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Struct1 : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool F + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public bool F => ctx.ReadDataBool(0UL, false); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public bool F + { + get => this.ReadDataBool(0UL, false); + set => this.WriteData(0UL, value, false); + } + } + } + + public class Struct8 : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public byte F + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public byte F => ctx.ReadDataByte(0UL, (byte)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public byte F + { + get => this.ReadDataByte(0UL, (byte)0); + set => this.WriteData(0UL, value, (byte)0); + } + } + } + + public class Struct16 : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ushort F + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ushort F => ctx.ReadDataUShort(0UL, (ushort)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public ushort F + { + get => this.ReadDataUShort(0UL, (ushort)0); + set => this.WriteData(0UL, value, (ushort)0); + } + } + } + + public class Struct32 : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint F + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint F => ctx.ReadDataUInt(0UL, 0U); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public uint F + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + } + } + + public class Struct64 : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong F + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong F => ctx.ReadDataULong(0UL, 0UL); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public ulong F + { + get => this.ReadDataULong(0UL, 0UL); + set => this.WriteData(0UL, value, 0UL); + } + } + } + + public class StructP : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string F + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string F => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string F + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Struct0c : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Pad = reader.Pad; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Pad = Pad; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Pad + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Pad => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string Pad + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Struct1c : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + Pad = reader.Pad; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + writer.Pad = Pad; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool F + { + get; + set; + } + + public string Pad + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public bool F => ctx.ReadDataBool(0UL, false); + public string Pad => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public bool F + { + get => this.ReadDataBool(0UL, false); + set => this.WriteData(0UL, value, false); + } + + public string Pad + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Struct8c : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + Pad = reader.Pad; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + writer.Pad = Pad; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public byte F + { + get; + set; + } + + public string Pad + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public byte F => ctx.ReadDataByte(0UL, (byte)0); + public string Pad => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public byte F + { + get => this.ReadDataByte(0UL, (byte)0); + set => this.WriteData(0UL, value, (byte)0); + } + + public string Pad + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Struct16c : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + Pad = reader.Pad; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + writer.Pad = Pad; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ushort F + { + get; + set; + } + + public string Pad + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ushort F => ctx.ReadDataUShort(0UL, (ushort)0); + public string Pad => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public ushort F + { + get => this.ReadDataUShort(0UL, (ushort)0); + set => this.WriteData(0UL, value, (ushort)0); + } + + public string Pad + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Struct32c : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + Pad = reader.Pad; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + writer.Pad = Pad; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint F + { + get; + set; + } + + public string Pad + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint F => ctx.ReadDataUInt(0UL, 0U); + public string Pad => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public uint F + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public string Pad + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Struct64c : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + Pad = reader.Pad; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + writer.Pad = Pad; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong F + { + get; + set; + } + + public string Pad + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public ulong F => ctx.ReadDataULong(0UL, 0UL); + public string Pad => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public ulong F + { + get => this.ReadDataULong(0UL, 0UL); + set => this.WriteData(0UL, value, 0UL); + } + + public string Pad + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class StructPc : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + F = reader.F; + Pad = reader.Pad; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.F = F; + writer.Pad = Pad; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string F + { + get; + set; + } + + public ulong Pad + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string F => ctx.ReadText(0, ""); + public ulong Pad => ctx.ReadDataULong(0UL, 0UL); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public string F + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public ulong Pad + { + get => this.ReadDataULong(0UL, 0UL); + set => this.WriteData(0UL, value, 0UL); + } + } + } + } + + public class TestFieldZeroIsBit : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Bit = reader.Bit; + SecondBit = reader.SecondBit; + ThirdField = reader.ThirdField; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Bit = Bit; + writer.SecondBit = SecondBit; + writer.ThirdField = ThirdField; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool Bit + { + get; + set; + } + + public bool SecondBit + { + get; + set; + } + + = true; + public byte ThirdField + { + get; + set; + } + + = 123; + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public bool Bit => ctx.ReadDataBool(0UL, false); + public bool SecondBit => ctx.ReadDataBool(1UL, true); + public byte ThirdField => ctx.ReadDataByte(8UL, (byte)123); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public bool Bit + { + get => this.ReadDataBool(0UL, false); + set => this.WriteData(0UL, value, false); + } + + public bool SecondBit + { + get => this.ReadDataBool(1UL, true); + set => this.WriteData(1UL, value, true); + } + + public byte ThirdField + { + get => this.ReadDataByte(8UL, (byte)123); + set => this.WriteData(8UL, value, (byte)123); + } + } + } + + public class TestListDefaults : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Lists = CapnpSerializable.Create(reader.Lists); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Lists?.serialize(writer.Lists); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + Lists = Lists ?? new Capnproto_test.Capnp.Test.TestLists() + {List0 = new Capnproto_test.Capnp.Test.TestLists.Struct0[]{new Capnproto_test.Capnp.Test.TestLists.Struct0() + {}, new Capnproto_test.Capnp.Test.TestLists.Struct0() + {}}, List1 = new Capnproto_test.Capnp.Test.TestLists.Struct1[]{new Capnproto_test.Capnp.Test.TestLists.Struct1() + {F = true}, new Capnproto_test.Capnp.Test.TestLists.Struct1() + {F = false}, new Capnproto_test.Capnp.Test.TestLists.Struct1() + {F = true}, new Capnproto_test.Capnp.Test.TestLists.Struct1() + {F = true}}, List8 = new Capnproto_test.Capnp.Test.TestLists.Struct8[]{new Capnproto_test.Capnp.Test.TestLists.Struct8() + {F = 123}, new Capnproto_test.Capnp.Test.TestLists.Struct8() + {F = 45}}, List16 = new Capnproto_test.Capnp.Test.TestLists.Struct16[]{new Capnproto_test.Capnp.Test.TestLists.Struct16() + {F = 12345}, new Capnproto_test.Capnp.Test.TestLists.Struct16() + {F = 6789}}, List32 = new Capnproto_test.Capnp.Test.TestLists.Struct32[]{new Capnproto_test.Capnp.Test.TestLists.Struct32() + {F = 123456789U}, new Capnproto_test.Capnp.Test.TestLists.Struct32() + {F = 234567890U}}, List64 = new Capnproto_test.Capnp.Test.TestLists.Struct64[]{new Capnproto_test.Capnp.Test.TestLists.Struct64() + {F = 1234567890123456UL}, new Capnproto_test.Capnp.Test.TestLists.Struct64() + {F = 2345678901234567UL}}, ListP = new Capnproto_test.Capnp.Test.TestLists.StructP[]{new Capnproto_test.Capnp.Test.TestLists.StructP() + {F = "foo"}, new Capnproto_test.Capnp.Test.TestLists.StructP() + {F = "bar"}}, Int32ListList = new IReadOnlyList[]{new int[]{1, 2, 3}, new int[]{4, 5}, new int[]{12341234}}, TextListList = new IReadOnlyList[]{new string[]{"foo", "bar"}, new string[]{"baz"}, new string[]{"qux", "corge"}}, StructListList = new IReadOnlyList[]{new Capnproto_test.Capnp.Test.TestAllTypes[]{new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 0, Int32Field = 123, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 0, Int32Field = 456, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}}, new Capnproto_test.Capnp.Test.TestAllTypes[]{new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 0, Int32Field = 789, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}}}}; + } + + public Capnproto_test.Capnp.Test.TestLists Lists + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestLists.READER Lists => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestLists.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.TestLists.WRITER Lists + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } + + public class TestLateUnion : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Foo = reader.Foo; + Bar = reader.Bar; + Baz = reader.Baz; + TheUnion = CapnpSerializable.Create(reader.TheUnion); + AnotherUnion = CapnpSerializable.Create(reader.AnotherUnion); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Foo = Foo; + writer.Bar = Bar; + writer.Baz = Baz; + TheUnion?.serialize(writer.TheUnion); + AnotherUnion?.serialize(writer.AnotherUnion); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public int Foo + { + get; + set; + } + + public string Bar + { + get; + set; + } + + public short Baz + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestLateUnion.@theUnion TheUnion + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestLateUnion.@anotherUnion AnotherUnion + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public int Foo => ctx.ReadDataInt(0UL, 0); + public string Bar => ctx.ReadText(0, ""); + public short Baz => ctx.ReadDataShort(32UL, (short)0); + public @theUnion.READER TheUnion => new @theUnion.READER(ctx); + public @anotherUnion.READER AnotherUnion => new @anotherUnion.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(3, 3); + } + + public int Foo + { + get => this.ReadDataInt(0UL, 0); + set => this.WriteData(0UL, value, 0); + } + + public string Bar + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public short Baz + { + get => this.ReadDataShort(32UL, (short)0); + set => this.WriteData(32UL, value, (short)0); + } + + public @theUnion.WRITER TheUnion + { + get => Rewrap<@theUnion.WRITER>(); + } + + public @anotherUnion.WRITER AnotherUnion + { + get => Rewrap<@anotherUnion.WRITER>(); + } + } + + public class @theUnion : ICapnpSerializable + { + public enum WHICH : ushort + { + Qux = 0, + Corge = 1, + Grault = 2, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Qux: + Qux = reader.Qux; + break; + case WHICH.Corge: + Corge = reader.Corge; + break; + case WHICH.Grault: + Grault = reader.Grault; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Qux: + _content = null; + break; + case WHICH.Corge: + _content = null; + break; + case WHICH.Grault: + _content = 0F; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Qux: + writer.Qux = Qux; + break; + case WHICH.Corge: + writer.Corge.Init(Corge); + break; + case WHICH.Grault: + writer.Grault = Grault.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Qux + { + get => _which == WHICH.Qux ? (string)_content : null; + set + { + _which = WHICH.Qux; + _content = value; + } + } + + public IReadOnlyList Corge + { + get => _which == WHICH.Corge ? (IReadOnlyList)_content : null; + set + { + _which = WHICH.Corge; + _content = value; + } + } + + public float? Grault + { + get => _which == WHICH.Grault ? (float? )_content : null; + set + { + _which = WHICH.Grault; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(48U, (ushort)0); + public string Qux => which == WHICH.Qux ? ctx.ReadText(1, "") : default; + public IReadOnlyList Corge => which == WHICH.Corge ? ctx.ReadList(1).CastInt() : default; + public float Grault => which == WHICH.Grault ? ctx.ReadDataFloat(64UL, 0F) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(48U, (ushort)0); + set => this.WriteData(48U, (ushort)value, (ushort)0); + } + + public string Qux + { + get => which == WHICH.Qux ? this.ReadText(1, "") : default; + set => this.WriteText(1, value, ""); + } + + public ListOfPrimitivesSerializer Corge + { + get => which == WHICH.Corge ? BuildPointer>(1) : default; + set => Link(1, value); + } + + public float Grault + { + get => which == WHICH.Grault ? this.ReadDataFloat(64UL, 0F) : default; + set => this.WriteData(64UL, value, 0F); + } + } + } + + public class @anotherUnion : ICapnpSerializable + { + public enum WHICH : ushort + { + Qux = 0, + Corge = 1, + Grault = 2, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Qux: + Qux = reader.Qux; + break; + case WHICH.Corge: + Corge = reader.Corge; + break; + case WHICH.Grault: + Grault = reader.Grault; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Qux: + _content = null; + break; + case WHICH.Corge: + _content = null; + break; + case WHICH.Grault: + _content = 0F; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Qux: + writer.Qux = Qux; + break; + case WHICH.Corge: + writer.Corge.Init(Corge); + break; + case WHICH.Grault: + writer.Grault = Grault.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Qux + { + get => _which == WHICH.Qux ? (string)_content : null; + set + { + _which = WHICH.Qux; + _content = value; + } + } + + public IReadOnlyList Corge + { + get => _which == WHICH.Corge ? (IReadOnlyList)_content : null; + set + { + _which = WHICH.Corge; + _content = value; + } + } + + public float? Grault + { + get => _which == WHICH.Grault ? (float? )_content : null; + set + { + _which = WHICH.Grault; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(96U, (ushort)0); + public string Qux => which == WHICH.Qux ? ctx.ReadText(2, "") : default; + public IReadOnlyList Corge => which == WHICH.Corge ? ctx.ReadList(2).CastInt() : default; + public float Grault => which == WHICH.Grault ? ctx.ReadDataFloat(128UL, 0F) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(96U, (ushort)0); + set => this.WriteData(96U, (ushort)value, (ushort)0); + } + + public string Qux + { + get => which == WHICH.Qux ? this.ReadText(2, "") : default; + set => this.WriteText(2, value, ""); + } + + public ListOfPrimitivesSerializer Corge + { + get => which == WHICH.Corge ? BuildPointer>(2) : default; + set => Link(2, value); + } + + public float Grault + { + get => which == WHICH.Grault ? this.ReadDataFloat(128UL, 0F) : default; + set => this.WriteData(128UL, value, 0F); + } + } + } + } + + public class TestOldVersion : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Old1 = reader.Old1; + Old2 = reader.Old2; + Old3 = CapnpSerializable.Create(reader.Old3); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Old1 = Old1; + writer.Old2 = Old2; + Old3?.serialize(writer.Old3); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public long Old1 + { + get; + set; + } + + public string Old2 + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestOldVersion Old3 + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public long Old1 => ctx.ReadDataLong(0UL, 0L); + public string Old2 => ctx.ReadText(0, ""); + public Capnproto_test.Capnp.Test.TestOldVersion.READER Old3 => ctx.ReadStruct(1, Capnproto_test.Capnp.Test.TestOldVersion.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 2); + } + + public long Old1 + { + get => this.ReadDataLong(0UL, 0L); + set => this.WriteData(0UL, value, 0L); + } + + public string Old2 + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public Capnproto_test.Capnp.Test.TestOldVersion.WRITER Old3 + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + + public class TestNewVersion : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Old1 = reader.Old1; + Old2 = reader.Old2; + Old3 = CapnpSerializable.Create(reader.Old3); + New1 = reader.New1; + New2 = reader.New2; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Old1 = Old1; + writer.Old2 = Old2; + Old3?.serialize(writer.Old3); + writer.New1 = New1; + writer.New2 = New2; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + New2 = New2 ?? "baz"; + } + + public long Old1 + { + get; + set; + } + + public string Old2 + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestNewVersion Old3 + { + get; + set; + } + + public long New1 + { + get; + set; + } + + = 987L; + public string New2 + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public long Old1 => ctx.ReadDataLong(0UL, 0L); + public string Old2 => ctx.ReadText(0, ""); + public Capnproto_test.Capnp.Test.TestNewVersion.READER Old3 => ctx.ReadStruct(1, Capnproto_test.Capnp.Test.TestNewVersion.READER.create); + public long New1 => ctx.ReadDataLong(64UL, 987L); + public string New2 => ctx.ReadText(2, "baz"); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(2, 3); + } + + public long Old1 + { + get => this.ReadDataLong(0UL, 0L); + set => this.WriteData(0UL, value, 0L); + } + + public string Old2 + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public Capnproto_test.Capnp.Test.TestNewVersion.WRITER Old3 + { + get => BuildPointer(1); + set => Link(1, value); + } + + public long New1 + { + get => this.ReadDataLong(64UL, 987L); + set => this.WriteData(64UL, value, 987L); + } + + public string New2 + { + get => this.ReadText(2, "baz"); + set => this.WriteText(2, value, "baz"); + } + } + } + + public class TestOldUnionVersion : ICapnpSerializable + { + public enum WHICH : ushort + { + A = 0, + B = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.A: + which = reader.which; + break; + case WHICH.B: + B = reader.B; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.A: + break; + case WHICH.B: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.A: + break; + case WHICH.B: + writer.B = B.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong? B + { + get => _which == WHICH.B ? (ulong? )_content : null; + set + { + _which = WHICH.B; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public ulong B => which == WHICH.B ? ctx.ReadDataULong(64UL, 0UL) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(2, 0); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public ulong B + { + get => which == WHICH.B ? this.ReadDataULong(64UL, 0UL) : default; + set => this.WriteData(64UL, value, 0UL); + } + } + } + + public class TestNewUnionVersion : ICapnpSerializable + { + public enum WHICH : ushort + { + A = 0, + B = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.A: + A = CapnpSerializable.Create(reader.A); + break; + case WHICH.B: + B = reader.B; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.A: + _content = null; + break; + case WHICH.B: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.A: + A?.serialize(writer.A); + break; + case WHICH.B: + writer.B = B.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestNewUnionVersion.@a A + { + get => _which == WHICH.A ? (Capnproto_test.Capnp.Test.TestNewUnionVersion.@a)_content : null; + set + { + _which = WHICH.A; + _content = value; + } + } + + public ulong? B + { + get => _which == WHICH.B ? (ulong? )_content : null; + set + { + _which = WHICH.B; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public @a.READER A => which == WHICH.A ? new @a.READER(ctx) : default; + public ulong B => which == WHICH.B ? ctx.ReadDataULong(64UL, 0UL) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(3, 0); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public @a.WRITER A + { + get => which == WHICH.A ? Rewrap<@a.WRITER>() : default; + } + + public ulong B + { + get => which == WHICH.B ? this.ReadDataULong(64UL, 0UL) : default; + set => this.WriteData(64UL, value, 0UL); + } + } + + public class @a : ICapnpSerializable + { + public enum WHICH : ushort + { + A0 = 0, + A1 = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.A0: + which = reader.which; + break; + case WHICH.A1: + A1 = reader.A1; + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.A0: + break; + case WHICH.A1: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.A0: + break; + case WHICH.A1: + writer.A1 = A1.Value; + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public ulong? A1 + { + get => _which == WHICH.A1 ? (ulong? )_content : null; + set + { + _which = WHICH.A1; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(64U, (ushort)0); + public ulong A1 => which == WHICH.A1 ? ctx.ReadDataULong(128UL, 0UL) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(64U, (ushort)0); + set => this.WriteData(64U, (ushort)value, (ushort)0); + } + + public ulong A1 + { + get => which == WHICH.A1 ? this.ReadDataULong(128UL, 0UL) : default; + set => this.WriteData(128UL, value, 0UL); + } + } + } + } + + public class TestStructUnion : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Un = CapnpSerializable.Create(reader.Un); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Un?.serialize(writer.Un); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestStructUnion.@un Un + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public @un.READER Un => new @un.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public @un.WRITER Un + { + get => Rewrap<@un.WRITER>(); + } + } + + public class @un : ICapnpSerializable + { + public enum WHICH : ushort + { + Struct = 0, + Object = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Struct: + Struct = CapnpSerializable.Create(reader.Struct); + break; + case WHICH.Object: + Object = CapnpSerializable.Create(reader.Object); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Struct: + _content = null; + break; + case WHICH.Object: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Struct: + Struct?.serialize(writer.Struct); + break; + case WHICH.Object: + Object?.serialize(writer.Object); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestStructUnion.SomeStruct Struct + { + get => _which == WHICH.Struct ? (Capnproto_test.Capnp.Test.TestStructUnion.SomeStruct)_content : null; + set + { + _which = WHICH.Struct; + _content = value; + } + } + + public Capnproto_test.Capnp.Test.TestAnyPointer Object + { + get => _which == WHICH.Object ? (Capnproto_test.Capnp.Test.TestAnyPointer)_content : null; + set + { + _which = WHICH.Object; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public Capnproto_test.Capnp.Test.TestStructUnion.SomeStruct.READER Struct => which == WHICH.Struct ? ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestStructUnion.SomeStruct.READER.create) : default; + public Capnproto_test.Capnp.Test.TestAnyPointer.READER Object => which == WHICH.Object ? ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestAnyPointer.READER.create) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public Capnproto_test.Capnp.Test.TestStructUnion.SomeStruct.WRITER Struct + { + get => which == WHICH.Struct ? BuildPointer(0) : default; + set => Link(0, value); + } + + public Capnproto_test.Capnp.Test.TestAnyPointer.WRITER Object + { + get => which == WHICH.Object ? BuildPointer(0) : default; + set => Link(0, value); + } + } + } + + public class SomeStruct : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + SomeText = reader.SomeText; + MoreText = reader.MoreText; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.SomeText = SomeText; + writer.MoreText = MoreText; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string SomeText + { + get; + set; + } + + public string MoreText + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string SomeText => ctx.ReadText(0, ""); + public string MoreText => ctx.ReadText(1, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public string SomeText + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public string MoreText + { + get => this.ReadText(1, ""); + set => this.WriteText(1, value, ""); + } + } + } + } + + public class TestPrintInlineStructs : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + SomeText = reader.SomeText; + StructList = reader.StructList.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.SomeText = SomeText; + writer.StructList.Init(StructList, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string SomeText + { + get; + set; + } + + public IReadOnlyList StructList + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string SomeText => ctx.ReadText(0, ""); + public IReadOnlyList StructList => ctx.ReadList(1).Cast(Capnproto_test.Capnp.Test.TestPrintInlineStructs.InlineStruct.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public string SomeText + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public ListOfStructsSerializer StructList + { + get => BuildPointer>(1); + set => Link(1, value); + } + } + + public class InlineStruct : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Int32Field = reader.Int32Field; + TextField = reader.TextField; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Int32Field = Int32Field; + writer.TextField = TextField; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public int Int32Field + { + get; + set; + } + + public string TextField + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public int Int32Field => ctx.ReadDataInt(0UL, 0); + public string TextField => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public int Int32Field + { + get => this.ReadDataInt(0UL, 0); + set => this.WriteData(0UL, value, 0); + } + + public string TextField + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + } + + public class TestWholeFloatDefault : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Field = reader.Field; + BigField = reader.BigField; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Field = Field; + writer.BigField = BigField; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public float Field + { + get; + set; + } + + = 123F; + public float BigField + { + get; + set; + } + + = 2E+30F; + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public float Field => ctx.ReadDataFloat(0UL, 123F); + public float BigField => ctx.ReadDataFloat(32UL, 2E+30F); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public float Field + { + get => this.ReadDataFloat(0UL, 123F); + set => this.WriteData(0UL, value, 123F); + } + + public float BigField + { + get => this.ReadDataFloat(32UL, 2E+30F); + set => this.WriteData(32UL, value, 2E+30F); + } + } + } + + public class TestGenerics : ICapnpSerializable where TFoo : class where TBar : class + { + public enum WHICH : ushort + { + Uv = 0, + Ug = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Uv: + which = reader.which; + break; + case WHICH.Ug: + Ug = CapnpSerializable.Create.@ug>(reader.Ug); + break; + } + + Foo = CapnpSerializable.Create(reader.Foo); + Rev = CapnpSerializable.Create>(reader.Rev); + List = reader.List.ToReadOnlyList(_ => CapnpSerializable.Create.Inner>(_)); + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Uv: + break; + case WHICH.Ug: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Uv: + break; + case WHICH.Ug: + Ug?.serialize(writer.Ug); + break; + } + + writer.Foo.SetObject(Foo); + Rev?.serialize(writer.Rev); + writer.List.Init(List, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public TFoo Foo + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics Rev + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.@ug Ug + { + get => _which == WHICH.Ug ? (Capnproto_test.Capnp.Test.TestGenerics.@ug)_content : null; + set + { + _which = WHICH.Ug; + _content = value; + } + } + + public IReadOnlyList.Inner> List + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public DeserializerState Foo => ctx.StructReadPointer(0); + public Capnproto_test.Capnp.Test.TestGenerics.READER Rev => ctx.ReadStruct(1, Capnproto_test.Capnp.Test.TestGenerics.READER.create); + public @ug.READER Ug => which == WHICH.Ug ? new @ug.READER(ctx) : default; + public IReadOnlyList.Inner.READER> List => ctx.ReadList(2).Cast(Capnproto_test.Capnp.Test.TestGenerics.Inner.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 3); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public DynamicSerializerState Foo + { + get => BuildPointer(0); + set => Link(0, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.WRITER Rev + { + get => BuildPointer.WRITER>(1); + set => Link(1, value); + } + + public @ug.WRITER Ug + { + get => which == WHICH.Ug ? Rewrap<@ug.WRITER>() : default; + } + + public ListOfStructsSerializer.Inner.WRITER> List + { + get => BuildPointer.Inner.WRITER>>(2); + set => Link(2, value); + } + } + + public class @ug : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Ugfoo = reader.Ugfoo; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Ugfoo = Ugfoo; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public int Ugfoo + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public int Ugfoo => ctx.ReadDataInt(32UL, 0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public int Ugfoo + { + get => this.ReadDataInt(32UL, 0); + set => this.WriteData(32UL, value, 0); + } + } + } + + public class Inner : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Foo = CapnpSerializable.Create(reader.Foo); + Bar = CapnpSerializable.Create(reader.Bar); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Foo.SetObject(Foo); + writer.Bar.SetObject(Bar); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public TFoo Foo + { + get; + set; + } + + public TBar Bar + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState Foo => ctx.StructReadPointer(0); + public DeserializerState Bar => ctx.StructReadPointer(1); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public DynamicSerializerState Foo + { + get => BuildPointer(0); + set => Link(0, value); + } + + public DynamicSerializerState Bar + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + + public class Inner2 : ICapnpSerializable where TBaz : class + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Bar = CapnpSerializable.Create(reader.Bar); + Baz = CapnpSerializable.Create(reader.Baz); + InnerBound = CapnpSerializable.Create.Inner>(reader.InnerBound); + InnerUnbound = CapnpSerializable.Create.Inner>(reader.InnerUnbound); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Bar.SetObject(Bar); + writer.Baz.SetObject(Baz); + InnerBound?.serialize(writer.InnerBound); + InnerUnbound?.serialize(writer.InnerUnbound); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public TBar Bar + { + get; + set; + } + + public TBaz Baz + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner InnerBound + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner InnerUnbound + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState Bar => ctx.StructReadPointer(0); + public DeserializerState Baz => ctx.StructReadPointer(1); + public Capnproto_test.Capnp.Test.TestGenerics.Inner.READER InnerBound => ctx.ReadStruct(2, Capnproto_test.Capnp.Test.TestGenerics.Inner.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner.READER InnerUnbound => ctx.ReadStruct(3, Capnproto_test.Capnp.Test.TestGenerics.Inner.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 4); + } + + public DynamicSerializerState Bar + { + get => BuildPointer(0); + set => Link(0, value); + } + + public DynamicSerializerState Baz + { + get => BuildPointer(1); + set => Link(1, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner.WRITER InnerBound + { + get => BuildPointer.Inner.WRITER>(2); + set => Link(2, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner.WRITER InnerUnbound + { + get => BuildPointer.Inner.WRITER>(3); + set => Link(3, value); + } + } + + public class DeepNest : ICapnpSerializable where TQux : class + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Foo = CapnpSerializable.Create(reader.Foo); + Bar = CapnpSerializable.Create(reader.Bar); + Baz = CapnpSerializable.Create(reader.Baz); + Qux = CapnpSerializable.Create(reader.Qux); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Foo.SetObject(Foo); + writer.Bar.SetObject(Bar); + writer.Baz.SetObject(Baz); + writer.Qux.SetObject(Qux); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public TFoo Foo + { + get; + set; + } + + public TBar Bar + { + get; + set; + } + + public TBaz Baz + { + get; + set; + } + + public TQux Qux + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState Foo => ctx.StructReadPointer(0); + public DeserializerState Bar => ctx.StructReadPointer(1); + public DeserializerState Baz => ctx.StructReadPointer(2); + public DeserializerState Qux => ctx.StructReadPointer(3); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 4); + } + + public DynamicSerializerState Foo + { + get => BuildPointer(0); + set => Link(0, value); + } + + public DynamicSerializerState Bar + { + get => BuildPointer(1); + set => Link(1, value); + } + + public DynamicSerializerState Baz + { + get => BuildPointer(2); + set => Link(2, value); + } + + public DynamicSerializerState Qux + { + get => BuildPointer(3); + set => Link(3, value); + } + } + + [Proxy(typeof(DeepNestInterfaceProxy<>)), Skeleton(typeof(DeepNestInterfaceSkeleton<>))] + public interface IDeepNestInterface : IDisposable + { + Task Call(CancellationToken cancellationToken_ = default); + } + + public class DeepNestInterfaceProxy : Proxy, IDeepNestInterface where TQuux : class + { + public async Task Call(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc.Inner2.DeepNest.DeepNestInterface.Params_call.WRITER>(); + var arg_ = new Capnproto_test.Capnp.Test.TestGenerics.Inner2.DeepNest.DeepNestInterface.Params_call() + {}; + arg_.serialize(in_); + var d_ = await Call(9816138025992274567UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create.Inner2.DeepNest.DeepNestInterface.Result_call>(d_); + return; + } + } + + public class DeepNestInterfaceSkeleton : Skeleton> where TQuux : class + { + public DeepNestInterfaceSkeleton() + { + SetMethodTable(Call); + } + + public override ulong InterfaceId => 9816138025992274567UL; + async Task Call(DeserializerState d_, CancellationToken cancellationToken_) + { + await Impl.Call(cancellationToken_); + var s_ = SerializerState.CreateForRpc.Inner2.DeepNest.DeepNestInterface.Result_call.WRITER>(); + return s_; + } + } + + public static class DeepNestInterface + where TQuux : class + { + public class Params_call : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_call : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + } + } + } + + [Proxy(typeof(InterfaceProxy<>)), Skeleton(typeof(InterfaceSkeleton<>))] + public interface IInterface : IDisposable + { + Task<(TQux, Capnproto_test.Capnp.Test.TestGenerics)> Call(Capnproto_test.Capnp.Test.TestGenerics.Inner2 arg_, CancellationToken cancellationToken_ = default); + } + + public class InterfaceProxy : Proxy, IInterface where TQux : class + { + public Task<(TQux, Capnproto_test.Capnp.Test.TestGenerics)> Call(Capnproto_test.Capnp.Test.TestGenerics.Inner2 arg_, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc.Inner2.WRITER>(); + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(14548678385738242652UL, 0, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create.Interface.Result_call>(d_); + return (r_.Qux, r_.Gen); + } + + ); + } + } + + public class InterfaceSkeleton : Skeleton> where TQux : class + { + public InterfaceSkeleton() + { + SetMethodTable(Call); + } + + public override ulong InterfaceId => 14548678385738242652UL; + Task Call(DeserializerState d_, CancellationToken cancellationToken_) + { + return Impatient.MaybeTailCall(Impl.Call(CapnpSerializable.Create.Inner2>(d_), cancellationToken_), (qux, gen) => + { + var s_ = SerializerState.CreateForRpc.Interface.Result_call.WRITER>(); + var r_ = new Capnproto_test.Capnp.Test.TestGenerics.Interface.Result_call{Qux = qux, Gen = gen}; + r_.serialize(s_); + return s_; + } + + ); + } + } + + public static class Interface + where TQux : class + { + public class Result_call : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Qux = CapnpSerializable.Create(reader.Qux); + Gen = CapnpSerializable.Create>(reader.Gen); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Qux.SetObject(Qux); + Gen?.serialize(writer.Gen); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public TQux Qux + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics Gen + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState Qux => ctx.StructReadPointer(0); + public Capnproto_test.Capnp.Test.TestGenerics.READER Gen => ctx.ReadStruct(1, Capnproto_test.Capnp.Test.TestGenerics.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public DynamicSerializerState Qux + { + get => BuildPointer(0); + set => Link(0, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.WRITER Gen + { + get => BuildPointer.WRITER>(1); + set => Link(1, value); + } + } + } + } + + public class UseAliases : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Foo = CapnpSerializable.Create(reader.Foo); + Inner = CapnpSerializable.Create.Inner>(reader.Inner); + Inner2 = CapnpSerializable.Create.Inner2>(reader.Inner2); + Inner2Bind = CapnpSerializable.Create.Inner2>(reader.Inner2Bind); + Inner2Text = CapnpSerializable.Create.Inner2>(reader.Inner2Text); + RevFoo = CapnpSerializable.Create(reader.RevFoo); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Foo.SetObject(Foo); + Inner?.serialize(writer.Inner); + Inner2?.serialize(writer.Inner2); + Inner2Bind?.serialize(writer.Inner2Bind); + Inner2Text?.serialize(writer.Inner2Text); + writer.RevFoo.SetObject(RevFoo); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public TFoo Foo + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner Inner + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2 Inner2 + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2 Inner2Bind + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2 Inner2Text + { + get; + set; + } + + public TBar RevFoo + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState Foo => ctx.StructReadPointer(0); + public Capnproto_test.Capnp.Test.TestGenerics.Inner.READER Inner => ctx.ReadStruct(1, Capnproto_test.Capnp.Test.TestGenerics.Inner.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER Inner2 => ctx.ReadStruct(2, Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER Inner2Bind => ctx.ReadStruct(3, Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER Inner2Text => ctx.ReadStruct(4, Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER.create); + public DeserializerState RevFoo => ctx.StructReadPointer(5); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 6); + } + + public DynamicSerializerState Foo + { + get => BuildPointer(0); + set => Link(0, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner.WRITER Inner + { + get => BuildPointer.Inner.WRITER>(1); + set => Link(1, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.WRITER Inner2 + { + get => BuildPointer.Inner2.WRITER>(2); + set => Link(2, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.WRITER Inner2Bind + { + get => BuildPointer.Inner2.WRITER>(3); + set => Link(3, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.WRITER Inner2Text + { + get => BuildPointer.Inner2.WRITER>(4); + set => Link(4, value); + } + + public DynamicSerializerState RevFoo + { + get => BuildPointer(5); + set => Link(5, value); + } + } + } + } + + public class TestGenericsWrapper : ICapnpSerializable where TFoo : class where TBar : class + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Value = CapnpSerializable.Create>(reader.Value); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Value?.serialize(writer.Value); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestGenerics Value + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestGenerics.READER Value => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestGenerics.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.TestGenerics.WRITER Value + { + get => BuildPointer.WRITER>(0); + set => Link(0, value); + } + } + } + + public class TestGenericsWrapper2 : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Value = CapnpSerializable.Create>(reader.Value); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Value?.serialize(writer.Value); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestGenericsWrapper Value + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestGenericsWrapper.READER Value => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestGenericsWrapper.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.TestGenericsWrapper.WRITER Value + { + get => BuildPointer.WRITER>(0); + set => Link(0, value); + } + } + } + + [Proxy(typeof(TestImplicitMethodParamsProxy)), Skeleton(typeof(TestImplicitMethodParamsSkeleton))] + public interface ITestImplicitMethodParams : IDisposable + { + Task> Call(TT foo, TU bar, CancellationToken cancellationToken_ = default) + where TT : class where TU : class; + } + + public class TestImplicitMethodParamsProxy : Proxy, ITestImplicitMethodParams + { + public Task> Call(TT foo, TU bar, CancellationToken cancellationToken_ = default) + where TT : class where TU : class + { + var in_ = SerializerState.CreateForRpc.WRITER>(); + var arg_ = new Capnproto_test.Capnp.Test.TestImplicitMethodParams.Params_call() + {Foo = foo, Bar = bar}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(10058534285777328794UL, 0, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create>(d_); + return r_; + } + + ); + } + } + + public class TestImplicitMethodParamsSkeleton : Skeleton + { + public TestImplicitMethodParamsSkeleton() + { + SetMethodTable(Call); + } + + public override ulong InterfaceId => 10058534285777328794UL; + Task Call(DeserializerState d_, CancellationToken cancellationToken_) + where TT : class where TU : class + { + var in_ = CapnpSerializable.Create>(d_); + return Impatient.MaybeTailCall(Impl.Call(in_.Foo, in_.Bar, cancellationToken_), r_ => + { + var s_ = SerializerState.CreateForRpc.WRITER>(); + r_.serialize(s_); + return s_; + } + + ); + } + } + + public static class TestImplicitMethodParams + { + public class Params_call : ICapnpSerializable where TT : class where TU : class + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Foo = CapnpSerializable.Create(reader.Foo); + Bar = CapnpSerializable.Create(reader.Bar); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Foo.SetObject(Foo); + writer.Bar.SetObject(Bar); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public TT Foo + { + get; + set; + } + + public TU Bar + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState Foo => ctx.StructReadPointer(0); + public DeserializerState Bar => ctx.StructReadPointer(1); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public DynamicSerializerState Foo + { + get => BuildPointer(0); + set => Link(0, value); + } + + public DynamicSerializerState Bar + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + } + + [Proxy(typeof(TestImplicitMethodParamsInGenericProxy<>)), Skeleton(typeof(TestImplicitMethodParamsInGenericSkeleton<>))] + public interface ITestImplicitMethodParamsInGeneric : IDisposable + { + Task> Call(TT foo, TU bar, CancellationToken cancellationToken_ = default) + where TT : class where TU : class; + } + + public class TestImplicitMethodParamsInGenericProxy : Proxy, ITestImplicitMethodParamsInGeneric where TV : class + { + public Task> Call(TT foo, TU bar, CancellationToken cancellationToken_ = default) + where TT : class where TU : class + { + var in_ = SerializerState.CreateForRpc.Params_call.WRITER>(); + var arg_ = new Capnproto_test.Capnp.Test.TestImplicitMethodParamsInGeneric.Params_call() + {Foo = foo, Bar = bar}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(16112979978201007305UL, 0, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create>(d_); + return r_; + } + + ); + } + } + + public class TestImplicitMethodParamsInGenericSkeleton : Skeleton> where TV : class + { + public TestImplicitMethodParamsInGenericSkeleton() + { + SetMethodTable(Call); + } + + public override ulong InterfaceId => 16112979978201007305UL; + Task Call(DeserializerState d_, CancellationToken cancellationToken_) + where TT : class where TU : class + { + var in_ = CapnpSerializable.Create.Params_call>(d_); + return Impatient.MaybeTailCall(Impl.Call(in_.Foo, in_.Bar, cancellationToken_), r_ => + { + var s_ = SerializerState.CreateForRpc.WRITER>(); + r_.serialize(s_); + return s_; + } + + ); + } + } + + public static class TestImplicitMethodParamsInGeneric + where TV : class + { + public class Params_call : ICapnpSerializable where TT : class where TU : class + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Foo = CapnpSerializable.Create(reader.Foo); + Bar = CapnpSerializable.Create(reader.Bar); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Foo.SetObject(Foo); + writer.Bar.SetObject(Bar); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public TT Foo + { + get; + set; + } + + public TU Bar + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState Foo => ctx.StructReadPointer(0); + public DeserializerState Bar => ctx.StructReadPointer(1); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public DynamicSerializerState Foo + { + get => BuildPointer(0); + set => Link(0, value); + } + + public DynamicSerializerState Bar + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + } + + public class TestGenericsUnion : ICapnpSerializable where TFoo : class where TBar : class + { + public enum WHICH : ushort + { + Foo = 0, + Bar = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.Foo: + Foo = CapnpSerializable.Create(reader.Foo); + break; + case WHICH.Bar: + Bar = CapnpSerializable.Create(reader.Bar); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.Foo: + _content = null; + break; + case WHICH.Bar: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.Foo: + writer.Foo.SetObject(Foo); + break; + case WHICH.Bar: + writer.Bar.SetObject(Bar); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public TFoo Foo + { + get => _which == WHICH.Foo ? (TFoo)_content : null; + set + { + _which = WHICH.Foo; + _content = value; + } + } + + public TBar Bar + { + get => _which == WHICH.Bar ? (TBar)_content : null; + set + { + _which = WHICH.Bar; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(0U, (ushort)0); + public DeserializerState Foo => which == WHICH.Foo ? ctx.StructReadPointer(0) : default; + public DeserializerState Bar => which == WHICH.Bar ? ctx.StructReadPointer(0) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(0U, (ushort)0); + set => this.WriteData(0U, (ushort)value, (ushort)0); + } + + public DynamicSerializerState Foo + { + get => which == WHICH.Foo ? BuildPointer(0) : default; + set => Link(0, value); + } + + public DynamicSerializerState Bar + { + get => which == WHICH.Bar ? BuildPointer(0) : default; + set => Link(0, value); + } + } + } + + public class TestUseGenerics : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Basic = CapnpSerializable.Create>(reader.Basic); + Inner = CapnpSerializable.Create.Inner>(reader.Inner); + Inner2 = CapnpSerializable.Create.Inner2>(reader.Inner2); + Unspecified = CapnpSerializable.Create>(reader.Unspecified); + UnspecifiedInner = CapnpSerializable.Create.Inner2>(reader.UnspecifiedInner); + Default = CapnpSerializable.Create>(reader.Default); + DefaultInner = CapnpSerializable.Create.Inner>(reader.DefaultInner); + DefaultUser = CapnpSerializable.Create(reader.DefaultUser); + Wrapper = CapnpSerializable.Create>(reader.Wrapper); + DefaultWrapper = CapnpSerializable.Create>(reader.DefaultWrapper); + DefaultWrapper2 = CapnpSerializable.Create(reader.DefaultWrapper2); + AliasFoo = CapnpSerializable.Create(reader.AliasFoo); + AliasInner = CapnpSerializable.Create.Inner>(reader.AliasInner); + AliasInner2 = CapnpSerializable.Create.Inner2>(reader.AliasInner2); + AliasInner2Bind = CapnpSerializable.Create.Inner2>>(reader.AliasInner2Bind); + AliasInner2Text = CapnpSerializable.Create.Inner2>(reader.AliasInner2Text); + AliasRev = reader.AliasRev; + UseAliases = CapnpSerializable.Create>.UseAliases>(reader.UseAliases); + Cap = CapnpSerializable.Create>(reader.Cap); + GenericCap = reader.GenericCap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + Basic?.serialize(writer.Basic); + Inner?.serialize(writer.Inner); + Inner2?.serialize(writer.Inner2); + Unspecified?.serialize(writer.Unspecified); + UnspecifiedInner?.serialize(writer.UnspecifiedInner); + Default?.serialize(writer.Default); + DefaultInner?.serialize(writer.DefaultInner); + DefaultUser?.serialize(writer.DefaultUser); + Wrapper?.serialize(writer.Wrapper); + DefaultWrapper?.serialize(writer.DefaultWrapper); + DefaultWrapper2?.serialize(writer.DefaultWrapper2); + AliasFoo?.serialize(writer.AliasFoo); + AliasInner?.serialize(writer.AliasInner); + AliasInner2?.serialize(writer.AliasInner2); + AliasInner2Bind?.serialize(writer.AliasInner2Bind); + AliasInner2Text?.serialize(writer.AliasInner2Text); + writer.AliasRev = AliasRev; + UseAliases?.serialize(writer.UseAliases); + Cap?.serialize(writer.Cap); + writer.GenericCap = GenericCap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + Default = Default ?? new Capnproto_test.Capnp.Test.TestGenerics() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Rev = new Capnproto_test.Capnp.Test.TestGenerics() + {Foo = "text", Rev = new Capnproto_test.Capnp.Test.TestGenerics() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 321, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Rev = new Capnproto_test.Capnp.Test.TestGenerics() + {}, List = new Capnproto_test.Capnp.Test.TestGenerics.Inner[]{}}, List = new Capnproto_test.Capnp.Test.TestGenerics.Inner[]{}}, List = new Capnproto_test.Capnp.Test.TestGenerics.Inner[]{}}; + DefaultInner = DefaultInner ?? new Capnproto_test.Capnp.Test.TestGenerics.Inner() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Bar = "text"}; + DefaultUser = DefaultUser ?? new Capnproto_test.Capnp.Test.TestUseGenerics() + {Basic = new Capnproto_test.Capnp.Test.TestGenerics() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Rev = new Capnproto_test.Capnp.Test.TestGenerics() + {}, List = new Capnproto_test.Capnp.Test.TestGenerics.Inner[]{}}, Inner = new Capnproto_test.Capnp.Test.TestGenerics.Inner() + {}, Inner2 = new Capnproto_test.Capnp.Test.TestGenerics.Inner2() + {}, Unspecified = new Capnproto_test.Capnp.Test.TestGenerics() + {}, UnspecifiedInner = new Capnproto_test.Capnp.Test.TestGenerics.Inner2() + {}, Default = new Capnproto_test.Capnp.Test.TestGenerics() + {}, DefaultInner = new Capnproto_test.Capnp.Test.TestGenerics.Inner() + {}, DefaultUser = new Capnproto_test.Capnp.Test.TestUseGenerics() + {}, Wrapper = new Capnproto_test.Capnp.Test.TestGenericsWrapper() + {}, DefaultWrapper = new Capnproto_test.Capnp.Test.TestGenericsWrapper() + {}, DefaultWrapper2 = new Capnproto_test.Capnp.Test.TestGenericsWrapper2() + {}, AliasFoo = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, AliasInner = new Capnproto_test.Capnp.Test.TestGenerics.Inner() + {}, AliasInner2 = new Capnproto_test.Capnp.Test.TestGenerics.Inner2() + {}, AliasInner2Bind = new Capnproto_test.Capnp.Test.TestGenerics.Inner2>() + {}, AliasInner2Text = new Capnproto_test.Capnp.Test.TestGenerics.Inner2() + {}, AliasRev = null, UseAliases = new Capnproto_test.Capnp.Test.TestGenerics>.UseAliases() + {}, Cap = new Capnproto_test.Capnp.Test.TestGenerics() + {}}; + DefaultWrapper = DefaultWrapper ?? new Capnproto_test.Capnp.Test.TestGenericsWrapper() + {Value = new Capnproto_test.Capnp.Test.TestGenerics() + {Foo = "text", Rev = new Capnproto_test.Capnp.Test.TestGenerics() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 321, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Rev = new Capnproto_test.Capnp.Test.TestGenerics() + {}, List = new Capnproto_test.Capnp.Test.TestGenerics.Inner[]{}}, List = new Capnproto_test.Capnp.Test.TestGenerics.Inner[]{}}}; + DefaultWrapper2 = DefaultWrapper2 ?? new Capnproto_test.Capnp.Test.TestGenericsWrapper2() + {Value = new Capnproto_test.Capnp.Test.TestGenericsWrapper() + {Value = new Capnproto_test.Capnp.Test.TestGenerics() + {Foo = "text", Rev = new Capnproto_test.Capnp.Test.TestGenerics() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 321, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Rev = new Capnproto_test.Capnp.Test.TestGenerics() + {}, List = new Capnproto_test.Capnp.Test.TestGenerics.Inner[]{}}, List = new Capnproto_test.Capnp.Test.TestGenerics.Inner[]{}}}}; + AliasFoo = AliasFoo ?? new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}; + AliasInner = AliasInner ?? new Capnproto_test.Capnp.Test.TestGenerics.Inner() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Bar = new Capnproto_test.Capnp.Test.TestAnyPointer() + {}}; + AliasInner2 = AliasInner2 ?? new Capnproto_test.Capnp.Test.TestGenerics.Inner2() + {Bar = new Capnproto_test.Capnp.Test.TestAnyPointer() + {}, InnerBound = new Capnproto_test.Capnp.Test.TestGenerics.Inner() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Bar = new Capnproto_test.Capnp.Test.TestAnyPointer() + {}}, InnerUnbound = new Capnproto_test.Capnp.Test.TestGenerics.Inner() + {}}; + AliasInner2Bind = AliasInner2Bind ?? new Capnproto_test.Capnp.Test.TestGenerics.Inner2>() + {Bar = new Capnproto_test.Capnp.Test.TestAnyPointer() + {}, Baz = new uint[]{12U, 34U}, InnerBound = new Capnproto_test.Capnp.Test.TestGenerics.Inner() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Bar = new Capnproto_test.Capnp.Test.TestAnyPointer() + {}}, InnerUnbound = new Capnproto_test.Capnp.Test.TestGenerics.Inner() + {}}; + AliasInner2Text = AliasInner2Text ?? new Capnproto_test.Capnp.Test.TestGenerics.Inner2() + {Bar = new Capnproto_test.Capnp.Test.TestAnyPointer() + {}, Baz = "text", InnerBound = new Capnproto_test.Capnp.Test.TestGenerics.Inner() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Bar = new Capnproto_test.Capnp.Test.TestAnyPointer() + {}}, InnerUnbound = new Capnproto_test.Capnp.Test.TestGenerics.Inner() + {}}; + AliasRev = AliasRev ?? "text"; + UseAliases = UseAliases ?? new Capnproto_test.Capnp.Test.TestGenerics>.UseAliases() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Inner = new Capnproto_test.Capnp.Test.TestGenerics>.Inner() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Bar = new uint[]{}}, Inner2 = new Capnproto_test.Capnp.Test.TestGenerics>.Inner2() + {Bar = new uint[]{}, InnerBound = new Capnproto_test.Capnp.Test.TestGenerics>.Inner() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Bar = new uint[]{}}, InnerUnbound = new Capnproto_test.Capnp.Test.TestGenerics>.Inner() + {}}, Inner2Bind = new Capnproto_test.Capnp.Test.TestGenerics>.Inner2() + {Bar = new uint[]{}, Baz = "text", InnerBound = new Capnproto_test.Capnp.Test.TestGenerics>.Inner() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Bar = new uint[]{}}, InnerUnbound = new Capnproto_test.Capnp.Test.TestGenerics>.Inner() + {}}, Inner2Text = new Capnproto_test.Capnp.Test.TestGenerics>.Inner2() + {Bar = new uint[]{}, Baz = "text", InnerBound = new Capnproto_test.Capnp.Test.TestGenerics>.Inner() + {Foo = new Capnproto_test.Capnp.Test.TestAllTypes() + {BoolField = false, Int8Field = 0, Int16Field = 123, Int32Field = 0, Int64Field = 0L, UInt8Field = 0, UInt16Field = 0, UInt32Field = 0U, UInt64Field = 0UL, Float32Field = 0F, Float64Field = 0, TextField = null, DataField = new byte[]{}, StructField = new Capnproto_test.Capnp.Test.TestAllTypes() + {}, EnumField = Capnproto_test.Capnp.Test.TestEnum.foo, VoidList = 0, BoolList = new bool[]{}, Int8List = new sbyte[]{}, Int16List = new short[]{}, Int32List = new int[]{}, Int64List = new long[]{}, UInt8List = new byte[]{}, UInt16List = new ushort[]{}, UInt32List = new uint[]{}, UInt64List = new ulong[]{}, Float32List = new float[]{}, Float64List = new double[]{}, TextList = new string[]{}, DataList = new IReadOnlyList[]{}, StructList = new Capnproto_test.Capnp.Test.TestAllTypes[]{}, EnumList = new Capnproto_test.Capnp.Test.TestEnum[]{}, InterfaceList = 0}, Bar = new uint[]{}}, InnerUnbound = new Capnproto_test.Capnp.Test.TestGenerics>.Inner() + {}}, RevFoo = new uint[]{12U, 34U, 56U}}; + } + + public Capnproto_test.Capnp.Test.TestGenerics Basic + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner Inner + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2 Inner2 + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics Unspecified + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2 UnspecifiedInner + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics Default + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner DefaultInner + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestUseGenerics DefaultUser + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenericsWrapper Wrapper + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenericsWrapper DefaultWrapper + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenericsWrapper2 DefaultWrapper2 + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestAllTypes AliasFoo + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner AliasInner + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2 AliasInner2 + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2> AliasInner2Bind + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2 AliasInner2Text + { + get; + set; + } + + public string AliasRev + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics>.UseAliases UseAliases + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics Cap + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestGenerics>.IInterface> GenericCap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestGenerics.READER Basic => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestGenerics.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner.READER Inner => ctx.ReadStruct(1, Capnproto_test.Capnp.Test.TestGenerics.Inner.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER Inner2 => ctx.ReadStruct(2, Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.READER Unspecified => ctx.ReadStruct(3, Capnproto_test.Capnp.Test.TestGenerics.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER UnspecifiedInner => ctx.ReadStruct(4, Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.READER Default => ctx.ReadStruct(5, Capnproto_test.Capnp.Test.TestGenerics.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner.READER DefaultInner => ctx.ReadStruct(6, Capnproto_test.Capnp.Test.TestGenerics.Inner.READER.create); + public Capnproto_test.Capnp.Test.TestUseGenerics.READER DefaultUser => ctx.ReadStruct(7, Capnproto_test.Capnp.Test.TestUseGenerics.READER.create); + public Capnproto_test.Capnp.Test.TestGenericsWrapper.READER Wrapper => ctx.ReadStruct(8, Capnproto_test.Capnp.Test.TestGenericsWrapper.READER.create); + public Capnproto_test.Capnp.Test.TestGenericsWrapper.READER DefaultWrapper => ctx.ReadStruct(9, Capnproto_test.Capnp.Test.TestGenericsWrapper.READER.create); + public Capnproto_test.Capnp.Test.TestGenericsWrapper2.READER DefaultWrapper2 => ctx.ReadStruct(10, Capnproto_test.Capnp.Test.TestGenericsWrapper2.READER.create); + public Capnproto_test.Capnp.Test.TestAllTypes.READER AliasFoo => ctx.ReadStruct(11, Capnproto_test.Capnp.Test.TestAllTypes.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner.READER AliasInner => ctx.ReadStruct(12, Capnproto_test.Capnp.Test.TestGenerics.Inner.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER AliasInner2 => ctx.ReadStruct(13, Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner2>.READER AliasInner2Bind => ctx.ReadStruct(14, Capnproto_test.Capnp.Test.TestGenerics.Inner2>.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER AliasInner2Text => ctx.ReadStruct(15, Capnproto_test.Capnp.Test.TestGenerics.Inner2.READER.create); + public string AliasRev => ctx.ReadText(16, "text"); + public Capnproto_test.Capnp.Test.TestGenerics>.UseAliases.READER UseAliases => ctx.ReadStruct(17, Capnproto_test.Capnp.Test.TestGenerics>.UseAliases.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics.READER Cap => ctx.ReadStruct(18, Capnproto_test.Capnp.Test.TestGenerics.READER.create); + public Capnproto_test.Capnp.Test.TestGenerics>.IInterface> GenericCap => ctx.ReadCap>.IInterface>>(19); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 20); + } + + public Capnproto_test.Capnp.Test.TestGenerics.WRITER Basic + { + get => BuildPointer.WRITER>(0); + set => Link(0, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner.WRITER Inner + { + get => BuildPointer.Inner.WRITER>(1); + set => Link(1, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.WRITER Inner2 + { + get => BuildPointer.Inner2.WRITER>(2); + set => Link(2, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.WRITER Unspecified + { + get => BuildPointer.WRITER>(3); + set => Link(3, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.WRITER UnspecifiedInner + { + get => BuildPointer.Inner2.WRITER>(4); + set => Link(4, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.WRITER Default + { + get => BuildPointer.WRITER>(5); + set => Link(5, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner.WRITER DefaultInner + { + get => BuildPointer.Inner.WRITER>(6); + set => Link(6, value); + } + + public Capnproto_test.Capnp.Test.TestUseGenerics.WRITER DefaultUser + { + get => BuildPointer(7); + set => Link(7, value); + } + + public Capnproto_test.Capnp.Test.TestGenericsWrapper.WRITER Wrapper + { + get => BuildPointer.WRITER>(8); + set => Link(8, value); + } + + public Capnproto_test.Capnp.Test.TestGenericsWrapper.WRITER DefaultWrapper + { + get => BuildPointer.WRITER>(9); + set => Link(9, value); + } + + public Capnproto_test.Capnp.Test.TestGenericsWrapper2.WRITER DefaultWrapper2 + { + get => BuildPointer(10); + set => Link(10, value); + } + + public Capnproto_test.Capnp.Test.TestAllTypes.WRITER AliasFoo + { + get => BuildPointer(11); + set => Link(11, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner.WRITER AliasInner + { + get => BuildPointer.Inner.WRITER>(12); + set => Link(12, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.WRITER AliasInner2 + { + get => BuildPointer.Inner2.WRITER>(13); + set => Link(13, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2>.WRITER AliasInner2Bind + { + get => BuildPointer.Inner2>.WRITER>(14); + set => Link(14, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.Inner2.WRITER AliasInner2Text + { + get => BuildPointer.Inner2.WRITER>(15); + set => Link(15, value); + } + + public string AliasRev + { + get => this.ReadText(16, "text"); + set => this.WriteText(16, value, "text"); + } + + public Capnproto_test.Capnp.Test.TestGenerics>.UseAliases.WRITER UseAliases + { + get => BuildPointer>.UseAliases.WRITER>(17); + set => Link(17, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics.WRITER Cap + { + get => BuildPointer.WRITER>(18); + set => Link(18, value); + } + + public Capnproto_test.Capnp.Test.TestGenerics>.IInterface> GenericCap + { + get => ReadCap>.IInterface>>(19); + set => LinkObject(19, value); + } + } + } + + public class TestEmptyStruct : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class TestConstants : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class TestAnyPointerConstants : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + AnyKindAsStruct = CapnpSerializable.Create(reader.AnyKindAsStruct); + AnyStructAsStruct = CapnpSerializable.Create(reader.AnyStructAsStruct); + AnyKindAsList = CapnpSerializable.Create(reader.AnyKindAsList); + AnyListAsList = reader.AnyListAsList.ToReadOnlyList(_ => (object)_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.AnyKindAsStruct.SetObject(AnyKindAsStruct); + writer.AnyStructAsStruct.SetObject(AnyStructAsStruct); + writer.AnyKindAsList.SetObject(AnyKindAsList); + writer.AnyListAsList.SetObject(AnyListAsList); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public AnyPointer AnyKindAsStruct + { + get; + set; + } + + public AnyPointer AnyStructAsStruct + { + get; + set; + } + + public AnyPointer AnyKindAsList + { + get; + set; + } + + public IReadOnlyList AnyListAsList + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState AnyKindAsStruct => ctx.StructReadPointer(0); + public DeserializerState AnyStructAsStruct => ctx.StructReadPointer(1); + public DeserializerState AnyKindAsList => ctx.StructReadPointer(2); + public IReadOnlyList AnyListAsList => (IReadOnlyList)ctx.ReadList(3); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 4); + } + + public DynamicSerializerState AnyKindAsStruct + { + get => BuildPointer(0); + set => Link(0, value); + } + + public DynamicSerializerState AnyStructAsStruct + { + get => BuildPointer(1); + set => Link(1, value); + } + + public DynamicSerializerState AnyKindAsList + { + get => BuildPointer(2); + set => Link(2, value); + } + + public DynamicSerializerState AnyListAsList + { + get => BuildPointer(3); + set => Link(3, value); + } + } + } + + [Proxy(typeof(TestInterfaceProxy)), Skeleton(typeof(TestInterfaceSkeleton))] + public interface ITestInterface : IDisposable + { + Task Foo(uint i, bool j, CancellationToken cancellationToken_ = default); + Task Bar(CancellationToken cancellationToken_ = default); + Task Baz(Capnproto_test.Capnp.Test.TestAllTypes s, CancellationToken cancellationToken_ = default); + } + + public class TestInterfaceProxy : Proxy, ITestInterface + { + public async Task Foo(uint i, bool j, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestInterface.Params_foo() + {I = i, J = j}; + arg_.serialize(in_); + var d_ = await Call(9865999890858873522UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return (r_.X); + } + + public async Task Bar(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestInterface.Params_bar() + {}; + arg_.serialize(in_); + var d_ = await Call(9865999890858873522UL, 1, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task Baz(Capnproto_test.Capnp.Test.TestAllTypes s, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestInterface.Params_baz() + {S = s}; + arg_.serialize(in_); + var d_ = await Call(9865999890858873522UL, 2, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + } + + public class TestInterfaceSkeleton : Skeleton + { + public TestInterfaceSkeleton() + { + SetMethodTable(Foo, Bar, Baz); + } + + public override ulong InterfaceId => 9865999890858873522UL; + Task Foo(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.Foo(in_.I, in_.J, cancellationToken_), x => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestInterface.Result_foo{X = x}; + r_.serialize(s_); + return s_; + } + + ); + } + + async Task Bar(DeserializerState d_, CancellationToken cancellationToken_) + { + await Impl.Bar(cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + + async Task Baz(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + await Impl.Baz(in_.S, cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + } + + public static class TestInterface + { + public class Params_foo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + I = reader.I; + J = reader.J; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.I = I; + writer.J = J; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint I + { + get; + set; + } + + public bool J + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint I => ctx.ReadDataUInt(0UL, 0U); + public bool J => ctx.ReadDataBool(32UL, false); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public uint I + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public bool J + { + get => this.ReadDataBool(32UL, false); + set => this.WriteData(32UL, value, false); + } + } + } + + public class Result_foo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + X = reader.X; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.X = X; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string X + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string X => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string X + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Params_bar : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_bar : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Params_baz : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + S = CapnpSerializable.Create(reader.S); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + S?.serialize(writer.S); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestAllTypes S + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestAllTypes.READER S => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestAllTypes.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.TestAllTypes.WRITER S + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } + + public class Result_baz : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + } + + [Proxy(typeof(TestExtendsProxy)), Skeleton(typeof(TestExtendsSkeleton))] + public interface ITestExtends : Capnproto_test.Capnp.Test.ITestInterface + { + Task Qux(CancellationToken cancellationToken_ = default); + Task Corge(Capnproto_test.Capnp.Test.TestAllTypes arg_, CancellationToken cancellationToken_ = default); + Task Grault(CancellationToken cancellationToken_ = default); + } + + public class TestExtendsProxy : Proxy, ITestExtends + { + public async Task Qux(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestExtends.Params_qux() + {}; + arg_.serialize(in_); + var d_ = await Call(16494920484927878984UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task Corge(Capnproto_test.Capnp.Test.TestAllTypes arg_, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + arg_.serialize(in_); + var d_ = await Call(16494920484927878984UL, 1, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task Grault(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestExtends.Params_grault() + {}; + arg_.serialize(in_); + var d_ = await Call(16494920484927878984UL, 2, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return r_; + } + + public async Task Foo(uint i, bool j, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestInterface.Params_foo() + {I = i, J = j}; + arg_.serialize(in_); + var d_ = await Call(9865999890858873522UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return (r_.X); + } + + public async Task Bar(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestInterface.Params_bar() + {}; + arg_.serialize(in_); + var d_ = await Call(9865999890858873522UL, 1, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task Baz(Capnproto_test.Capnp.Test.TestAllTypes s, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestInterface.Params_baz() + {S = s}; + arg_.serialize(in_); + var d_ = await Call(9865999890858873522UL, 2, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + } + + public class TestExtendsSkeleton : Skeleton + { + public TestExtendsSkeleton() + { + SetMethodTable(Qux, Corge, Grault); + } + + public override ulong InterfaceId => 16494920484927878984UL; + async Task Qux(DeserializerState d_, CancellationToken cancellationToken_) + { + await Impl.Qux(cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + + async Task Corge(DeserializerState d_, CancellationToken cancellationToken_) + { + await Impl.Corge(CapnpSerializable.Create(d_), cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + + Task Grault(DeserializerState d_, CancellationToken cancellationToken_) + { + return Impatient.MaybeTailCall(Impl.Grault(cancellationToken_), r_ => + { + var s_ = SerializerState.CreateForRpc(); + r_.serialize(s_); + return s_; + } + + ); + } + } + + public static class TestExtends + { + public class Params_qux : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_qux : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_corge : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Params_grault : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + } + + [Proxy(typeof(TestExtends2Proxy)), Skeleton(typeof(TestExtends2Skeleton))] + public interface ITestExtends2 : Capnproto_test.Capnp.Test.ITestExtends + { + } + + public class TestExtends2Proxy : Proxy, ITestExtends2 + { + public async Task Qux(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestExtends.Params_qux() + {}; + arg_.serialize(in_); + var d_ = await Call(16494920484927878984UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task Corge(Capnproto_test.Capnp.Test.TestAllTypes arg_, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + arg_.serialize(in_); + var d_ = await Call(16494920484927878984UL, 1, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task Grault(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestExtends.Params_grault() + {}; + arg_.serialize(in_); + var d_ = await Call(16494920484927878984UL, 2, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return r_; + } + + public async Task Foo(uint i, bool j, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestInterface.Params_foo() + {I = i, J = j}; + arg_.serialize(in_); + var d_ = await Call(9865999890858873522UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return (r_.X); + } + + public async Task Bar(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestInterface.Params_bar() + {}; + arg_.serialize(in_); + var d_ = await Call(9865999890858873522UL, 1, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task Baz(Capnproto_test.Capnp.Test.TestAllTypes s, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestInterface.Params_baz() + {S = s}; + arg_.serialize(in_); + var d_ = await Call(9865999890858873522UL, 2, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + } + + public class TestExtends2Skeleton : Skeleton + { + public TestExtends2Skeleton() + { + SetMethodTable(); + } + + public override ulong InterfaceId => 11013518732491786115UL; + } + + [Proxy(typeof(TestPipelineProxy)), Skeleton(typeof(TestPipelineSkeleton))] + public interface ITestPipeline : IDisposable + { + Task<(string, Capnproto_test.Capnp.Test.TestPipeline.Box)> GetCap(uint n, Capnproto_test.Capnp.Test.ITestInterface inCap, CancellationToken cancellationToken_ = default); + Task TestPointers(Capnproto_test.Capnp.Test.ITestInterface cap, AnyPointer obj, IReadOnlyList list, CancellationToken cancellationToken_ = default); + Task<(string, Capnproto_test.Capnp.Test.TestPipeline.AnyBox)> GetAnyCap(uint n, BareProxy inCap, CancellationToken cancellationToken_ = default); + } + + public class TestPipelineProxy : Proxy, ITestPipeline + { + public Task<(string, Capnproto_test.Capnp.Test.TestPipeline.Box)> GetCap(uint n, Capnproto_test.Capnp.Test.ITestInterface inCap, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestPipeline.Params_getCap() + {N = n, InCap = inCap}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(11935670180855499984UL, 0, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create(d_); + return (r_.S, r_.OutBox); + } + + ); + } + + public async Task TestPointers(Capnproto_test.Capnp.Test.ITestInterface cap, AnyPointer obj, IReadOnlyList list, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestPipeline.Params_testPointers() + {Cap = cap, Obj = obj, List = list}; + arg_.serialize(in_); + var d_ = await Call(11935670180855499984UL, 1, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public Task<(string, Capnproto_test.Capnp.Test.TestPipeline.AnyBox)> GetAnyCap(uint n, BareProxy inCap, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestPipeline.Params_getAnyCap() + {N = n, InCap = inCap}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(11935670180855499984UL, 2, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create(d_); + return (r_.S, r_.OutBox); + } + + ); + } + } + + public class TestPipelineSkeleton : Skeleton + { + public TestPipelineSkeleton() + { + SetMethodTable(GetCap, TestPointers, GetAnyCap); + } + + public override ulong InterfaceId => 11935670180855499984UL; + Task GetCap(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.GetCap(in_.N, in_.InCap, cancellationToken_), (s, outBox) => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestPipeline.Result_getCap{S = s, OutBox = outBox}; + r_.serialize(s_); + return s_; + } + + ); + } + + async Task TestPointers(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + await Impl.TestPointers(in_.Cap, in_.Obj, in_.List, cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + + Task GetAnyCap(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.GetAnyCap(in_.N, in_.InCap, cancellationToken_), (s, outBox) => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestPipeline.Result_getAnyCap{S = s, OutBox = outBox}; + r_.serialize(s_); + return s_; + } + + ); + } + } + + public static partial class PipeliningSupportExtensions + { + static readonly MemberAccessPath Path_getCap_OutBox_Cap = new MemberAccessPath(1U, 0U); + public static Capnproto_test.Capnp.Test.ITestInterface OutBox_Cap(this Task<(string, Capnproto_test.Capnp.Test.TestPipeline.Box)> task) + { + return (Capnproto_test.Capnp.Test.ITestInterface)CapabilityReflection.CreateProxy(Impatient.GetAnswer(task).Access(Path_getCap_OutBox_Cap)); + } + + static readonly MemberAccessPath Path_getAnyCap_OutBox_Cap = new MemberAccessPath(1U, 0U); + public static BareProxy OutBox_Cap(this Task<(string, Capnproto_test.Capnp.Test.TestPipeline.AnyBox)> task) + { + return (BareProxy)CapabilityReflection.CreateProxy(Impatient.GetAnswer(task).Access(Path_getAnyCap_OutBox_Cap)); + } + } + + public static class TestPipeline + { + public class Box : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestInterface Cap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class AnyBox : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public BareProxy Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public BareProxy Cap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public BareProxy Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Params_getCap : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + N = reader.N; + InCap = reader.InCap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.N = N; + writer.InCap = InCap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint N + { + get; + set; + } + + public Capnproto_test.Capnp.Test.ITestInterface InCap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint N => ctx.ReadDataUInt(0UL, 0U); + public Capnproto_test.Capnp.Test.ITestInterface InCap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public uint N + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public Capnproto_test.Capnp.Test.ITestInterface InCap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Result_getCap : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + S = reader.S; + OutBox = CapnpSerializable.Create(reader.OutBox); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.S = S; + OutBox?.serialize(writer.OutBox); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string S + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestPipeline.Box OutBox + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string S => ctx.ReadText(0, ""); + public Capnproto_test.Capnp.Test.TestPipeline.Box.READER OutBox => ctx.ReadStruct(1, Capnproto_test.Capnp.Test.TestPipeline.Box.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public string S + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public Capnproto_test.Capnp.Test.TestPipeline.Box.WRITER OutBox + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + + public class Params_testPointers : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + Obj = CapnpSerializable.Create(reader.Obj); + List = reader.List; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + writer.Obj.SetObject(Obj); + writer.List.Init(List); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get; + set; + } + + public AnyPointer Obj + { + get; + set; + } + + public IReadOnlyList List + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestInterface Cap => ctx.ReadCap(0); + public DeserializerState Obj => ctx.StructReadPointer(1); + public IReadOnlyList List => ctx.ReadCapList(2); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 3); + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + + public DynamicSerializerState Obj + { + get => BuildPointer(1); + set => Link(1, value); + } + + public ListOfCapsSerializer List + { + get => BuildPointer>(2); + set => Link(2, value); + } + } + } + + public class Result_testPointers : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Params_getAnyCap : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + N = reader.N; + InCap = reader.InCap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.N = N; + writer.InCap = InCap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint N + { + get; + set; + } + + public BareProxy InCap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint N => ctx.ReadDataUInt(0UL, 0U); + public BareProxy InCap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public uint N + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public BareProxy InCap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Result_getAnyCap : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + S = reader.S; + OutBox = CapnpSerializable.Create(reader.OutBox); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.S = S; + OutBox?.serialize(writer.OutBox); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string S + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestPipeline.AnyBox OutBox + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string S => ctx.ReadText(0, ""); + public Capnproto_test.Capnp.Test.TestPipeline.AnyBox.READER OutBox => ctx.ReadStruct(1, Capnproto_test.Capnp.Test.TestPipeline.AnyBox.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public string S + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public Capnproto_test.Capnp.Test.TestPipeline.AnyBox.WRITER OutBox + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + } + + [Proxy(typeof(TestCallOrderProxy)), Skeleton(typeof(TestCallOrderSkeleton))] + public interface ITestCallOrder : IDisposable + { + Task GetCallSequence(uint expected, CancellationToken cancellationToken_ = default); + } + + public class TestCallOrderProxy : Proxy, ITestCallOrder + { + public async Task GetCallSequence(uint expected, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestCallOrder.Params_getCallSequence() + {Expected = expected}; + arg_.serialize(in_); + var d_ = await Call(11594359141811814481UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return (r_.N); + } + } + + public class TestCallOrderSkeleton : Skeleton + { + public TestCallOrderSkeleton() + { + SetMethodTable(GetCallSequence); + } + + public override ulong InterfaceId => 11594359141811814481UL; + Task GetCallSequence(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.GetCallSequence(in_.Expected, cancellationToken_), n => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestCallOrder.Result_getCallSequence{N = n}; + r_.serialize(s_); + return s_; + } + + ); + } + } + + public static class TestCallOrder + { + public class Params_getCallSequence : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Expected = reader.Expected; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Expected = Expected; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint Expected + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint Expected => ctx.ReadDataUInt(0UL, 0U); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public uint Expected + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + } + } + + public class Result_getCallSequence : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + N = reader.N; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.N = N; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint N + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint N => ctx.ReadDataUInt(0UL, 0U); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public uint N + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + } + } + } + + [Proxy(typeof(TestTailCalleeProxy)), Skeleton(typeof(TestTailCalleeSkeleton))] + public interface ITestTailCallee : IDisposable + { + Task Foo(int i, string t, CancellationToken cancellationToken_ = default); + } + + public class TestTailCalleeProxy : Proxy, ITestTailCallee + { + public Task Foo(int i, string t, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestTailCallee.Params_foo() + {I = i, T = t}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(15985132292242203195UL, 0, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create(d_); + return r_; + } + + ); + } + } + + public class TestTailCalleeSkeleton : Skeleton + { + public TestTailCalleeSkeleton() + { + SetMethodTable(Foo); + } + + public override ulong InterfaceId => 15985132292242203195UL; + Task Foo(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.Foo(in_.I, in_.T, cancellationToken_), r_ => + { + var s_ = SerializerState.CreateForRpc(); + r_.serialize(s_); + return s_; + } + + ); + } + } + + public static partial class PipeliningSupportExtensions + { + static readonly MemberAccessPath Path_foo_C = new MemberAccessPath(1U); + public static Capnproto_test.Capnp.Test.ITestCallOrder C(this Task task) + { + return (Capnproto_test.Capnp.Test.ITestCallOrder)CapabilityReflection.CreateProxy(Impatient.GetAnswer(task).Access(Path_foo_C)); + } + } + + public static class TestTailCallee + { + public class TailResult : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + I = reader.I; + T = reader.T; + C = reader.C; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.I = I; + writer.T = T; + writer.C = C; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public uint I + { + get; + set; + } + + public string T + { + get; + set; + } + + public Capnproto_test.Capnp.Test.ITestCallOrder C + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public uint I => ctx.ReadDataUInt(0UL, 0U); + public string T => ctx.ReadText(0, ""); + public Capnproto_test.Capnp.Test.ITestCallOrder C => ctx.ReadCap(1); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 2); + } + + public uint I + { + get => this.ReadDataUInt(0UL, 0U); + set => this.WriteData(0UL, value, 0U); + } + + public string T + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public Capnproto_test.Capnp.Test.ITestCallOrder C + { + get => ReadCap(1); + set => LinkObject(1, value); + } + } + } + + public class Params_foo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + I = reader.I; + T = reader.T; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.I = I; + writer.T = T; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public int I + { + get; + set; + } + + public string T + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public int I => ctx.ReadDataInt(0UL, 0); + public string T => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public int I + { + get => this.ReadDataInt(0UL, 0); + set => this.WriteData(0UL, value, 0); + } + + public string T + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + } + + [Proxy(typeof(TestTailCallerProxy)), Skeleton(typeof(TestTailCallerSkeleton))] + public interface ITestTailCaller : IDisposable + { + Task Foo(int i, Capnproto_test.Capnp.Test.ITestTailCallee callee, CancellationToken cancellationToken_ = default); + } + + public class TestTailCallerProxy : Proxy, ITestTailCaller + { + public Task Foo(int i, Capnproto_test.Capnp.Test.ITestTailCallee callee, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestTailCaller.Params_foo() + {I = i, Callee = callee}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(9731139705278181429UL, 0, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create(d_); + return r_; + } + + ); + } + } + + public class TestTailCallerSkeleton : Skeleton + { + public TestTailCallerSkeleton() + { + SetMethodTable(Foo); + } + + public override ulong InterfaceId => 9731139705278181429UL; + Task Foo(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.Foo(in_.I, in_.Callee, cancellationToken_), r_ => + { + var s_ = SerializerState.CreateForRpc(); + r_.serialize(s_); + return s_; + } + + ); + } + } + + public static partial class PipeliningSupportExtensions + { + } + + public static class TestTailCaller + { + public class Params_foo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + I = reader.I; + Callee = reader.Callee; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.I = I; + writer.Callee = Callee; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public int I + { + get; + set; + } + + public Capnproto_test.Capnp.Test.ITestTailCallee Callee + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public int I => ctx.ReadDataInt(0UL, 0); + public Capnproto_test.Capnp.Test.ITestTailCallee Callee => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public int I + { + get => this.ReadDataInt(0UL, 0); + set => this.WriteData(0UL, value, 0); + } + + public Capnproto_test.Capnp.Test.ITestTailCallee Callee + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + } + + [Proxy(typeof(TestHandleProxy)), Skeleton(typeof(TestHandleSkeleton))] + public interface ITestHandle : IDisposable + { + } + + public class TestHandleProxy : Proxy, ITestHandle + { + } + + public class TestHandleSkeleton : Skeleton + { + public TestHandleSkeleton() + { + SetMethodTable(); + } + + public override ulong InterfaceId => 11785461720995412501UL; + } + + [Proxy(typeof(TestMoreStuffProxy)), Skeleton(typeof(TestMoreStuffSkeleton))] + public interface ITestMoreStuff : Capnproto_test.Capnp.Test.ITestCallOrder + { + Task CallFoo(Capnproto_test.Capnp.Test.ITestInterface cap, CancellationToken cancellationToken_ = default); + Task CallFooWhenResolved(Capnproto_test.Capnp.Test.ITestInterface cap, CancellationToken cancellationToken_ = default); + Task NeverReturn(Capnproto_test.Capnp.Test.ITestInterface cap, CancellationToken cancellationToken_ = default); + Task Hold(Capnproto_test.Capnp.Test.ITestInterface cap, CancellationToken cancellationToken_ = default); + Task CallHeld(CancellationToken cancellationToken_ = default); + Task GetHeld(CancellationToken cancellationToken_ = default); + Task Echo(Capnproto_test.Capnp.Test.ITestCallOrder cap, CancellationToken cancellationToken_ = default); + Task ExpectCancel(Capnproto_test.Capnp.Test.ITestInterface cap, CancellationToken cancellationToken_ = default); + Task<(string, string)> MethodWithDefaults(string a, uint b, string c, CancellationToken cancellationToken_ = default); + Task GetHandle(CancellationToken cancellationToken_ = default); + Task GetNull(CancellationToken cancellationToken_ = default); + Task GetEnormousString(CancellationToken cancellationToken_ = default); + Task MethodWithNullDefault(string a, Capnproto_test.Capnp.Test.ITestInterface b, CancellationToken cancellationToken_ = default); + } + + public class TestMoreStuffProxy : Proxy, ITestMoreStuff + { + public async Task CallFoo(Capnproto_test.Capnp.Test.ITestInterface cap, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_callFoo() + {Cap = cap}; + arg_.serialize(in_); + var d_ = await Call(15980754968839795663UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return (r_.S); + } + + public async Task CallFooWhenResolved(Capnproto_test.Capnp.Test.ITestInterface cap, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_callFooWhenResolved() + {Cap = cap}; + arg_.serialize(in_); + var d_ = await Call(15980754968839795663UL, 1, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return (r_.S); + } + + public Task NeverReturn(Capnproto_test.Capnp.Test.ITestInterface cap, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_neverReturn() + {Cap = cap}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(15980754968839795663UL, 2, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create(d_); + return (r_.CapCopy); + } + + ); + } + + public async Task Hold(Capnproto_test.Capnp.Test.ITestInterface cap, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_hold() + {Cap = cap}; + arg_.serialize(in_); + var d_ = await Call(15980754968839795663UL, 3, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task CallHeld(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_callHeld() + {}; + arg_.serialize(in_); + var d_ = await Call(15980754968839795663UL, 4, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return (r_.S); + } + + public Task GetHeld(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_getHeld() + {}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(15980754968839795663UL, 5, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create(d_); + return (r_.Cap); + } + + ); + } + + public Task Echo(Capnproto_test.Capnp.Test.ITestCallOrder cap, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_echo() + {Cap = cap}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(15980754968839795663UL, 6, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create(d_); + return (r_.Cap); + } + + ); + } + + public async Task ExpectCancel(Capnproto_test.Capnp.Test.ITestInterface cap, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_expectCancel() + {Cap = cap}; + arg_.serialize(in_); + var d_ = await Call(15980754968839795663UL, 7, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task<(string, string)> MethodWithDefaults(string a, uint b, string c, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_methodWithDefaults() + {A = a, B = b, C = c}; + arg_.serialize(in_); + var d_ = await Call(15980754968839795663UL, 8, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return (r_.D, r_.E); + } + + public Task GetHandle(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_getHandle() + {}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(15980754968839795663UL, 9, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create(d_); + return (r_.Handle); + } + + ); + } + + public Task GetNull(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_getNull() + {}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(15980754968839795663UL, 10, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create(d_); + return (r_.NullCap); + } + + ); + } + + public async Task GetEnormousString(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_getEnormousString() + {}; + arg_.serialize(in_); + var d_ = await Call(15980754968839795663UL, 11, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return (r_.Str); + } + + public async Task MethodWithNullDefault(string a, Capnproto_test.Capnp.Test.ITestInterface b, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Params_methodWithNullDefault() + {A = a, B = b}; + arg_.serialize(in_); + var d_ = await Call(15980754968839795663UL, 12, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task GetCallSequence(uint expected, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestCallOrder.Params_getCallSequence() + {Expected = expected}; + arg_.serialize(in_); + var d_ = await Call(11594359141811814481UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return (r_.N); + } + } + + public class TestMoreStuffSkeleton : Skeleton + { + public TestMoreStuffSkeleton() + { + SetMethodTable(CallFoo, CallFooWhenResolved, NeverReturn, Hold, CallHeld, GetHeld, Echo, ExpectCancel, MethodWithDefaults, GetHandle, GetNull, GetEnormousString, MethodWithNullDefault); + } + + public override ulong InterfaceId => 15980754968839795663UL; + Task CallFoo(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.CallFoo(in_.Cap, cancellationToken_), s => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Result_callFoo{S = s}; + r_.serialize(s_); + return s_; + } + + ); + } + + Task CallFooWhenResolved(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.CallFooWhenResolved(in_.Cap, cancellationToken_), s => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Result_callFooWhenResolved{S = s}; + r_.serialize(s_); + return s_; + } + + ); + } + + Task NeverReturn(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.NeverReturn(in_.Cap, cancellationToken_), capCopy => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Result_neverReturn{CapCopy = capCopy}; + r_.serialize(s_); + return s_; + } + + ); + } + + async Task Hold(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + await Impl.Hold(in_.Cap, cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + + Task CallHeld(DeserializerState d_, CancellationToken cancellationToken_) + { + return Impatient.MaybeTailCall(Impl.CallHeld(cancellationToken_), s => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Result_callHeld{S = s}; + r_.serialize(s_); + return s_; + } + + ); + } + + Task GetHeld(DeserializerState d_, CancellationToken cancellationToken_) + { + return Impatient.MaybeTailCall(Impl.GetHeld(cancellationToken_), cap => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Result_getHeld{Cap = cap}; + r_.serialize(s_); + return s_; + } + + ); + } + + Task Echo(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.Echo(in_.Cap, cancellationToken_), cap => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Result_echo{Cap = cap}; + r_.serialize(s_); + return s_; + } + + ); + } + + async Task ExpectCancel(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + await Impl.ExpectCancel(in_.Cap, cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + + Task MethodWithDefaults(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.MethodWithDefaults(in_.A, in_.B, in_.C, cancellationToken_), (d, e) => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Result_methodWithDefaults{D = d, E = e}; + r_.serialize(s_); + return s_; + } + + ); + } + + Task GetHandle(DeserializerState d_, CancellationToken cancellationToken_) + { + return Impatient.MaybeTailCall(Impl.GetHandle(cancellationToken_), handle => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Result_getHandle{Handle = handle}; + r_.serialize(s_); + return s_; + } + + ); + } + + Task GetNull(DeserializerState d_, CancellationToken cancellationToken_) + { + return Impatient.MaybeTailCall(Impl.GetNull(cancellationToken_), nullCap => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Result_getNull{NullCap = nullCap}; + r_.serialize(s_); + return s_; + } + + ); + } + + Task GetEnormousString(DeserializerState d_, CancellationToken cancellationToken_) + { + return Impatient.MaybeTailCall(Impl.GetEnormousString(cancellationToken_), str => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMoreStuff.Result_getEnormousString{Str = str}; + r_.serialize(s_); + return s_; + } + + ); + } + + async Task MethodWithNullDefault(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + await Impl.MethodWithNullDefault(in_.A, in_.B, cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + } + + public static partial class PipeliningSupportExtensions + { + static readonly MemberAccessPath Path_neverReturn_Eager = new MemberAccessPath(0U); + public static Capnproto_test.Capnp.Test.ITestInterface Eager(this Task task) + { + return (Capnproto_test.Capnp.Test.ITestInterface)CapabilityReflection.CreateProxy(Impatient.GetAnswer(task).Access(Path_neverReturn_Eager)); + } + + static readonly MemberAccessPath Path_echo_Eager = new MemberAccessPath(0U); + public static Capnproto_test.Capnp.Test.ITestCallOrder Eager(this Task task) + { + return (Capnproto_test.Capnp.Test.ITestCallOrder)CapabilityReflection.CreateProxy(Impatient.GetAnswer(task).Access(Path_echo_Eager)); + } + + static readonly MemberAccessPath Path_getHandle_Eager = new MemberAccessPath(0U); + public static Capnproto_test.Capnp.Test.ITestHandle Eager(this Task task) + { + return (Capnproto_test.Capnp.Test.ITestHandle)CapabilityReflection.CreateProxy(Impatient.GetAnswer(task).Access(Path_getHandle_Eager)); + } + + static readonly MemberAccessPath Path_getNull_Eager = new MemberAccessPath(0U); + public static Capnproto_test.Capnp.Test.ITestMoreStuff Eager(this Task task) + { + return (Capnproto_test.Capnp.Test.ITestMoreStuff)CapabilityReflection.CreateProxy(Impatient.GetAnswer(task).Access(Path_getNull_Eager)); + } + } + + public static class TestMoreStuff + { + public class Params_callFoo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestInterface Cap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Result_callFoo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + S = reader.S; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.S = S; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string S + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string S => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string S + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Params_callFooWhenResolved : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestInterface Cap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Result_callFooWhenResolved : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + S = reader.S; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.S = S; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string S + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string S => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string S + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Params_neverReturn : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestInterface Cap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Result_neverReturn : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + CapCopy = reader.CapCopy; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.CapCopy = CapCopy; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestInterface CapCopy + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestInterface CapCopy => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestInterface CapCopy + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Params_hold : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestInterface Cap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Result_hold : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Params_callHeld : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_callHeld : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + S = reader.S; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.S = S; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string S + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string S => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string S + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Params_getHeld : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_getHeld : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestInterface Cap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Params_echo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestCallOrder Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestCallOrder Cap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestCallOrder Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Result_echo : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestCallOrder Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestCallOrder Cap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestCallOrder Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Params_expectCancel : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestInterface Cap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Result_expectCancel : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Params_methodWithDefaults : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + A = reader.A; + B = reader.B; + C = reader.C; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.A = A; + writer.B = B; + writer.C = C; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + C = C ?? "foo"; + } + + public string A + { + get; + set; + } + + public uint B + { + get; + set; + } + + = 123U; + public string C + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string A => ctx.ReadText(0, ""); + public uint B => ctx.ReadDataUInt(0UL, 123U); + public string C => ctx.ReadText(1, "foo"); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 2); + } + + public string A + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public uint B + { + get => this.ReadDataUInt(0UL, 123U); + set => this.WriteData(0UL, value, 123U); + } + + public string C + { + get => this.ReadText(1, "foo"); + set => this.WriteText(1, value, "foo"); + } + } + } + + public class Result_methodWithDefaults : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + D = reader.D; + E = reader.E; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.D = D; + writer.E = E; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + E = E ?? "bar"; + } + + public string D + { + get; + set; + } + + public string E + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string D => ctx.ReadText(0, ""); + public string E => ctx.ReadText(1, "bar"); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public string D + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public string E + { + get => this.ReadText(1, "bar"); + set => this.WriteText(1, value, "bar"); + } + } + } + + public class Params_getHandle : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_getHandle : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Handle = reader.Handle; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Handle = Handle; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestHandle Handle + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestHandle Handle => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestHandle Handle + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Params_getNull : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_getNull : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + NullCap = reader.NullCap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.NullCap = NullCap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.ITestMoreStuff NullCap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.ITestMoreStuff NullCap => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.ITestMoreStuff NullCap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Params_getEnormousString : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_getEnormousString : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Str = reader.Str; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Str = Str; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Str + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Str => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string Str + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Params_methodWithNullDefault : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + A = reader.A; + B = reader.B; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.A = A; + writer.B = B; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string A + { + get; + set; + } + + public Capnproto_test.Capnp.Test.ITestInterface B + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string A => ctx.ReadText(0, ""); + public Capnproto_test.Capnp.Test.ITestInterface B => ctx.ReadCap(1); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public string A + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public Capnproto_test.Capnp.Test.ITestInterface B + { + get => ReadCap(1); + set => LinkObject(1, value); + } + } + } + + public class Result_methodWithNullDefault : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + } + + [Proxy(typeof(TestMembraneProxy)), Skeleton(typeof(TestMembraneSkeleton))] + public interface ITestMembrane : IDisposable + { + Task MakeThing(CancellationToken cancellationToken_ = default); + Task CallPassThrough(Capnproto_test.Capnp.Test.TestMembrane.IThing thing, bool tailCall, CancellationToken cancellationToken_ = default); + Task CallIntercept(Capnproto_test.Capnp.Test.TestMembrane.IThing thing, bool tailCall, CancellationToken cancellationToken_ = default); + Task Loopback(Capnproto_test.Capnp.Test.TestMembrane.IThing thing, CancellationToken cancellationToken_ = default); + Task WaitForever(CancellationToken cancellationToken_ = default); + } + + public class TestMembraneProxy : Proxy, ITestMembrane + { + public Task MakeThing(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMembrane.Params_makeThing() + {}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(13870398341137210380UL, 0, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create(d_); + return (r_.Thing); + } + + ); + } + + public async Task CallPassThrough(Capnproto_test.Capnp.Test.TestMembrane.IThing thing, bool tailCall, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMembrane.Params_callPassThrough() + {Thing = thing, TailCall = tailCall}; + arg_.serialize(in_); + var d_ = await Call(13870398341137210380UL, 1, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return r_; + } + + public async Task CallIntercept(Capnproto_test.Capnp.Test.TestMembrane.IThing thing, bool tailCall, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMembrane.Params_callIntercept() + {Thing = thing, TailCall = tailCall}; + arg_.serialize(in_); + var d_ = await Call(13870398341137210380UL, 2, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return r_; + } + + public Task Loopback(Capnproto_test.Capnp.Test.TestMembrane.IThing thing, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMembrane.Params_loopback() + {Thing = thing}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(13870398341137210380UL, 3, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create(d_); + return (r_.Thing); + } + + ); + } + + public async Task WaitForever(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMembrane.Params_waitForever() + {}; + arg_.serialize(in_); + var d_ = await Call(13870398341137210380UL, 4, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + } + + public class TestMembraneSkeleton : Skeleton + { + public TestMembraneSkeleton() + { + SetMethodTable(MakeThing, CallPassThrough, CallIntercept, Loopback, WaitForever); + } + + public override ulong InterfaceId => 13870398341137210380UL; + Task MakeThing(DeserializerState d_, CancellationToken cancellationToken_) + { + return Impatient.MaybeTailCall(Impl.MakeThing(cancellationToken_), thing => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMembrane.Result_makeThing{Thing = thing}; + r_.serialize(s_); + return s_; + } + + ); + } + + Task CallPassThrough(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.CallPassThrough(in_.Thing, in_.TailCall, cancellationToken_), r_ => + { + var s_ = SerializerState.CreateForRpc(); + r_.serialize(s_); + return s_; + } + + ); + } + + Task CallIntercept(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.CallIntercept(in_.Thing, in_.TailCall, cancellationToken_), r_ => + { + var s_ = SerializerState.CreateForRpc(); + r_.serialize(s_); + return s_; + } + + ); + } + + Task Loopback(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + return Impatient.MaybeTailCall(Impl.Loopback(in_.Thing, cancellationToken_), thing => + { + var s_ = SerializerState.CreateForRpc(); + var r_ = new Capnproto_test.Capnp.Test.TestMembrane.Result_loopback{Thing = thing}; + r_.serialize(s_); + return s_; + } + + ); + } + + async Task WaitForever(DeserializerState d_, CancellationToken cancellationToken_) + { + await Impl.WaitForever(cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + } + + public static partial class PipeliningSupportExtensions + { + static readonly MemberAccessPath Path_makeThing_Eager = new MemberAccessPath(0U); + public static Capnproto_test.Capnp.Test.TestMembrane.IThing Eager(this Task task) + { + return (Capnproto_test.Capnp.Test.TestMembrane.IThing)CapabilityReflection.CreateProxy(Impatient.GetAnswer(task).Access(Path_makeThing_Eager)); + } + } + + public static class TestMembrane + { + [Proxy(typeof(ThingProxy)), Skeleton(typeof(ThingSkeleton))] + public interface IThing : IDisposable + { + Task PassThrough(CancellationToken cancellationToken_ = default); + Task Intercept(CancellationToken cancellationToken_ = default); + } + + public class ThingProxy : Proxy, IThing + { + public async Task PassThrough(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMembrane.Thing.Params_passThrough() + {}; + arg_.serialize(in_); + var d_ = await Call(10615798940090972439UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return r_; + } + + public async Task Intercept(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestMembrane.Thing.Params_intercept() + {}; + arg_.serialize(in_); + var d_ = await Call(10615798940090972439UL, 1, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return r_; + } + } + + public class ThingSkeleton : Skeleton + { + public ThingSkeleton() + { + SetMethodTable(PassThrough, Intercept); + } + + public override ulong InterfaceId => 10615798940090972439UL; + Task PassThrough(DeserializerState d_, CancellationToken cancellationToken_) + { + return Impatient.MaybeTailCall(Impl.PassThrough(cancellationToken_), r_ => + { + var s_ = SerializerState.CreateForRpc(); + r_.serialize(s_); + return s_; + } + + ); + } + + Task Intercept(DeserializerState d_, CancellationToken cancellationToken_) + { + return Impatient.MaybeTailCall(Impl.Intercept(cancellationToken_), r_ => + { + var s_ = SerializerState.CreateForRpc(); + r_.serialize(s_); + return s_; + } + + ); + } + } + + public static class Thing + { + public class Params_passThrough : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Params_intercept : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + } + + public class Result : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Text = reader.Text; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Text = Text; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Text + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Text => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string Text + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class Params_makeThing : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_makeThing : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Thing = reader.Thing; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Thing = Thing; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Params_callPassThrough : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Thing = reader.Thing; + TailCall = reader.TailCall; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Thing = Thing; + writer.TailCall = TailCall; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing + { + get; + set; + } + + public bool TailCall + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing => ctx.ReadCap(0); + public bool TailCall => ctx.ReadDataBool(0UL, false); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing + { + get => ReadCap(0); + set => LinkObject(0, value); + } + + public bool TailCall + { + get => this.ReadDataBool(0UL, false); + set => this.WriteData(0UL, value, false); + } + } + } + + public class Params_callIntercept : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Thing = reader.Thing; + TailCall = reader.TailCall; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Thing = Thing; + writer.TailCall = TailCall; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing + { + get; + set; + } + + public bool TailCall + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing => ctx.ReadCap(0); + public bool TailCall => ctx.ReadDataBool(0UL, false); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing + { + get => ReadCap(0); + set => LinkObject(0, value); + } + + public bool TailCall + { + get => this.ReadDataBool(0UL, false); + set => this.WriteData(0UL, value, false); + } + } + } + + public class Params_loopback : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Thing = reader.Thing; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Thing = Thing; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Result_loopback : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Thing = reader.Thing; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Thing = Thing; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing => ctx.ReadCap(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Thing + { + get => ReadCap(0); + set => LinkObject(0, value); + } + } + } + + public class Params_waitForever : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_waitForever : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + } + + public class TestContainMembrane : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Cap = reader.Cap; + List = reader.List; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Cap = Cap; + writer.List.Init(List); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Cap + { + get; + set; + } + + public IReadOnlyList List + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestMembrane.IThing Cap => ctx.ReadCap(0); + public IReadOnlyList List => ctx.ReadCapList(1); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public Capnproto_test.Capnp.Test.TestMembrane.IThing Cap + { + get => ReadCap(0); + set => LinkObject(0, value); + } + + public ListOfCapsSerializer List + { + get => BuildPointer>(1); + set => Link(1, value); + } + } + } + + public class TestTransferCap : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + List = reader.List.ToReadOnlyList(_ => CapnpSerializable.Create(_)); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.List.Init(List, (_s1, _v1) => _v1?.serialize(_s1)); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public IReadOnlyList List + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public IReadOnlyList List => ctx.ReadList(0).Cast(Capnproto_test.Capnp.Test.TestTransferCap.Element.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public ListOfStructsSerializer List + { + get => BuildPointer>(0); + set => Link(0, value); + } + } + + public class Element : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Text = reader.Text; + Cap = reader.Cap; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Text = Text; + writer.Cap = Cap; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Text + { + get; + set; + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Text => ctx.ReadText(0, ""); + public Capnproto_test.Capnp.Test.ITestInterface Cap => ctx.ReadCap(1); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public string Text + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + + public Capnproto_test.Capnp.Test.ITestInterface Cap + { + get => ReadCap(1); + set => LinkObject(1, value); + } + } + } + } + + [Proxy(typeof(TestKeywordMethodsProxy)), Skeleton(typeof(TestKeywordMethodsSkeleton))] + public interface ITestKeywordMethods : IDisposable + { + Task Delete(CancellationToken cancellationToken_ = default); + Task Class(CancellationToken cancellationToken_ = default); + Task Void(CancellationToken cancellationToken_ = default); + Task Return(CancellationToken cancellationToken_ = default); + } + + public class TestKeywordMethodsProxy : Proxy, ITestKeywordMethods + { + public async Task Delete(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestKeywordMethods.Params_delete() + {}; + arg_.serialize(in_); + var d_ = await Call(11160837778045172988UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task Class(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestKeywordMethods.Params_class() + {}; + arg_.serialize(in_); + var d_ = await Call(11160837778045172988UL, 1, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task Void(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestKeywordMethods.Params_void() + {}; + arg_.serialize(in_); + var d_ = await Call(11160837778045172988UL, 2, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + + public async Task Return(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestKeywordMethods.Params_return() + {}; + arg_.serialize(in_); + var d_ = await Call(11160837778045172988UL, 3, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + } + + public class TestKeywordMethodsSkeleton : Skeleton + { + public TestKeywordMethodsSkeleton() + { + SetMethodTable(Delete, Class, Void, Return); + } + + public override ulong InterfaceId => 11160837778045172988UL; + async Task Delete(DeserializerState d_, CancellationToken cancellationToken_) + { + await Impl.Delete(cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + + async Task Class(DeserializerState d_, CancellationToken cancellationToken_) + { + await Impl.Class(cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + + async Task Void(DeserializerState d_, CancellationToken cancellationToken_) + { + await Impl.Void(cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + + async Task Return(DeserializerState d_, CancellationToken cancellationToken_) + { + await Impl.Return(cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + } + + public static class TestKeywordMethods + { + public class Params_delete : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_delete : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Params_class : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_class : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Params_void : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_void : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Params_return : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_return : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + } + + [Proxy(typeof(TestAuthenticatedBootstrapProxy<>)), Skeleton(typeof(TestAuthenticatedBootstrapSkeleton<>))] + public interface ITestAuthenticatedBootstrap : IDisposable + { + Task GetCallerId(CancellationToken cancellationToken_ = default); + } + + public class TestAuthenticatedBootstrapProxy : Proxy, ITestAuthenticatedBootstrap where TVatId : class + { + public Task GetCallerId(CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc.Params_getCallerId.WRITER>(); + var arg_ = new Capnproto_test.Capnp.Test.TestAuthenticatedBootstrap.Params_getCallerId() + {}; + arg_.serialize(in_); + return Impatient.MakePipelineAware(Call(16893789964317726925UL, 0, in_.Rewrap(), false, cancellationToken_), d_ => + { + var r_ = CapnpSerializable.Create.Result_getCallerId>(d_); + return (r_.Caller); + } + + ); + } + } + + public class TestAuthenticatedBootstrapSkeleton : Skeleton> where TVatId : class + { + public TestAuthenticatedBootstrapSkeleton() + { + SetMethodTable(GetCallerId); + } + + public override ulong InterfaceId => 16893789964317726925UL; + Task GetCallerId(DeserializerState d_, CancellationToken cancellationToken_) + { + return Impatient.MaybeTailCall(Impl.GetCallerId(cancellationToken_), caller => + { + var s_ = SerializerState.CreateForRpc.Result_getCallerId.WRITER>(); + var r_ = new Capnproto_test.Capnp.Test.TestAuthenticatedBootstrap.Result_getCallerId{Caller = caller}; + r_.serialize(s_); + return s_; + } + + ); + } + } + + public static class TestAuthenticatedBootstrap + where TVatId : class + { + public class Params_getCallerId : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class Result_getCallerId : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Caller = CapnpSerializable.Create(reader.Caller); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Caller.SetObject(Caller); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public TVatId Caller + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public DeserializerState Caller => ctx.StructReadPointer(0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public DynamicSerializerState Caller + { + get => BuildPointer(0); + set => Link(0, value); + } + } + } + } + + public class TestSturdyRef : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + HostId = CapnpSerializable.Create(reader.HostId); + ObjectId = CapnpSerializable.Create(reader.ObjectId); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + HostId?.serialize(writer.HostId); + writer.ObjectId.SetObject(ObjectId); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestSturdyRefHostId HostId + { + get; + set; + } + + public AnyPointer ObjectId + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestSturdyRefHostId.READER HostId => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestSturdyRefHostId.READER.create); + public DeserializerState ObjectId => ctx.StructReadPointer(1); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 2); + } + + public Capnproto_test.Capnp.Test.TestSturdyRefHostId.WRITER HostId + { + get => BuildPointer(0); + set => Link(0, value); + } + + public DynamicSerializerState ObjectId + { + get => BuildPointer(1); + set => Link(1, value); + } + } + } + + public class TestSturdyRefHostId : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + Host = reader.Host; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.Host = Host; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public string Host + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public string Host => ctx.ReadText(0, ""); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 1); + } + + public string Host + { + get => this.ReadText(0, ""); + set => this.WriteText(0, value, ""); + } + } + } + + public class TestSturdyRefObjectId : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + TheTag = reader.TheTag; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.TheTag = TheTag; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestSturdyRefObjectId.Tag TheTag + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public Capnproto_test.Capnp.Test.TestSturdyRefObjectId.Tag TheTag => (Capnproto_test.Capnp.Test.TestSturdyRefObjectId.Tag)ctx.ReadDataUShort(0UL, (ushort)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public Capnproto_test.Capnp.Test.TestSturdyRefObjectId.Tag TheTag + { + get => (Capnproto_test.Capnp.Test.TestSturdyRefObjectId.Tag)this.ReadDataUShort(0UL, (ushort)0); + set => this.WriteData(0UL, (ushort)value, (ushort)0); + } + } + + public enum Tag : ushort + { + testInterface, + testExtends, + testPipeline, + testTailCallee, + testTailCaller, + testMoreStuff + } + } + + public class TestProvisionId : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class TestRecipientId : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class TestThirdPartyCapId : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class TestJoinResult : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + + public class TestNameAnnotation : ICapnpSerializable + { + public enum WHICH : ushort + { + BadFieldName = 0, + Bar = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.BadFieldName: + BadFieldName = reader.BadFieldName; + break; + case WHICH.Bar: + Bar = reader.Bar; + break; + } + + AnotherBadFieldName = reader.AnotherBadFieldName; + BadlyNamedUnion = CapnpSerializable.Create(reader.BadlyNamedUnion); + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.BadFieldName: + _content = false; + break; + case WHICH.Bar: + _content = 0; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.BadFieldName: + writer.BadFieldName = BadFieldName.Value; + break; + case WHICH.Bar: + writer.Bar = Bar.Value; + break; + } + + writer.AnotherBadFieldName = AnotherBadFieldName; + BadlyNamedUnion?.serialize(writer.BadlyNamedUnion); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool? BadFieldName + { + get => _which == WHICH.BadFieldName ? (bool? )_content : null; + set + { + _which = WHICH.BadFieldName; + _content = value; + } + } + + public sbyte? Bar + { + get => _which == WHICH.Bar ? (sbyte? )_content : null; + set + { + _which = WHICH.Bar; + _content = value; + } + } + + public Capnproto_test.Capnp.Test.TestNameAnnotation.BadlyNamedEnum AnotherBadFieldName + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestNameAnnotation.@badlyNamedUnion BadlyNamedUnion + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(16U, (ushort)0); + public bool BadFieldName => which == WHICH.BadFieldName ? ctx.ReadDataBool(0UL, false) : default; + public sbyte Bar => which == WHICH.Bar ? ctx.ReadDataSByte(0UL, (sbyte)0) : default; + public Capnproto_test.Capnp.Test.TestNameAnnotation.BadlyNamedEnum AnotherBadFieldName => (Capnproto_test.Capnp.Test.TestNameAnnotation.BadlyNamedEnum)ctx.ReadDataUShort(32UL, (ushort)0); + public @badlyNamedUnion.READER BadlyNamedUnion => new @badlyNamedUnion.READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(16U, (ushort)0); + set => this.WriteData(16U, (ushort)value, (ushort)0); + } + + public bool BadFieldName + { + get => which == WHICH.BadFieldName ? this.ReadDataBool(0UL, false) : default; + set => this.WriteData(0UL, value, false); + } + + public sbyte Bar + { + get => which == WHICH.Bar ? this.ReadDataSByte(0UL, (sbyte)0) : default; + set => this.WriteData(0UL, value, (sbyte)0); + } + + public Capnproto_test.Capnp.Test.TestNameAnnotation.BadlyNamedEnum AnotherBadFieldName + { + get => (Capnproto_test.Capnp.Test.TestNameAnnotation.BadlyNamedEnum)this.ReadDataUShort(32UL, (ushort)0); + set => this.WriteData(32UL, (ushort)value, (ushort)0); + } + + public @badlyNamedUnion.WRITER BadlyNamedUnion + { + get => Rewrap<@badlyNamedUnion.WRITER>(); + } + } + + public class @badlyNamedUnion : ICapnpSerializable + { + public enum WHICH : ushort + { + BadlyNamedGroup = 0, + Baz = 1, + undefined = 65535 + } + + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + switch (reader.which) + { + case WHICH.BadlyNamedGroup: + BadlyNamedGroup = CapnpSerializable.Create(reader.BadlyNamedGroup); + break; + case WHICH.Baz: + Baz = CapnpSerializable.Create(reader.Baz); + break; + } + + applyDefaults(); + } + + private WHICH _which = WHICH.undefined; + private object _content; + public WHICH which + { + get => _which; + set + { + if (value == _which) + return; + _which = value; + switch (value) + { + case WHICH.BadlyNamedGroup: + _content = null; + break; + case WHICH.Baz: + _content = null; + break; + } + } + } + + public void serialize(WRITER writer) + { + writer.which = which; + switch (which) + { + case WHICH.BadlyNamedGroup: + BadlyNamedGroup?.serialize(writer.BadlyNamedGroup); + break; + case WHICH.Baz: + Baz?.serialize(writer.Baz); + break; + } + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public Capnproto_test.Capnp.Test.TestNameAnnotation.@badlyNamedUnion.@badlyNamedGroup BadlyNamedGroup + { + get => _which == WHICH.BadlyNamedGroup ? (Capnproto_test.Capnp.Test.TestNameAnnotation.@badlyNamedUnion.@badlyNamedGroup)_content : null; + set + { + _which = WHICH.BadlyNamedGroup; + _content = value; + } + } + + public Capnproto_test.Capnp.Test.TestNameAnnotation.NestedStruct Baz + { + get => _which == WHICH.Baz ? (Capnproto_test.Capnp.Test.TestNameAnnotation.NestedStruct)_content : null; + set + { + _which = WHICH.Baz; + _content = value; + } + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public WHICH which => (WHICH)ctx.ReadDataUShort(48U, (ushort)0); + public @badlyNamedGroup.READER BadlyNamedGroup => which == WHICH.BadlyNamedGroup ? new @badlyNamedGroup.READER(ctx) : default; + public Capnproto_test.Capnp.Test.TestNameAnnotation.NestedStruct.READER Baz => which == WHICH.Baz ? ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestNameAnnotation.NestedStruct.READER.create) : default; + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + + public WHICH which + { + get => (WHICH)this.ReadDataUShort(48U, (ushort)0); + set => this.WriteData(48U, (ushort)value, (ushort)0); + } + + public @badlyNamedGroup.WRITER BadlyNamedGroup + { + get => which == WHICH.BadlyNamedGroup ? Rewrap<@badlyNamedGroup.WRITER>() : default; + } + + public Capnproto_test.Capnp.Test.TestNameAnnotation.NestedStruct.WRITER Baz + { + get => which == WHICH.Baz ? BuildPointer(0) : default; + set => Link(0, value); + } + } + + public class @badlyNamedGroup : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + } + } + } + } + + public enum BadlyNamedEnum : ushort + { + foo, + bar, + baz + } + + public class NestedStruct : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + BadNestedFieldName = reader.BadNestedFieldName; + AnotherBadNestedFieldName = CapnpSerializable.Create(reader.AnotherBadNestedFieldName); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.BadNestedFieldName = BadNestedFieldName; + AnotherBadNestedFieldName?.serialize(writer.AnotherBadNestedFieldName); + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public bool BadNestedFieldName + { + get; + set; + } + + public Capnproto_test.Capnp.Test.TestNameAnnotation.NestedStruct AnotherBadNestedFieldName + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public bool BadNestedFieldName => ctx.ReadDataBool(0UL, false); + public Capnproto_test.Capnp.Test.TestNameAnnotation.NestedStruct.READER AnotherBadNestedFieldName => ctx.ReadStruct(0, Capnproto_test.Capnp.Test.TestNameAnnotation.NestedStruct.READER.create); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 1); + } + + public bool BadNestedFieldName + { + get => this.ReadDataBool(0UL, false); + set => this.WriteData(0UL, value, false); + } + + public Capnproto_test.Capnp.Test.TestNameAnnotation.NestedStruct.WRITER AnotherBadNestedFieldName + { + get => BuildPointer(0); + set => Link(0, value); + } + } + + public enum DeeplyNestedEnum : ushort + { + quux, + corge, + grault + } + } + } + + [Proxy(typeof(TestNameAnnotationInterfaceProxy)), Skeleton(typeof(TestNameAnnotationInterfaceSkeleton))] + public interface ITestNameAnnotationInterface : IDisposable + { + Task BadlyNamedMethod(byte badlyNamedParam, CancellationToken cancellationToken_ = default); + } + + public class TestNameAnnotationInterfaceProxy : Proxy, ITestNameAnnotationInterface + { + public async Task BadlyNamedMethod(byte badlyNamedParam, CancellationToken cancellationToken_ = default) + { + var in_ = SerializerState.CreateForRpc(); + var arg_ = new Capnproto_test.Capnp.Test.TestNameAnnotationInterface.Params_badlyNamedMethod() + {BadlyNamedParam = badlyNamedParam}; + arg_.serialize(in_); + var d_ = await Call(15065286897585459595UL, 0, in_.Rewrap(), false, cancellationToken_).WhenReturned; + var r_ = CapnpSerializable.Create(d_); + return; + } + } + + public class TestNameAnnotationInterfaceSkeleton : Skeleton + { + public TestNameAnnotationInterfaceSkeleton() + { + SetMethodTable(BadlyNamedMethod); + } + + public override ulong InterfaceId => 15065286897585459595UL; + async Task BadlyNamedMethod(DeserializerState d_, CancellationToken cancellationToken_) + { + var in_ = CapnpSerializable.Create(d_); + await Impl.BadlyNamedMethod(in_.BadlyNamedParam, cancellationToken_); + var s_ = SerializerState.CreateForRpc(); + return s_; + } + } + + public static class TestNameAnnotationInterface + { + public class Params_badlyNamedMethod : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + BadlyNamedParam = reader.BadlyNamedParam; + applyDefaults(); + } + + public void serialize(WRITER writer) + { + writer.BadlyNamedParam = BadlyNamedParam; + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public byte BadlyNamedParam + { + get; + set; + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + public byte BadlyNamedParam => ctx.ReadDataByte(0UL, (byte)0); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(1, 0); + } + + public byte BadlyNamedParam + { + get => this.ReadDataByte(0UL, (byte)0); + set => this.WriteData(0UL, value, (byte)0); + } + } + } + + public class Result_badlyNamedMethod : ICapnpSerializable + { + void ICapnpSerializable.Deserialize(DeserializerState arg_) + { + var reader = READER.create(arg_); + applyDefaults(); + } + + public void serialize(WRITER writer) + { + } + + void ICapnpSerializable.Serialize(SerializerState arg_) + { + serialize(arg_.Rewrap()); + } + + public void applyDefaults() + { + } + + public struct READER + { + readonly DeserializerState ctx; + public READER(DeserializerState ctx) + { + this.ctx = ctx; + } + + public static READER create(DeserializerState ctx) => new READER(ctx); + public static implicit operator DeserializerState(READER reader) => reader.ctx; + public static implicit operator READER(DeserializerState ctx) => new READER(ctx); + } + + public class WRITER : SerializerState + { + public WRITER() + { + this.SetStruct(0, 0); + } + } + } + } +} \ No newline at end of file diff --git a/MsBuildGenerationTest/capnp/testdata/annotated-json.binary b/MsBuildGenerationTest/capnp/testdata/annotated-json.binary new file mode 100644 index 0000000..6c54755 Binary files /dev/null and b/MsBuildGenerationTest/capnp/testdata/annotated-json.binary differ diff --git a/MsBuildGenerationTest/capnp/testdata/annotated.json b/MsBuildGenerationTest/capnp/testdata/annotated.json new file mode 100644 index 0000000..bb51400 --- /dev/null +++ b/MsBuildGenerationTest/capnp/testdata/annotated.json @@ -0,0 +1,22 @@ +{ "names-can_contain!anything Really": "foo", + "flatFoo": 123, + "flatBar": "abc", + "renamed-flatBaz": {"hello": true}, + "flatQux": "cba", + "pfx.foo": "this is a long string in order to force multi-line pretty printing", + "pfx.renamed-bar": 321, + "pfx.baz": {"hello": true}, + "pfx.xfp.qux": "fed", + "union-type": "renamed-bar", + "barMember": 789, + "multiMember": "ghi", + "dependency": {"renamed-foo": "corge"}, + "simpleGroup": {"renamed-grault": "garply"}, + "enums": ["qux", "renamed-bar", "foo", "renamed-baz"], + "innerJson": [123, "hello", {"object": true}], + "testBase64": "ZnJlZA==", + "testHex": "706c756768", + "bUnion": "renamed-bar", + "bValue": 678, + "externalUnion": {"type": "bar", "value": "cba"}, + "unionWithVoid": {"type": "voidValue"} } diff --git a/MsBuildGenerationTest/capnp/testdata/binary b/MsBuildGenerationTest/capnp/testdata/binary new file mode 100644 index 0000000..ea39763 Binary files /dev/null and b/MsBuildGenerationTest/capnp/testdata/binary differ diff --git a/MsBuildGenerationTest/capnp/testdata/errors.capnp.nobuild b/MsBuildGenerationTest/capnp/testdata/errors.capnp.nobuild new file mode 100644 index 0000000..a909e97 --- /dev/null +++ b/MsBuildGenerationTest/capnp/testdata/errors.capnp.nobuild @@ -0,0 +1,161 @@ +# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# This file is intended to test that various error cases are detected as errors. The error +# output is matched against a golden file. The file name has the .nobuild extension to make +# sure that a build system which automatically builds .capnp files does not try to build this one. + +# + +@0xccd0890aa4926a9b; +# Can't really test the missing-ID error because the output is intentionally unpredictable. + +const notType :Int32 = 123; +annotation notFieldAnnotation(struct) :Int32; +annotation fieldAnnotation(field) :Int32; + +struct Foo { + dupName @0 :Int32; + dupName @1 :Int32; + dupNumber1 @2 :Int32; + dupNumber2 @2 :Int32; + + missingNumber @4 :Int32; + next @5 :Int32; + + emptyUnion :union {} + emptyGroup :group {} + + singletonUnion :union { + field @6 :Int32; + } + + union { + dupName @7 :Int32; + f8 @8 :Int32; + } + union { + f9 @9 :Int32; + f10 @10 :Int32; + } + + struct wrongTypeStyle {} + WrongFieldStyle @11 :Int32; + under_score @12 :Int32; + + containsStruct :group { + f13 @13 :Int32; + struct CantNestHere {} + } + + retroUnion @16! :union { + f14 @14 :Int32; + f15 @15 :Int32; + } + + missingColonAndEclamation @18 union { + f19 @19 :Int32; + f20 @20 :Int32; + } + + missingExclamation @21 :union { + f22 @22 :Int32; + f23 @23 :Int32; + } + + missingColon @24! union { + f19 @25 :Int32; + f20 @26 :Int32; + } + + unnamedInNamed :union { + f27 @27 :Int32; + f28 @28 :Int32; + union { + # content is ignored + } + } + + listWithoutParam @31 :List; + listWithTooManyParams @32 :List(Int32, Int64); + listAnyPointer @33 :List(AnyPointer); + notAType @34 :notType; + noParams @35 :Foo(Int32); + + defaultOutOfRange @36 :Int16 = 1234567; + defaultOutOfRange2 @37 :UInt16 = -1; + defaultWrongType @38 :Text = 123; + defaultWrongType2 @39 :Text = [123]; + defaultWrongType3 @40 :Text = (foo = 123, bar = 456); + defaultTooBigToBeNegative @41 :Int64 = -0x8000000000000001; + defaultNotConstant @42 :Int32 = .Foo; + defaultConstantNotQualified @43 :Int32 = notType; + + notAnnotation @44 :Int32 $Foo(123); + badAnnotation @45 :Int32 $notFieldAnnotation(123); + notVoidAnnotation @46 :Int32 $fieldAnnotation; + + undefinedImport @17 :import "noshuchfile.capnp".Bar; + undefinedAbsolute @47 : .NoSuch; + undefinedRelative @29 :NoSuch; + undefinedMember @30 :Foo.NoSuch; +} + +struct Bar { + x @3 :Text; + someGroup :group { + defaultMissingFieldName @2 :Bar = (x = "abcd", 456); + defaultNoSuchField @0 :Bar = (nosuchfield = 123); + defaultGroupMismatch @1 :Bar = (someGroup = 123); + } +} + + +using Bar; + +enum DupEnumerants { + dupName @0; + dupName @1; + dupNumber1 @2; + dupNumber2 @2; +} + +const recursive: UInt32 = .recursive; + +struct Generic(T, U) { +} + +struct UseGeneric { + tooFew @0 :Generic(Text); + tooMany @1 :Generic(Text, Data, List(Int32)); + doubleBind @2 :Generic(Text, Data)(Data, Text); + primitiveBinding @3 :Generic(Text, Int32); +} + +const embedBadType :UInt32 = embed "binary"; +const embedNoSuchFile :Data = embed "no-such-file"; + +using Baz = import "nosuchfile-unused.capnp".Baz; +# Check that an import in an unused `using` still reports error. + +interface TestInterface { + foo @0 (a :UInt32 = null); +} diff --git a/MsBuildGenerationTest/capnp/testdata/errors.txt b/MsBuildGenerationTest/capnp/testdata/errors.txt new file mode 100644 index 0000000..ed238e4 --- /dev/null +++ b/MsBuildGenerationTest/capnp/testdata/errors.txt @@ -0,0 +1,60 @@ +file:74:30-32: error: As of Cap'n Proto v0.3, it is no longer necessary to assign numbers to unions. However, removing the number will break binary compatibility. If this is an old protocol and you need to retain compatibility, please add an exclamation point after the number to indicate that it is really needed, e.g. `foo @1! :union {`. If this is a new protocol or compatibility doesn't matter, just remove the @n entirely. Sorry for the inconvenience, and thanks for being an early adopter! :) +file:74:30-32: error: As of Cap'n Proto v0.3, the 'union' keyword should be prefixed with a colon for named unions, e.g. `foo :union {`. +file:79:23-25: error: As of Cap'n Proto v0.3, it is no longer necessary to assign numbers to unions. However, removing the number will break binary compatibility. If this is an old protocol and you need to retain compatibility, please add an exclamation point after the number to indicate that it is really needed, e.g. `foo @1! :union {`. If this is a new protocol or compatibility doesn't matter, just remove the @n entirely. Sorry for the inconvenience, and thanks for being an early adopter! :) +file:84:17-19: error: As of Cap'n Proto v0.3, the 'union' keyword should be prefixed with a colon for named unions, e.g. `foo :union {`. +file:132:7-10: error: 'using' declaration without '=' must specify a named declaration from a different scope. +file:37:3-10: error: 'dupName' is already defined in this scope. +file:36:3-10: error: 'dupName' previously defined here. +file:52:5-12: error: 'dupName' is already defined in this scope. +file:36:3-10: error: 'dupName' previously defined here. +file:55:3-8: error: An unnamed union is already defined in this scope. +file:51:3-8: error: Previously defined here. +file:60:10-24: error: Type names must begin with a capital letter. +file:61:3-18: error: Non-type names must begin with a lower-case letter. +file:62:3-14: error: Cap'n Proto declaration names should use camelCase and must not contain underscores. (Code generators may convert names to the appropriate style for the target language.) +file:66:5-27: error: This kind of declaration doesn't belong here. +file:44:3-23: error: Union must have at least two members. +file:45:3-23: error: Group must have at least one member. +file:47: error: Union must have at least two members. +file:92: error: Unions cannot contain unnamed unions. +file:39:15-16: error: Duplicate ordinal number. +file:38:15-16: error: Ordinal @2 originally used here. +file:41:18-19: error: Skipped ordinal @3. Ordinals must be sequential with no holes. +file:69:15-17: error: Union ordinal, if specified, must be greater than no more than one of its member ordinals (i.e. there can only be one field retroactively unionized). +file:116:31-50: error: Import failed: noshuchfile.capnp +file:118:26-32: error: Not defined: NoSuch +file:119:28-34: error: 'Foo' has no member named 'NoSuch' +file:97:25-29: error: 'List' requires exactly one parameter. +file:98:30-48: error: Too many generic parameters. +file:98:30-34: error: 'List' requires exactly one parameter. +file:99:23-39: error: 'List(AnyPointer)' is not supported. +file:100:17-24: error: 'notType' is not a type. +file:101:17-27: error: Declaration does not accept generic parameters. +file:103:34-41: error: Integer value out of range. +file:104:37-38: error: Integer value out of range. +file:105:32-35: error: Type mismatch; expected Text. +file:106:33-38: error: Type mismatch; expected Text. +file:107:33-55: error: Type mismatch; expected Text. +file:108:43-61: error: Integer is too big to be negative. +file:109:35-39: error: '.Foo' does not refer to a constant. +file:110:44-51: error: Constant names must be qualified to avoid confusion. Please replace 'notType' with '.notType', if that's what you intended. +file:117:28-34: error: Not defined: NoSuch +file:112:29-32: error: 'Foo' is not an annotation. +file:113:29-47: error: 'notFieldAnnotation' cannot be applied to this kind of declaration. +file:114:33-48: error: 'fieldAnnotation' requires a value. +file:126:35-46: error: Struct has no field named 'nosuchfield'. +file:127:49-52: error: Type mismatch; expected group. +file:125:52-55: error: Missing field name. +file:136:3-10: error: 'dupName' is already defined in this scope. +file:135:3-10: error: 'dupName' previously defined here. +file:138:15-16: error: Duplicate ordinal number. +file:137:15-16: error: Ordinal @2 originally used here. +file:141:7-16: error: Declaration recursively depends on itself. +file:147:14-27: error: Not enough generic parameters. +file:148:15-47: error: Too many generic parameters. +file:149:18-49: error: Double-application of generic parameters. +file:150:38-43: error: Sorry, only pointer types can be used as generic parameters. +file:153:30-44: error: Embeds can only be used when Text, Data, or a struct is expected. +file:154:37-51: error: Couldn't read file for embed: no-such-file +file:160:23-27: error: Only pointer parameters can declare their default as 'null'. +file:156:20-45: error: Import failed: nosuchfile-unused.capnp diff --git a/MsBuildGenerationTest/capnp/testdata/flat b/MsBuildGenerationTest/capnp/testdata/flat new file mode 100644 index 0000000..427fc31 Binary files /dev/null and b/MsBuildGenerationTest/capnp/testdata/flat differ diff --git a/MsBuildGenerationTest/capnp/testdata/lists.binary b/MsBuildGenerationTest/capnp/testdata/lists.binary new file mode 100644 index 0000000..30ae630 Binary files /dev/null and b/MsBuildGenerationTest/capnp/testdata/lists.binary differ diff --git a/MsBuildGenerationTest/capnp/testdata/packed b/MsBuildGenerationTest/capnp/testdata/packed new file mode 100644 index 0000000..8627833 Binary files /dev/null and b/MsBuildGenerationTest/capnp/testdata/packed differ diff --git a/MsBuildGenerationTest/capnp/testdata/packedflat b/MsBuildGenerationTest/capnp/testdata/packedflat new file mode 100644 index 0000000..7c304a9 Binary files /dev/null and b/MsBuildGenerationTest/capnp/testdata/packedflat differ diff --git a/MsBuildGenerationTest/capnp/testdata/pretty.json b/MsBuildGenerationTest/capnp/testdata/pretty.json new file mode 100644 index 0000000..abf82d6 --- /dev/null +++ b/MsBuildGenerationTest/capnp/testdata/pretty.json @@ -0,0 +1,88 @@ +{ "voidField": null, + "boolField": true, + "int8Field": -123, + "int16Field": -12345, + "int32Field": -12345678, + "int64Field": "-123456789012345", + "uInt8Field": 234, + "uInt16Field": 45678, + "uInt32Field": 3456789012, + "uInt64Field": "12345678901234567890", + "float32Field": 1234.5, + "float64Field": -1.23e47, + "textField": "foo", + "dataField": [98, 97, 114], + "structField": { + "voidField": null, + "boolField": true, + "int8Field": -12, + "int16Field": 3456, + "int32Field": -78901234, + "int64Field": "56789012345678", + "uInt8Field": 90, + "uInt16Field": 1234, + "uInt32Field": 56789012, + "uInt64Field": "345678901234567890", + "float32Field": -1.2499999646475857e-10, + "float64Field": 345, + "textField": "baz", + "dataField": [113, 117, 120], + "structField": { + "voidField": null, + "boolField": false, + "int8Field": 0, + "int16Field": 0, + "int32Field": 0, + "int64Field": "0", + "uInt8Field": 0, + "uInt16Field": 0, + "uInt32Field": 0, + "uInt64Field": "0", + "float32Field": 0, + "float64Field": 0, + "textField": "nested", + "structField": {"voidField": null, "boolField": false, "int8Field": 0, "int16Field": 0, "int32Field": 0, "int64Field": "0", "uInt8Field": 0, "uInt16Field": 0, "uInt32Field": 0, "uInt64Field": "0", "float32Field": 0, "float64Field": 0, "textField": "really nested", "enumField": "foo", "interfaceField": null}, + "enumField": "foo", + "interfaceField": null }, + "enumField": "baz", + "interfaceField": null, + "voidList": [null, null, null], + "boolList": [false, true, false, true, true], + "int8List": [12, -34, -128, 127], + "int16List": [1234, -5678, -32768, 32767], + "int32List": [12345678, -90123456, -2147483648, 2147483647], + "int64List": ["123456789012345", "-678901234567890", "-9223372036854775808", "9223372036854775807"], + "uInt8List": [12, 34, 0, 255], + "uInt16List": [1234, 5678, 0, 65535], + "uInt32List": [12345678, 90123456, 0, 4294967295], + "uInt64List": ["123456789012345", "678901234567890", "0", "18446744073709551615"], + "float32List": [0, 1234567, 9.9999999338158125e36, -9.9999999338158125e36, 9.99999991097579e-38, -9.99999991097579e-38], + "float64List": [0, 123456789012345, 1e306, -1e306, 1e-306, -1e-306], + "textList": ["quux", "corge", "grault"], + "dataList": [[103, 97, 114, 112, 108, 121], [119, 97, 108, 100, 111], [102, 114, 101, 100]], + "structList": [ + {"voidField": null, "boolField": false, "int8Field": 0, "int16Field": 0, "int32Field": 0, "int64Field": "0", "uInt8Field": 0, "uInt16Field": 0, "uInt32Field": 0, "uInt64Field": "0", "float32Field": 0, "float64Field": 0, "textField": "x structlist 1", "enumField": "foo", "interfaceField": null}, + {"voidField": null, "boolField": false, "int8Field": 0, "int16Field": 0, "int32Field": 0, "int64Field": "0", "uInt8Field": 0, "uInt16Field": 0, "uInt32Field": 0, "uInt64Field": "0", "float32Field": 0, "float64Field": 0, "textField": "x structlist 2", "enumField": "foo", "interfaceField": null}, + {"voidField": null, "boolField": false, "int8Field": 0, "int16Field": 0, "int32Field": 0, "int64Field": "0", "uInt8Field": 0, "uInt16Field": 0, "uInt32Field": 0, "uInt64Field": "0", "float32Field": 0, "float64Field": 0, "textField": "x structlist 3", "enumField": "foo", "interfaceField": null} ], + "enumList": ["qux", "bar", "grault"] }, + "enumField": "corge", + "interfaceField": null, + "voidList": [null, null, null, null, null, null], + "boolList": [true, false, false, true], + "int8List": [111, -111], + "int16List": [11111, -11111], + "int32List": [111111111, -111111111], + "int64List": ["1111111111111111111", "-1111111111111111111"], + "uInt8List": [111, 222], + "uInt16List": [33333, 44444], + "uInt32List": [3333333333], + "uInt64List": ["11111111111111111111"], + "float32List": [5555.5, "Infinity", "-Infinity", "NaN"], + "float64List": [7777.75, "Infinity", "-Infinity", "NaN"], + "textList": ["plugh", "xyzzy", "thud"], + "dataList": [[111, 111, 112, 115], [101, 120, 104, 97, 117, 115, 116, 101, 100], [114, 102, 99, 51, 48, 57, 50]], + "structList": [ + {"voidField": null, "boolField": false, "int8Field": 0, "int16Field": 0, "int32Field": 0, "int64Field": "0", "uInt8Field": 0, "uInt16Field": 0, "uInt32Field": 0, "uInt64Field": "0", "float32Field": 0, "float64Field": 0, "textField": "structlist 1", "enumField": "foo", "interfaceField": null}, + {"voidField": null, "boolField": false, "int8Field": 0, "int16Field": 0, "int32Field": 0, "int64Field": "0", "uInt8Field": 0, "uInt16Field": 0, "uInt32Field": 0, "uInt64Field": "0", "float32Field": 0, "float64Field": 0, "textField": "structlist 2", "enumField": "foo", "interfaceField": null}, + {"voidField": null, "boolField": false, "int8Field": 0, "int16Field": 0, "int32Field": 0, "int64Field": "0", "uInt8Field": 0, "uInt16Field": 0, "uInt32Field": 0, "uInt64Field": "0", "float32Field": 0, "float64Field": 0, "textField": "structlist 3", "enumField": "foo", "interfaceField": null} ], + "enumList": ["foo", "garply"] } diff --git a/MsBuildGenerationTest/capnp/testdata/pretty.txt b/MsBuildGenerationTest/capnp/testdata/pretty.txt new file mode 100644 index 0000000..079ff8d --- /dev/null +++ b/MsBuildGenerationTest/capnp/testdata/pretty.txt @@ -0,0 +1,187 @@ +( voidField = void, + boolField = true, + int8Field = -123, + int16Field = -12345, + int32Field = -12345678, + int64Field = -123456789012345, + uInt8Field = 234, + uInt16Field = 45678, + uInt32Field = 3456789012, + uInt64Field = 12345678901234567890, + float32Field = 1234.5, + float64Field = -1.23e47, + textField = "foo", + dataField = "bar", + structField = ( + voidField = void, + boolField = true, + int8Field = -12, + int16Field = 3456, + int32Field = -78901234, + int64Field = 56789012345678, + uInt8Field = 90, + uInt16Field = 1234, + uInt32Field = 56789012, + uInt64Field = 345678901234567890, + float32Field = -1.25e-10, + float64Field = 345, + textField = "baz", + dataField = "qux", + structField = ( + voidField = void, + boolField = false, + int8Field = 0, + int16Field = 0, + int32Field = 0, + int64Field = 0, + uInt8Field = 0, + uInt16Field = 0, + uInt32Field = 0, + uInt64Field = 0, + float32Field = 0, + float64Field = 0, + textField = "nested", + structField = ( + voidField = void, + boolField = false, + int8Field = 0, + int16Field = 0, + int32Field = 0, + int64Field = 0, + uInt8Field = 0, + uInt16Field = 0, + uInt32Field = 0, + uInt64Field = 0, + float32Field = 0, + float64Field = 0, + textField = "really nested", + enumField = foo, + interfaceField = void ), + enumField = foo, + interfaceField = void ), + enumField = baz, + interfaceField = void, + voidList = [void, void, void], + boolList = [false, true, false, true, true], + int8List = [12, -34, -128, 127], + int16List = [1234, -5678, -32768, 32767], + int32List = [12345678, -90123456, -2147483648, 2147483647], + int64List = [123456789012345, -678901234567890, -9223372036854775808, 9223372036854775807], + uInt8List = [12, 34, 0, 255], + uInt16List = [1234, 5678, 0, 65535], + uInt32List = [12345678, 90123456, 0, 4294967295], + uInt64List = [123456789012345, 678901234567890, 0, 18446744073709551615], + float32List = [0, 1234567, 1e37, -1e37, 1e-37, -1e-37], + float64List = [0, 123456789012345, 1e306, -1e306, 1e-306, -1e-306], + textList = ["quux", "corge", "grault"], + dataList = ["garply", "waldo", "fred"], + structList = [ + ( voidField = void, + boolField = false, + int8Field = 0, + int16Field = 0, + int32Field = 0, + int64Field = 0, + uInt8Field = 0, + uInt16Field = 0, + uInt32Field = 0, + uInt64Field = 0, + float32Field = 0, + float64Field = 0, + textField = "x structlist 1", + enumField = foo, + interfaceField = void ), + ( voidField = void, + boolField = false, + int8Field = 0, + int16Field = 0, + int32Field = 0, + int64Field = 0, + uInt8Field = 0, + uInt16Field = 0, + uInt32Field = 0, + uInt64Field = 0, + float32Field = 0, + float64Field = 0, + textField = "x structlist 2", + enumField = foo, + interfaceField = void ), + ( voidField = void, + boolField = false, + int8Field = 0, + int16Field = 0, + int32Field = 0, + int64Field = 0, + uInt8Field = 0, + uInt16Field = 0, + uInt32Field = 0, + uInt64Field = 0, + float32Field = 0, + float64Field = 0, + textField = "x structlist 3", + enumField = foo, + interfaceField = void ) ], + enumList = [qux, bar, grault] ), + enumField = corge, + interfaceField = void, + voidList = [void, void, void, void, void, void], + boolList = [true, false, false, true], + int8List = [111, -111], + int16List = [11111, -11111], + int32List = [111111111, -111111111], + int64List = [1111111111111111111, -1111111111111111111], + uInt8List = [111, 222], + uInt16List = [33333, 44444], + uInt32List = [3333333333], + uInt64List = [11111111111111111111], + float32List = [5555.5, inf, -inf, nan], + float64List = [7777.75, inf, -inf, nan], + textList = ["plugh", "xyzzy", "thud"], + dataList = ["oops", "exhausted", "rfc3092"], + structList = [ + ( voidField = void, + boolField = false, + int8Field = 0, + int16Field = 0, + int32Field = 0, + int64Field = 0, + uInt8Field = 0, + uInt16Field = 0, + uInt32Field = 0, + uInt64Field = 0, + float32Field = 0, + float64Field = 0, + textField = "structlist 1", + enumField = foo, + interfaceField = void ), + ( voidField = void, + boolField = false, + int8Field = 0, + int16Field = 0, + int32Field = 0, + int64Field = 0, + uInt8Field = 0, + uInt16Field = 0, + uInt32Field = 0, + uInt64Field = 0, + float32Field = 0, + float64Field = 0, + textField = "structlist 2", + enumField = foo, + interfaceField = void ), + ( voidField = void, + boolField = false, + int8Field = 0, + int16Field = 0, + int32Field = 0, + int64Field = 0, + uInt8Field = 0, + uInt16Field = 0, + uInt32Field = 0, + uInt64Field = 0, + float32Field = 0, + float64Field = 0, + textField = "structlist 3", + enumField = foo, + interfaceField = void ) ], + enumList = [foo, garply] ) diff --git a/MsBuildGenerationTest/capnp/testdata/segmented b/MsBuildGenerationTest/capnp/testdata/segmented new file mode 100644 index 0000000..c2840b4 Binary files /dev/null and b/MsBuildGenerationTest/capnp/testdata/segmented differ diff --git a/MsBuildGenerationTest/capnp/testdata/segmented-packed b/MsBuildGenerationTest/capnp/testdata/segmented-packed new file mode 100644 index 0000000..c4a968e Binary files /dev/null and b/MsBuildGenerationTest/capnp/testdata/segmented-packed differ diff --git a/MsBuildGenerationTest/capnp/testdata/short.json b/MsBuildGenerationTest/capnp/testdata/short.json new file mode 100644 index 0000000..26cbfd0 --- /dev/null +++ b/MsBuildGenerationTest/capnp/testdata/short.json @@ -0,0 +1 @@ +{"voidField":null,"boolField":true,"int8Field":-123,"int16Field":-12345,"int32Field":-12345678,"int64Field":"-123456789012345","uInt8Field":234,"uInt16Field":45678,"uInt32Field":3456789012,"uInt64Field":"12345678901234567890","float32Field":1234.5,"float64Field":-1.23e47,"textField":"foo","dataField":[98,97,114],"structField":{"voidField":null,"boolField":true,"int8Field":-12,"int16Field":3456,"int32Field":-78901234,"int64Field":"56789012345678","uInt8Field":90,"uInt16Field":1234,"uInt32Field":56789012,"uInt64Field":"345678901234567890","float32Field":-1.2499999646475857e-10,"float64Field":345,"textField":"baz","dataField":[113,117,120],"structField":{"voidField":null,"boolField":false,"int8Field":0,"int16Field":0,"int32Field":0,"int64Field":"0","uInt8Field":0,"uInt16Field":0,"uInt32Field":0,"uInt64Field":"0","float32Field":0,"float64Field":0,"textField":"nested","structField":{"voidField":null,"boolField":false,"int8Field":0,"int16Field":0,"int32Field":0,"int64Field":"0","uInt8Field":0,"uInt16Field":0,"uInt32Field":0,"uInt64Field":"0","float32Field":0,"float64Field":0,"textField":"really nested","enumField":"foo","interfaceField":null},"enumField":"foo","interfaceField":null},"enumField":"baz","interfaceField":null,"voidList":[null,null,null],"boolList":[false,true,false,true,true],"int8List":[12,-34,-128,127],"int16List":[1234,-5678,-32768,32767],"int32List":[12345678,-90123456,-2147483648,2147483647],"int64List":["123456789012345","-678901234567890","-9223372036854775808","9223372036854775807"],"uInt8List":[12,34,0,255],"uInt16List":[1234,5678,0,65535],"uInt32List":[12345678,90123456,0,4294967295],"uInt64List":["123456789012345","678901234567890","0","18446744073709551615"],"float32List":[0,1234567,9.9999999338158125e36,-9.9999999338158125e36,9.99999991097579e-38,-9.99999991097579e-38],"float64List":[0,123456789012345,1e306,-1e306,1e-306,-1e-306],"textList":["quux","corge","grault"],"dataList":[[103,97,114,112,108,121],[119,97,108,100,111],[102,114,101,100]],"structList":[{"voidField":null,"boolField":false,"int8Field":0,"int16Field":0,"int32Field":0,"int64Field":"0","uInt8Field":0,"uInt16Field":0,"uInt32Field":0,"uInt64Field":"0","float32Field":0,"float64Field":0,"textField":"x structlist 1","enumField":"foo","interfaceField":null},{"voidField":null,"boolField":false,"int8Field":0,"int16Field":0,"int32Field":0,"int64Field":"0","uInt8Field":0,"uInt16Field":0,"uInt32Field":0,"uInt64Field":"0","float32Field":0,"float64Field":0,"textField":"x structlist 2","enumField":"foo","interfaceField":null},{"voidField":null,"boolField":false,"int8Field":0,"int16Field":0,"int32Field":0,"int64Field":"0","uInt8Field":0,"uInt16Field":0,"uInt32Field":0,"uInt64Field":"0","float32Field":0,"float64Field":0,"textField":"x structlist 3","enumField":"foo","interfaceField":null}],"enumList":["qux","bar","grault"]},"enumField":"corge","interfaceField":null,"voidList":[null,null,null,null,null,null],"boolList":[true,false,false,true],"int8List":[111,-111],"int16List":[11111,-11111],"int32List":[111111111,-111111111],"int64List":["1111111111111111111","-1111111111111111111"],"uInt8List":[111,222],"uInt16List":[33333,44444],"uInt32List":[3333333333],"uInt64List":["11111111111111111111"],"float32List":[5555.5,"Infinity","-Infinity","NaN"],"float64List":[7777.75,"Infinity","-Infinity","NaN"],"textList":["plugh","xyzzy","thud"],"dataList":[[111,111,112,115],[101,120,104,97,117,115,116,101,100],[114,102,99,51,48,57,50]],"structList":[{"voidField":null,"boolField":false,"int8Field":0,"int16Field":0,"int32Field":0,"int64Field":"0","uInt8Field":0,"uInt16Field":0,"uInt32Field":0,"uInt64Field":"0","float32Field":0,"float64Field":0,"textField":"structlist 1","enumField":"foo","interfaceField":null},{"voidField":null,"boolField":false,"int8Field":0,"int16Field":0,"int32Field":0,"int64Field":"0","uInt8Field":0,"uInt16Field":0,"uInt32Field":0,"uInt64Field":"0","float32Field":0,"float64Field":0,"textField":"structlist 2","enumField":"foo","interfaceField":null},{"voidField":null,"boolField":false,"int8Field":0,"int16Field":0,"int32Field":0,"int64Field":"0","uInt8Field":0,"uInt16Field":0,"uInt32Field":0,"uInt64Field":"0","float32Field":0,"float64Field":0,"textField":"structlist 3","enumField":"foo","interfaceField":null}],"enumList":["foo","garply"]} diff --git a/MsBuildGenerationTest/capnp/testdata/short.txt b/MsBuildGenerationTest/capnp/testdata/short.txt new file mode 100644 index 0000000..d738fb3 --- /dev/null +++ b/MsBuildGenerationTest/capnp/testdata/short.txt @@ -0,0 +1 @@ +(voidField = void, boolField = true, int8Field = -123, int16Field = -12345, int32Field = -12345678, int64Field = -123456789012345, uInt8Field = 234, uInt16Field = 45678, uInt32Field = 3456789012, uInt64Field = 12345678901234567890, float32Field = 1234.5, float64Field = -1.23e47, textField = "foo", dataField = "bar", structField = (voidField = void, boolField = true, int8Field = -12, int16Field = 3456, int32Field = -78901234, int64Field = 56789012345678, uInt8Field = 90, uInt16Field = 1234, uInt32Field = 56789012, uInt64Field = 345678901234567890, float32Field = -1.25e-10, float64Field = 345, textField = "baz", dataField = "qux", structField = (voidField = void, boolField = false, int8Field = 0, int16Field = 0, int32Field = 0, int64Field = 0, uInt8Field = 0, uInt16Field = 0, uInt32Field = 0, uInt64Field = 0, float32Field = 0, float64Field = 0, textField = "nested", structField = (voidField = void, boolField = false, int8Field = 0, int16Field = 0, int32Field = 0, int64Field = 0, uInt8Field = 0, uInt16Field = 0, uInt32Field = 0, uInt64Field = 0, float32Field = 0, float64Field = 0, textField = "really nested", enumField = foo, interfaceField = void), enumField = foo, interfaceField = void), enumField = baz, interfaceField = void, voidList = [void, void, void], boolList = [false, true, false, true, true], int8List = [12, -34, -128, 127], int16List = [1234, -5678, -32768, 32767], int32List = [12345678, -90123456, -2147483648, 2147483647], int64List = [123456789012345, -678901234567890, -9223372036854775808, 9223372036854775807], uInt8List = [12, 34, 0, 255], uInt16List = [1234, 5678, 0, 65535], uInt32List = [12345678, 90123456, 0, 4294967295], uInt64List = [123456789012345, 678901234567890, 0, 18446744073709551615], float32List = [0, 1234567, 1e37, -1e37, 1e-37, -1e-37], float64List = [0, 123456789012345, 1e306, -1e306, 1e-306, -1e-306], textList = ["quux", "corge", "grault"], dataList = ["garply", "waldo", "fred"], structList = [(voidField = void, boolField = false, int8Field = 0, int16Field = 0, int32Field = 0, int64Field = 0, uInt8Field = 0, uInt16Field = 0, uInt32Field = 0, uInt64Field = 0, float32Field = 0, float64Field = 0, textField = "x structlist 1", enumField = foo, interfaceField = void), (voidField = void, boolField = false, int8Field = 0, int16Field = 0, int32Field = 0, int64Field = 0, uInt8Field = 0, uInt16Field = 0, uInt32Field = 0, uInt64Field = 0, float32Field = 0, float64Field = 0, textField = "x structlist 2", enumField = foo, interfaceField = void), (voidField = void, boolField = false, int8Field = 0, int16Field = 0, int32Field = 0, int64Field = 0, uInt8Field = 0, uInt16Field = 0, uInt32Field = 0, uInt64Field = 0, float32Field = 0, float64Field = 0, textField = "x structlist 3", enumField = foo, interfaceField = void)], enumList = [qux, bar, grault]), enumField = corge, interfaceField = void, voidList = [void, void, void, void, void, void], boolList = [true, false, false, true], int8List = [111, -111], int16List = [11111, -11111], int32List = [111111111, -111111111], int64List = [1111111111111111111, -1111111111111111111], uInt8List = [111, 222], uInt16List = [33333, 44444], uInt32List = [3333333333], uInt64List = [11111111111111111111], float32List = [5555.5, inf, -inf, nan], float64List = [7777.75, inf, -inf, nan], textList = ["plugh", "xyzzy", "thud"], dataList = ["oops", "exhausted", "rfc3092"], structList = [(voidField = void, boolField = false, int8Field = 0, int16Field = 0, int32Field = 0, int64Field = 0, uInt8Field = 0, uInt16Field = 0, uInt32Field = 0, uInt64Field = 0, float32Field = 0, float64Field = 0, textField = "structlist 1", enumField = foo, interfaceField = void), (voidField = void, boolField = false, int8Field = 0, int16Field = 0, int32Field = 0, int64Field = 0, uInt8Field = 0, uInt16Field = 0, uInt32Field = 0, uInt64Field = 0, float32Field = 0, float64Field = 0, textField = "structlist 2", enumField = foo, interfaceField = void), (voidField = void, boolField = false, int8Field = 0, int16Field = 0, int32Field = 0, int64Field = 0, uInt8Field = 0, uInt16Field = 0, uInt32Field = 0, uInt64Field = 0, float32Field = 0, float64Field = 0, textField = "structlist 3", enumField = foo, interfaceField = void)], enumList = [foo, garply]) diff --git a/MsBuildGenerationTest/nuget.config b/MsBuildGenerationTest/nuget.config new file mode 100644 index 0000000..862b371 --- /dev/null +++ b/MsBuildGenerationTest/nuget.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index db6030c..829271a 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Solution/project structure is as follows: * Capnp.Net.Runtime is the runtime implementation, a .NET assembly. * capnpc-csharp is the generator backend for C# language. * Capnp.Net.Runtime.Tests is an MS Unit Testing assembly, containing - you guessed it - the test suite. - * capnpc-csharp.tests contains the generator backend test suite. + * CapnpC.CSharp.Generator.Tests contains the generator backend test suite. - CapnpCompatTest.sln compiles to a native x86 executable which depends on the original Cap'n Proto C++ implementation. It is (partially) required by the test suite for interoperability testing. ## Features diff --git a/appveyor.yml b/appveyor.yml index b08ea80..73a0e42 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,8 @@ version: '1.0.{build}' image: Visual Studio 2019 -branches: - only: - - master +# branches: +# only: +# - master cache: - c:\Tools\vcpkg\installed init: @@ -28,8 +28,11 @@ before_build: - cmd: dotnet restore ./Capnp.Net.Runtime.Core21/Capnp.Net.Runtime.Core21.csproj --verbosity m - cmd: dotnet restore ./Capnp.Net.Runtime.Tests/Capnp.Net.Runtime.Tests.Std20.csproj --verbosity m - cmd: dotnet restore ./Capnp.Net.Runtime.Tests.Core21/Capnp.Net.Runtime.Tests.Core21.csproj --verbosity m + - cmd: dotnet restore ./CapnpC.CSharp.Generator/CapnpC.CSharp.Generator.csproj --verbosity m + - cmd: dotnet restore ./CapnpC.CSharp.Generator.Tests/CapnpC.CSharp.Generator.Tests.csproj --verbosity m + - cmd: dotnet restore ./CapnpC.CSharp.MsBuild.Generation/CapnpC.CSharp.MsBuild.Generation.csproj --verbosity m + - cmd: dotnet restore ./CapnpC.CSharp.MsBuild.Generation.Tests/CapnpC.CSharp.MsBuild.Generation.Tests.csproj --verbosity m - cmd: dotnet restore ./capnpc-csharp/capnpc-csharp.csproj --verbosity m - - cmd: dotnet restore ./capnpc-csharp.tests/capnpc-csharp.tests.csproj --verbosity m build_script: - cmd: msbuild ./Capnp.Net.sln /p:Configuration="Debug" - cmd: msbuild ./Capnp.Net.sln /p:Configuration="Release" @@ -39,9 +42,12 @@ build_script: after_build: # For once the build has completed artifacts: - - path: Capnp.Net.Runtime\bin\Release\Capnp.Net.Runtime.$(appveyor_build_version).nupkg + - path: bin\Release\Capnp.Net.Runtime.$(appveyor_build_version).nupkg name: Capnp.Net.Runtime type: NuGetPackage + - path: bin\Release\CapnpC.CSharp.MsBuild.Generation.$(appveyor_build_version).nupkg + name: CapnpC.CSharp.MsBuild.Generation + type: NuGetPackage - path: chocolatey\install\capnpc-csharp-win-x86.$(appveyor_build_version).nupkg name: capnpc-csharp-win-x86 type: NuGetPackage @@ -50,12 +56,15 @@ artifacts: type: NuGetPackage clone_depth: 1 test_script: - - cmd: vstest.console /logger:Appveyor /inIsolation capnpc-csharp.tests\bin\Release\netcoreapp2.2\capnpc-csharp.tests.dll + - cmd: vstest.console /logger:Appveyor /inIsolation CapnpC.CSharp.Generator.Tests\bin\Release\netcoreapp2.2\CapnpC.CSharp.Generator.Tests.dll - cmd: cd %APPVEYOR_BUILD_FOLDER%\chocolatey\install - cmd: choco install capnpc-csharp --source=".;https://chocolatey.org/api/v2" --force -y - cmd: cd %APPVEYOR_BUILD_FOLDER%\install-test - cmd: compile-test + - cmd: cd %APPVEYOR_BUILD_FOLDER% + - cmd: vstest.console /logger:Appveyor /inIsolation CapnpC.CSharp.Generator.Tests\bin\Release\netcoreapp2.2\CapnpC.CSharp.Generator.Tests.dll - cmd: choco uninstall capnpc-csharp -y + - cmd: cd %APPVEYOR_BUILD_FOLDER%\install-test - cmd: notinstalled-test - cmd: cd %APPVEYOR_BUILD_FOLDER%\chocolatey\install - cmd: choco install capnpc-csharp-win-x86 --source=".;https://chocolatey.org/api/v2" --force -y @@ -64,6 +73,9 @@ test_script: - cmd: choco uninstall capnpc-csharp-win-x86 -y - cmd: notinstalled-test - cmd: cd %APPVEYOR_BUILD_FOLDER% + - cmd: vstest.console /logger:Appveyor /inIsolation CapnpC.CSharp.MsBuild.Generation.Tests\bin\Release\netcoreapp2.2\CapnpC.CSharp.MsBuild.Generation.Tests.dll + - cmd: msbuild -t:restore ./MsBuildGenerationTest/MsBuildGenerationTest.csproj /p:Configuration="Debug" /p:PackageReferenceVersion="%APPVEYOR_BUILD_VERSION%" + - cmd: msbuild ./MsBuildGenerationTest/MsBuildGenerationTest.sln /p:Configuration="Debug" /p:PackageReferenceVersion="%APPVEYOR_BUILD_VERSION%" - cmd: vstest.console /logger:Appveyor /inIsolation Capnp.Net.Runtime.Tests\bin\Debug\netcoreapp2.2\Capnp.Net.Runtime.Tests.Std20.dll - cmd: vstest.console /logger:Appveyor /inIsolation Capnp.Net.Runtime.Tests\bin\Release\netcoreapp2.2\Capnp.Net.Runtime.Tests.Std20.dll - cmd: vstest.console /logger:Appveyor /inIsolation Capnp.Net.Runtime.Tests.Core21\bin\Debug\netcoreapp2.2\Capnp.Net.Runtime.Tests.Core21.dll diff --git a/capnpc-csharp.tests/CodeGenerator.feature b/capnpc-csharp.tests/CodeGenerator.feature deleted file mode 100644 index 89768b9..0000000 --- a/capnpc-csharp.tests/CodeGenerator.feature +++ /dev/null @@ -1,20 +0,0 @@ -Feature: CodeGenerator - In order to ensure that the generator backend produces valid output - As a contributor - I want to get notified when there is any deviation from reference output - -Scenario: Comparing backend output with reference - Given I have a binary code generator request "test.capnp.bin" - And my reference output is "test.cs" - When I invoke capnpc-csharp - Then the generated output must match the reference - -Scenario Outline: Invalid binary code generator requests - Given I have a binary code generator request - When I invoke capnpc-csharp - Then the invocation must fail - -Examples: - | bin | - | null.bin | - | test.cs | \ No newline at end of file diff --git a/capnpc-csharp.tests/FeatureSteps/CodeGeneratorSteps.cs b/capnpc-csharp.tests/FeatureSteps/CodeGeneratorSteps.cs deleted file mode 100644 index 4d3a893..0000000 --- a/capnpc-csharp.tests/FeatureSteps/CodeGeneratorSteps.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.IO; -using System.Reflection; -using TechTalk.SpecFlow; - -namespace capnpc_csharp.Tests -{ - [Binding] - public class CodeGeneratorSteps - { - Stream _inputStream; - string _referenceOutputContent; - string _exceptedOutputFileName; - string _actualGeneratedContent; - bool _success; - Exception _generateException; - - internal static Stream LoadResource(string name) - { - var assembly = Assembly.GetExecutingAssembly(); - string[] names = assembly.GetManifestResourceNames(); - string urn = Array.Find(names, n => n.EndsWith(name, StringComparison.OrdinalIgnoreCase)); - Assert.IsNotNull(urn, $"Test specification error: {name} does not exist"); - return assembly.GetManifestResourceStream(urn); - } - - [Given(@"I have a binary code generator request ""(.*)""")] - [Given(@"I have a binary code generator request (.*)")] - public void GivenIHaveABinaryCodeGeneratorRequest(string binaryRequestFileName) - { - _inputStream = LoadResource(binaryRequestFileName); - } - - [Given(@"my reference output is ""(.*)""")] - public void GivenMyReferenceOutputIs(string expectedOutputFileName) - { - _exceptedOutputFileName = expectedOutputFileName; - using (var stream = LoadResource(expectedOutputFileName)) - using (var reader = new StreamReader(stream)) - { - _referenceOutputContent = reader.ReadToEnd(); - } - } - - [When(@"I invoke capnpc-csharp")] - public void WhenIInvokeCapnpc_Csharp() - { - try - { - using (_inputStream) - { - string tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - Directory.CreateDirectory(tempDir); - Environment.CurrentDirectory = tempDir; - - CapnpC.Program.GenerateFromStream(_inputStream); - - string outPath = Path.Combine(tempDir, _exceptedOutputFileName); - _actualGeneratedContent = File.ReadAllText(outPath); - _success = true; - } - } - catch (Exception exception) - { - _generateException = exception; - } - } - - [Then(@"the generated output must match the reference")] - public void ThenTheGeneratedOutputMustMatchTheReference() - { - Assert.IsTrue(_success, $"Code generation failed: {_generateException?.Message}"); - Assert.AreEqual(_referenceOutputContent, _actualGeneratedContent); - } - - [Then(@"the invocation must fail")] - public void ThenTheInvocationMustFail() - { - Assert.IsFalse(_success, "Code generation was supposed to fail, but it didn't"); - } - } -} diff --git a/capnpc-csharp/Program.cs b/capnpc-csharp/Program.cs index 3f71b4b..b8eccee 100644 --- a/capnpc-csharp/Program.cs +++ b/capnpc-csharp/Program.cs @@ -1,30 +1,14 @@ using Capnp; +using CapnpC.CSharp.Generator; using System; using System.IO; using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleToAttribute("capnpc-csharp.tests")] +using System.Security; namespace CapnpC { internal class Program { - internal static void GenerateFromStream(Stream input) - { - WireFrame segments; - - using (input) - { - segments = Framing.ReadSegments(input); - } - - var dec = DeserializerState.CreateRoot(segments); - var reader = Schema.CodeGeneratorRequest.Reader.Create(dec); - var model = Model.SchemaModel.Create(reader); - var codeGen = new Generator.CodeGenerator(model, new Generator.GeneratorOptions()); - codeGen.Generate(); - } - static void Main(string[] args) { Stream input; @@ -41,13 +25,36 @@ namespace CapnpC input = Console.OpenStandardInput(); } - try + var result = CapnpCompilation.GenerateFromStream(input); + + if (result.IsSuccess) { - GenerateFromStream(input); + foreach (var generatedFile in result.GeneratedFiles) + { + if (generatedFile.IsSuccess) + { + string outputFile = generatedFile.CapnpFilePath + ".cs"; + + try + { + File.WriteAllText(outputFile, generatedFile.GeneratedContent); + } + catch (Exception exception) + { + Console.Error.WriteLine(exception.Message); + Environment.ExitCode = -1; + } + } + else + { + Console.Error.WriteLine($"Error generating {generatedFile.CapnpFilePath}: {generatedFile.Exception.Message}"); + Environment.ExitCode = -1; + } + } } - catch (Exception exception) + else { - Console.Error.WriteLine(exception.Message); + Console.Error.WriteLine(result.Exception.Message); Environment.ExitCode = -1; } } diff --git a/capnpc-csharp/capnpc-csharp.csproj b/capnpc-csharp/capnpc-csharp.csproj index 3e3531e..5895299 100644 --- a/capnpc-csharp/capnpc-csharp.csproj +++ b/capnpc-csharp/capnpc-csharp.csproj @@ -14,10 +14,7 @@ Git capnp capnpc RPC serialization cerealization 1.0.0 - - - - + Debug;Release @@ -27,6 +24,7 @@ + diff --git a/install-test/compile-test.bat b/install-test/compile-test.bat index 2162124..b93a2da 100644 --- a/install-test/compile-test.bat +++ b/install-test/compile-test.bat @@ -1,8 +1,8 @@ @echo off capnp compile -ocsharp -I%cd% .\capnp\schema.capnp if %ERRORLEVEL% neq 0 exit /b 1 -if exist .\capnp\schema.cs ( - del .\capnp\schema.cs +if exist .\capnp\schema.capnp.cs ( + del .\capnp\schema.capnp.cs ) else ( exit /b 2 ) diff --git a/test.capnp.bin b/test.capnp.bin deleted file mode 100644 index e69de29..0000000