Skip to content

Script file info cmdlets #602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 91 commits into from
Closed

Conversation

anamnavi
Copy link
Member

@anamnavi anamnavi commented Jan 31, 2022

PR Summary

PR Context

PR Checklist

@@ -386,18 +386,48 @@ .VERSION 1.0
return false;
}

keyName = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like both keyName and value are only used within the for loop below. So they can be defined there (in that scope) instead of here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, in the latest commit this is in a helper method GetMetadataFromCommentLines().

We need the keyName and value variables defined outside the for loop, as we're iterating through lines of the metadata string. When grabbing the key name and value, the value can continue onto the next line. So for certain metadata properties we may not get all the value on that line/within the current iteration of the for loop.


// get end of file contents
string[] totalFileContents = File.ReadAllLines(scriptFileInfoPath);
var contentAfterAndIncludingDescription = totalFileContents.SkipWhile(x => !x.Contains(".DESCRIPTION")).ToList();
var contentAfterDescription = contentAfterAndIncludingDescription.SkipWhile(x => !x.Contains("#>")).Skip(1).ToList();
endOfFileContents = String.Join("\n", contentAfterDescription.ToArray());
endOfFileContents = String.Join("\n", contentAfterAndIncludingDescription.SkipWhile(x => !x.Contains("#>")).Skip(1).ToArray());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this. It is not clear what this is doing and whether script content, that can also include comments, is always included in endOfFileContents. Instead of using LINQ I would prefer to see a utility method that is a bit more explicit about what it is doing.

@anamnavi
Copy link
Member Author

this PR willl be closed in favor of #708

@anamnavi anamnavi closed this Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants