Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Remove FEATURE_ETLEVENTS conditional compilation #30071

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,8 @@ public enum EventLevel
}
public abstract partial class EventListener : System.IDisposable
{
#if FEATURE_ETLEVENTS
public event EventHandler<EventSourceCreatedEventArgs> EventSourceCreated;
public event EventHandler<EventWrittenEventArgs> EventWritten;
#endif
protected EventListener() { }
public void DisableEvents(System.Diagnostics.Tracing.EventSource eventSource) { }
public virtual void Dispose() { }
Expand All @@ -129,11 +127,7 @@ public void EnableEvents(System.Diagnostics.Tracing.EventSource eventSource, Sys
public void EnableEvents(System.Diagnostics.Tracing.EventSource eventSource, System.Diagnostics.Tracing.EventLevel level, System.Diagnostics.Tracing.EventKeywords matchAnyKeyword, System.Collections.Generic.IDictionary<string, string> arguments) { }
protected static int EventSourceIndex(System.Diagnostics.Tracing.EventSource eventSource) { throw null; }
protected internal virtual void OnEventSourceCreated(System.Diagnostics.Tracing.EventSource eventSource) { }
#if FEATURE_ETLEVENTS
protected internal virtual void OnEventWritten(System.Diagnostics.Tracing.EventWrittenEventArgs eventData) { }
#else
protected internal abstract void OnEventWritten(System.Diagnostics.Tracing.EventWrittenEventArgs eventData);
#endif
}
[System.FlagsAttribute]
public enum EventManifestOptions
Expand Down Expand Up @@ -235,13 +229,11 @@ public EventSourceAttribute() { }
public string LocalizationResources { get { throw null; } set { } }
public string Name { get { throw null; } set { } }
}
#if FEATURE_ETLEVENTS
public class EventSourceCreatedEventArgs : EventArgs
{
public EventSourceCreatedEventArgs() { }
public EventSource EventSource { get; }
}
#endif
public partial class EventSourceException : System.Exception
{
public EventSourceException() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProjectGuid>{0D8C8BAE-E5A5-4E9F-B101-3D18BD81D261}</ProjectGuid>
<IsPartialFacadeAssembly Condition="'$(TargetGroup)' == 'netfx'">true</IsPartialFacadeAssembly>
<DefineConstants Condition="'$(TargetGroup)' == 'netcoreapp'">$(DefineConstants);FEATURE_ETLEVENTS</DefineConstants>
<!-- CS0067: unused event, reference assembly does not care -->
<NoWarn>$(NoWarn);0067</NoWarn>
</PropertyGroup>
Expand All @@ -16,11 +14,8 @@
<ItemGroup>
<Compile Include="System.Diagnostics.Tracing.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<ItemGroup>
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<Reference Include="mscorlib" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
<AssemblyName>System.Diagnostics.Tracing</AssemblyName>
<ProjectGuid>{EB880FDC-326D-42B3-A3FD-0CD3BA29A7F4}</ProjectGuid>
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<!-- CSC adds a typeforward for the internal nested type EventSource.EventMetadata but
GenFacades doesn't consider this as a viable target for a typeforward since it's internal -->
<GenFacadesIgnoreMissingTypes Condition="'$(TargetGroup)' == 'netfx'">true</GenFacadesIgnoreMissingTypes>
<DefineConstants Condition="'$(TargetGroup)' == 'netfx'">$(DefineConstants);NO_EVENTCOMMANDEXECUTED_SUPPORT</DefineConstants>
</PropertyGroup>
<!-- Default configurations to help VS understand the options -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Unix-Debug|AnyCPU'" />
Expand All @@ -23,12 +19,8 @@
<Compile Include="FxCopBaseline.cs" />
<Compile Include="System\Diagnostics\Tracing\EventCounter.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<ItemGroup>
<ReferenceFromRuntime Include="System.Private.CoreLib" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<Reference Include="mscorlib" />
<Reference Include="System" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -292,24 +292,7 @@ internal void Remove(EventCounter eventCounter)

private void RegisterCommandCallback()
{
// Old destktop runtimes don't have this
#if NO_EVENTCOMMANDEXECUTED_SUPPORT
// We could not build against the API that had the EventCommandExecuted but maybe it is there are runtime.
// use reflection to try to get it.
System.Reflection.MethodInfo method = typeof(EventSource).GetMethod("add_EventCommandExecuted");
if (method != null)
{
method.Invoke(_eventSource, new object[] { (EventHandler<EventCommandEventArgs>)OnEventSourceCommand });
}
else
{
string msg = "EventCounterError: Old Runtime that does not support EventSource.EventCommandExecuted. EventCounters not Supported";
_eventSource.Write(msg);
Debug.WriteLine(msg);
}
#else
_eventSource.EventCommandExecuted += OnEventSourceCommand;
#endif
}

private void OnEventSourceCommand(object sender, EventCommandEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ public class EventListenerListener : Listener
private EventListener _listener;
private Action<EventSource> _onEventSourceCreated;

#if FEATURE_ETLEVENTS
public event EventHandler<EventSourceCreatedEventArgs> EventSourceCreated
{
add
Expand Down Expand Up @@ -331,11 +330,9 @@ public event EventHandler<EventWrittenEventArgs> EventWritten
this._listener.EventWritten -= value;
}
}
#endif

public EventListenerListener(bool useEventsToListen = false)
{
#if FEATURE_ETLEVENTS
if (useEventsToListen)
{
_listener = new HelperEventListener(null);
Expand All @@ -344,7 +341,6 @@ public EventListenerListener(bool useEventsToListen = false)
_listener.EventWritten += mListenerEventWritten;
}
else
#endif
{
_listener = new HelperEventListener(this);
}
Expand Down Expand Up @@ -421,10 +417,8 @@ protected override void OnEventSourceCreated(EventSource eventSource)

protected override void OnEventWritten(EventWrittenEventArgs eventData)
{
#if FEATURE_ETLEVENTS
// OnEventWritten is abstract in netfx <= 461
base.OnEventWritten(eventData);
#endif
_forwardTo?.OnEvent?.Invoke(new EventListenerEvent(eventData));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ private void Test_Write_Metric(Listener listener)


/*************************************************************************/
#if FEATURE_EVENTCOUNTER_DISPOSE
tests.Add(new SubTest("EventCounter: Dispose()",
delegate ()
{
Expand All @@ -278,7 +277,6 @@ private void Test_Write_Metric(Listener listener)
ValidateSingleEventCounter(evts[3], "Request", 0, 0, 0, float.PositiveInfinity, float.NegativeInfinity);
ValidateSingleEventCounter(evts[4], "Error", 0, 0, 0, float.PositiveInfinity, float.NegativeInfinity);
}));
#endif
/*************************************************************************/
EventTestHarness.RunTests(tests, listener, logger);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ public void Test_WriteEvent_ZeroKwds()
TestUtilities.CheckNoEventSourcesRunning("Stop");
}

#if FEATURE_ETLEVENTS
[Fact]
public void Test_EventSourceCreatedEvents_BeforeListener()
{
Expand Down Expand Up @@ -483,6 +482,5 @@ public void Test_EventSourceCreatedEvents_AfterListener()

TestUtilities.CheckNoEventSourcesRunning("Stop");
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{7E0E1B11-FF70-461E-99F7-C0AF252C0C60}</ProjectGuid>
<DefineConstants Condition="'$(TargetGroup)' == 'netcoreapp'">$(DefineConstants);FEATURE_ETLEVENTS</DefineConstants>
<DefineConstants Condition="'$(TargetGroup)' == 'netcoreapp'">$(DefineConstants);FEATURE_EVENTCOUNTER_DISPOSE</DefineConstants>
<DefineConstants Condition="'$(TargetGroup)' == 'netcoreapp' And '$(TargetsWindows)' == 'true'">$(DefineConstants);USE_ETW</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down