From df6efd2a55975716b76319ecc75c247872965ef5 Mon Sep 17 00:00:00 2001 From: Iain McGinniss <309153+iainmcgin@users.noreply.github.com> Date: Mon, 20 Apr 2026 22:08:03 +0800 Subject: [PATCH] fix: add missing text and allow_message_set parameters to protoc plugin The protoc-gen-buffa plugin was missing support for the `text` and `allow_message_set` codegen options that are available in buffa-build. This made text format generation and message_set_wire_format support unavailable when using the protoc/buf plugin workflow. Add `text=true` and `allow_message_set=true` as recognized plugin parameters, matching the existing pattern for `json`, `views`, etc. Co-authored-by: Qiaochu Hu <110803307+hobostay@users.noreply.github.com> --- protoc-gen-buffa/src/main.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/protoc-gen-buffa/src/main.rs b/protoc-gen-buffa/src/main.rs index ed30a82..1398900 100644 --- a/protoc-gen-buffa/src/main.rs +++ b/protoc-gen-buffa/src/main.rs @@ -129,7 +129,9 @@ fn parse_config(params: &str) -> Result { "views" => codegen.generate_views = value.trim() == "true", "unknown_fields" => codegen.preserve_unknown_fields = value.trim() != "false", "json" => codegen.generate_json = value.trim() == "true", + "text" => codegen.generate_text = value.trim() == "true", "arbitrary" => codegen.generate_arbitrary = value.trim() == "true", + "allow_message_set" => codegen.allow_message_set = value.trim() == "true", "strict_utf8" | "strict_utf8_mapping" => { codegen.strict_utf8_mapping = value.trim() == "true" } @@ -289,4 +291,28 @@ mod tests { let err = parse_config("mod_file=mod.rs").err().unwrap(); assert!(err.contains("protoc-gen-buffa-packaging")); } + + #[test] + fn text_true() { + let config = parse_config("text=true").unwrap(); + assert!(config.codegen.generate_text); + } + + #[test] + fn text_default_is_false() { + let config = parse_config("").unwrap(); + assert!(!config.codegen.generate_text); + } + + #[test] + fn allow_message_set_true() { + let config = parse_config("allow_message_set=true").unwrap(); + assert!(config.codegen.allow_message_set); + } + + #[test] + fn allow_message_set_default_is_false() { + let config = parse_config("").unwrap(); + assert!(!config.codegen.allow_message_set); + } }