From 9a12085ef95bc5d9ab4f78aa3c2e5ab88f927816 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 8 Oct 2015 11:17:14 -0700 Subject: [PATCH] Suppress [Obsolete] warnings for TelemetrySource --- NuGet.config | 2 +- .../Internal/HostingEngine.cs | 12 ++++++++---- src/Microsoft.AspNet.Hosting/WebHostBuilder.cs | 2 ++ .../TestServerTests.cs | 2 ++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/NuGet.config b/NuGet.config index 1707938c61..03704957e8 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,4 +1,4 @@ - + diff --git a/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs b/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs index 55b4170469..d0a951849d 100644 --- a/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs +++ b/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs @@ -88,7 +88,9 @@ namespace Microsoft.AspNet.Hosting.Internal var logger = _applicationServices.GetRequiredService>(); var contextFactory = _applicationServices.GetRequiredService(); var contextAccessor = _applicationServices.GetRequiredService(); +#pragma warning disable 0618 var telemetrySource = _applicationServices.GetRequiredService(); +#pragma warning restore 0618 var server = ServerFactory.Start(_serverInstance, async features => { @@ -96,12 +98,12 @@ namespace Microsoft.AspNet.Hosting.Internal httpContext.ApplicationServices = _applicationServices; var requestIdentifier = GetRequestIdentifier(httpContext); contextAccessor.HttpContext = httpContext; - +#pragma warning disable 0618 if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.BeginRequest")) { telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.BeginRequest", new { httpContext = httpContext }); } - +#pragma warning restore 0618 try { using (logger.IsEnabled(LogLevel.Critical) @@ -113,18 +115,20 @@ namespace Microsoft.AspNet.Hosting.Internal } catch (Exception ex) { +#pragma warning disable 0618 if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.UnhandledException")) { telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.UnhandledException", new { httpContext = httpContext, exception = ex }); } - +#pragma warning restore 0618 throw; } - +#pragma warning disable 0618 if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.EndRequest")) { telemetrySource.WriteTelemetry("Microsoft.AspNet.Hosting.EndRequest", new { httpContext = httpContext }); } +#pragma warning restore 0618 }); _applicationLifetime.NotifyStarted(); diff --git a/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs b/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs index 2e969d90cc..e3ae6b3517 100644 --- a/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs +++ b/src/Microsoft.AspNet.Hosting/WebHostBuilder.cs @@ -99,9 +99,11 @@ namespace Microsoft.AspNet.Hosting services.AddSingleton(); services.AddLogging(); +#pragma warning disable 0618 var telemetrySource = new TelemetryListener("Microsoft.AspNet"); services.AddInstance(telemetrySource); services.AddInstance(telemetrySource); +#pragma warning restore 0618 // Conjure up a RequestServices services.AddTransient(); diff --git a/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs b/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs index 58d8e09699..9bb5cdd9e6 100644 --- a/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs +++ b/test/Microsoft.AspNet.TestHost.Tests/TestServerTests.cs @@ -437,6 +437,7 @@ namespace Microsoft.AspNet.TestHost Assert.Equal("FoundFoo:False", await result.Content.ReadAsStringAsync()); } +#pragma warning disable 0618 [Fact] public async Task BeginEndTelemetryAvailable() { @@ -480,6 +481,7 @@ namespace Microsoft.AspNet.TestHost Assert.NotNull(listener.UnhandledException?.HttpContext); Assert.NotNull(listener.UnhandledException?.Exception); } +#pragma warning restore 0618 public class TestTelemetryListener {