tonybaloney / CSnakes

Embed Python in .NET
https://tonybaloney.github.io/CSnakes/
MIT License
343 stars 24 forks source link

Make generated code pretty to read (and write) #280

Closed atifaziz closed 1 month ago

atifaziz commented 1 month ago

This PR adds snapshot-based testing of the generated code and then goes to make the generated code (hopefully) a joy to read and write by formatting with conventional spacing and indentation. This helps with readability for users who may want to step into the code in the debugger and also allows changes to the generate code to be Git-tracked, fully tested and reviewable as part of future PRs. While the integration tests covered the runtime behaviour, this helps to ensure that accidental source changes don't slip by without notice.

The new tests exercise the generated code for all the Python files from the integration tests:

The snapshot testing is leveraged from Shouldly using its ShouldMatchApproved.

This will also eventually help with generating prettier code via a CLI (#192).