Make sure that SettingFile arg is parsed before we load the settings#7449
Make sure that SettingFile arg is parsed before we load the settings#7449TravisEz13 merged 26 commits intoPowerShell:masterfrom
Conversation
… build environment.
aca4308 to
5979c49
Compare
f98c185 to
ebf9239
Compare
ebf9239 to
5c48dbc
Compare
There was a problem hiding this comment.
We could combine three if in one or use ? operator in just single return.
There was a problem hiding this comment.
Maybe use TryParseSettingFileHelper?
There was a problem hiding this comment.
We could exclude if-s and use single return.
There was a problem hiding this comment.
sorry, I don't follow what you are saying.
Well, looking at the code, I made a guess.
There was a problem hiding this comment.
I meant
return (match.Trim().ToLowerInvariant().IndexOf(switchKey, StringComparison.Ordinal) == 0) && (switchKey.Length >= smallestUnambiguousMatch.Length)
| { | ||
| // We need to read the settings file before we create the console host | ||
| string[] tempArgs = new string[args.GetLength(0)]; | ||
| args.CopyTo(tempArgs, 0); |
There was a problem hiding this comment.
Could you please clarify why we need clone args?
There was a problem hiding this comment.
The existing code cloned the args. I don't want to break something by not cloning.
There was a problem hiding this comment.
Reviewing the code. I don't think it has to be. I especially don't think it has to be twice. compromise, I'll remove the second clone, you file an issue to remove the first one.
| } | ||
|
|
||
| #region Internal properties | ||
| internal bool AbortStartup |
There was a problem hiding this comment.
Should #region be in position with the line?
f48196f to
ed941fa
Compare
|
@iSazonov I believe I have addressed all your comments one way or another. |
| /// The command line parameters to be processed. | ||
| /// </param> | ||
| /// <param name="argIndex"> | ||
| /// The index in args to the argument following '-SettingFile'. |
There was a problem hiding this comment.
The parameter name is generic but comment says that it is used only for '-SettingFile' - should the parameter name reflects the fact?
| var consoleSessionSetting = Utils.GetPolicySetting<ConsoleSessionConfiguration>(Utils.CurrentUserThenSystemWideConfig); | ||
|
|
||
| return (consoleSessionSetting?.EnableConsoleSessionConfiguration == true && !string.IsNullOrEmpty(consoleSessionSetting?.ConsoleSessionConfigurationName)) ? | ||
| consoleSessionSetting.ConsoleSessionConfigurationName : string.Empty; |
There was a problem hiding this comment.
Maybe use more short name like settings to get more short code strings.
There was a problem hiding this comment.
this is an existing variable name. Please file an issues
There was a problem hiding this comment.
It is not clear that we get from the method. I'd replace var with explicit type.
Can we use:
(string switchKey, bool shouldBreak) = GetSwitchKey(args, ref i, null, ref noexitSeen); Named argument for null will be good.
There was a problem hiding this comment.
Named arguments will be good for constants. Below I see some such patterns.
| path = path.Replace(StringLiterals.AlternatePathSeparator, | ||
| StringLiterals.DefaultPathSeparator); | ||
|
|
||
| return Path.GetFullPath(path); |
There was a problem hiding this comment.
The method is used once and then we call File.Exist() where Path.GetFullPath() is called again.
https://source.dot.net/#System.IO.FileSystem/System/IO/File.cs,119
We could simplify the TryParseSettingFileHelper() method - remove try-catch there (line 429), move the line 574 to TryParseSettingFileHelper() before File.Exist()
There was a problem hiding this comment.
existing code, please file an issue, the method was just changed from an instance to static
There was a problem hiding this comment.
Please revert -after to -After.
| { | ||
| configFile = NormalizeFilePath(args[argIndex]); | ||
| } | ||
| catch (Exception ex) |
There was a problem hiding this comment.
I believe we could remove the try-catch. See my comment for NormalizeFilePath() method.
dantraMSFT
left a comment
There was a problem hiding this comment.
None of my comments are blocking but recommend you reconsider adding release logic for the new Dbg.Assert calls.
|
|
||
|
|
||
| class PSLogItem | ||
| { |
There was a problem hiding this comment.
I suggest updating the comment block at the top of the file to call out the change in format.
Other than that, this file LGTM
| env: TRAVIS_CI_CACHE_NAME=linux | ||
| - os: osx | ||
| osx_image: xcode8.1 | ||
| osx_image: xcode9.4 |
There was a problem hiding this comment.
I assume this means we won't be running tests against the prior OS version, right?
There was a problem hiding this comment.
I found no differences in the log format, but yes correct
There was a problem hiding this comment.
The assert message is misleading. The method can only be called once since _dirtyEarlyParse is a static field.
Additionally, back this up with a release test or simply return if true. We don't run debug tests enough to catch this problem.
There was a problem hiding this comment.
removed, I verified this can be run multiple times
There was a problem hiding this comment.
Back this up with a check in release mode. At a minimum, silently ignore and return.
There was a problem hiding this comment.
The comment about writing errors doesn't appear to apply.
There was a problem hiding this comment.
Updated comment (I have not pushed at this point.)
| string[] tempArgs = new string[args.GetLength(0)]; | ||
| args.CopyTo(tempArgs, 0); | ||
|
|
||
| CommandLineParameterParser.EarlyParse(tempArgs); |
There was a problem hiding this comment.
I've created issue #7460 to move this call to UnmanagedPSEntry.Start prior to PSEtwLog.LogConsoleStartup().
| Export-PSOsLog -After $after -Verbose | Set-Content -Path $contentFile | ||
| $items = Get-PSOsLog -Path $contentFile -Id $logId -After $after -TotalCount 3 -Verbose | ||
| # Made tests more reliable | ||
| Start-Sleep -Milliseconds 500 |
There was a problem hiding this comment.
I've created issue #7462 to address the Start-Sleep workaround as well as the possible false-positive in filtering test below.
There was a problem hiding this comment.
I'm pretty sure tuple field names are case sensitive.
2906b02 to
b8dcdfe
Compare
f1aec6f to
00c2a10
Compare
PR Summary
Make sure that SettingFile arg is parsed before we load the settings
Also, fix the following Travis-ci issues:
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests