Skip to content

Commit 9cc4c86

Browse files
committed
Post-merge
1 parent f318139 commit 9cc4c86

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,18 @@ public static void OnTrace(AvTraceBuilder traceBuilder, ReadOnlySpan<object> par
9191
{
9292
for (int i = 0; i < parameters.Length; i++)
9393
{
94-
object o = parameters[i];
94+
object objectParam = parameters[i];
9595
traceBuilder.Append(" ");
96-
if (o is string s)
96+
97+
if (objectParam is string stringValue)
9798
{
98-
traceBuilder.Append(s);
99+
traceBuilder.Append(stringValue);
99100
}
100-
else if (o != null)
101+
else if (objectParam is not null)
101102
{
102-
traceBuilder.Append(o.GetType().Name);
103+
traceBuilder.Append(objectParam.GetType().Name);
103104
traceBuilder.Append(":");
104-
Describe(traceBuilder, o);
105+
Describe(traceBuilder, objectParam);
105106
}
106107
else
107108
{

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

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

256255
// Compose the trace string.
257-
258256
AvTraceBuilder traceBuilder = new AvTraceBuilder(AntiFormat(message)); // Holds the format string
259257
object[] combinedArgs = null; // Holds the combined labels & parameters arrays.
260258
int formatIndex = 0;
@@ -264,7 +262,7 @@ public string Trace(TraceEventType type, int eventId, string message, string[] l
264262
// Create array of pre-computed size
265263
int combinedArgsLength = Math.Min(labels.Length - 1, parameters.Length) * 2;
266264
if (combinedArgsLength > 0)
267-
combinedArgs = new object[combinedArgsLength];
265+
combinedArgs = new object[combinedArgsLength];
268266

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

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

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

298295
// Add the parameter to the combined list.
299-
300296
combinedArgs[j * 2 + 1] = parameters[j];
301297
}
302-
else // Add the parameter to the combined list.
298+
// Add the parameter to the combined list.
299+
else
303300
{
304301
combinedArgs[j * 2 + 1] = parameters[j];
305302
}
306303
}
307304

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

0 commit comments

Comments
 (0)