Fix ulong/uint/ushort event properties displayed as signed types in event viewer #2313
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Event properties with unsigned integer types (
ulong,uint,ushort) were being displayed as their signed equivalents (long,int,short) in the event viewer, even when the event source explicitly wrote unsigned values.For example, when writing a
ulongvalue using:The value would be displayed as a
longin the event viewer instead ofulong, causing confusion and potentially displaying negative values for large unsigned numbers.Solution
Updated the
PayloadFetchconstructor inDynamicTraceEventParser.csto preserve unsigned types when parsing event metadata from registered trace event parsers (TDH - Trace Data Helper):TdhInputType.UInt16now maps totypeof(ushort)instead oftypeof(short)TdhInputType.UInt32now maps totypeof(uint)instead oftypeof(int)TdhInputType.UInt64now maps totypeof(ulong)instead oftypeof(long)The
TdhInputType.UInt8case was not modified as it already correctly maps totypeof(byte).Implementation Details
The fix separates the handling of signed and unsigned types in the switch statement. Each unsigned type now has its own case that sets the appropriate .NET unsigned type. The
PayloadValuemethod already had proper support for reading these unsigned types (TypeCode.UInt16, TypeCode.UInt32, TypeCode.UInt64), so no changes were needed there.This change makes the
DynamicTraceEventParserbehavior consistent withEventPipeMetadata, which already correctly uses unsigned types for EventPipe events.Fixes issue where unsigned event properties were displayed as signed types.
Original prompt
Fixes #2309
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.