Fix settings file array parsing when no commas are present#1161
Merged
JamesWTruher merged 6 commits intoPowerShell:developmentfrom Mar 7, 2019
Merged
Fix settings file array parsing when no commas are present#1161JamesWTruher merged 6 commits intoPowerShell:developmentfrom
JamesWTruher merged 6 commits intoPowerShell:developmentfrom
Conversation
bergmeister
reviewed
Mar 1, 2019
JamesWTruher
reviewed
Mar 1, 2019
bergmeister
approved these changes
Mar 1, 2019
rjmholt
commented
Mar 1, 2019
| case "false": | ||
| return false; | ||
|
|
||
| case "null": |
Contributor
Author
There was a problem hiding this comment.
Noticed this was missing and quickly added it. Makes sense from a layering perspective -- null should be parse-able but might not be allowed as a configurable value.
Collaborator
There was a problem hiding this comment.
What about just simplifying the whole code to bool.tryparse ?
Contributor
Author
There was a problem hiding this comment.
If one of the possibilities is null, then it would probably look like:
string varName = varExprAst.VariablePath.UserPath.ToLower();
if (bool.TryParse(varName, out bool val))
{
return val;
}
if (varName == "null")
{
return null;
}
throw CreateInvalidDataExceptionFromAst(varExprAst);I'm not sure that's simpler though -- the switch/case has a nice flow to me, and ideally the C# compiler knows better than I do about how to make it work quickly. (Although it looks like that's not the case, since I would implement a trie for optimum speed).
JamesWTruher
approved these changes
Mar 7, 2019
bergmeister
pushed a commit
to bergmeister/PSScriptAnalyzer
that referenced
this pull request
Mar 22, 2019
…l#1161) * Fix settings file array parsing when no commas are present * Add extra test * Improve comment * Add test file * Change test to accept null * Fix new-item call in PS 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Fixes #1160.
The settings parsing logic didn't automatically capture arrays where elements are separated by newline.
I've fix that in the parser and added some tests to make sure it stays fixed.
PR Checklist
.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.