func (db Builder) Build() (out Out) {
	if db.NumEnums+db.NumMessages+db.NumExtensions+db.NumServices == 0 {
		db.unmarshalCounts(db.RawDescriptor, true)
	}
	if db.TypeResolver == nil {
		db.TypeResolver = preg.GlobalTypes
	}
	if db.FileRegistry == nil {
		db.FileRegistry = preg.GlobalFiles
	}
	fd := newRawFile(db)
	out.File = fd
	out.Enums = fd.allEnums
	out.Messages = fd.allMessages
	out.Extensions = fd.allExtensions
	out.Services = fd.allServices
	if err := db.FileRegistry.RegisterFile(fd); err != nil {
		panic(err)
	}
	return out
}
Build constructs a FileDescriptor given the parameters set in Builder.
It assumes that the inputs are well-formed and panics if any inconsistencies
are encountered.

If NumEnums+NumMessages+NumExtensions+NumServices is zero,
then Build automatically derives them from the raw descriptor.
package filedesc
import (
	"google.golang.org/protobuf/encoding/protowire"
	"google.golang.org/protobuf/internal/genid"
	"google.golang.org/protobuf/reflect/protoreflect"
	pref "google.golang.org/protobuf/reflect/protoreflect"
	preg "google.golang.org/protobuf/reflect/protoregistry"
)
type Builder struct {
	GoPackagePath string
	RawDescriptor []byte
	NumEnums int32
	NumMessages int32
	NumExtensions int32
	NumServices int32
	TypeResolver interface {
		preg.ExtensionTypeResolver
	}
	FileRegistry interface {
		FindFileByPath(string) (protoreflect.FileDescriptor, error)
		FindDescriptorByName(pref.FullName) (pref.Descriptor, error)
		RegisterFile(pref.FileDescriptor) error
	}
}
type resolverByIndex interface {
	FindEnumByIndex(int32, int32, []Enum, []Message) pref.EnumDescriptor
	FindMessageByIndex(int32, int32, []Enum, []Message) pref.MessageDescriptor
}
const (
	listFieldDeps int32 = iota
	listExtTargets
	listExtDeps
	listMethInDeps
	listMethOutDeps
)
type Out struct {
	File pref.FileDescriptor
	Enums []Enum
	Messages []Message
	Extensions []Extension
	Services []Service
}