Skip to content

Commit 1f0045f

Browse files
author
Andrew Hall
authored
Only use complex types for TypeCode.Object (#9502)
This will make it easier for us to write TN. Looking at all the values available in learn.microsoft.com/en-us/dotnet/api/system.typecode?view=net-7.0 it seems they should all just be directly written except for TypeCode.Object
1 parent 6342648 commit 1f0045f

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/Razor/src/Microsoft.VisualStudio.Editor.Razor/Telemetry/TelemetryReporter.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,17 @@ public void ReportEvent(string name, Severity severity, params Property[] proper
8585

8686
private static void AddToProperties(IDictionary<string, object?> properties, Property property)
8787
{
88-
if (IsNumericValue(property.Value))
88+
if (IsComplexValue(property.Value))
8989
{
90-
properties.Add(GetPropertyName(property.Name), property.Value);
90+
properties.Add(GetPropertyName(property.Name), new TelemetryComplexProperty(property.Value));
9191
}
9292
else
9393
{
94-
properties.Add(GetPropertyName(property.Name), new TelemetryComplexProperty(property.Value));
94+
properties.Add(GetPropertyName(property.Name), property.Value);
9595
}
9696

97-
static bool IsNumericValue(object? o)
98-
{
99-
return o is Type { IsEnum: false } type &&
100-
Type.GetTypeCode(type) is >= TypeCode.Char and <= TypeCode.Double;
101-
}
97+
static bool IsComplexValue(object? o)
98+
=> o is Type type && Type.GetTypeCode(type) == TypeCode.Object;
10299
}
103100

104101
public void ReportFault(Exception exception, string? message, params object?[] @params)

0 commit comments

Comments
 (0)