Skip to content
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 @@ -1806,7 +1806,7 @@ internal static string GetLocalAdminUserName(string computerName, PSCredential p
}
else
{
localUserName = string.Concat(computerName.AsSpan().Slice(0, dotIndex), "\\", psLocalCredential.UserName);
localUserName = string.Concat(computerName.AsSpan(0, dotIndex), "\\", psLocalCredential.UserName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ private Uri PrepareUri(Uri uri)
UriBuilder uriBuilder = new UriBuilder(uri);
if (uriBuilder.Query != null && uriBuilder.Query.Length > 1)
{
uriBuilder.Query = string.Concat(uriBuilder.Query.AsSpan().Slice(1), "&", FormatDictionary(bodyAsDictionary));
uriBuilder.Query = string.Concat(uriBuilder.Query.AsSpan(1), "&", FormatDictionary(bodyAsDictionary));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ private bool ParseFile(string[] args, ref int i, bool noexitSeen)
static object ConvertToBoolIfPossible(string arg)
{
// Before parsing we skip '$' if present.
return arg.Length > 0 && bool.TryParse(arg.AsSpan().Slice(arg[0] == '$' ? 1 : 0), out bool boolValue)
return arg.Length > 0 && bool.TryParse(arg.AsSpan(arg[0] == '$' ? 1 : 0), out bool boolValue)
? (object)boolValue
: (object)arg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private static bool TryParseUpdateFile(
int dateStartIndex = updateFileName.LastIndexOf('_') + 1;

if (!DateTime.TryParse(
updateFileName.AsSpan().Slice(dateStartIndex),
updateFileName.AsSpan(dateStartIndex),
CultureInfo.InvariantCulture,
DateTimeStyles.AssumeLocal,
out lastUpdateDate))
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.WSMan.Management/ConfigProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3647,13 +3647,13 @@ private string GetCorrectCaseOfName(string ChildName, string hostname, string pa
else
{
if (ChildName.StartsWith(WSManStringLiterals.containerListener, StringComparison.OrdinalIgnoreCase))
result = string.Concat(WSManStringLiterals.containerListener, "_", ChildName.AsSpan().Slice(ChildName.IndexOf('_') + 1));
result = string.Concat(WSManStringLiterals.containerListener, "_", ChildName.AsSpan(ChildName.IndexOf('_') + 1));
if (ChildName.StartsWith(WSManStringLiterals.containerSingleResource, StringComparison.OrdinalIgnoreCase))
result = string.Concat(WSManStringLiterals.containerSingleResource, "_", ChildName.AsSpan().Slice(ChildName.IndexOf('_') + 1));
result = string.Concat(WSManStringLiterals.containerSingleResource, "_", ChildName.AsSpan(ChildName.IndexOf('_') + 1));
if (ChildName.StartsWith(WSManStringLiterals.containerSecurity, StringComparison.OrdinalIgnoreCase))
result = string.Concat(WSManStringLiterals.containerSecurity, "_", ChildName.AsSpan().Slice(ChildName.IndexOf('_') + 1));
result = string.Concat(WSManStringLiterals.containerSecurity, "_", ChildName.AsSpan(ChildName.IndexOf('_') + 1));
if (ChildName.StartsWith(WSManStringLiterals.containerClientCertificate, StringComparison.OrdinalIgnoreCase))
result = string.Concat(WSManStringLiterals.containerClientCertificate, "_", ChildName.AsSpan().Slice(ChildName.IndexOf('_') + 1));
result = string.Concat(WSManStringLiterals.containerClientCertificate, "_", ChildName.AsSpan(ChildName.IndexOf('_') + 1));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ internal static List<CompletionResult> CompleteCommandParameter(CompletionContex
&& !string.IsNullOrWhiteSpace(context.WordToComplete) && context.WordToComplete.StartsWith('-'))
{
var lastAst = context.RelatedAsts.Last();
var wordToMatch = string.Concat(context.WordToComplete.AsSpan().Slice(1), "*");
var wordToMatch = string.Concat(context.WordToComplete.AsSpan(1), "*");
var pattern = WildcardPattern.Get(wordToMatch, WildcardOptions.IgnoreCase);
var parameterNames = keywordAst.CommandElements.Where(ast => ast is CommandParameterAst).Select(ast => (ast as CommandParameterAst).ParameterName);
foreach (var parameterName in s_parameterNamesOfImportDSCResource)
Expand Down Expand Up @@ -4707,7 +4707,7 @@ internal static List<CompletionResult> CompleteVariable(CompletionContext contex
provider = wordToComplete.Substring(0, colon + 1);
if (s_variableScopes.Contains(provider, StringComparer.OrdinalIgnoreCase))
{
pattern = string.Concat("variable:", wordToComplete.AsSpan().Slice(colon + 1), "*");
pattern = string.Concat("variable:", wordToComplete.AsSpan(colon + 1), "*");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/regex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ StringComparison GetStringComparison()
if (index == Pattern.Length - 1 && Pattern[index] == '*')
{
// No special characters present in the pattern before last position and last character is asterisk.
var patternWithoutAsterisk = Pattern.AsMemory().Slice(0, index);
var patternWithoutAsterisk = Pattern.AsMemory(0, index);
_isMatch = str => str.AsSpan().StartsWith(patternWithoutAsterisk.Span, GetStringComparison());
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ internal static string IndexStringMessage(object index)
// Convert this index into something printable (we hope)...
string msgString = PSObject.ToString(null, index, ",", null, null, true, true);
if (msgString.Length > 20)
msgString = string.Concat(msgString.AsSpan().Slice(0, 20), " ...");
msgString = string.Concat(msgString.AsSpan(0, 20), " ...");
return msgString;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ private static string GetParameterText(string parameterName)
else
{
string whitespaces = parameterName.Substring(endPosition);
parameterText = string.Concat("-", parameterName.AsSpan().Slice(0, endPosition), ":", whitespaces);
parameterText = string.Concat("-", parameterName.AsSpan(0, endPosition), ":", whitespaces);
}

return parameterText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2376,7 +2376,7 @@ protected override void NewItem(
if (strTargetPath.StartsWith(".\\", StringComparison.OrdinalIgnoreCase) ||
strTargetPath.StartsWith("./", StringComparison.OrdinalIgnoreCase))
{
normalizedTargetPath = Path.Join(SessionState.Internal.CurrentLocation.ProviderPath, strTargetPath.AsSpan().Slice(2));
normalizedTargetPath = Path.Join(SessionState.Internal.CurrentLocation.ProviderPath, strTargetPath.AsSpan(2));
}

GetFileSystemInfo(normalizedTargetPath, out isDirectory);
Expand Down