Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ private string BuildStructuredQueryFromHashTable(EventLogSession eventLogSession
string query = queriedLogsQueryMap[keyLogName];
result.Append(query);

if (query.EndsWith("*", StringComparison.OrdinalIgnoreCase))
if (query.EndsWith('*'))
{
//
// No provider predicate: just add the XPath string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private string GetDrivePath(string driveName)
{
drivePath = driveName;
}
else if (driveName.EndsWith(":", StringComparison.OrdinalIgnoreCase))
else if (driveName.EndsWith(':'))
{
drivePath = driveName + "\\";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@ internal static bool ContainsSystemDrive(string[] drives, string sysdrive)
string driveApp;
foreach (string drive in drives)
{
if (!drive.EndsWith("\\", StringComparison.OrdinalIgnoreCase))
if (!drive.EndsWith('\\'))
{
driveApp = string.Concat(drive, "\\");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected override void ProcessRecord()
// Do not insert './' if result path is not relative
if (!adjustedPath.StartsWith(
currentPath.Drive?.Root ?? currentPath.Path, StringComparison.OrdinalIgnoreCase) &&
!adjustedPath.StartsWith(".", StringComparison.OrdinalIgnoreCase))
!adjustedPath.StartsWith('.'))
{
adjustedPath = SessionState.Path.Combine(".", adjustedPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ internal void ReadHeader()
values[0] = values[0].Substring(9);
Header = values;
}
else if (values.Count != 0 && values[0].StartsWith("#"))
else if (values.Count != 0 && values[0].StartsWith('#'))
{
// Skip all lines starting with '#'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ bool TryGetBoolValue(string arg, out bool boolValue)

if (!System.IO.File.Exists(_file))
{
if (args[i].StartsWith("-") && args[i].Length > 1)
if (args[i].StartsWith('-') && args[i].Length > 1)
{
string param = args[i].Substring(1, args[i].Length - 1).ToLower();
StringBuilder possibleParameters = new StringBuilder();
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Microsoft.WSMan.Management/ConfigProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2969,7 +2969,7 @@ private string GetFilterString(Hashtable cmdlinevalues, string[] pkey)
}
}

if (filter.ToString().EndsWith("+", StringComparison.OrdinalIgnoreCase))
if (filter.ToString().EndsWith('+'))
filter.Remove(filter.ToString().Length - 1, 1);
return filter.ToString();
}
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Microsoft.WSMan.Management/WsManHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ internal string GetURIWithFilter(string uri, string filter, Hashtable selectorse
if (operation.Equals("remove", StringComparison.OrdinalIgnoreCase))
{
sburi.Append(GetFilterString(selectorset));
if (sburi.ToString().EndsWith("?", StringComparison.OrdinalIgnoreCase))
if (sburi.ToString().EndsWith('?'))
{
sburi.Remove(sburi.Length - 1, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ internal static List<CompletionResult> PSv2GenerateMatchSetOfFiles(PowerShellExe

lastWord = lastWord ?? string.Empty;
bool isLastWordEmpty = string.IsNullOrEmpty(lastWord);
bool lastCharIsStar = !isLastWordEmpty && lastWord.EndsWith("*", StringComparison.Ordinal);
bool lastCharIsStar = !isLastWordEmpty && lastWord.EndsWith('*');
bool containsGlobChars = WildcardPattern.ContainsWildcardCharacters(lastWord);

string wildWord = lastWord + "*";
Expand Down Expand Up @@ -1045,9 +1045,9 @@ private static bool PSv2ShouldFullyQualifyPathsPath(PowerShellExecutionHelper he
{
// These are special cases, as they represent cases where the user expects to
// see the full path.
if (lastWord.StartsWith("~", StringComparison.OrdinalIgnoreCase) ||
lastWord.StartsWith("\\", StringComparison.OrdinalIgnoreCase) ||
lastWord.StartsWith("/", StringComparison.OrdinalIgnoreCase))
if (lastWord.StartsWith('~') ||
lastWord.StartsWith('\\') ||
lastWord.StartsWith('/'))
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ internal List<CompletionResult> GetResultHelper(CompletionContext completionCont
}

// Handle scenarios like this: dir -path:<tab>
if (completionContext.WordToComplete.EndsWith(":", StringComparison.Ordinal))
if (completionContext.WordToComplete.EndsWith(':'))
{
replacementIndex = tokenAtCursor.Extent.EndScriptPosition.Offset;
replacementLength = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ internal static List<CompletionResult> CompleteModuleName(CompletionContext cont
var result = new List<CompletionResult>();
var quote = HandleDoubleAndSingleQuote(ref moduleName);

if (!moduleName.EndsWith("*", StringComparison.Ordinal))
if (!moduleName.EndsWith('*'))
{
moduleName += "*";
}
Expand Down Expand Up @@ -507,7 +507,7 @@ internal static List<CompletionResult> CompleteCommandParameter(CompletionContex
// If parent is DynamicKeywordStatementAst - 'Import-DscResource',
// then customize the auto completion results
if (keywordAst != null && string.Equals(keywordAst.Keyword.Keyword, "Import-DscResource", StringComparison.OrdinalIgnoreCase)
&& !string.IsNullOrWhiteSpace(context.WordToComplete) && context.WordToComplete.StartsWith("-", StringComparison.OrdinalIgnoreCase))
&& !string.IsNullOrWhiteSpace(context.WordToComplete) && context.WordToComplete.StartsWith('-'))
{
var lastAst = context.RelatedAsts.Last();
var wordToMatch = context.WordToComplete.Substring(1) + "*";
Expand Down Expand Up @@ -536,7 +536,7 @@ internal static List<CompletionResult> CompleteCommandParameter(CompletionContex
// Parent must be a command
commandAst = (CommandAst)parameterAst.Parent;
partialName = parameterAst.ParameterName;
withColon = context.WordToComplete.EndsWith(":", StringComparison.Ordinal);
withColon = context.WordToComplete.EndsWith(':');
}
else
{
Expand Down Expand Up @@ -807,7 +807,7 @@ where pattern.IsMatch(alias)
/// <returns>A list of completion results.</returns>
public static List<CompletionResult> CompleteOperator(string wordToComplete)
{
if (wordToComplete.StartsWith("-", StringComparison.Ordinal))
if (wordToComplete.StartsWith('-'))
{
wordToComplete = wordToComplete.Substring(1);
}
Expand Down Expand Up @@ -846,7 +846,7 @@ internal static List<CompletionResult> CompleteCommandArgument(CompletionContext
{
commandAst = (CommandAst)expressionAst.Parent;

if (expressionAst is ErrorExpressionAst && expressionAst.Extent.Text.EndsWith(",", StringComparison.Ordinal))
if (expressionAst is ErrorExpressionAst && expressionAst.Extent.Text.EndsWith(','))
{
context.WordToComplete = string.Empty;
// BUGBUG context.CursorPosition = expressionAst.Extent.StartScriptPosition;
Expand Down Expand Up @@ -978,7 +978,7 @@ internal static List<CompletionResult> CompleteCommandArgument(CompletionContext
else if (expressionAst.Parent is CommandParameterAst && expressionAst.Parent.Parent is CommandAst)
{
commandAst = (CommandAst)expressionAst.Parent.Parent;
if (expressionAst is ErrorExpressionAst && expressionAst.Extent.Text.EndsWith(",", StringComparison.Ordinal))
if (expressionAst is ErrorExpressionAst && expressionAst.Extent.Text.EndsWith(','))
{
// dir -Path: a.txt,<tab>
context.WordToComplete = string.Empty;
Expand Down Expand Up @@ -1228,7 +1228,7 @@ internal static List<CompletionResult> CompleteCommandArgument(CompletionContext
secondToLastMemberAst.Extent.EndLineNumber == pathAst.Extent.StartLineNumber &&
secondToLastMemberAst.Extent.EndColumnNumber == pathAst.Extent.StartColumnNumber)
{
var memberName = pathAst.Value.EndsWith("*", StringComparison.Ordinal)
var memberName = pathAst.Value.EndsWith('*')
? pathAst.Value
: pathAst.Value + "*";
var targetExpr = secondToLastMemberAst.Expression;
Expand Down Expand Up @@ -2911,7 +2911,7 @@ private static void NativeCompletionEventLogCommands(CompletionContext context,
var logName = context.WordToComplete ?? string.Empty;
var quote = HandleDoubleAndSingleQuote(ref logName);

if (!logName.EndsWith("*", StringComparison.Ordinal))
if (!logName.EndsWith('*'))
{
logName += "*";
}
Expand Down Expand Up @@ -2962,7 +2962,7 @@ private static void NativeCompletionJobCommands(CompletionContext context, strin
var wordToComplete = context.WordToComplete ?? string.Empty;
var quote = HandleDoubleAndSingleQuote(ref wordToComplete);

if (!wordToComplete.EndsWith("*", StringComparison.Ordinal))
if (!wordToComplete.EndsWith('*'))
{
wordToComplete += "*";
}
Expand Down Expand Up @@ -3049,7 +3049,7 @@ private static void NativeCompletionScheduledJobCommands(CompletionContext conte
var wordToComplete = context.WordToComplete ?? string.Empty;
var quote = HandleDoubleAndSingleQuote(ref wordToComplete);

if (!wordToComplete.EndsWith("*", StringComparison.Ordinal))
if (!wordToComplete.EndsWith('*'))
{
wordToComplete += "*";
}
Expand Down Expand Up @@ -3183,7 +3183,7 @@ private static void NativeCompletionProcessCommands(CompletionContext context, s
var wordToComplete = context.WordToComplete ?? string.Empty;
var quote = HandleDoubleAndSingleQuote(ref wordToComplete);

if (!wordToComplete.EndsWith("*", StringComparison.Ordinal))
if (!wordToComplete.EndsWith('*'))
{
wordToComplete += "*";
}
Expand Down Expand Up @@ -3274,7 +3274,7 @@ private static void NativeCompletionProviderCommands(CompletionContext context,
var providerName = context.WordToComplete ?? string.Empty;
var quote = HandleDoubleAndSingleQuote(ref providerName);

if (!providerName.EndsWith("*", StringComparison.Ordinal))
if (!providerName.EndsWith('*'))
{
providerName += "*";
}
Expand Down Expand Up @@ -3318,7 +3318,7 @@ private static void NativeCompletionDriveCommands(CompletionContext context, str
var wordToComplete = context.WordToComplete ?? string.Empty;
var quote = HandleDoubleAndSingleQuote(ref wordToComplete);

if (!wordToComplete.EndsWith("*", StringComparison.Ordinal))
if (!wordToComplete.EndsWith('*'))
{
wordToComplete += "*";
}
Expand Down Expand Up @@ -3365,7 +3365,7 @@ private static void NativeCompletionServiceCommands(CompletionContext context, s
var wordToComplete = context.WordToComplete ?? string.Empty;
var quote = HandleDoubleAndSingleQuote(ref wordToComplete);

if (!wordToComplete.EndsWith("*", StringComparison.Ordinal))
if (!wordToComplete.EndsWith('*'))
{
wordToComplete += "*";
}
Expand Down Expand Up @@ -3451,7 +3451,7 @@ private static void NativeCompletionVariableCommands(CompletionContext context,

var variableName = context.WordToComplete ?? string.Empty;
var quote = HandleDoubleAndSingleQuote(ref variableName);
if (!variableName.EndsWith("*", StringComparison.Ordinal))
if (!variableName.EndsWith('*'))
{
variableName += "*";
}
Expand Down Expand Up @@ -3511,7 +3511,7 @@ private static void NativeCompletionAliasCommands(CompletionContext context, str
var commandName = context.WordToComplete ?? string.Empty;
var quote = HandleDoubleAndSingleQuote(ref commandName);

if (!commandName.EndsWith("*", StringComparison.Ordinal))
if (!commandName.EndsWith('*'))
{
commandName += "*";
}
Expand Down Expand Up @@ -3572,7 +3572,7 @@ private static void NativeCompletionTraceSourceCommands(CompletionContext contex
var traceSourceName = context.WordToComplete ?? string.Empty;
var quote = HandleDoubleAndSingleQuote(ref traceSourceName);

if (!traceSourceName.EndsWith("*", StringComparison.Ordinal))
if (!traceSourceName.EndsWith('*'))
{
traceSourceName += "*";
}
Expand Down Expand Up @@ -4008,7 +4008,7 @@ private static ArgumentLocation GenerateArgumentLocation(AstParameterArgumentPai
if (!prev.ParameterSpecified)
return new ArgumentLocation() { Argument = null, IsPositional = true, Position = position };

return prev.Parameter.Extent.Text.EndsWith(":", StringComparison.Ordinal)
return prev.Parameter.Extent.Text.EndsWith(':')
? new ArgumentLocation() { Argument = prev, IsPositional = false, Position = -1 }

: new ArgumentLocation() { Argument = null, IsPositional = true, Position = position };
Expand Down Expand Up @@ -4520,7 +4520,7 @@ internal static List<string> GetFileShares(string machine, bool ignoreHidden)

if ((shareInfo.type & STYPE_MASK) != STYPE_DISKTREE)
continue;
if (ignoreHidden && shareInfo.netname.EndsWith("$", StringComparison.Ordinal))
if (ignoreHidden && shareInfo.netname.EndsWith('$'))
continue;
shares.Add(shareInfo.netname);
}
Expand Down Expand Up @@ -6122,7 +6122,7 @@ internal static List<CompletionResult> CompleteStatementFlags(TokenKind kind, st

Diagnostics.Assert(!string.IsNullOrEmpty(wordToComplete) && wordToComplete[0].IsDash(), "the word to complete should start with '-'");
wordToComplete = wordToComplete.Substring(1);
bool withColon = wordToComplete.EndsWith(":", StringComparison.Ordinal);
bool withColon = wordToComplete.EndsWith(':');
wordToComplete = withColon ? wordToComplete.Remove(wordToComplete.Length - 1) : wordToComplete;

string enumString = LanguagePrimitives.EnumSingleTypeConverter.EnumValues(typeof(SwitchFlags));
Expand Down
4 changes: 2 additions & 2 deletions 4 src/System.Management.Automation/engine/CommandDiscovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ private static CommandInfo TryModuleAutoLoading(string commandName, ExecutionCon
}
}

if (string.IsNullOrEmpty(moduleName) || string.IsNullOrEmpty(moduleCommandName) || moduleName.EndsWith(".", StringComparison.Ordinal))
if (string.IsNullOrEmpty(moduleName) || string.IsNullOrEmpty(moduleCommandName) || moduleName.EndsWith('.'))
return null;

bool etwEnabled = CommandDiscoveryEventSource.Log.IsEnabled();
Expand Down Expand Up @@ -1668,7 +1668,7 @@ internal Collection<int> IndexOfRelativePath()
{
string path = this[index];
if (!string.IsNullOrEmpty(path) &&
path.StartsWith(".", StringComparison.Ordinal))
path.StartsWith('.'))
{
result.Add(index);
}
Expand Down
4 changes: 2 additions & 2 deletions 4 src/System.Management.Automation/engine/CommandInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,8 @@ public Type Type
{
// We ignore the exception.
if (Name != null &&
Name.StartsWith("[", StringComparison.OrdinalIgnoreCase) &&
Name.EndsWith("]", StringComparison.OrdinalIgnoreCase))
Name.StartsWith('[') &&
Name.EndsWith(']'))
{
string tmp = Name.Substring(1, Name.Length - 2);
TypeResolver.TryResolveType(tmp, out _type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected override void Validate(object arguments, EngineIntrinsics engineIntrin
string varName = arguments as string;
if (varName != null)
{
if (varName.StartsWith("+", StringComparison.Ordinal))
if (varName.StartsWith('+'))
{
varName = varName.Substring(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ internal void SetupOutVariable()
// as it needs to handle much of its OutVariable support itself.
if (
(!string.IsNullOrEmpty(this.OutVariable)) &&
(!(this.OutVariable.StartsWith("+", StringComparison.Ordinal))) &&
(!(this.OutVariable.StartsWith('+'))) &&
string.Equals("Out-Default", _thisCommand.CommandInfo.Name, StringComparison.OrdinalIgnoreCase))
{
if (_state == null)
Expand Down Expand Up @@ -2492,7 +2492,7 @@ internal void SetupVariable(VariableStreamKind streamKind, string variableName,
if (_state == null)
_state = new SessionState(Context.EngineSessionState);

if (variableName.StartsWith("+", StringComparison.Ordinal))
if (variableName.StartsWith('+'))
{
variableName = variableName.Substring(1);
object oldValue = PSObject.Base(_state.PSVariable.GetValue(variableName));
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.