microsoft / microsoft/yardl

Embedded schema does not distinguish flags from enums

Open
#296 0 comments 0 reactions 1 assignee View on GitHub

@naegelejd is already working on this.

Since Jul 1, 2026.

Dominant language
C++
Stars
35
Forks
14
Avg merge
5d 17h
Merged PRs (30d)
1

Description

Problem

The schema string that Yardl embeds in every binary/NDJSON file does not record whether an enum-like type is a !flags type. As a result, a !flags definition and an !enum definition are byte-for-byte identical in the embedded schema. Any consumer that works purely from the embedded schema (e.g. a dynamic/schema-only reader, or a third-party tool) cannot reproduce Yardl's own flags semantics, and cannot even reproduce Yardl's own NDJSON output for affected protocols.

Concrete differences between Yardl's SDK output and a schema-only reader on the models/test/unittests.yml protocols:

Protocol Yardl SDK Schema-only reader
FlagsMONDAY+WEDNESDAY+FRIDAY ["monday","wednesday","friday"] 21
FlagsSUNDAY ["sunday"]` "sunday"
EnumsRecordWithEnums.flags [] 0
Unions[null, Fruits, DaysOfWeek] holding Fruits.APPLE "apple" (simple) {"T1":"apple"} (tagged)

These are the only fidelity differences observed across all 29 protocols in unittests.yml; everything else round-trips byte-for-byte. (Discovered while prototyping a dynamic, schema-only binary reader.)

Proposed fix

Emit the flags marker in the protocol schema. Simplest is to give EnumDefinition a custom MarshalJSON (or add an isFlags field) so the embedded types[] carries it — mirroring the existing enum/flags distinction in TypeDefinitions.MarshalJSON.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.