-
Notifications
You must be signed in to change notification settings - Fork 51
XenServer.NET and PS module project file updates. #131
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Just a minor comment.
powershell/gen_powershell_binding.ml
Outdated
] in | ||
|
||
let filtered = List.filter (fun x -> x.content <> "") cmdlets in | ||
List.map (fun x-> write_file x.filename x.content; x.filename) filtered; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better name would be non_empty
or similar. I would also consider doing filter and map-ing in one go:
cmdlets
|> List.filter (fun x -> x.content <> "")
|> List.map ...
Is it correct that List.map
has a side effect (writing a file) and returns values? Otherwise List.iter
would be better. I would also consider creating a function to handle writing to a file.
let with_output filename f =
let io = open_out filename in
finally
(fun () -> f io)
(fun () -> close_out io)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does look weird; I've used List.map because I needed somehow to collect the file names together in order to populate the project file in lines 105-114. I'm happy to change it if a cleaner way to achieve this can be suggested.
write_file is defined in line 341 - do you mean creating one function in the common folder of this repo? (Indeed each generator file in this repo defines its own).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like a function like with_output
because opening, closing, and exception handling are in one place.
I don't think it matters much but I would try to compute content and filenames first such that I would not have to rely on the function emitting the content to return the name if you need it. It's not worth spending too much energy on this. The code is clear in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think it looks better now.
I've only corrected this one instance of write_file
to use with_output
; I'll do the other instances in this repo in a different PR, because I would like to avoid conflicts in view of the upcoming merge of the json
branch into master
.
1365297
to
48a7257
Compare
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
…ode. Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
…ule with MSBuild. The advantage of this is that it makes debugging of the PowerShell source code, which is written in C#, much easier because it provides a ready project with all the source files included and a set-up debug configuration. Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
Feel free to merge this. |
The most important change in this PR is that a project file template was added to facilitate building the PowerShell module with MSBuild. The advantage of this is that it makes debugging of the PowerShell source code, which is written in C#, much easier because it provides a ready project with all the source files included and a set-up debug configuration.