Skip to content

Commit 548e8d7

Browse files
committed
sample EventSource test app
1 parent 4b9e103 commit 548e8d7

File tree

3 files changed

+48
-7
lines changed

3 files changed

+48
-7
lines changed
Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,52 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
5-
6-
class Program
4+
namespace EP_Target
75
{
8-
static void Main()
6+
using System;
7+
using System.Diagnostics.Tracing;
8+
using System.Threading;
9+
10+
public static class Program
11+
{
12+
public static void Main(string[] args)
13+
{
14+
Console.WriteLine("Waiting 10 seconds to client to get the PID");
15+
Thread.Sleep(10 * 1000);
16+
17+
TargetStartLogging();
18+
19+
Console.WriteLine("Done done!");
20+
}
21+
22+
private static void TargetStartLogging()
23+
{
24+
DemoEventSource.Log.AppStarted("Hello World From .NET!", 12);
25+
}
26+
}
27+
28+
[EventSource(Name = "Demo")]
29+
class DemoEventSource : EventSource
930
{
10-
Console.WriteLine("Hello world");
31+
public static DemoEventSource Log { get; } = new DemoEventSource();
32+
33+
[Event(1, Keywords = Keywords.Startup)]
34+
public void AppStarted(string message, int favoriteNumber) => WriteEvent(1, message, favoriteNumber);
35+
36+
[Event(2, Keywords = Keywords.Requests)]
37+
public void RequestStart(int requestId) => WriteEvent(2, requestId);
38+
39+
[Event(3, Keywords = Keywords.Requests)]
40+
public void RequestStop(int requestId) => WriteEvent(3, requestId);
41+
42+
[Event(4, Keywords = Keywords.Startup, Level = EventLevel.Verbose)]
43+
public void DebugMessage(string message) => WriteEvent(4, message);
44+
45+
46+
public class Keywords
47+
{
48+
public const EventKeywords Startup = (EventKeywords)0x0001;
49+
public const EventKeywords Requests = (EventKeywords)0x0002;
50+
}
1151
}
1252
}

src/coreclr/tools/aot/ILCompiler/repro/repro.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1212
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
1313
<RunAnalyzers>false</RunAnalyzers>
14+
<EventSourceSupport>true</EventSourceSupport>
1415
</PropertyGroup>
1516

1617
<Target Name="GenerateReproProjectResponseFile"
@@ -34,7 +35,7 @@
3435
<ReproResponseLines Include="--stacktracedata" />
3536
<ReproResponseLines Include="--scanreflection" />
3637
<ReproResponseLines Include="--feature:System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=false" />
37-
<ReproResponseLines Include="--feature:System.Diagnostics.Tracing.EventSource.IsSupported=false" />
38+
<ReproResponseLines Include="--feature:System.Diagnostics.Tracing.EventSource.IsSupported=true" />
3839
<ReproResponseLines Include="--feature:System.Resources.ResourceManager.AllowCustomResourceTypes=false" />
3940
<ReproResponseLines Include="--feature:System.Linq.Expressions.CanCompileToIL=false" />
4041
<ReproResponseLines Include="--feature:System.Linq.Expressions.CanEmitObjectArrayDelegate=false" />

src/coreclr/tools/aot/ILCompiler/reproNative/reproNative.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
<Link>
8282
<SubSystem>Console</SubSystem>
8383
<GenerateDebugInformation>true</GenerateDebugInformation>
84-
<AdditionalDependencies>$(ArtifactsRoot)bin\repro\x64\Debug\repro.obj;$(Win32SDKLibs);%(AdditionalDependencies);$(ArtifactsRoot)bin\coreclr\windows.x64.Debug\aotsdk\Runtime.WorkstationGC.lib;$(ArtifactsRoot)bin\coreclr\windows.x64.Debug\aotsdk\System.Globalization.Native.Aot.lib;$(ArtifactsRoot)bin\coreclr\windows.x64.Debug\aotsdk\System.IO.Compression.Native.Aot.lib</AdditionalDependencies>
84+
<AdditionalDependencies>$(ArtifactsRoot)bin\repro\x64\Debug\repro.obj;$(Win32SDKLibs);%(AdditionalDependencies);$(ArtifactsRoot)bin\coreclr\windows.x64.Debug\aotsdk\Runtime.WorkstationGC.lib;$(ArtifactsRoot)bin\coreclr\windows.x64.Debug\aotsdk\System.Globalization.Native.Aot.lib;$(ArtifactsRoot)bin\coreclr\windows.x64.Debug\aotsdk\System.IO.Compression.Native.Aot.lib;$(ArtifactsRoot)bin\coreclr\windows.x64.Debug\aotsdk\Aot.EventPipe.lib;</AdditionalDependencies>
8585
</Link>
8686
</ItemDefinitionGroup>
8787
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">

0 commit comments

Comments
 (0)