This repository was archived by the owner on Jun 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
src/betterproto2_compiler Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -266,6 +266,10 @@ def custom_methods(self) -> list[str]:
266266
267267 return methods_source
268268
269+ @property
270+ def descriptor (self ):
271+ return self .proto_obj .SerializeToString ()
272+
269273
270274def is_map (proto_field_obj : FieldDescriptorProto , parent_message : DescriptorProto ) -> bool :
271275 """True if proto_field_obj is a map, otherwise False."""
@@ -594,6 +598,10 @@ def py_name(self) -> str:
594598 def deprecated (self ) -> bool :
595599 return bool (self .proto_obj .options and self .proto_obj .options .deprecated )
596600
601+ @property
602+ def descriptor (self ):
603+ return self .proto_obj .SerializeToString ()
604+
597605
598606@dataclass (kw_only = True )
599607class ServiceCompiler (ProtoContentBase ):
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ class {{ enum.py_name | add_to_all }}(betterproto2.Enum):
66 """
77 {% endif %}
88
9+ @staticmethod
10+ def _serialized_pb():
11+ return {{ enum.descriptor }}
12+
913 {% for entry in enum .entries %}
1014 {{ entry.name }} = {{ entry.value }}
1115 {% if entry .comment %}
@@ -45,6 +49,10 @@ class {{ message.py_name | add_to_all }}(betterproto2.Message):
4549 """
4650 {% endif %}
4751
52+ @staticmethod
53+ def _serialized_pb():
54+ return {{ message.descriptor }}
55+
4856 {% for field in message .fields %}
4957 {{ field.get_field_string() }}
5058 {% if field .comment %}
You can’t perform that action at this time.
0 commit comments