Skip to content

Update EventSource.xml#9247

Merged
tarekgh merged 1 commit intodotnet:mainfrom
msnilsen:patch-1
Sep 6, 2023
Merged

Update EventSource.xml#9247
tarekgh merged 1 commit intodotnet:mainfrom
msnilsen:patch-1

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 community-contribution Indicates that the PR has been added by a community member area-System.DateTime labels 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

davmason commented Sep 6, 2023

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

@tarekgh tarekgh enabled auto-merge September 6, 2023 23:45
@tarekgh tarekgh merged commit e927ea9 into dotnet:main Sep 6, 2023
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