/// <summary>Helper: create a new instance to deserializing into</summary>
 public static FileDescriptorProto DeserializeLength(Stream stream, int length)
 {
     var instance = new FileDescriptorProto();
     DeserializeLength(stream, length, instance);
     return instance;
 }
 /// <summary>Helper: put the buffer into a MemoryStream and create a new instance to deserializing into</summary>
 public static FileDescriptorProto Deserialize(byte[] buffer)
 {
     var instance = new FileDescriptorProto();
     using (var ms = new MemoryStream(buffer))
         Deserialize(ms, instance);
     return instance;
 }
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static FileDescriptorProto DeserializeLengthDelimited(Stream stream)
 {
     var instance = new FileDescriptorProto();
     DeserializeLengthDelimited(stream, instance);
     return instance;
 }
 /// <summary>Helper: Serialize with a varint length prefix</summary>
 public static void SerializeLengthDelimited(Stream stream, FileDescriptorProto instance)
 {
     var data = SerializeToBytes(instance);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, (uint)data.Length);
     stream.Write(data, 0, data.Length);
 }
 /// <summary>Helper: Serialize into a MemoryStream and return its byte array</summary>
 public static byte[] SerializeToBytes(FileDescriptorProto instance)
 {
     using (var ms = new MemoryStream())
     {
         Serialize(ms, instance);
         return ms.ToArray();
     }
 }
        /// <summary>Serialize the instance into the stream</summary>
        public static void Serialize(Stream stream, FileDescriptorProto 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));
            }
            if (instance.Package != null)
            {
                // Key for field: 2, LengthDelimited
                stream.WriteByte(18);
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Package));
            }
            if (instance.Dependency != null)
            {
                foreach (var i3 in instance.Dependency)
                {
                    // Key for field: 3, LengthDelimited
                    stream.WriteByte(26);
                    global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(i3));
                }
            }
            if (instance.PublicDependency != null)
            {
                foreach (var i10 in instance.PublicDependency)
                {
                    // Key for field: 10, Varint
                    stream.WriteByte(80);
                    global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt64(stream,(ulong)i10);
                }
            }
            if (instance.WeakDependency != null)
            {
                foreach (var i11 in instance.WeakDependency)
                {
                    // Key for field: 11, Varint
                    stream.WriteByte(88);
                    global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt64(stream,(ulong)i11);
                }
            }
            if (instance.MessageType != null)
            {
                foreach (var i4 in instance.MessageType)
                {
                    // Key for field: 4, LengthDelimited
                    stream.WriteByte(34);
                    msField.SetLength(0);
                    Google.Protobuf.DescriptorProto.Serialize(msField, i4);
                    // Length delimited byte array
                    uint length4 = (uint)msField.Length;
                    global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length4);
                    msField.WriteTo(stream);

                }
            }
            if (instance.EnumType != null)
            {
                foreach (var i5 in instance.EnumType)
                {
                    // Key for field: 5, LengthDelimited
                    stream.WriteByte(42);
                    msField.SetLength(0);
                    Google.Protobuf.EnumDescriptorProto.Serialize(msField, i5);
                    // Length delimited byte array
                    uint length5 = (uint)msField.Length;
                    global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length5);
                    msField.WriteTo(stream);

                }
            }
            if (instance.Service != null)
            {
                foreach (var i6 in instance.Service)
                {
                    // Key for field: 6, LengthDelimited
                    stream.WriteByte(50);
                    msField.SetLength(0);
                    Google.Protobuf.ServiceDescriptorProto.Serialize(msField, i6);
                    // Length delimited byte array
                    uint length6 = (uint)msField.Length;
                    global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length6);
                    msField.WriteTo(stream);

                }
            }
            if (instance.Extension != null)
            {
                foreach (var i7 in instance.Extension)
                {
                    // Key for field: 7, LengthDelimited
                    stream.WriteByte(58);
                    msField.SetLength(0);
                    Google.Protobuf.FieldDescriptorProto.Serialize(msField, i7);
                    // Length delimited byte array
                    uint length7 = (uint)msField.Length;
                    global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length7);
                    msField.WriteTo(stream);

                }
            }
            if (instance.Options != null)
            {
                // Key for field: 8, LengthDelimited
                stream.WriteByte(66);
                msField.SetLength(0);
                Google.Protobuf.FileOptions.Serialize(msField, instance.Options);
                // Length delimited byte array
                uint length8 = (uint)msField.Length;
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length8);
                msField.WriteTo(stream);

            }
            if (instance.SourceCodeInfo != null)
            {
                // Key for field: 9, LengthDelimited
                stream.WriteByte(74);
                msField.SetLength(0);
                Google.Protobuf.SourceCodeInfo.Serialize(msField, instance.SourceCodeInfo);
                // Length delimited byte array
                uint length9 = (uint)msField.Length;
                global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length9);
                msField.WriteTo(stream);

            }
            global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Push(msField);
        }
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static FileDescriptorProto Deserialize(Stream stream)
 {
     FileDescriptorProto instance = new FileDescriptorProto();
     Deserialize(stream, instance);
     return instance;
 }