public void MessageDisembargo() { var mb = MessageBuilder.Create(); { var w = mb.BuildRoot <Message.WRITER>(); w.which = Message.WHICH.Disembargo; var ctx = w.Disembargo.Context; ctx.which = Disembargo.context.WHICH.SenderLoopback; ctx.SenderLoopback = 1234567u; var tgt = w.Disembargo.Target; tgt.which = MessageTarget.WHICH.PromisedAnswer; tgt.PromisedAnswer.QuestionId = 7654321u; } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); { Assert.AreEqual(Message.WHICH.Disembargo, r.which); Assert.AreEqual(Disembargo.context.WHICH.SenderLoopback, r.Disembargo.Context.which); Assert.AreEqual(1234567u, r.Disembargo.Context.SenderLoopback); Assert.AreEqual(MessageTarget.WHICH.PromisedAnswer, r.Disembargo.Target.which); Assert.AreEqual(7654321u, r.Disembargo.Target.PromisedAnswer.QuestionId); } }
public void MessageAccept() { var mb = MessageBuilder.Create(); { var w = mb.BuildRoot <Message.WRITER>(); w.which = Message.WHICH.Accept; Assert.AreEqual(Message.WHICH.Accept, w.which); w.Accept.Embargo = true; Assert.IsTrue(w.Accept.Embargo); w.Accept.Provision.SetStruct(2, 0); w.Accept.Provision.WriteData(0, long.MinValue); w.Accept.Provision.WriteData(64, long.MaxValue); Assert.AreEqual(long.MinValue, w.Accept.Provision.ReadDataLong(0)); Assert.AreEqual(long.MaxValue, w.Accept.Provision.ReadDataLong(64)); w.Accept.QuestionId = 0x87654321u; Assert.AreEqual(0x87654321u, w.Accept.QuestionId); } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); Assert.AreEqual(Message.WHICH.Accept, r.which); Assert.IsTrue(r.Accept.Embargo); Assert.AreEqual(ObjectKind.Struct, r.Accept.Provision.Kind); Assert.AreEqual(long.MinValue, r.Accept.Provision.ReadDataLong(0)); Assert.AreEqual(long.MaxValue, r.Accept.Provision.ReadDataLong(64)); Assert.AreEqual(0x87654321u, r.Accept.QuestionId); }
public void MessageProvide() { var mb = MessageBuilder.Create(); { var w = mb.BuildRoot <Message.WRITER>(); w.which = Message.WHICH.Provide; w.Provide.QuestionId = 0xbbbbbbbb; w.Provide.Recipient.SetStruct(1, 0); w.Provide.Recipient.WriteData(0, -1); w.Provide.Target.which = MessageTarget.WHICH.PromisedAnswer; w.Provide.Target.PromisedAnswer.QuestionId = 0xcccccccc; w.Provide.Target.PromisedAnswer.Transform.Init(1); w.Provide.Target.PromisedAnswer.Transform[0].which = PromisedAnswer.Op.WHICH.Noop; } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); { Assert.AreEqual(Message.WHICH.Provide, r.which); Assert.AreEqual(0xbbbbbbbb, r.Provide.QuestionId); Assert.AreEqual(-1, r.Provide.Recipient.ReadDataInt(0)); Assert.AreEqual(MessageTarget.WHICH.PromisedAnswer, r.Provide.Target.which); Assert.AreEqual(0xcccccccc, r.Provide.Target.PromisedAnswer.QuestionId); Assert.AreEqual(1, r.Provide.Target.PromisedAnswer.Transform.Count); Assert.AreEqual(PromisedAnswer.Op.WHICH.Noop, r.Provide.Target.PromisedAnswer.Transform[0].which); } }
public void Issue20() { RpcRequest <ArithmeticOperationRequest> rpcRequest = new RpcRequest <ArithmeticOperationRequest>(); rpcRequest.Method = "AddTwoNumbers"; ArithmeticOperationRequest request = new ArithmeticOperationRequest(); request.NumA = 5; request.NumB = 8; rpcRequest.Request = request; var msg = MessageBuilder.Create(); var root = msg.BuildRoot <RpcRequest <ArithmeticOperationRequest> .WRITER>(); rpcRequest.serialize(root); var mems = new MemoryStream(); var pump = new FramePump(mems); pump.Send(msg.Frame); mems.Seek(0, SeekOrigin.Begin); var frame = Framing.ReadSegments(mems); var deserializer = DeserializerState.CreateRoot(frame); var mainRequest = new RpcRequest <ArithmeticOperationRequest> .READER(deserializer); var innerRequest = new ArithmeticOperationRequest.READER(mainRequest.Request); Console.WriteLine("Method Name: " + mainRequest.Method); Console.WriteLine("NumA: " + innerRequest.NumA.ToString()); Console.WriteLine("NumB: " + innerRequest.NumB.ToString()); }
public void MessageReturn() { var mb = MessageBuilder.Create(); { var w = mb.BuildRoot <Message.WRITER>(); w.which = Message.WHICH.Return; w.Return.which = Return.WHICH.Results; w.Return.Results.CapTable.Init(1); w.Return.Results.CapTable[0].which = CapDescriptor.WHICH.SenderHosted; w.Return.Results.CapTable[0].SenderHosted = 0x22222222; var content = w.Return.Results.Content.Rewrap <DynamicSerializerState>(); content.SetStruct(2, 0); content.WriteData(0, double.MinValue); content.WriteData(64, double.MaxValue); Assert.IsTrue(w.Return.ReleaseParamCaps); w.Return.ReleaseParamCaps = false; } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); { Assert.AreEqual(Message.WHICH.Return, r.which); Assert.AreEqual(Return.WHICH.Results, r.Return.which); Assert.AreEqual(1, r.Return.Results.CapTable.Count); Assert.AreEqual(CapDescriptor.WHICH.SenderHosted, r.Return.Results.CapTable[0].which); Assert.AreEqual(0x22222222u, r.Return.Results.CapTable[0].SenderHosted); Assert.AreEqual(double.MinValue, r.Return.Results.Content.ReadDataDouble(0)); Assert.AreEqual(double.MaxValue, r.Return.Results.Content.ReadDataDouble(64)); Assert.IsFalse(r.Return.ReleaseParamCaps); } }
static void Main(string[] args) { Stream input; if (args.Length > 0) { input = new FileStream(args[0], FileMode.Open, FileAccess.Read); } else { input = Console.OpenStandardInput(); } 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(); }
public void MessageJoin() { var mb = MessageBuilder.Create(); { var w = mb.BuildRoot <Message.WRITER>(); w.which = Message.WHICH.Join; w.Join.KeyPart.SetStruct(2, 0); w.Join.KeyPart.WriteData(0, long.MinValue); w.Join.KeyPart.WriteData(64, long.MaxValue); w.Join.QuestionId = 0x88888888; w.Join.Target.which = MessageTarget.WHICH.ImportedCap; w.Join.Target.ImportedCap = 0x99999999; } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); { Assert.AreEqual(Message.WHICH.Join, r.which); Assert.AreEqual(ObjectKind.Struct, r.Join.KeyPart.Kind); Assert.AreEqual(long.MinValue, r.Join.KeyPart.ReadDataLong(0)); Assert.AreEqual(long.MaxValue, r.Join.KeyPart.ReadDataLong(64)); Assert.AreEqual(0x88888888, r.Join.QuestionId); Assert.AreEqual(MessageTarget.WHICH.ImportedCap, r.Join.Target.which); Assert.AreEqual(0x99999999, r.Join.Target.ImportedCap); } }
public static EsiSystem ConvertFromCGRMessage(EsiContext ctxt, Stream stream) { var frame = Framing.ReadSegments(stream); var deserializer = DeserializerState.CreateRoot(frame); var reader = CodeGeneratorRequest.READER.create(deserializer); return(Convert(ctxt, reader)); }
public void Issue45() { var input = CodeGeneratorSteps.LoadResource("Issue45.capnp.bin"); using (input) { var frame = Framing.ReadSegments(input); var ds = DeserializerState.CreateRoot(frame); var cgr = CapnpSerializable.Create <CodeGeneratorRequest>(ds); Assert.IsTrue(cgr.Nodes.Count > 0); } }
static Model.SchemaModel Load(string inputName) { WireFrame segments; var input = CodeGeneratorSteps.LoadResource(inputName); using (input) { segments = Framing.ReadSegments(input); } var dec = DeserializerState.CreateRoot(segments); var reader = CodeGeneratorRequest.Reader.Create(dec); var model = Model.SchemaModel.Create(reader); return(model); }
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(); }
public void MessageBootstrap() { var mb = MessageBuilder.Create(); { var w = mb.BuildRoot <Message.WRITER>(); w.which = Message.WHICH.Bootstrap; Assert.AreEqual(Message.WHICH.Bootstrap, w.which); w.Bootstrap.QuestionId = 0xaa55aa55u; } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); Assert.AreEqual(Message.WHICH.Bootstrap, r.which); Assert.AreEqual(0xaa55aa55u, r.Bootstrap.QuestionId); }
public void MessageAbort() { var mb = MessageBuilder.Create(); { var w = mb.BuildRoot <Message.WRITER>(); w.which = Message.WHICH.Abort; Assert.AreEqual(Message.WHICH.Abort, w.which); w.Abort.Reason = "reason"; Assert.AreEqual("reason", w.Abort.Reason); } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); Assert.AreEqual(Message.WHICH.Abort, r.which); Assert.AreEqual("reason", r.Abort.Reason); }
public void MessageFinish() { var mb = MessageBuilder.Create(); { var w = mb.BuildRoot <Message.WRITER>(); w.which = Message.WHICH.Finish; w.Finish.QuestionId = 0xaaaaaaaa; } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); { Assert.AreEqual(Message.WHICH.Finish, r.which); Assert.AreEqual(0xaaaaaaaa, r.Finish.QuestionId); } }
public void MessageRelease() { var mb = MessageBuilder.Create(); { var w = mb.BuildRoot <Message.WRITER>(); w.which = Message.WHICH.Release; w.Release.Id = 0xdddddddd; w.Release.ReferenceCount = 27; } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); { Assert.AreEqual(Message.WHICH.Release, r.which); Assert.AreEqual(0xdddddddd, r.Release.Id); Assert.AreEqual(27u, r.Release.ReferenceCount); } }
public void BuildDynamicMessage() { var mb = MessageBuilder.Create(128); Assert.IsNull(mb.Root); var root = mb.BuildRoot <Struct2D0P>(); Assert.IsNotNull(root); Assert.AreSame(root, mb.Root); root.WriteData(0, long.MinValue); root.WriteData(64, long.MaxValue); var frame = mb.Frame; var droot = DeserializerState.CreateRoot(frame); Assert.AreEqual(ObjectKind.Struct, droot.Kind); Assert.AreEqual(2, droot.StructDataCount); Assert.AreEqual(long.MinValue, droot.ReadDataLong(0)); Assert.AreEqual(long.MaxValue, droot.ReadDataLong(64)); }
public void SmallSegments() { WireFrame frame; for (int i = 1; i <= 8; i++) { { var mb = MessageBuilder.Create(128); var root = mb.BuildRoot <Struct0D1P>(); var p = root.BuildPointer(0); p.SetListOfValues(64, i); frame = mb.Frame; } { var root = DeserializerState.CreateRoot(frame); Assert.AreEqual(i, root.StructReadPointer(0).ListElementCount); } } }
/// <summary> /// Generates C# code from given input stream /// </summary> /// <param name="input">input stream containing the binary code generation request, which the frontend capnpc emits</param> /// <returns>generation result</returns> /// <exception cref="ArgumentNullException">if <paramref name="input"/> is null</exception> 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)); } }
public void MessageUnimplemented() { var mb = MessageBuilder.Create(); { var u = mb.BuildRoot <Message.WRITER>(); u.which = Message.WHICH.Unimplemented; var w = u.Unimplemented; w.which = Message.WHICH.Resolve; w.Resolve.which = Resolve.WHICH.Exception; w.Resolve.Exception.Reason = "reason"; } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); { Assert.AreEqual(Message.WHICH.Unimplemented, r.which); Assert.AreEqual(Message.WHICH.Resolve, r.Unimplemented.which); Assert.AreEqual(Resolve.WHICH.Exception, r.Unimplemented.Resolve.which); Assert.AreEqual("reason", r.Unimplemented.Resolve.Exception.Reason); } }
public void MessageResolve() { var mb = MessageBuilder.Create(); { var w = mb.BuildRoot <Message.WRITER>(); w.which = Message.WHICH.Resolve; w.Resolve.which = Resolve.WHICH.Cap; w.Resolve.Cap.which = CapDescriptor.WHICH.SenderHosted; w.Resolve.Cap.SenderHosted = 0xeeeeeeee; w.Resolve.PromiseId = 0x11111111; } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); { Assert.AreEqual(Message.WHICH.Resolve, r.which); Assert.AreEqual(CapDescriptor.WHICH.SenderHosted, r.Resolve.Cap.which); Assert.AreEqual(0xeeeeeeee, r.Resolve.Cap.SenderHosted); Assert.AreEqual(0x11111111u, r.Resolve.PromiseId); } }
public void BadPointers() { var data = new ulong[1]; var wf = new WireFrame(new Memory <ulong>[] { new Memory <ulong>(data) }); var d0 = DeserializerState.CreateRoot(wf); Assert.AreEqual(ObjectKind.Nil, d0.Kind); WirePointer p = default; p.BeginStruct(1, 0); p.Offset = 0; data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); p.BeginList(ListKind.ListOfBits, 64); data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); p.BeginList(ListKind.ListOfBytes, 8); data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); p.BeginList(ListKind.ListOfEmpty, 6400); data[0] = p; var d1 = DeserializerState.CreateRoot(wf); p.BeginList(ListKind.ListOfInts, 2); data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); p.BeginList(ListKind.ListOfLongs, 1); data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); p.BeginList(ListKind.ListOfPointers, 1); data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); p.BeginList(ListKind.ListOfShorts, 4); data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); p.BeginList(ListKind.ListOfStructs, 1); data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); p.SetFarPointer(0, 0, false); data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); p.SetFarPointer(1, 0, false); data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); p.SetFarPointer(0, 1, false); data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); p.SetFarPointer(0, 0, true); data[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf)); var data2 = new ulong[3]; var wf2 = new WireFrame(new Memory <ulong>[] { new Memory <ulong>(data2) }); p.BeginList(ListKind.ListOfStructs, 1); data2[0] = p; data2[1] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf2)); p.SetFarPointer(0, 1, true); data2[0] = p; data2[1] = 0; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf2)); p.SetFarPointer(0, 1, false); data2[1] = p; data2[2] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf2)); p.SetFarPointer(0, 2, true); data2[0] = p; Assert.ThrowsException <DeserializationException>(() => DeserializerState.CreateRoot(wf2)); }
public void MessageCall() { var mb = MessageBuilder.Create(); { var w = mb.BuildRoot <Message.WRITER>(); w.which = Message.WHICH.Call; Assert.AreEqual(Message.WHICH.Call, w.which); w.Call.AllowThirdPartyTailCall = true; w.Call.InterfaceId = ulong.MaxValue; w.Call.MethodId = 0x1111; w.Call.Params.CapTable.Init(6); w.Call.Params.CapTable[0].which = CapDescriptor.WHICH.None; w.Call.Params.CapTable[1].which = CapDescriptor.WHICH.ReceiverAnswer; w.Call.Params.CapTable[1].ReceiverAnswer.QuestionId = 0x12345678u; w.Call.Params.CapTable[1].ReceiverAnswer.Transform.Init(2); w.Call.Params.CapTable[1].ReceiverAnswer.Transform[0].which = PromisedAnswer.Op.WHICH.GetPointerField; w.Call.Params.CapTable[1].ReceiverAnswer.Transform[0].GetPointerField = 0x2222; w.Call.Params.CapTable[1].ReceiverAnswer.Transform[1].which = PromisedAnswer.Op.WHICH.Noop; w.Call.Params.CapTable[2].which = CapDescriptor.WHICH.ReceiverHosted; w.Call.Params.CapTable[2].ReceiverHosted = 12345678u; w.Call.Params.CapTable[3].which = CapDescriptor.WHICH.SenderHosted; w.Call.Params.CapTable[3].SenderHosted = 23456789u; w.Call.Params.CapTable[4].which = CapDescriptor.WHICH.SenderPromise; w.Call.Params.CapTable[4].SenderPromise = 34567890u; w.Call.Params.CapTable[5].which = CapDescriptor.WHICH.ThirdPartyHosted; w.Call.Params.CapTable[5].ThirdPartyHosted.Id.SetStruct(1, 0); w.Call.Params.CapTable[5].ThirdPartyHosted.Id.WriteData(0, double.Epsilon); w.Call.Params.CapTable[5].ThirdPartyHosted.VineId = 111111u; Assert.AreEqual(CapDescriptor.WHICH.None, w.Call.Params.CapTable[0].which); Assert.AreEqual(CapDescriptor.WHICH.ReceiverAnswer, w.Call.Params.CapTable[1].which); Assert.AreEqual(CapDescriptor.WHICH.ReceiverHosted, w.Call.Params.CapTable[2].which); Assert.AreEqual(CapDescriptor.WHICH.SenderHosted, w.Call.Params.CapTable[3].which); Assert.AreEqual(CapDescriptor.WHICH.SenderPromise, w.Call.Params.CapTable[4].which); Assert.AreEqual(CapDescriptor.WHICH.ThirdPartyHosted, w.Call.Params.CapTable[5].which); var content = w.Call.Params.Content.Rewrap <DynamicSerializerState>(); content.SetStruct(1, 0); content.WriteData(0, double.PositiveInfinity); w.Call.QuestionId = 0x77777777u; w.Call.SendResultsTo.which = Call.sendResultsTo.WHICH.ThirdParty; w.Call.SendResultsTo.ThirdParty.SetStruct(1, 0); w.Call.SendResultsTo.ThirdParty.WriteData(0, double.NegativeInfinity); w.Call.Target.which = MessageTarget.WHICH.PromisedAnswer; w.Call.Target.PromisedAnswer.QuestionId = 5555555u; } var r = Message.READER.create(DeserializerState.CreateRoot(mb.Frame)); Assert.AreEqual(Message.WHICH.Call, r.which); Assert.IsTrue(r.Call.AllowThirdPartyTailCall); Assert.AreEqual(ulong.MaxValue, r.Call.InterfaceId); Assert.AreEqual((ushort)0x1111, r.Call.MethodId); var capTable = r.Call.Params.CapTable; Assert.AreEqual(6, capTable.Count); Assert.AreEqual(CapDescriptor.WHICH.None, capTable[0].which); Assert.AreEqual(CapDescriptor.WHICH.ReceiverAnswer, capTable[1].which); Assert.AreEqual(0x12345678u, capTable[1].ReceiverAnswer.QuestionId); var transform = capTable[1].ReceiverAnswer.Transform; Assert.AreEqual(2, transform.Count); Assert.AreEqual(PromisedAnswer.Op.WHICH.GetPointerField, transform[0].which); Assert.AreEqual((ushort)0x2222, transform[0].GetPointerField); Assert.AreEqual(PromisedAnswer.Op.WHICH.Noop, transform[1].which); Assert.AreEqual(CapDescriptor.WHICH.ReceiverHosted, capTable[2].which); Assert.AreEqual(12345678u, capTable[2].ReceiverHosted); Assert.AreEqual(CapDescriptor.WHICH.SenderHosted, capTable[3].which); Assert.AreEqual(23456789u, capTable[3].SenderHosted); Assert.AreEqual(CapDescriptor.WHICH.SenderPromise, capTable[4].which); Assert.AreEqual(34567890u, capTable[4].SenderPromise); Assert.AreEqual(CapDescriptor.WHICH.ThirdPartyHosted, capTable[5].which); var tph = capTable[5].ThirdPartyHosted; Assert.AreEqual(ObjectKind.Struct, tph.Id.Kind); Assert.AreEqual(double.Epsilon, tph.Id.ReadDataDouble(0)); Assert.AreEqual(111111u, tph.VineId); Assert.AreEqual(ObjectKind.Struct, r.Call.Params.Content.Kind); Assert.AreEqual(double.PositiveInfinity, r.Call.Params.Content.ReadDataDouble(0)); Assert.AreEqual(0x77777777u, r.Call.QuestionId); var srt = r.Call.SendResultsTo; Assert.AreEqual(Call.sendResultsTo.WHICH.ThirdParty, srt.which); Assert.AreEqual(ObjectKind.Struct, srt.ThirdParty.Kind); Assert.AreEqual(double.NegativeInfinity, srt.ThirdParty.ReadDataDouble(0)); Assert.AreEqual(MessageTarget.WHICH.PromisedAnswer, r.Call.Target.which); Assert.AreEqual(5555555u, r.Call.Target.PromisedAnswer.QuestionId); }
/// <summary> /// Processes a sent or received RPC frame /// </summary> /// <param name="dir">frame direction</param> /// <param name="frame">actual frame</param> public void TraceFrame(FrameDirection dir, WireFrame frame) { if (!_timer.IsRunning) { _timer.Start(); } _traceWriter.Write($@"{_timer.ElapsedTicks, 10} | {Thread.CurrentThread.ManagedThreadId, 10} | "); _traceWriter.Write(dir == FrameDirection.Tx ? "Tx |" : "Rx |"); var dec = DeserializerState.CreateRoot(frame); var msg = Message.READER.create(dec); string tag; switch (msg.which) { case Message.WHICH.Abort: _traceWriter.WriteLine($"ABORT {msg.Abort.Reason}"); break; case Message.WHICH.Bootstrap: tag = dir == FrameDirection.Tx ? "Q" : "A"; _traceWriter.WriteLine($"BOOTSTRAP {tag}{msg.Bootstrap.QuestionId}"); break; case Message.WHICH.Call: tag = dir == FrameDirection.Tx ? "Q" : "A"; _traceWriter.Write($"CALL {tag}{msg.Call.QuestionId}, I: {msg.Call.InterfaceId:x} M: {msg.Call.MethodId} "); RenderMessageTarget(msg.Call.Target, dir); _traceWriter.Write(HeaderSpace); _traceWriter.WriteLine($"Send results to {msg.Call.SendResultsTo.which}"); RenderCapTable(msg.Call.Params.CapTable, dir); break; case Message.WHICH.Disembargo: _traceWriter.Write($"DISEMBARGO {msg.Disembargo.Context.which}"); switch (msg.Disembargo.Context.which) { case Disembargo.context.WHICH.Provide: _traceWriter.Write($" {msg.Disembargo.Context.Provide}"); break; case Disembargo.context.WHICH.ReceiverLoopback: _traceWriter.Write($" E{msg.Disembargo.Context.ReceiverLoopback}"); break; case Disembargo.context.WHICH.SenderLoopback: _traceWriter.Write($" E{msg.Disembargo.Context.SenderLoopback}"); break; } _traceWriter.WriteLine("."); _traceWriter.Write(HeaderSpace); RenderMessageTarget(msg.Disembargo.Target, dir); break; case Message.WHICH.Finish: tag = dir == FrameDirection.Tx ? "Q" : "A"; _traceWriter.WriteLine($"FINISH {tag}{msg.Finish.QuestionId}, release: {msg.Finish.ReleaseResultCaps}"); break; case Message.WHICH.Release: tag = dir == FrameDirection.Tx ? "CR" : "CL"; _traceWriter.WriteLine($"RELEASE {tag}{msg.Release.Id}, count: {msg.Release.ReferenceCount}"); break; case Message.WHICH.Resolve: tag = dir == FrameDirection.Tx ? "CL" : "CR"; _traceWriter.Write($"RESOLVE {tag}{msg.Resolve.PromiseId}: {msg.Resolve.which}"); switch (msg.Resolve.which) { case Resolve.WHICH.Cap: RenderCapDescriptor(msg.Resolve.Cap, dir); _traceWriter.WriteLine("."); break; case Resolve.WHICH.Exception: _traceWriter.WriteLine($" {msg.Resolve.Exception.Reason}"); break; } break; case Message.WHICH.Return: tag = dir == FrameDirection.Tx ? "A" : "Q"; _traceWriter.Write($"RETURN {tag}{msg.Return.AnswerId} {msg.Return.which}"); switch (msg.Return.which) { case Return.WHICH.Exception: _traceWriter.WriteLine($" {msg.Return.Exception.Reason}"); break; case Return.WHICH.Results: _traceWriter.WriteLine($", release: {msg.Return.ReleaseParamCaps}"); RenderCapTable(msg.Return.Results.CapTable, dir); break; case Return.WHICH.TakeFromOtherQuestion: tag = dir == FrameDirection.Tx ? "Q" : "A"; _traceWriter.WriteLine($" {tag}{msg.Return.TakeFromOtherQuestion}"); break; default: _traceWriter.WriteLine(); break; } break; case Message.WHICH.Unimplemented: _traceWriter.WriteLine($"UNIMPLEMENTED {msg.Unimplemented.which}"); break; case Message.WHICH.Accept: _traceWriter.WriteLine("ACCEPT"); break; case Message.WHICH.Join: _traceWriter.WriteLine("JOIN"); break; case Message.WHICH.Provide: _traceWriter.WriteLine($"PROVIDE {msg.Provide.QuestionId}"); RenderMessageTarget(msg.Provide.Target, dir); break; case Message.WHICH.ObsoleteDelete: _traceWriter.WriteLine("OBSOLETEDELETE"); break; case Message.WHICH.ObsoleteSave: _traceWriter.WriteLine("OBSOLETESAVE"); break; default: _traceWriter.WriteLine($"Unknown message {msg.which}"); break; } }