grpc-swift
grpc-swift copied to clipboard
Pay back some technical debt on the codegen
Is your feature request related to a problem? Please describe it.
Users have hit a number of bugs caused by the codegen.
We inherited the codegen from the old version but never considered whether doing so was the right thing to do.
When writing the codegen it's really easy to miss something and it's severely under-tested. Our tests are limited to generating code in certain scenarios and diffing with expected output. This has to be done as integration tests which also requires us to regenerate the expected output if some formatting changes, for example.
Describe the solution you'd like
It would be great if we could split the codegen into at least two parts: generating the structure of the code the be emitted and then formatting the code to be emitted. Generating the structure could allow us to unit test the code gen in a much more granular way.
This definitely requires some investigation though, the effort required to do this simply might not outweigh the cost and would need exploring first.
Describe alternatives you've considered
Tidying up the existing codegen would be a good start: recently we added withIndentation which allows indentation to be managed properly, additional functions like this could improve the legibility a lot.
We could improve the integration tests such that we have a single project containing a number of modules which relate to different scenarios. This would at least ensure that the code always compiles.
Additional context
None.