The field descriptor.
        /// <summary>
        /// The file descriptor proto.
        /// </summary>
        /// <param name="totalLength">
        /// The total length.
        /// </param>
        /// <param name="fd">
        /// The file descriptor.
        /// </param>
        // ReSharper disable once FunctionComplexityOverflow
        private void FileDescriptorProto(uint totalLength, FileDescriptor fd)
        {
            intend++;

            while (totalLength != 0)
            {
                int type, no;
                var l = GetTypeAndFieldNo(out type, out no);
                ix += l;
                totalLength -= (uint)l;

                switch (no)
                {
                    case 1: // string name
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.Name = GetString(length);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, Name = {3}", type, no, length, fd.Name));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 2: // string package
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.Package = GetString(length);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, Package = {3}", type, no, length, fd.Package));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 3: // string[] dependecy
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            var value = GetString(length);
                            fd.Dependencies.Add(value);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, Dependency = {3}", type, no, length, value));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 4: // DescriptorProto[] message type
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - DescriptorProto", type, no, length));
                            var md = new MessageDescriptor();
                            fd.MessageTypes.Add(md);
                            DescriptorProto(length, md);
                            totalLength -= length;
                            break;
                        }

                    case 5: // EnumDescriptorProto[] enum type
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - EnumDescriptorProto", type, no, length));
                            var ed = new EnumDescriptor();
                            fd.EnumTypes.Add(ed);
                            EnumDescriptorProto(length, ed);
                            totalLength -= length;
                            break;
                        }

                    case 6: // ServiceDescriptorProto[] service
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - ServiceDescriptorProto", type, no, length));
                            var sd = new ServiceDescriptor();
                            fd.Services.Add(sd);
                            ServiceDescriptorProto(length, sd);
                            totalLength -= length;
                            break;
                        }

                    case 7: // FieldDescriptorProto[] extension
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - FieldDescriptorProto", type, no, length));
                            var fd2 = new FieldDescriptor();
                            fd.Extensions.Add(fd2);
                            FieldDescriptorProto(length, fd2);
                            totalLength -= length;
                            break;
                        }

                    case 8: // FileOptions options
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - FileOptions", type, no, length));
                            if (fd.Options == null)
                            {
                                fd.Options = new FileOptions();
                            }

                            FileOptions(length, fd.Options);
                            totalLength -= length;
                            break;
                        }

                    case 9: // SourceCodeInfo source_code_info
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - SourceCodeInfo", type, no, length));
                            fd.SourceCodeInfo = new SourceCodeInfo();
                            ////SourceCodeInfo(length, fd.SourceCodeInfo);
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 10: // int32[] public_dependency
                        {
                            uint value;
                            var ixl = GetVarint(out value);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.PublicDependencies.Add((int)value);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, public_dependency = {3}", type, no, ixl, value));
                            break;
                        }

                    case 11: // int32[] weak_dependency
                        {
                            uint value;
                            var ixl = GetVarint(out value);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.WeakDependencies.Add((int)value);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, weak_dependency = {3}", type, no, ixl, value));
                            break;
                        }
                }
            }

            intend--;
        }
        /// <summary>
        /// The message descriptor proto.
        /// </summary>
        /// <param name="totalLength">
        /// The total length.
        /// </param>
        /// <param name="md">
        /// The message descriptor.
        /// </param>
        private void DescriptorProto(uint totalLength, MessageDescriptor md)
        {
            intend++;

            while (totalLength != 0)
            {
                int type, no;
                var l = GetTypeAndFieldNo(out type, out no);
                ix += l;
                totalLength -= (uint)l;

                switch (no)
                {
                    case 1: // string name
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            md.Name = GetString(length);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, Name = {3}", type, no, length, md.Name));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 2: // FieldDescriptorProto[] field
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - FieldDescriptorProto field", type, no, length));
                            var fd = new FieldDescriptor();
                            md.Fields.Add(fd);
                            FieldDescriptorProto(length, fd);
                            totalLength -= length;
                            break;
                        }

                    case 3: // DescriptorProto[] nested_type
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - DescriptorProto", type, no, length));
                            var msg = new MessageDescriptor();
                            md.NestedTypes.Add(msg);
                            DescriptorProto(length, msg);
                            totalLength -= length;
                            break;
                        }

                    case 4: // EnumDescriptorProto[] enum_type
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - EnumDescriptorProto", type, no, length));
                            var ed = new EnumDescriptor();
                            md.EnumTypes.Add(ed);
                            EnumDescriptorProto(length, ed);
                            totalLength -= length;
                            break;
                        }

                    case 5: // ExtensionRange[] extension_range
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - ExtensionRange", type, no, length));
                            var er = new MessageDescriptor.ExtensionRange();
                            md.ExtensionRanges.Add(er);
                            ExtensionRange(length, er);
                            totalLength -= length;
                            break;
                        }

                    case 6: // FieldDescriptorProto[] extension
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - FieldDescriptorProto extension", type, no, length));
                            var fd = new FieldDescriptor();
                            md.Fields.Add(fd);
                            FieldDescriptorProto(length, fd);
                            totalLength -= length;
                            break;
                        }

                    case 7: // MessageOptions options
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - MessageOptions", type, no, length));
                            if (md.Options == null)
                            {
                                md.Options = new MessageOptions();
                            }

                            MessageOptions(length, md.Options);
                            totalLength -= length;
                            break;
                        }

                    case 8: // OneofDescriptorProto[] oneof_decl
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2} - OneofDescriptorProto", type, no, length));
                            var od = new OneofDescriptor();
                            md.OneofDecl.Add(od);
                            OneofDescriptorProto(length, od);
                            totalLength -= length;
                            break;
                        }
                }
            }

            intend--;
        }
        /// <summary>
        /// The field descriptor proto.
        /// </summary>
        /// <param name="totalLength">
        /// The total length.
        /// </param>
        /// <param name="fd">
        /// The field descriptor.
        /// </param>
        // ReSharper disable once FunctionComplexityOverflow
        private void FieldDescriptorProto(uint totalLength, FieldDescriptor fd)
        {
            intend++;

            while (totalLength != 0)
            {
                int type, no;
                var l = GetTypeAndFieldNo(out type, out no);
                ix += l;
                totalLength -= (uint)l;

                switch (no)
                {
                    case 1: // string name
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.Name = GetString(length);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, Name = {3}", type, no, length, fd.Name));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 2: // string extendee
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.Extendee = GetString(length);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, extendee = {3}", type, no, length, fd.Extendee));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 3: // int32 number
                        {
                            uint value;
                            var ixl = GetVarint(out value);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.Number = (int)value;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, number = {3}", type, no, ixl, value));
                            break;
                        }

                    case 4: // Label label
                        {
                            uint value;
                            var ixl = GetVarint(out value);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.Label = (FieldDescriptor.Labels)value;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, label = {3}", type, no, ixl, value));
                            break;
                        }

                    case 5: // Type type
                        {
                            uint value;
                            var ixl = GetVarint(out value);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.Type = (FieldDescriptor.Types)value;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, type = {3}", type, no, ixl, value));
                            break;
                        }

                    case 6: // string type_name
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.TypeName = GetString(length);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, type_name = {3}", type, no, length, fd.TypeName));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 7: // string default_value
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.DefaultValue = GetString(length);
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, default_value = {3}", type, no, length, fd.DefaultValue));
                            ix += (int)length;
                            totalLength -= length;
                            break;
                        }

                    case 8: // FieldOptions options
                        {
                            uint length;
                            var ixl = GetVarint(out length);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, FieldOptions", type, no, length));
                            if (fd.Options == null)
                            {
                                fd.Options = new FieldOptions();
                            }

                            FieldOptions(length, fd.Options);
                            totalLength -= length;
                            break;
                        }

                    case 9: // int32 oneof_index
                        {
                            uint value;
                            var ixl = GetVarint(out value);
                            ix += ixl;
                            totalLength -= (uint)ixl;
                            fd.OneofIndex = (int)value;
                            Write(string.Format("Type = {0}, F#= {1}, Length = {2}, oneof_index = {3}", type, no, ixl, value));
                            break;
                        }
                }
            }

            intend--;
        }