Skip to content

Clarify WriteEventCore arguments - #7925

Merged
gewarren merged 3 commits into
dotnet:mainfrom
noahfalk:write_event_core
Apr 7, 2022
Merged

gewarren merged 3 commits into
dotnet:mainfrom
noahfalk:write_event_core

Conversation

@noahfalk

@noahfalk noahfalk commented Apr 5, 2022

Copy link
Copy Markdown
Member

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.

@noahfalk
noahfalk requested a review from a team as a code owner April 5, 2022 01:02
@ghost

ghost commented Apr 5, 2022

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/area-system-diagnostics-tracing
See info in area-owners.md if you want to be subscribed.

Issue Details

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.

Author: noahfalk
Assignees: -
Labels:

area-System.Diagnostics.Tracing

Milestone: -

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.
@noahfalk

noahfalk commented Apr 5, 2022

Copy link
Copy Markdown
Member Author

cc @dotnet/dotnet-diag

@opbld32

opbld32 commented Apr 5, 2022

Copy link
Copy Markdown

Docs Build status updates of commit e0a712b:

✅ Validation status: passed

File Status Preview URL Details
xml/System.Diagnostics.Tracing/EventSource.xml ✅Succeeded View

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@opbld33

opbld33 commented Apr 5, 2022

Copy link
Copy Markdown

Docs Build status updates of commit 7b6c1bf:

✅ Validation status: passed

File Status Preview URL Details
xml/System.Diagnostics.Tracing/EventSource.xml ✅Succeeded View

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@BillWagner

Copy link
Copy Markdown
Member

@gewarren What do you think on this one? Should we pull the code into an included sample?

@josalem josalem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code snippets are a good way to show this information.

@opbld31

opbld31 commented Apr 6, 2022

Copy link
Copy Markdown

Docs Build status updates of commit 105be8c:

✅ Validation status: passed

File Status Preview URL Details
xml/System.Diagnostics.Tracing/EventSource.xml ✅Succeeded View

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

@gfoidl gfoidl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits to follow coding standard in dotnet-org.

@noahfalk

noahfalk commented Apr 7, 2022

Copy link
Copy Markdown
Member Author

I updated the code snippet with @gfoidl's style suggestions. @gewarren assuming all looks well can you hit the merge button for me? Thanks all!

@opbld30

opbld30 commented Apr 7, 2022

Copy link
Copy Markdown

Docs Build status updates of commit 9bd8d8b:

✅ Validation status: passed

File Status Preview URL Details
xml/System.Diagnostics.Tracing/EventSource.xml ✅Succeeded View

For more details, please refer to the build report.

Note: Broken links written as relative paths are included in the above build report. For broken links written as absolute paths or external URLs, see the broken link report.

For any questions, please:

desc.Size = 8;

// string arg
fixed(byte* ptr = arg)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be char* ptr?

fixed(byte* ptr = arg)
{
int length = arg.Length;
desc.DataPointer = ptr;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a cast to IntPtr.

{
int length = arg.Length;
desc.DataPointer = ptr;
desc.Size = (arg.Length + 1) * 2; // strings use 2 byte per char UTF16 encoding and a null terminator at the end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a note saying that the string must not contain embedded null characters. ETW consumers expect the string to end at the first null character.

@noahfalk

noahfalk commented Apr 8, 2022

Copy link
Copy Markdown
Member Author

@KalleOlaviNiemitalo - thanks for catching my mistakes : ) I opened a new PR since this one had already merged.
#7940

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EventSource should mention some built-in types require special handling