Open
Description
Background and motivation
According to eventsource-getting-started
Eventone must call like WriteEvent
or WriteEventCore
to write event.
But this is a regular code.
API Proposal
No any changed, but the partial base on EventSource
class, partial method and has EventAttribute
method will be generated.
API Usage
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];
fixed(char* addressPtr = address)
{
datas[0] = new global::System.Diagnostics.Tracing.EventSource.EventData
{
DataPointer = addressPtr,
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);
}
}
Alternative Designs
No
Risks
No