You can generate a Protobuf message without knowing its type at compile time by loading its descriptors, creating a dynamic message, and walking its fields through the runtime’s reflection API. Descriptors provide the message’s schema shape—not realistic sample data or application rules—so a useful mock generator also needs an explicit policy for values, collection sizes, recursion, and domain-specific constraints.
What descriptors provide—and what they leave out
Protocol Buffers describes a descriptor as schema metadata. The official documentation puts the key limitation plainly: “Protocol Buffers do not contain descriptions of their own types.” A serialized FileDescriptorSet can carry schema definitions alongside data, and a dynamic-message implementation can use those definitions at runtime. This self-describing-message technique depends on runtime support for dynamic messages, which varies by platform. Protocol Buffers Documentation: Self-describing Messages
As an Amazon Associate I earn from qualifying purchases.
A descriptor can tell your generator a field’s name, number, declared type, cardinality, and relevant schema structure. Reflection can then read or set fields without generated code for each message. But a descriptor does not inherently say whether a string should look like an email address, whether two amounts must reconcile, which identifier format your application expects, or what combinations of values constitute a valid business state. Those requirements belong in generator policy, custom options or external metadata, and fixtures—not in assumptions about the schema API. C++ descriptor API
Free tools Windows power users keep installed
One-click scans. No signup required.
- Schema knowledge: field structure and declared types are available when the relevant definitions are loaded.
- Value meaning: realistic distributions, formats, sensitivity classifications, and cross-field rules are not guaranteed by descriptors.
- Schema completeness: a descriptor set cannot provide definitions that were not included. Missing extension definitions and unknown wire fields require separate handling.
Build a runtime generator in two layers
Keep generic traversal separate from value generation. The traversal layer understands descriptors and reflection; the policy layer decides how to populate each field. This split makes the generator reusable across message types while letting tests choose deterministic, boundary-focused, or domain-aware data.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
1. Load the schema and resolve the root message
Obtain a descriptor set containing the root message’s file and imported dependencies needed to resolve referenced types. Build or populate a descriptor pool, then find the fully qualified name of the message to generate. The self-describing-message approach uses a FileDescriptorSet; confirm that the deployed runtime supports dynamic messages. Protocol Buffers Documentation: Self-describing Messages
2. Create a dynamic message instance
Use the dynamic-message API for your language. In C++, DynamicMessageFactory creates prototypes from descriptors, and those descriptors must outlive the factory. In Java, DynamicMessage supports arbitrary message types represented by a Descriptors.Descriptor. Keep the descriptor pool, descriptors, factory, and created messages within compatible lifetimes. C++ DynamicMessageFactory API Java DynamicMessage API
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
3. Traverse fields and populate them by declared type
For each message descriptor, iterate its fields and dispatch on the field descriptor’s type. Populate scalar fields according to policy, choose enum values from the enum’s declared values, and recurse into nested message fields. Use the runtime’s reflection operations for mutation; exact method names and constraints differ by language. In C++, a field descriptor passed to reflection must belong to the message’s type. C++ Message and Reflection API
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Handle repeated fields and maps with explicit size policies rather than assuming they should be empty or arbitrarily large. For each oneof group, select at most one member: Protobuf semantics allow only one field in a oneof to be set at a time. Protocol Buffers Overview
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
4. Apply value providers instead of pretending generic values are realistic
Define providers for values with application meaning—for example, identifiers, timestamps, URLs, or amounts that must correlate with other fields. Give generic fallback values an explicit synthetic label or policy so callers do not mistake them for valid business fixtures. A descriptor-driven fallback is a convenience, not a claim that the resulting message is realistic.
5. Bound recursion and collection sizes
Recursive message schemas and repeated fields can produce unbounded output unless your generator imposes limits. Set a maximum recursion depth, per-field repeated and map counts, and an overall message-size budget appropriate to the test environment. These are generator design choices, not universal Protobuf defaults; the right bounds depend on your application and workload.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
6. Validate generated messages
Check required-field initialization where it applies, serialize and parse round trips, and run application-level property checks for invariants your schema does not express. Use deterministic seeds when reproducible test failures matter, and include boundary cases deliberately rather than relying on random sampling to hit them.
Recommended Free Tools
Choose a generation policy that matches the test
| Need | Practical approach | What it does not guarantee |
|---|---|---|
| Message types known at compile time | Use generated message classes for straightforward, type-safe fixtures. | Generated classes do not supply business-realistic values automatically. |
| Message types selected at runtime | Load descriptors and use a dynamic message plus reflection. | Runtime traversal provides schema-aware construction, not domain semantics. |
| Repeatable unit-test inputs | Use deterministic seeds, fixed fixtures, or field-specific providers. | A seed alone does not enforce cross-field business rules. |
| Opaque data preservation | Copy and serialize message objects using binary/message-oriented operations. | Preserving unknown bytes does not make them understood or newly generated. |
Handle extensions and unknown fields deliberately
Extensions require definitions, not just declarations
Extensions are defined outside the containing message. An extension declaration advertises allocation metadata; it is not itself a full field descriptor returned by ordinary field lookup. To populate actual extension fields, load the extension definitions and use the runtime’s extension-aware lookup or registry support. Proto2 and editions support extensions; proto3 does not support message extensions other than custom options. Confirm the syntax and runtime behavior for the schema edition you use. Editions Language Guide Extension Declarations Proto2 Language Guide
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Unknown fields are not descriptor-known fields
A newly generated message has no descriptor basis for inventing unknown values. When parsing a message with fields unknown to the current schema, reflection’s ListFields does not include them. If you are copying a real message and must preserve opaque unknown fields, prefer binary message operations; JSON conversion or rebuilding field by field can lose information. Text-format data that gives an unknown field number without its schema type cannot reliably be reconstructed into wire format. C++ Message and Reflection API Proto2 Language Guide Text Format Language Specification
Quick Recap
Common implementation mistakes
- Assuming every runtime has the same dynamic APIs: the cited official APIs cover C++ and Java; check support and behavior for the language and runtime you deploy.
- Letting descriptor lifetimes end too soon in C++: keep descriptors alive longer than any
DynamicMessageFactorythat uses them. - Passing a field descriptor from another message type: reflection operations require the descriptor to belong to the message being accessed.
- Generating without resource bounds: recursive types and repeated data can inflate fixtures unexpectedly.
- Equating schema validity with business validity: a message may satisfy its Protobuf structure and still violate application invariants.
- Treating extension declarations as complete fields: load actual extension definitions if the generator must populate them.
- Using JSON or field-by-field copying when opaque unknown data matters: those paths may discard fields the current descriptor does not know.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




