TGViewer
Telegram github commits and releases Telegram github commits and releases @tgappsupdates · 4.54K subscribers
Post #20689 38
UnigramDev/Unigram/develop • a234a07 • 5 files, +1124/-967
Rewrite the API generator that was only ever meant to be a spike

Same output, byte for byte: the generated TdDotNetApi.g.cs is identical before
and after, which is the only check available given the app itself cannot be
built here. Every emitter string literal was moved rather than retyped.

Split into the parts that were tangled together - SchemaGenerator drives, Schema/
parses td_api.tl, Emit/ writes the C#, Crc32 is the hash the generated switches
key on and must stay in step with ClientJson's copy.

The robustness this was missing:

- A malformed scheme threw, and the catch-all returned the exception text as
the generated source. One bad line became thousands of "type or namespace
not found" errors with no hint of the cause. Errors are now Diagnostics
(TDAPI001/TDAPI002) carrying the line number, and the rest of the file still
generates - a dropped //@field now reports "'localFile' has no
//@download_offset for its 'download_offset' field" and costs one class.
- The reader indexed past the last line unless the file ended blank, and its
constructor scanned for a comment that a malformed file need not contain.
- A doc line with a bare @key threw on the missing value.
- Name conversion built strings with += per character, and reachability used
List.Contains over ~3000 types.

Dropped along the way: a variable that was always empty and the dead branch it
guarded, an unreachable disjunct in the UpdateFile/File test, and a duplicated
abstract-type index built twice per run.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

UnigramDev/Unigram/develop • 3b0a179 • 5 files, +92/-50
Scan to the terminator instead of bounds-checking every byte

td_receive returns a NUL-terminated buffer, and JSON has to escape a raw NUL, so
the terminator is an unambiguous end marker. TdJsonReader's scan loops now test
only for content and stop at it, with _index <= _length checked once per token
rather than once per byte. Reading past the buffer becomes impossible rather than
merely checked for.

4.1x against Utf8JsonReader on .NET Native, up from 3.7x. It does not recover the
43% the hardening cost on the desktop JIT, and the reason for that is still
unknown - two hypotheses measured and refuted, written up in the README. The
shipping toolchain is unaffected, so it is parked.

Fixtures.Load appends a terminator and GuardedBuffer.Place writes one inside the
committed region, keeping the guard page immediately after it. Verified the sweep
still has teeth: dropping the NUL test from ReadNumber access-violates over all
70,512 truncations.

Also records why generating FromJson only for received types had to be removed:
"received" is not the same as "reachable from a function return type", updates
only qualify because the scheme declares testUseUpdate, and richMessageSourceBlocks
qualifies not at all and is patched in by hand.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

UnigramDev/Unigram/develop • 9293493 • 1 files, +7/-0
List spacing

UnigramDev/Unigram/develop • 6ef3146 • 1 files, +1/-1
Click events

#unigram
More from @tgappsupdates
  1. Oct 12, 2026TGX-Android/Telegram-X/main • 012c76b • 2 files, +3/-3 Always use `c++_shared` now TGX-And…
  2. Oct 11, 2026morethanwords/tweb/master • 94bbdf4 • 2 files, +98/-2 Folder tags: leave the rows without…
  3. Oct 11, 2026UnigramDev/Unigram/accessibility-keyboard • 7db678f • 3 files, +76/-1 Wire the call microp…
  4. Oct 11, 2026UnigramDev/Unigram/accessibility-keyboard • 202b2ad • 3 files, +76/-1 Wire the call microp…
  5. Oct 11, 2026UnigramDev/Unigram/accessibility-keyboard • a995f8e • 1 files, +80/-0 Add keyboard actions…
  6. Oct 11, 2026UnigramDev/Unigram/develop • 04a9e11 • 1 files, +23/-5 Try to preserve managed exception U…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →