Skip to content

Commit dfc5189

Browse files
Use char overloads (#56531)
Use overloads that take a `char` for single-character strings.
1 parent 288e111 commit dfc5189

File tree

11 files changed

+26
-26
lines changed

11 files changed

+26
-26
lines changed

src/Hosting/TestHost/src/ClientHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ protected override async Task<HttpResponseMessage> SendAsync(
159159
// User-Agent is a space delineated single line header but HttpRequestHeaders parses it as multiple elements.
160160
if (string.Equals(header.Key, HeaderNames.UserAgent, StringComparison.OrdinalIgnoreCase))
161161
{
162-
req.Headers.Append(header.Key, string.Join(" ", header.Value));
162+
req.Headers.Append(header.Key, string.Join(' ', header.Value));
163163
}
164164
else
165165
{

src/Http/Authentication.Abstractions/src/TokenExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static void StoreTokens(this AuthenticationProperties properties, IEnumer
4646

4747
if (tokenNames.Count > 0)
4848
{
49-
properties.Items[TokenNamesKey] = string.Join(";", tokenNames);
49+
properties.Items[TokenNamesKey] = string.Join(';', tokenNames);
5050
}
5151
}
5252

src/Http/Http.Abstractions/src/Internal/ParsingHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static void SetHeaderJoined(IHeaderDictionary headers, string key, String
5757
}
5858
else
5959
{
60-
headers[key] = string.Join(",", value.Select(QuoteIfNeeded));
60+
headers[key] = string.Join(',', value.Select(QuoteIfNeeded));
6161
}
6262
}
6363

@@ -116,7 +116,7 @@ public static void AppendHeaderJoined(IHeaderDictionary headers, string key, par
116116
}
117117
else
118118
{
119-
headers[key] = existing + "," + string.Join(",", values.Select(QuoteIfNeeded));
119+
headers[key] = existing + "," + string.Join(',', values.Select(QuoteIfNeeded));
120120
}
121121
}
122122

src/Http/Http.Abstractions/src/WebSocketManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private string DebuggerToString()
5151
return IsWebSocketRequest switch
5252
{
5353
false => "IsWebSocketRequest = false",
54-
true => $"IsWebSocketRequest = true, RequestedProtocols = {string.Join(",", WebSocketRequestedProtocols)}",
54+
true => $"IsWebSocketRequest = true, RequestedProtocols = {string.Join(',', WebSocketRequestedProtocols)}",
5555
};
5656
}
5757

src/Http/Http/src/BindingAddress.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,17 @@ public static BindingAddress Parse(string address)
179179
}
180180
}
181181

182-
pathDelimiterStart = address.IndexOf(":", schemeDelimiterEnd + unixPipeHostPrefixLength, StringComparison.Ordinal);
182+
pathDelimiterStart = address.IndexOf(':', schemeDelimiterEnd + unixPipeHostPrefixLength);
183183
pathDelimiterEnd = pathDelimiterStart + ":".Length;
184184
}
185185
else if (isNamedPipe)
186186
{
187-
pathDelimiterStart = address.IndexOf(":", schemeDelimiterEnd + NamedPipeHostPrefix.Length, StringComparison.Ordinal);
187+
pathDelimiterStart = address.IndexOf(':', schemeDelimiterEnd + NamedPipeHostPrefix.Length);
188188
pathDelimiterEnd = pathDelimiterStart + ":".Length;
189189
}
190190
else
191191
{
192-
pathDelimiterStart = address.IndexOf("/", schemeDelimiterEnd, StringComparison.Ordinal);
192+
pathDelimiterStart = address.IndexOf('/', schemeDelimiterEnd);
193193
pathDelimiterEnd = pathDelimiterStart;
194194
}
195195

