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

Add EventSource event method generation #107176

Closed
wants to merge 9 commits into from

Conversation

Cricle
Copy link

@Cricle Cricle commented Aug 30, 2024

Contributes to #107069

  • Final result
//Writing code...

[EventSourceEventGenerate]
internal sealed unsafe /*It's mandatory or in method write unsafe*/ partial class RuntimeEventSource : EventSource
{
    [Event(1)]
    public partial void GoHome(string address,double usedTime);
}


//Will generated
public void GoHome(string address,double usedTime)
{
    address ??= System.String.Empty;
    global::System.Diagnostics.Tracing.EventSource.EventData* datas = stackalloc global::System.Diagnostics.Tracing.EventSource.EventData[2];
    datas[0] = new global::System.Diagnostics.Tracing.EventSource.EventData
    {
        //Use unsafe method because it is faster than fixed, and easily to generate
        DataPointer = (nint)global::System.Runtime.CompilerServices.Unsafe.AsPointer(ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(global::System.MemoryExtensions.AsSpan(address)),
        Size = (address.Length + 1) * sizeof(char)
    };
    datas[1] = new global::System.Diagnostics.Tracing.EventSource.EventData
    {
        DataPointer = (nint)(&usedTime),
        Size = sizeof(double)
    };
    WriteEventWithRelatedActivityIdCore(1, null, 2, datas);
    OnRaise(i, address);
}

[global::System.Diagnostics.Tracing.NonEventAttribute]
partial void OnRaise(int i, string address);

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 30, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Aug 30, 2024
@Cricle Cricle force-pushed the add-eventsource-event-method-gen branch from bcf9c9b to 0bc2122 Compare August 30, 2024 10:24
@jkotas jkotas added area-System.Diagnostics.Tracing and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Aug 30, 2024
Copy link
Contributor

Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti
See info in area-owners.md if you want to be subscribed.

@Cricle Cricle marked this pull request as ready for review September 4, 2024 01:23
@Cricle
Copy link
Author

Cricle commented Sep 4, 2024

But I don't how to start the generation test. ~

Please let me know if you need additional tests, or if you need to modify the way you test~

I think I found how to test this code.

@Cricle Cricle marked this pull request as ready for review September 28, 2024 08:16
@tommcdon
Copy link
Member

@noahfalk @tarekgh would you mind reviewing this PR?

@tarekgh tarekgh removed their assignment Oct 21, 2024
@tarekgh
Copy link
Member

tarekgh commented Oct 21, 2024

@tommcdon @Cricle this need to go through design review before accepting it. https://github.com/dotnet/runtime/blob/main/docs/project/api-review-process.md

@Cricle
Copy link
Author

Cricle commented Oct 21, 2024

@tommcdon @Cricle this need to go through design review before accepting it. https://github.com/dotnet/runtime/blob/main/docs/project/api-review-process.md

Would I need to create an 'API Proposal' issue link this PR?

@tarekgh
Copy link
Member

tarekgh commented Oct 21, 2024

@Cricle you may update #107069 and use it for the design review. I would suggest closing this PR till the design review is done because this will depend on when the design review will be scheduled. Thanks for your help here!

@Cricle
Copy link
Author

Cricle commented Oct 22, 2024

@tarekgh @tommcdon I has been update this issure #107069

@tarekgh
Copy link
Member

tarekgh commented Oct 22, 2024

I'll let @noahfalk look at the proposal and mark the issue as ready for review when it is ready. @Cricle do you mind closing this PR till the request get reviewed and approved?

@Cricle Cricle closed this Oct 22, 2024
@noahfalk
Copy link
Member

Thanks @Cricle - I wasn't able to get to this today but its on my todo list to look at tomorrow.

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.

6 participants