refactor: extract shared codegen helpers into internal/genhelper and dedup cpp/csharp/go loaders#167
Merged
Merged
Conversation
…dedup cpp/csharp/go loaders - add internal/genhelper with shared file-header (ProtocVersion/header) and map-key (MapKey/MapKeySlice) helpers - replace per-loader duplicated helper code in cpp/csharp/go by reusing the shared genhelper package - internal/options: extract GetWorksheetOptions/IsWorksheet shared helpers - csharp: drop unused gen/messagerName params from genMessage/genMapGetters/generateFileContent - remove obsolete cmd/protoc-gen-go-tableau-loader/helper.go - test(csharp): align shared fixtures (HubFixture/LoadTests)
wenchy
requested changes
Jun 16, 2026
| Fd protoreflect.FieldDescriptor // the map field descriptor this key belongs to | ||
| } | ||
| // MapKey aliases the cross-language shared key descriptor; see genhelper.MapKey. | ||
| type MapKey = genhelper.MapKey |
Member
There was a problem hiding this comment.
struct embeding is more appropriate (auto reuse methods).
Collaborator
Author
There was a problem hiding this comment.
MapKey has no method.
…oss loaders Define a single generic genhelper.MapKeySlice[F ParamFormatter] carrying all shared methods (AddMapKey/GenGetParams/GenGetArguments/GenCustom/ GenOtherArguments) as members. Each loader only provides a zero-size ParamFormatter and aliases the slice, removing duplicated per-language definitions of MapKeySlice and its methods across the cpp/csharp/go loaders.
wenchy
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Each
protoc-gen-*-tableau-loaderplugin previously carried its own near-identicalcopies of the generated-file header logic and the map-key handling logic. This PR
consolidates those into a new cross-language package,
internal/genhelper, andrewires the C++ / C# / Go loaders to reuse it, removing a large amount of
duplicated code.
Net change: +234 / −365 across 15 files (≈130 lines of duplication removed).
Changes
New shared package:
internal/genhelperheader.go—ProtocVersion()(extracts the protoc compiler version fromthe codegen request) and
GenerateSourcePath()(writes the// source:/deprecation comment).
mapkey.go— sharedMapKey/MapKeySliceandAddMapKey()withcross-level name/field-name deduplication. Go / C++ / C# alias it directly
(
type MapKey = genhelper.MapKey); the TS loader embeds it to addlanguage-specific fields, so every loader shares the same base.
Loader dedup
with the shared
genhelperpackage (helper/helper.goslimmed down in all three).gen/messagerNameparams fromgenMessage/genMapGetters/generateFileContent(pure pass-through,never used in the C# code path).
cmd/protoc-gen-go-tableau-loader/helper.go.Shared internal helpers
internal/options: extractedGetWorksheetOptions()/IsWorksheet()andreused them across
NeedGenOrderedMap/NeedGenIndex/NeedGenOrderedIndex/NeedGenFile; added theLangTSconstant.internal/indexandinternal/xproto.Tests
HubFixture/LoadTests) with therefactored helpers.
Notes
refactor with no behavioral changes.
ts-loaderbranch and reuses the same
internal/genhelper. This branch is intentionallyscoped to the non-TS (cpp/csharp/go + shared internal) changes so it can be
reviewed and merged independently.
Verification
go build ./...✅go vet ./cmd/... ./internal/...✅ (no warnings)