@@ -205,7 +205,7 @@ public static BindingAddress Parse(string address)
205205
var hasSpecifiedPort = false;
206206
if (!isUnixPipe)
207207
{
208-
var portDelimiterStart = address.LastIndexOf(":", pathDelimiterStart - 1, pathDelimiterStart - schemeDelimiterEnd, StringComparison.Ordinal);
208+
var portDelimiterStart = address.LastIndexOf(':', pathDelimiterStart - 1, pathDelimiterStart - schemeDelimiterEnd);
209209
if (portDelimiterStart >= 0)
210210
{
211211
var portDelimiterEnd = portDelimiterStart + ":".Length;

src/Http/Http/src/Features/FormFeature.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@ private MediaTypeHeaderValue? ContentType
7272
{
7373
get
7474
{
75-
MediaTypeHeaderValue? mt = null;
75+
MediaTypeHeaderValue? mt = null;
7676

77-
if (_request is not null)
78-
{
79-
_ = MediaTypeHeaderValue.TryParse(_request.ContentType, out mt);
80-
}
77+
if (_request is not null)
78+
{
79+
_ = MediaTypeHeaderValue.TryParse(_request.ContentType, out mt);
80+
}
8181

82-
if (_form is not null && mt is null)
83-
{
84-
mt = _formContentType;
85-
}
82+
if (_form is not null && mt is null)
83+
{
84+
mt = _formContentType;
85+
}
8686

87-
return mt;
87+
return mt;
8888
}
8989
}
9090

@@ -127,9 +127,9 @@ public IFormCollection? Form
127127
{
128128
_formContentType = null;
129129
}
130-
else
130+
else
131131
{
132-
_formContentType ??= new MediaTypeHeaderValue("application/x-www-form-urlencoded");
132+
_formContentType ??= new MediaTypeHeaderValue("application/x-www-form-urlencoded");
133133
}
134134
}
135135
}

src/Http/Routing/src/HostAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public override string ToString()
5353
{
5454
var hostsDisplay = (Hosts.Count == 0)
5555
? "*:*"
56-
: string.Join(",", Hosts.Select(h => h.Contains(':') ? h : h + ":*"));
56+
: string.Join(',', Hosts.Select(h => h.Contains(':') ? h : h + ":*"));
5757

5858
return DebuggerHelpers.GetDebugText(nameof(Hosts), hostsDisplay);
5959
}

src/Mvc/Mvc.Abstractions/src/ModelBinding/CompositeBindingSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static CompositeBindingSource Create(
5353
}
5454
}
5555

56-
var id = string.Join("&", bindingSources.Select(s => s.Id).OrderBy(s => s, StringComparer.Ordinal));
56+
var id = string.Join('&', bindingSources.Select(s => s.Id).OrderBy(s => s, StringComparer.Ordinal));
5757
return new CompositeBindingSource(id, displayName, bindingSources);
5858
}
5959

src/Security/Authorization/Policy/src/PolicyEvaluator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public virtual async Task<AuthenticateResult> AuthenticateAsync(AuthorizationPol
5454
if (newPrincipal != null)
5555
{
5656
context.User = newPrincipal;
57-
var ticket = new AuthenticationTicket(newPrincipal, string.Join(";", policy.AuthenticationSchemes));
57+
var ticket = new AuthenticationTicket(newPrincipal, string.Join(';', policy.AuthenticationSchemes));
5858
// ExpiresUtc is the easiest property to reason about when dealing with multiple schemes
5959
// SignalR will use this property to evaluate auth expiration for long running connections
6060
ticket.Properties.ExpiresUtc = minExpiresUtc;

src/Shared/Diagnostics/BaseView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected void EndWriteAttribute()
118118
Debug.Assert(AttributeValues != null);
119119
Debug.Assert(!string.IsNullOrEmpty(AttributeEnding));
120120

121-
var attributes = string.Join(" ", AttributeValues);
121+
var attributes = string.Join(' ', AttributeValues);
122122
Output.Write(attributes);
123123
AttributeValues = null;
124124

src/Shared/RazorViews/BaseView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected void EndWriteAttribute()
158158
Debug.Assert(AttributeValues != null);
159159
Debug.Assert(!string.IsNullOrEmpty(AttributeEnding));
160160

161-
var attributes = string.Join(" ", AttributeValues);
161+
var attributes = string.Join(' ', AttributeValues);
162162
Output.Write(attributes);
163163
AttributeValues = null;
164164

0 commit comments

Comments
 (0)