Skip to content
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

Update EventSource.xml #9247

Merged
merged 1 commit into from
Sep 6, 2023
Merged

Update EventSource.xml #9247

merged 1 commit into from
Sep 6, 2023

Conversation

msnilsen
Copy link
Contributor

@msnilsen msnilsen commented Sep 1, 2023

Clamp fileTime to > Jan 1st, 1601

Summary

DateTime.MinValue causes arg.ToFileTimeUtc() to throw an exception.

When using mc.exe to translate a manifest specifying a Data element with inType="win:SYSTEMTIME" outType="xs:dateTime" to c# code, the generated code can handle DateTime.MinValue and it clamps the value to 0b11110000.

However, when using EventRegister to convert an EventSource class to a manifest, the manifest it builds uses inType="win:FILETIME" for a parameter of type DateTime. Then, when using mc.exe to translate that manifest to c#, it generates the code specified in this documentation:

long argFileTime = arg.ToFileTime();
userDataPtr[0].DataPointer = (UInt64)(&argFileTime);
userDataPtr[0].Size = (uint)(sizeof(long));

Which causes the code using this class to throw an exception instead of acting how it did previously, which was having the datetime clamped to the earliest systemtime.

Fixes #9246

@msnilsen msnilsen requested a review from a team as a code owner September 1, 2023 19:17
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Sep 1, 2023
@learn-build-service-prod
Copy link

Learn Build status updates of commit b8142a3:

✅ 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.

For any questions, please:

@ghost
Copy link

ghost commented Sep 5, 2023

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

Issue Details

Clamp fileTime to > Jan 1st, 1601

Summary

DateTime.MinValue causes arg.ToFileTimeUtc() to throw an exception.

When using mc.exe to translate a manifest specifying a Data element with inType="win:SYSTEMTIME" outType="xs:dateTime" to c# code, the generated code can handle DateTime.MinValue and it clamps the value to 0b11110000.

However, when using EventRegister to convert an EventSource class to a manifest, the manifest it builds uses inType="win:FILETIME" for a parameter of type DateTime. Then, when using mc.exe to translate that manifest to c#, it generates the code specified in this documentation:

long argFileTime = arg.ToFileTime();
userDataPtr[0].DataPointer = (UInt64)(&argFileTime);
userDataPtr[0].Size = (uint)(sizeof(long));

Which causes the code using this class to throw an exception instead of acting how it did previously, which was having the datetime clamped to the earliest systemtime.

Fixes #9246

Author: msnilsen
Assignees: -
Labels:

area-System.Diagnostics.Tracing, community-contribution

Milestone: -

@tarekgh
Copy link
Member

tarekgh commented Sep 5, 2023

CC @davmason

@noahfalk
Copy link
Member

noahfalk commented Sep 6, 2023

@msnilsen - Thanks for investigating the issue and contributing a fix to the docs. Very much appreciated!

Clamp fileTime to > Jan 1st, 1601
@learn-build-service-prod
Copy link

Learn Build status updates of commit e4b7c36:

✅ 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.

For any questions, please:

@davmason
Copy link
Member

davmason commented Sep 6, 2023

Thanks! Looks good to me outside of Tarek's feedback

@tarekgh tarekgh merged commit e927ea9 into dotnet:main Sep 6, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Diagnostics.Tracing community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WriteEventCore documentation specifies handling DateTime inconsistently
4 participants