Skip to content

Introduce EventSource.IsSupported feature switch #38129

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

Merged
merged 5 commits into from
Jun 27, 2020
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
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>71b580038fb704df63e03c6b7ae7d2c6a4fdd71d</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="5.0.0-beta.20316.1">
<Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="5.0.0-beta.20325.16">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>71b580038fb704df63e03c6b7ae7d2c6a4fdd71d</Sha>
<Sha>b91c34a908efe4d95ac487a33b88521c76c6c3cf</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Feed" Version="5.0.0-beta.20316.1">
<Uri>https://github.com/dotnet/arcade</Uri>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<MicrosoftDotNetXUnitExtensionsVersion>5.0.0-beta.20316.1</MicrosoftDotNetXUnitExtensionsVersion>
<MicrosoftDotNetXUnitConsoleRunnerVersion>2.5.1-beta.20316.1</MicrosoftDotNetXUnitConsoleRunnerVersion>
<MicrosoftDotNetBuildTasksPackagingVersion>5.0.0-beta.20316.1</MicrosoftDotNetBuildTasksPackagingVersion>
<MicrosoftDotNetRemoteExecutorVersion>5.0.0-beta.20316.1</MicrosoftDotNetRemoteExecutorVersion>
<MicrosoftDotNetRemoteExecutorVersion>5.0.0-beta.20325.16</MicrosoftDotNetRemoteExecutorVersion>
<MicrosoftDotNetVersionToolsTasksVersion>5.0.0-beta.20316.1</MicrosoftDotNetVersionToolsTasksVersion>
<!-- Installer dependencies -->
<MicrosoftNETCoreAppVersion>5.0.0-preview.4.20202.18</MicrosoftNETCoreAppVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// 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 Xunit;
using SdtEventSources;
using Microsoft.DotNet.RemoteExecutor;
#if USE_MDT_EVENTSOURCE
using Microsoft.Diagnostics.Tracing;
#else
using System.Diagnostics.Tracing;
#endif

namespace BasicEventSourceTests
{
public class TestNotSupported
{
/// <summary>
/// Tests using EventSource when the System.Diagnostics.Tracing.EventSource.IsSupported
/// feature switch is set to disable all EventSource operations.
/// </summary>
[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
public void TestBasicOperations_IsSupported_False()
{
RemoteInvokeOptions options = new RemoteInvokeOptions();
options.RuntimeConfigurationOptions.Add("System.Diagnostics.Tracing.EventSource.IsSupported", false);

RemoteExecutor.Invoke(() =>
{
using (var log = new EventSourceTest())
{
using (var listener = new LoudListener(log))
{
IEnumerable<EventSource> sources = EventSource.GetSources();
Assert.Empty(sources);

Assert.Null(EventSource.GenerateManifest(typeof(SimpleEventSource), string.Empty, EventManifestOptions.OnlyIfNeededForRegistration));
Assert.Null(EventSource.GenerateManifest(typeof(EventSourceTest), string.Empty, EventManifestOptions.AllCultures));

log.Event0();
Assert.Null(LoudListener.LastEvent);

EventSource.SendCommand(log, EventCommand.Enable, commandArguments: null);
Assert.False(log.IsEnabled());
}
}
}, options).Dispose();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<Compile Include="BasicEventSourceTest\Harness\Listeners.cs" />
<Compile Include="BasicEventSourceTest\TestEventCounter.cs" />
<Compile Include="BasicEventSourceTest\TestFilter.cs" />
<Compile Include="BasicEventSourceTest\TestNotSupported.cs" />
<Compile Include="BasicEventSourceTest\TestShutdown.cs" />
<Compile Include="BasicEventSourceTest\TestsEventSourceLifetime.cs" />
<Compile Include="BasicEventSourceTest\TestsManifestGeneration.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<linker>
<assembly fullname="System.Private.CoreLib">
<type fullname="System.Diagnostics.Tracing.EventSource" feature="System.Diagnostics.Tracing.EventSource.IsSupported" featurevalue="false">
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
<method signature="System.Boolean IsEnabled()" body="stub" value="false" />
<method signature="System.Boolean IsEnabled(System.Diagnostics.Tracing.EventLevel,System.Diagnostics.Tracing.EventKeywords)" body="stub" value="false" />
<method signature="System.Boolean IsEnabled(System.Diagnostics.Tracing.EventLevel,System.Diagnostics.Tracing.EventKeywords,System.Diagnostics.Tracing.EventChannel)" body="stub" value="false" />
</type>
<type fullname="System.Globalization.GlobalizationMode">
<method signature="System.Boolean get_Invariant()" body="stub" value="true" feature="System.Globalization.Invariant" featurevalue="true" />
</type>
Expand Down
Loading