Skip to content

feat: add C# and Python generators and extend TS client generation#126

Closed
elzalem wants to merge 2 commits intomainfrom
feature/csharp-python-generators
Closed

feat: add C# and Python generators and extend TS client generation#126
elzalem wants to merge 2 commits intomainfrom
feature/csharp-python-generators

Conversation

@elzalem
Copy link
Collaborator

@elzalem elzalem commented Mar 2, 2026

Summary

This PR adds two new Sebuf generators and extends the TypeScript client generator for a few missing contract shapes.

Changes included here:

  • add protoc-gen-csharp-http
  • add protoc-gen-py-client
  • add a shared internal contract model used by the new generators
  • extend protoc-gen-ts-client to support message-only proto files
  • add field_names=json|proto support for TS client output
  • fix TS client generation for empty request messages

Why

Sebuf already supports Go and TypeScript generation, but it was missing generator coverage for C# and Python clients.

While integrating Sebuf into a downstream project, a few TS generator gaps also surfaced:

  • some proto packages only define messages and still need generated client-side model output
  • some consumers need proto field names rather than JSON/camel names
  • empty request RPCs could produce awkward or invalid generated code paths

These changes make Sebuf usable across more client stacks without relying on repo-local custom generators.

What Changed

New generators

  • cmd/protoc-gen-csharp-http
  • cmd/protoc-gen-py-client

These generators emit contract/model code from the same proto inputs Sebuf already handles for other languages.

Shared contract traversal

  • internal/contractmodel

This consolidates message/enum/service traversal logic so the new generators do not duplicate structure walking.

TypeScript generator improvements

  • message-only proto support
  • field_names=json|proto option
  • empty-request handling fix

These changes are covered by updated golden tests.

Tests

Added or updated tests for:

  • C# generator golden output
  • Python generator golden output
  • TS generator golden output for message-only protos
  • TS generator output for proto field naming
  • existing TS generator paths affected by empty request handling

@elzalem elzalem requested a review from SebastienMelki March 2, 2026 13:29
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

🔍 CI Pipeline Status

Lint: success
Test: success
Coverage: success
Build: success
Integration: success


📊 Coverage Report: Available in checks above
🔗 Artifacts: Test results and coverage reports uploaded

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 0% with 265 lines in your changes missing coverage. Please review.
✅ Project coverage is 2.99%. Comparing base (917521f) to head (dca9c89).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/pyclientgen/generator.go 0.00% 106 Missing ⚠️
internal/csharpgen/generator.go 0.00% 103 Missing ⚠️
internal/tscommon/types.go 0.00% 28 Missing ⚠️
internal/tsclientgen/generator.go 0.00% 19 Missing ⚠️
internal/tsclientgen/types.go 0.00% 8 Missing ⚠️
internal/tsservergen/generator.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main    #126      +/-   ##
========================================
- Coverage   3.17%   2.99%   -0.19%     
========================================
  Files         47      49       +2     
  Lines       7485    7941     +456     
========================================
  Hits         238     238              
- Misses      7243    7699     +456     
  Partials       4       4              
Flag Coverage Δ
unittests 2.99% <0.00%> (-0.19%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant