/// <summary>Helper: Serialize into a MemoryStream and return its byte array</summary>
 public static byte[] SerializeToBytes(FieldDescriptorProto instance)
 {
     using (var ms = new MemoryStream())
     {
         Serialize(ms, instance);
         return ms.ToArray();
     }
 }
 /// <summary>Helper: Serialize with a varint length prefix</summary>
 public static void SerializeLengthDelimited(Stream stream, FieldDescriptorProto instance)
 {
     var data = SerializeToBytes(instance);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, (uint)data.Length);
     stream.Write(data, 0, data.Length);
 }
        /// <summary>Serialize the instance into the stream</summary>
        public static void Serialize(Stream stream, FieldDescriptorProto instance)
        {
            var msField = global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Pop();
            if (instance.Name != null)
            {
                // Key for field: 1, LengthDelimited
                stream.WriteByte(10);
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Name));
            }
            // Key for field: 3, Varint
            stream.WriteByte(24);
            global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt64(stream,(ulong)instance.Number);
            // Key for field: 4, Varint
            stream.WriteByte(32);
            global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt64(stream,(ulong)instance.label);
            // Key for field: 5, Varint
            stream.WriteByte(40);
            global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt64(stream,(ulong)instance.type);
            if (instance.TypeName != null)
            {
                // Key for field: 6, LengthDelimited
                stream.WriteByte(50);
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.TypeName));
            }
            if (instance.Extendee != null)
            {
                // Key for field: 2, LengthDelimited
                stream.WriteByte(18);
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Extendee));
            }
            if (instance.DefaultValue != null)
            {
                // Key for field: 7, LengthDelimited
                stream.WriteByte(58);
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.DefaultValue));
            }
            if (instance.Options != null)
            {
                // Key for field: 8, LengthDelimited
                stream.WriteByte(66);
                msField.SetLength(0);
                Google.Protobuf.FieldOptions.Serialize(msField, instance.Options);
                // Length delimited byte array
                uint length8 = (uint)msField.Length;
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length8);
                msField.WriteTo(stream);

            }
            global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Push(msField);
        }
 /// <summary>Helper: put the buffer into a MemoryStream and create a new instance to deserializing into</summary>
 public static FieldDescriptorProto Deserialize(byte[] buffer)
 {
     var instance = new FieldDescriptorProto();
     using (var ms = new MemoryStream(buffer))
         Deserialize(ms, instance);
     return instance;
 }
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static FieldDescriptorProto DeserializeLength(Stream stream, int length)
 {
     var instance = new FieldDescriptorProto();
     DeserializeLength(stream, length, instance);
     return instance;
 }
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static FieldDescriptorProto DeserializeLengthDelimited(Stream stream)
 {
     var instance = new FieldDescriptorProto();
     DeserializeLengthDelimited(stream, instance);
     return instance;
 }
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static FieldDescriptorProto Deserialize(Stream stream)
 {
     FieldDescriptorProto instance = new FieldDescriptorProto();
     Deserialize(stream, instance);
     return instance;
 }