-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EventSource
should mention some built-in types require special handling
#2608
Comments
@hoyosjs ^ ping, per Vinod |
For C# 9, a source generator could generate the bodies of these methods and take care of the marshalling. dotnet/runtime#45699 already added EventSourceGenerator but it does not do this yet, as it focuses on initialization performance rather than developer convenience. The documentation would still help developers using other languages or .NET Framework targets that do not support C# 9. |
Fixes: dotnet/diagnostics#2608 WriteEventCore takes an array of EventData arguments but only provided a few sparse examples on how to initialize these values. Several of the types not shown have non-intuitive encodings that can't be inferred from the few examples. This change provides a more complete listing, in particular including bool, DateTime, string, and byte[] which are non-obvious.
Fixes: dotnet/diagnostics#2608 WriteEventCore takes an array of EventData arguments but only provided a few sparse examples on how to initialize these values. Several of the types not shown have non-intuitive encodings that can't be inferred from the few examples. This change provides a more complete listing, in particular including bool, DateTime, string, and byte[] which are non-obvious.
Fixed! dotnet/dotnet-api-docs#7925 |
Documentation Request
EventSource
does not mention that some built-in .NET types need to be mapped to the types expected by ETW. Presumably this has something to do with the reflection-generated manifests, but I haven't dug in to verify that.To illustrate the issue, it is easy enough to modify some of the examples in the above link to end up with an event source like:
Which is subtly wrong as
DateTime
andbool
do not map 1-to-1 to the format ETW expects - specificallyDateTime
must be aFILETIME
andbool
must be mapped to anint
of 1 or 0.bool
is particular insidious, as the size mismatch between the passed and expected types can result in data corruption (for the followingEventData
s) and potentially reads garbage data off the stack.A corrected version of the above would be:
Ideally, any built-in
System.*
types that might reasonably be on an event should have an example of how to prepare them forEventData
. I don't know how involved that would be, so an acceptable alternative would be to just call out that some types need special handling and a link to the relevant ETW documentation (which might be this).Previous documentation
There's the existing documentation of the
EventSource
class which should probably be amended.There's also ETW's input type remarks which are relevant, though the mapping from those types to .NET types is not always clear.
The text was updated successfully, but these errors were encountered: