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]:
266
266
267
267
return methods_source
268
268
269
+ @property
270
+ def descriptor (self ):
271
+ return self .proto_obj .SerializeToString ()
272
+
269
273
270
274
def is_map (proto_field_obj : FieldDescriptorProto , parent_message : DescriptorProto ) -> bool :
271
275
"""True if proto_field_obj is a map, otherwise False."""
@@ -594,6 +598,10 @@ def py_name(self) -> str:
594
598
def deprecated (self ) -> bool :
595
599
return bool (self .proto_obj .options and self .proto_obj .options .deprecated )
596
600
601
+ @property
602
+ def descriptor (self ):
603
+ return self .proto_obj .SerializeToString ()
604
+
597
605
598
606
@dataclass (kw_only = True )
599
607
class 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):
6
6
"""
7
7
{% endif %}
8
8
9
+ @staticmethod
10
+ def _serialized_pb():
11
+ return {{ enum.descriptor }}
12
+
9
13
{% for entry in enum .entries %}
10
14
{{ entry.name }} = {{ entry.value }}
11
15
{% if entry .comment %}
@@ -45,6 +49,10 @@ class {{ message.py_name | add_to_all }}(betterproto2.Message):
45
49
"""
46
50
{% endif %}
47
51
52
+ @staticmethod
53
+ def _serialized_pb():
54
+ return {{ message.descriptor }}
55
+
48
56
{% for field in message .fields %}
49
57
{{ field.get_field_string() }}
50
58
{% if field .comment %}
You can’t perform that action at this time.
0 commit comments