Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit c897021

Browse files
committed
CA-267461: Fix powershell bindings generator for some constructors
The problem was in New-XenClusterHost.cs, we had the following code generated: ``` [Parameter(ParameterSetName = "Fields")] public XenRef<XenAPI.Cluster> Cluster { get; set; } [Parameter(ParameterSetName = "Fields")] public XenRef<XenAPI.Host> XenHost { get; set; } ... if (Record != null) { Cluster = Record.cluster; Host = Record.host; } ``` where Cluster was being set correctly, but it was trying to assign to Host rather than XenHost. The Hashtbl implementation slightly further on was correct: ``` Cluster = Marshalling.ParseRef<Cluster>(HashTable, "cluster"); XenHost = Marshalling.ParseRef<Host>(HashTable, "host"); ``` The fix it to use the code used in the Hashtbl part, which is a call to `ocaml_class_to_csharp_property x` rather than `exposed_class_name (pascal_case x)`. Turns out the implementation of `ocaml_class_to_csharp_property` is: ```ocaml let ocaml_class_to_csharp_property classname = if (classname = "host") then "XenHost" else (exposed_class_name (pascal_case classname)) ``` Signed-off-by: Jon Ludlam <[email protected]>
1 parent 7f234a9 commit c897021

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

powershell/gen_powershell_binding.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -599,13 +599,13 @@ and explode_record_fields message fields =
599599
let print_map tl hd =
600600
sprintf "
601601
%s = CommonCmdletFunctions.ConvertDictionaryToHashtable(Record.%s);%s"
602-
(exposed_class_name (pascal_case (full_name hd)))
602+
(ocaml_class_to_csharp_property (full_name hd))
603603
(full_name hd)
604604
(explode_record_fields message tl) in
605605
let print_record tl hd =
606606
sprintf "
607607
%s = Record.%s;%s"
608-
(exposed_class_name (pascal_case (full_name hd)))
608+
(ocaml_class_to_csharp_property (full_name hd))
609609
(full_name hd)
610610
(explode_record_fields message tl) in
611611
match fields with

0 commit comments

Comments
 (0)