Skip to content

Commit 83eb746

Browse files
Copilotbrianrob
andcommitted
Add PayloadString formatting support for unsigned integer types
Co-authored-by: brianrob <[email protected]>
1 parent 1e312a1 commit 83eb746

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/TraceEvent/TraceEvent.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,42 @@ public virtual string PayloadString(int index, IFormatProvider formatProvider =
11241124
}
11251125
}
11261126

1127+
if (value is uint)
1128+
{
1129+
if (formatProvider != null)
1130+
{
1131+
return ((uint)value).ToString(formatProvider);
1132+
}
1133+
else
1134+
{
1135+
return ((uint)value).ToString("n0");
1136+
}
1137+
}
1138+
1139+
if (value is short)
1140+
{
1141+
if (formatProvider != null)
1142+
{
1143+
return ((short)value).ToString(formatProvider);
1144+
}
1145+
else
1146+
{
1147+
return ((short)value).ToString("n0");
1148+
}
1149+
}
1150+
1151+
if (value is ushort)
1152+
{
1153+
if (formatProvider != null)
1154+
{
1155+
return ((ushort)value).ToString(formatProvider);
1156+
}
1157+
else
1158+
{
1159+
return ((ushort)value).ToString("n0");
1160+
}
1161+
}
1162+
11271163
if (value is long)
11281164
{
11291165
if (PayloadNames[index] == "objectId") // TODO this is a hack.
@@ -1141,6 +1177,18 @@ public virtual string PayloadString(int index, IFormatProvider formatProvider =
11411177
}
11421178
}
11431179

1180+
if (value is ulong)
1181+
{
1182+
if (formatProvider != null)
1183+
{
1184+
return ((ulong)value).ToString(formatProvider);
1185+
}
1186+
else
1187+
{
1188+
return ((ulong)value).ToString("n0");
1189+
}
1190+
}
1191+
11441192
if (value is double)
11451193
{
11461194
if (formatProvider != null)

0 commit comments

Comments
 (0)