forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Diagnostics.Tracing ILLinkTrim entries
- Fix PropertyValue/ReferenceTypeHelper with a DynamicDependency - RuntimeEventSource doesn't need to be rooted. This class is used by IL and doesn't get trimmed. - EventPipe* and NativeRuntimeEventSource only need to be rooted in CoreCLR, since they aren't used in Mono. So they are moved to just CoreCLR's ILLinkTrim file. Contributes to dotnet#35199
- Loading branch information
Showing
5 changed files
with
104 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/libraries/System.Diagnostics.Tracing/tests/TrimmingTests/EventSourcePropertyValueTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Diagnostics.Tracing; | ||
|
||
/// <summary> | ||
/// Tests that using EventSource with a reference type EventData works on a | ||
/// trimmed application. | ||
/// See System.Diagnostics.Tracing.PropertyValue.GetReferenceTypePropertyGetter. | ||
/// </summary> | ||
internal class Program | ||
{ | ||
[EventData] | ||
private class TestData | ||
{ | ||
public int TestInt { get; set; } | ||
public TestSubData SubData { get; set; } | ||
} | ||
|
||
[EventData] | ||
private class TestSubData | ||
{ | ||
public int SubInt { get; set; } | ||
} | ||
|
||
[EventSource(Name = EventSourceName)] | ||
private class TestEventSource : EventSource | ||
{ | ||
public const string EventSourceName = "MyTest"; | ||
public static TestEventSource Log = new TestEventSource(); | ||
|
||
public TestEventSource() : base(EventSourceSettings.EtwSelfDescribingEventFormat) { } | ||
|
||
[Event(1)] | ||
public void LogData(TestData data) | ||
{ | ||
Write("LogData", data); | ||
} | ||
} | ||
|
||
private class TestEventListener : EventListener | ||
{ | ||
public ReadOnlyCollection<object> LogDataPayload { get; set; } | ||
|
||
protected override void OnEventSourceCreated(EventSource eventSource) | ||
{ | ||
if (eventSource.Name == TestEventSource.EventSourceName) | ||
{ | ||
EnableEvents(eventSource, EventLevel.Verbose); | ||
} | ||
|
||
base.OnEventSourceCreated(eventSource); | ||
} | ||
|
||
protected override void OnEventWritten(EventWrittenEventArgs eventData) | ||
{ | ||
if (eventData.EventName == "LogData") | ||
{ | ||
LogDataPayload = eventData.Payload; | ||
} | ||
|
||
base.OnEventWritten(eventData); | ||
} | ||
} | ||
|
||
public static int Main() | ||
{ | ||
using (var listener = new TestEventListener()) | ||
{ | ||
var testData = new TestData() | ||
{ | ||
TestInt = 5, | ||
SubData = new TestSubData() | ||
{ | ||
SubInt = 6 | ||
} | ||
}; | ||
TestEventSource.Log.LogData(testData); | ||
|
||
if (listener.LogDataPayload?.Count == 2 && | ||
(int)listener.LogDataPayload[0] == testData.TestInt && | ||
(int)((IDictionary<string, object>)listener.LogDataPayload[1])["SubInt"] == testData.SubData.SubInt) | ||
{ | ||
return 100; | ||
} | ||
|
||
return -1; | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...tem.Diagnostics.Tracing/tests/TrimmingTests/System.Diagnostics.Tracing.TrimmingTests.proj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project DefaultTargets="Build"> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" /> | ||
|
||
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters