Skip to content

Commit 7e26b70

Browse files
committed
Post-merge
1 parent 00ac909 commit 7e26b70

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/TraceData.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

@@ -92,17 +92,18 @@ static public void OnTrace(AvTraceBuilder traceBuilder, ReadOnlySpan<object> par
9292
{
9393
for (int i = 0; i < parameters.Length; i++)
9494
{
95-
object o = parameters[i];
95+
object objectParam = parameters[i];
9696
traceBuilder.Append(" ");
97-
if (o is string s)
97+
98+
if (objectParam is string stringValue)
9899
{
99-
traceBuilder.Append(s);
100+
traceBuilder.Append(stringValue);
100101
}
101-
else if (o != null)
102+
else if (objectParam is not null)
102103
{
103-
traceBuilder.Append(o.GetType().Name);
104+
traceBuilder.Append(objectParam.GetType().Name);
104105
traceBuilder.Append(":");
105-
Describe(traceBuilder, o);
106+
Describe(traceBuilder, objectParam);
106107
}
107108
else
108109
{

src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/AvTrace.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,10 @@ internal static bool IsDebuggerAttached()
250250
public string Trace(TraceEventType type, int eventId, string message, string[] labels, params ReadOnlySpan<object> parameters)
251251
{
252252
// Don't bother building the string if this trace is going to be ignored.
253-
254-
if (_traceSource == null || !_traceSource.Switch.ShouldTrace(type))
253+
if (_traceSource is null || !_traceSource.Switch.ShouldTrace(type))
255254
return null;
256255

257256
// Compose the trace string.
258-
259257
AvTraceBuilder traceBuilder = new AvTraceBuilder(AntiFormat(message)); // Holds the format string
260258
object[] combinedArgs = null; // Holds the combined labels & parameters arrays.
261259
int formatIndex = 0;
@@ -265,7 +263,7 @@ public string Trace(TraceEventType type, int eventId, string message, string[] l
265263
// Create array of pre-computed size
266264
int combinedArgsLength = Math.Min(labels.Length - 1, parameters.Length) * 2;
267265
if (combinedArgsLength > 0)
268-
combinedArgs = new object[combinedArgsLength];
266+
combinedArgs = new object[combinedArgsLength];
269267

270268
int i = 1, j = 0;
271269
for (; i < labels.Length && j < parameters.Length; i++, j++)
@@ -279,14 +277,13 @@ public string Trace(TraceEventType type, int eventId, string message, string[] l
279277

280278
// If the parameter is null, convert to "<null>"; otherwise,
281279
// when a string.format is ultimately called it produces bad results.
282-
if (parameters[j] == null)
280+
if (parameters[j] is null)
283281
{
284282
combinedArgs[j * 2 + 1] = "<null>";
285283
}
286284

287285
// Otherwise, if this is an interesting object, add the hash code and type to
288286
// the format string explicitly.
289-
290287
else if (!SuppressGeneratedParameters
291288
&& parameters[j].GetType() != typeof(string)
292289
&& parameters[j] is not ValueType
@@ -297,19 +294,18 @@ public string Trace(TraceEventType type, int eventId, string message, string[] l
297294
traceBuilder.Append($"; {labels[i]}.Type='{GetTypeHelper(parameters[j])}'");
298295

299296
// Add the parameter to the combined list.
300-
301297
combinedArgs[j * 2 + 1] = parameters[j];
302298
}
303-
else // Add the parameter to the combined list.
299+
// Add the parameter to the combined list.
300+
else
304301
{
305302
combinedArgs[j * 2 + 1] = parameters[j];
306303
}
307304
}
308305

309306
// It's OK if we terminate because we have more labels than parameters;
310307
// this is used by traces to have out-values in the Stop message.
311-
312-
if (TraceExtraMessages != null && j < parameters.Length)
308+
if (TraceExtraMessages is not null && j < parameters.Length)
313309
{
314310
TraceExtraMessages(traceBuilder, parameters.Slice(j));
315311
}

0 commit comments

Comments
 (0)