|
if (dataType.IsEnum) |
|
dataType = Enum.GetUnderlyingType(dataType); |
|
|
|
if (dataType == typeof(string)) |
|
{ |
|
result = StringTypeInfo.Instance(); |
|
} |
|
else if (dataType == typeof(bool)) |
|
{ |
|
result = ScalarTypeInfo.Boolean(); |
|
} |
|
else if (dataType == typeof(byte)) |
|
{ |
|
result = ScalarTypeInfo.Byte(); |
|
} |
|
else if (dataType == typeof(sbyte)) |
|
{ |
|
result = ScalarTypeInfo.SByte(); |
|
} |
|
else if (dataType == typeof(short)) |
|
{ |
|
result = ScalarTypeInfo.Int16(); |
|
} |
|
else if (dataType == typeof(ushort)) |
|
{ |
|
result = ScalarTypeInfo.UInt16(); |
|
} |
|
else if (dataType == typeof(int)) |
|
{ |
|
result = ScalarTypeInfo.Int32(); |
|
} |
|
else if (dataType == typeof(uint)) |
|
{ |
|
result = ScalarTypeInfo.UInt32(); |
|
} |
|
else if (dataType == typeof(long)) |
|
{ |
|
result = ScalarTypeInfo.Int64(); |
|
} |
|
else if (dataType == typeof(ulong)) |
|
{ |
|
result = ScalarTypeInfo.UInt64(); |
|
} |
|
else if (dataType == typeof(char)) |
|
{ |
|
result = ScalarTypeInfo.Char(); |
|
} |
|
else if (dataType == typeof(double)) |
|
{ |
|
result = ScalarTypeInfo.Double(); |
|
} |
|
else if (dataType == typeof(float)) |
|
{ |
|
result = ScalarTypeInfo.Single(); |
|
} |
|
else if (dataType == typeof(DateTime)) |
|
{ |
|
result = DateTimeTypeInfo.Instance(); |
|
} |
|
else if (dataType == typeof(decimal)) |
|
{ |
|
result = DecimalTypeInfo.Instance(); |
|
} |
|
else if (dataType == typeof(IntPtr)) |
|
{ |
|
result = ScalarTypeInfo.IntPtr(); |
|
} |
|
else if (dataType == typeof(UIntPtr)) |
|
{ |
|
result = ScalarTypeInfo.UIntPtr(); |
|
} |
|
else if (dataType == typeof(Guid)) |
|
{ |
|
result = ScalarTypeInfo.Guid(); |
|
} |
|
else if (dataType == typeof(TimeSpan)) |
|
{ |
|
result = TimeSpanTypeInfo.Instance(); |
|
} |
|
else if (dataType == typeof(DateTimeOffset)) |
|
{ |
|
result = DateTimeOffsetTypeInfo.Instance(); |
|
} |
|
else if (dataType == typeof(EmptyStruct)) |
|
{ |
|
result = NullTypeInfo.Instance(); |
|
} |
|
else if (IsGenericMatch(dataType, typeof(Nullable<>))) |
|
{ |
|
result = new NullableTypeInfo(dataType, recursionCheck); |
|
} |
Related to:
open-telemetry/opentelemetry-dotnet#4428
open-telemetry/opentelemetry-dotnet#4392
On suppressing the warnings for https://github.com/open-telemetry/opentelemetry-dotnet/blob/ef0c9217087bfca0d6fe9206ccde343eb4e5738c/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs#L203
Regarding the below documentation:
https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-warnings/il2026
When enabling trimming analysis, the message specifies:
"... EventSource will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type"
I checked with @eerhardt that IL2026 could be suppressed in this case: https://github.com/open-telemetry/opentelemetry-dotnet/blob/10eb79cdddbe400608fcdf2dd8ccf91d5a36f262/src/OpenTelemetry/Internal/OpenTelemetrySdkEventSource.cs#L203
because the definition of primitive type here is different from the definition of
system.type.isprimitive.The definition of the primitive type here means:
runtime/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/Statics.cs
Lines 484 to 574 in ab2b80d
I'd like to request an update on the IL2026 documentation to provide the definition/exhaustive list of primitive type where the warning could be safely suppressed.
@agocke , @LakshanF