GitHub

FileOptions

API reference for FileOptions.

The fields of google.protobuf.FileOptions.

Attributes

AttributeTypeDescription
java_packagestr

Sets the Java package where classes generated from this .proto will be placed. By default, the proto package is used, but this is often inappropriate because proto packages do not normally start with backwards domain names.

java_outer_classnamestr

Controls the name of the wrapper Java class generated for the .proto file. That class will always contain the .proto file's getDescriptor() method as well as any top-level extensions defined in the .proto file. If java_multiple_files is disabled, then all the other classes from the .proto file will be nested inside the single wrapper outer class.

java_multiple_filesbool

If enabled, then the Java code generator will generate a separate .java file for each top-level message, enum, and service defined in the .proto file. Thus, these types will not be nested inside the wrapper class named by java_outer_classname. However, the wrapper class will still be generated to contain the file's getDescriptor() method as well as any top-level extensions defined in the file.

java_generate_equals_and_hashbool

This option does nothing.

java_string_check_utf8bool

A proto2 file can set this to true to opt in to UTF-8 checking for Java, which will throw an exception if invalid UTF-8 is parsed from the wire or assigned to a string field.

TODO: clarify exactly what kinds of field types this option applies to, and update these docs accordingly.

Proto3 files already perform these checks. Setting the option explicitly to false has no effect: it cannot be used to opt proto3 files out of UTF-8 checks.

optimize_forint

A FileOptions_OptimizeMode.

go_packagestr

Sets the Go package where structs generated from this .proto will be placed. If omitted, the Go package will be derived from the following:

  • The basename of the package import path, if provided.
  • Otherwise, the package statement in the .proto file, if present.
  • Otherwise, the basename of the .proto file, without extension.
cc_generic_servicesbool

Should generic services be generated in each language? "Generic" services are not specific to any particular RPC system. They are generated by the main code generators in each language (without additional plugins). Generic services were the only kind of service generation supported by early versions of google.protobuf.

Generic services are now considered deprecated in favor of using plugins that generate code specific to your particular RPC system. Therefore, these default to false. Old code which depends on generic services should explicitly set them to true.

java_generic_servicesbool
py_generic_servicesbool
deprecatedbool

Is this file deprecated? Depending on the target platform, this can emit Deprecated annotations for everything in the file, or it will be completely ignored; in the very least, this is a formalization for deprecating files.

cc_enable_arenasbool

Enables the use of arenas for the proto messages in this file. This applies only to generated classes for C++.

objc_class_prefixstr

Sets the objective c class prefix which is prepended to all objective c generated classes from this .proto. There is no default.

csharp_namespacestr

Namespace for generated classes; defaults to the package.

swift_prefixstr

By default Swift generators will take the proto package and CamelCase it replacing '.' with underscore and use that to prefix the types/symbols defined. When this options is provided, they will use this value instead to prefix the types/symbols defined.

php_class_prefixstr

Sets the php class prefix which is prepended to all php generated classes from this .proto. Default is empty.

php_namespacestr

Use this option to change the namespace of php generated classes. Default is empty. When this option is empty, the package name will be used for determining the namespace.

php_metadata_namespacestr

Use this option to change the namespace of php generated metadata classes. Default is empty. When this option is empty, the proto file name will be used for determining the namespace.

ruby_packagestr

Use this option to change the package of ruby generated classes. Default is empty. When this option is not set, the package name will be used for determining the ruby package.

featuresFeatureSet

Any features defined in the specific edition. WARNING: This field should only be used by protobuf plugins or special cases like the proto compiler. Other uses are discouraged and developers should rely on the protoreflect APIs for their client language.

uninterpreted_optionlist[UninterpretedOption]

The parser stores options it doesn't recognize here. See the documentation for the "Options" section above.