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

Conversation

kc284
Copy link

@kc284 kc284 commented Jan 3, 2018

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.

Copy link
Contributor

@lindig lindig left a 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.

] in

let filtered = List.filter (fun x -> x.content <> "") cmdlets in
List.map (fun x-> write_file x.filename x.content; x.filename) filtered;
Copy link
Contributor

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)

Copy link
Author

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).

Copy link
Contributor

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.

Copy link
Author

@kc284 kc284 Jan 5, 2018

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.

@kc284 kc284 force-pushed the msbuild branch 3 times, most recently from 1365297 to 48a7257 Compare January 9, 2018 11:19
Konstantina Chremmou added 5 commits January 11, 2018 13:28
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>
@lindig
Copy link
Contributor

lindig commented Jan 11, 2018

Feel free to merge this.

@MihaelaStoica MihaelaStoica merged commit 49e9dcd into xapi-project:master Jan 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants