8000 Minor code clean-up changes (#5737) · PowerShell/PowerShell@ac53dff · GitHub
[go: up one dir, main page]

Skip to content

Commit ac53dff

Browse files
kwkamdaxian-dbw
authored andcommitted
Minor code clean-up changes (#5737)
1 parent 982dbfe commit ac53dff

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed

src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4257,7 +4257,7 @@ internal static IEnumerable<CompletionResult> CompleteFilename(CompletionContext
42574257
{
42584258
var sessionStateInternal = executionContext.EngineSessionState;
42594259
completionText = sessionStateInternal.NormalizeRelativePath(path, sessionStateInternal.CurrentLocation.ProviderPath);
4260-
string parentDirectory = ".." + Path.DirectorySeparatorChar;
4260+
string parentDirectory = ".." + StringLiterals.DefaultPathSeparator;
42614261
if (!completionText.StartsWith(parentDirectory, StringComparison.Ordinal))
42624262
completionText = Path.Combine(".", completionText);
42634263
}
@@ -4472,13 +4472,9 @@ internal static List<CompletionResult> CompleteVariable(CompletionContext contex
44724472
var wordToComplete = context.WordToComplete;
44734473
var colon = wordToComplete.IndexOf(':');
44744474

4475-
var prefix = "$";
44764475
var lastAst = context.RelatedAsts.Last();
44774476
var variableAst = lastAst as VariableExpressionAst;
4478-
if (variableAst != null && variableAst.Splatted)
4479-
{
4480-
prefix = "@";
4481-
}
4477+
var prefix = variableAst != null && variableAst.Splatted ? "@" : "$";
44824478

44834479
// Look for variables in the input (e.g. parameters, etc.) before checking session state - these
44844480
// variables might not exist in session state yet.
@@ -5923,7 +5919,7 @@ private static string GetNamespaceToRemove(CompletionContext context, TypeComple
59235919
internal static List<CompletionResult> CompleteHelpTopics(CompletionContext context)
59245920
{
59255921
var results = new List<CompletionResult>();
5926-
var dirPath = Utils.GetApplicationBase(Utils.DefaultPowerShellShellID) + Path.DirectorySeparatorChar + CultureInfo.CurrentCulture.Name;
5922+
var dirPath = Utils.GetApplicationBase(Utils.DefaultPowerShellShellID) + StringLiterals.DefaultPathSeparator + CultureInfo.CurrentCulture.Name;
59275923
var wordToComplete = context.WordToComplete + "*";
59285924
var topicPattern = WildcardPattern.Get("about_*.help.txt", WildcardOptions.IgnoreCase);
59295925
List<string> files = new List<string>();

src/System.Management.Automation/engine/parser/TypeInferenceVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ internal class TypeInferenceVisitor : ICustomAstVisitor2
423423
{
424424
private readonly TypeInferenceContext _context;
425425

426-
private static readonly PSTypeName StringPSTypeName = new PSTypeName(typeof(string));
426+
private static readonly PSTypeName StringPSTypeName = new PSTypeName(typeof(string));
427427

428428
public TypeInferenceVisitor(TypeInferenceContext context)
429429
{

src/System.Management.Automation/help/HelpCommentsParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ internal XmlDocument BuildXmlFromComments()
353353
// The title is automatically generated
354354
XmlElement title = _doc.CreateElement("maml:title", mamlURI);
355355
string titleStr = string.Format(CultureInfo.InvariantCulture,
356-
" -------------------------- {0} {1} --------------------------",
356+
"\t\t\t\t-------------------------- {0} {1} --------------------------",
357357
HelpDisplayStrings.ExampleUpperCase, count++);
358358
XmlText title_text = _doc.CreateTextNode(titleStr);
359359
example_node.AppendChild(title).AppendChild(title_text);

src/System.Management.Automation/namespaces/FileSystemProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4981,13 +4981,13 @@ protected override string NormalizeRelativePath(
49814981
try
49824982
{
49834983
string originalPathComparison = path;
4984-
if (!originalPathComparison.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase))
4984+
if (!originalPathComparison.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase))
49854985
{
49864986
originalPathComparison += StringLiterals.DefaultPathSeparator;
49874987
}
49884988

49894989
string basePathComparison = basePath;
4990-
if (!basePathComparison.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase))
4990+
if (!basePathComparison.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase))
49914991
{
49924992
basePathComparison += StringLiterals.DefaultPathSeparator;
49934993
}
@@ -5190,7 +5190,7 @@ private string NormalizeRelativePathHelper(string path, string basePath)
51905190
// See if the base and the path are already the same. We resolve this to
51915191
// ..\Leaf, since resolving "." to "." doesn't offer much information.
51925192
if (String.Equals(path, basePath, StringComparison.OrdinalIgnoreCase) &&
5193-
(!originalPath.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase)))
5193+
(!originalPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
51945194
{
51955195
string childName = GetChildName(path);
51965196
result = MakePath("..", childName);
@@ -5237,7 +5237,7 @@ private string NormalizeRelativePathHelper(string path, string basePath)
52375237
if (!String.IsNullOrEmpty(commonBase))
52385238
{
52395239
if (String.Equals(path, commonBase, StringComparison.OrdinalIgnoreCase) &&
5240-
(!path.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase)))
5240+
(!path.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
52415241
{
52425242
string childName = GetChildName(path);
52435243
result = MakePath("..", result);

src/System.Management.Automation/namespaces/NavigationProviderBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ internal string ContractRelativePath(
663663
// See if the base and the path are already the same. We resolve this to
664664
// ..\Leaf, since resolving "." to "." doesn't offer much information.
665665
if (String.Equals(normalizedPath, normalizedBasePath, StringComparison.OrdinalIgnoreCase) &&
666-
(!originalPath.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase)))
666+
(!originalPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
667667
{
668668
string childName = GetChildName(path);
669669
result = MakePath("..", childName);
@@ -703,7 +703,7 @@ internal string ContractRelativePath(
703703
if (!String.IsNullOrEmpty(commonBase))
704704
{
705705
if (String.Equals(normalizedPath, commonBase, StringComparison.OrdinalIgnoreCase) &&
706-
(!normalizedPath.EndsWith("" + StringLiterals.DefaultPathSeparator, StringComparison.OrdinalIgnoreCase)))
706+
(!normalizedPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
707707
{
708708
string childName = GetChildName(path);
709709
result = MakePath("..", result);

0 commit comments

Comments
 (0)
0