Skip to content

Commit 0af2b37

Browse files
CP-309867: Render the PowerShell cmdlet files from mustache templates (xapi-project#7313)
The PowerShell generator builds each cmdlet's C# file with sprintf, with the fixed parts of the file mixed in among the code that works out the variable parts. That makes it hard to see what a generated cmdlet looks like, and hard to change it. It's also the only SDK generator here with no tests. This PR moves those fixed parts into mustache templates. The psd1, destructor, HTTP action and ConvertTo-XenRef files already work this way. It also adds golden-file tests for the new templates. It's a refactor: the generated SDK doesn't change. A full generator run from this branch is byte-identical to one from master: 413 files, including all 402 cmdlet .cs files. Testing - The generated SDK is byte-identical to master's, checked by diffing a full generator run from each. - dune build @fmt, the sdk-gen build, dune test ocaml/sdk-gen/powershell (7 tests) and ./quality-gate.sh pass on both commits.
2 parents b132418 + 06b494b commit 0af2b37

13 files changed

Lines changed: 1189 additions & 459 deletions

‎ocaml/sdk-gen/powershell/dune‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
(executable
22
(modes exe)
33
(name gen_powershell_binding)
4+
(modules gen_powershell_binding common_functions)
45
(libraries astring CommonFunctions mustache xapi-datamodel))
56

7+
(test
8+
(name test_gen_powershell)
9+
(package xapi-sdk)
10+
(modules test_gen_powershell)
11+
(libraries CommonFunctions alcotest fmt mustache xapi-test-utils)
12+
(deps
13+
(source_tree test_data)
14+
(source_tree templates)))
15+
616
(rule
717
(alias generate)
818
(targets
@@ -20,7 +30,7 @@
2030
(bash "rm autogen-out/.gitignore")
2131
(bash "%{sh} autogen-out/"))))
2232

23-
(data_only_dirs templates)
33+
(data_only_dirs test_data templates)
2434

2535
(install
2636
(package xapi-sdk)

0 commit comments

Comments
 (0)