diff --git a/src/Microsoft.AspNet.Mvc.Core/Controllers/ControllerActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/Controllers/ControllerActionInvoker.cs index 53cef6c952..a07e109f7f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Controllers/ControllerActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Controllers/ControllerActionInvoker.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.Controllers private readonly ControllerActionDescriptor _descriptor; private readonly IControllerFactory _controllerFactory; private readonly IControllerActionArgumentBinder _argumentBinder; - +#pragma warning disable 0618 public ControllerActionInvoker( ActionContext actionContext, IReadOnlyList filterProviders, @@ -129,6 +129,7 @@ namespace Microsoft.AspNet.Mvc.Controllers "descriptor"); } } +#pragma warning disable 0618 protected override object CreateInstance() { diff --git a/src/Microsoft.AspNet.Mvc.Core/Controllers/ControllerActionInvokerProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Controllers/ControllerActionInvokerProvider.cs index b5ac119b14..4104725bbb 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Controllers/ControllerActionInvokerProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Controllers/ControllerActionInvokerProvider.cs @@ -18,6 +18,7 @@ namespace Microsoft.AspNet.Mvc.Controllers { public class ControllerActionInvokerProvider : IActionInvokerProvider { +#pragma warning disable 0618 private readonly IControllerActionArgumentBinder _argumentBinder; private readonly IControllerFactory _controllerFactory; private readonly IFilterProvider[] _filterProviders; @@ -53,6 +54,7 @@ namespace Microsoft.AspNet.Mvc.Controllers _logger = loggerFactory.CreateLogger(); _telemetry = telemetry; } +#pragma warning restore 0618 public int Order { diff --git a/src/Microsoft.AspNet.Mvc.Core/Controllers/FilterActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/Controllers/FilterActionInvoker.cs index 13b4159b62..036b681162 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Controllers/FilterActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Controllers/FilterActionInvoker.cs @@ -31,7 +31,9 @@ namespace Microsoft.AspNet.Mvc.Controllers private readonly IReadOnlyList _valueProviderFactories; private readonly IActionBindingContextAccessor _actionBindingContextAccessor; private readonly ILogger _logger; +#pragma warning disable 0618 private readonly TelemetrySource _telemetry; +#pragma warning restore 0618 private readonly int _maxModelValidationErrors; private IFilterMetadata[] _filters; @@ -61,6 +63,7 @@ namespace Microsoft.AspNet.Mvc.Controllers private const string ResultFilterShortCircuitLogMessage = "Request was short circuited at result filter '{ResultFilter}'."; +#pragma warning disable 0618 public FilterActionInvoker( ActionContext actionContext, IReadOnlyList filterProviders, @@ -137,6 +140,7 @@ namespace Microsoft.AspNet.Mvc.Controllers _telemetry = telemetry; _maxModelValidationErrors = maxModelValidationErrors; } +#pragma warning restore 0618 protected ActionContext ActionContext { get; private set; } @@ -652,6 +656,7 @@ namespace Microsoft.AspNet.Mvc.Controllers try { +#pragma warning disable 0618 if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionMethod")) { _telemetry.WriteTelemetry( @@ -663,11 +668,13 @@ namespace Microsoft.AspNet.Mvc.Controllers controller = _actionExecutingContext.Controller }); } +#pragma warning restore 0618 result = await InvokeActionAsync(_actionExecutingContext); } finally { +#pragma warning disable 0618 if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionMethod")) { _telemetry.WriteTelemetry( @@ -680,6 +687,7 @@ namespace Microsoft.AspNet.Mvc.Controllers result = result }); } +#pragma warning restore 0618 } _actionExecutedContext = new ActionExecutedContext( @@ -827,12 +835,14 @@ namespace Microsoft.AspNet.Mvc.Controllers private async Task InvokeResultAsync(IActionResult result) { +#pragma warning disable 0618 if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionResult")) { _telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.BeforeActionResult", new { actionContext = ActionContext, result = result }); } +#pragma warning restore 0618 try { @@ -840,12 +850,14 @@ namespace Microsoft.AspNet.Mvc.Controllers } finally { +#pragma warning disable 0618 if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionResult")) { _telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.AfterActionResult", new { actionContext = ActionContext, result = result }); } +#pragma warning restore 0618 } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Infrastructure/MvcRouteHandler.cs b/src/Microsoft.AspNet.Mvc.Core/Infrastructure/MvcRouteHandler.cs index d6c3275620..ee0cf5e79c 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Infrastructure/MvcRouteHandler.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Infrastructure/MvcRouteHandler.cs @@ -20,7 +20,9 @@ namespace Microsoft.AspNet.Mvc.Infrastructure private IActionInvokerFactory _actionInvokerFactory; private IActionSelector _actionSelector; private ILogger _logger; +#pragma warning disable 0618 private TelemetrySource _telemetry; +#pragma warning restore 0618 public VirtualPathData GetVirtualPath(VirtualPathContext context) { @@ -80,12 +82,14 @@ namespace Microsoft.AspNet.Mvc.Infrastructure { context.RouteData = newRouteData; +#pragma warning disable 0618 if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeAction")) { _telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.BeforeAction", new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData }); } +#pragma warning restore 0618 using (_logger.BeginScope("ActionId: {ActionId}", actionDescriptor.Id)) { @@ -97,12 +101,14 @@ namespace Microsoft.AspNet.Mvc.Infrastructure } finally { +#pragma warning disable 0618 if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterAction")) { _telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.AfterAction", new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData }); } +#pragma warning restore 0618 if (!context.IsHandled) { @@ -150,10 +156,12 @@ namespace Microsoft.AspNet.Mvc.Infrastructure _logger = factory.CreateLogger(); } +#pragma warning disable 0618 if (_telemetry == null) { _telemetry = context.RequestServices.GetRequiredService(); } +#pragma warning restore 0618 } } } diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/PartialViewResultExecutor.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/PartialViewResultExecutor.cs index 702d2382ad..9298d4523a 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/PartialViewResultExecutor.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/PartialViewResultExecutor.cs @@ -16,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures /// public class PartialViewResultExecutor : ViewExecutor { +#pragma warning disable 0618 /// /// Creates a new . /// @@ -39,6 +40,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures Logger = loggerFactory.CreateLogger(); } +#pragma warning restore 0618 /// /// Gets the . @@ -69,6 +71,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures var result = viewEngine.FindPartialView(actionContext, viewName); if (result.Success) { +#pragma warning disable 0618 if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewFound")) { Telemetry.WriteTelemetry( @@ -82,11 +85,12 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures view = result.View, }); } - +#pragma warning restore 0618 Logger.LogVerbose("The partial view '{PartialViewName}' was found.", viewName); } else { +#pragma warning disable 0618 if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound")) { Telemetry.WriteTelemetry( @@ -100,6 +104,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures searchedLocations = result.SearchedLocations }); } +#pragma warning restore 0618 Logger.LogError( "The partial view '{PartialViewName}' was not found. Searched locations: {SearchedViewLocations}", diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/ViewExecutor.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/ViewExecutor.cs index e796d9c179..1da471999e 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/ViewExecutor.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/ViewExecutor.cs @@ -26,6 +26,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures Encoding = Encoding.UTF8 }.CopyAsReadOnly(); +#pragma warning disable 0618 /// /// Creates a new . /// @@ -69,6 +70,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures /// Gets the . /// protected TelemetrySource Telemetry { get; } +#pragma warning restore 0618 /// /// Gets the default . @@ -158,21 +160,25 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures writer, ViewOptions.HtmlHelperOptions); +#pragma warning disable 0618 if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeView")) { Telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.BeforeView", new { view = view, viewContext = viewContext, }); } +#pragma warning restore 0618 await view.RenderAsync(viewContext); +#pragma warning disable 0618 if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterView")) { Telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.AfterView", new { view = view, viewContext = viewContext, }); } +#pragma warning restore 0618 // Perf: Invoke FlushAsync to ensure any buffered content is asynchronously written to the underlying // response asynchronously. In the absence of this line, the buffer gets synchronously written to the diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/ViewResultExecutor.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/ViewResultExecutor.cs index 7d9e390d1e..b64edcb02f 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/ViewResultExecutor.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/ViewResultExecutor.cs @@ -16,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures /// public class ViewResultExecutor : ViewExecutor { +#pragma warning disable 0618 /// /// Creates a new . /// @@ -39,6 +40,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures Logger = loggerFactory.CreateLogger(); } +#pragma warning restore 0618 /// /// Gets the . @@ -69,6 +71,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures var result = viewEngine.FindView(actionContext, viewName); if (result.Success) { +#pragma warning disable 0618 if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewFound")) { Telemetry.WriteTelemetry( @@ -82,11 +85,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures view = result.View, }); } +#pragma warning restore 0618 Logger.LogVerbose("The view '{ViewName}' was found.", viewName); } else { +#pragma warning disable 0618 if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound")) { Telemetry.WriteTelemetry( @@ -100,6 +105,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures searchedLocations = result.SearchedLocations }); } +#pragma warning restore 0618 Logger.LogError( "The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}", diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionInvokerTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionInvokerTest.cs index b2ea998636..8c2bc64d37 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionInvokerTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionInvokerTest.cs @@ -2041,7 +2041,7 @@ namespace Microsoft.AspNet.Mvc.Controllers filterProvider .SetupGet(fp => fp.Order) .Returns(-1000); - +#pragma warning disable 0618 var invoker = new TestControllerActionInvoker( actionContext, new[] { filterProvider.Object }, @@ -2057,7 +2057,7 @@ namespace Microsoft.AspNet.Mvc.Controllers new NullLoggerFactory().CreateLogger(), new TelemetryListener("Microsoft.AspNet"), maxAllowedErrorsInModelState); - +#pragma warning restore 0618 return invoker; } @@ -2101,6 +2101,7 @@ namespace Microsoft.AspNet.Mvc.Controllers .Returns(new TestController()); var metadataProvider = new EmptyModelMetadataProvider(); +#pragma warning disable 0618 var invoker = new ControllerActionInvoker( actionContext, new List(), @@ -2118,6 +2119,7 @@ namespace Microsoft.AspNet.Mvc.Controllers new NullLoggerFactory().CreateLogger(), new TelemetryListener("Microsoft.AspNet"), 200); +#pragma warning restore 0618 // Act await invoker.InvokeAsync(); @@ -2204,6 +2206,7 @@ namespace Microsoft.AspNet.Mvc.Controllers private class TestControllerActionInvoker : ControllerActionInvoker { +#pragma warning disable 0618 public TestControllerActionInvoker( ActionContext actionContext, IFilterProvider[] filterProvider, @@ -2237,6 +2240,7 @@ namespace Microsoft.AspNet.Mvc.Controllers { ControllerFactory = controllerFactory; } +#pragma warning restore 0618 public MockControllerFactory ControllerFactory { get; } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Infrastructure/MvcRouteHandlerTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Infrastructure/MvcRouteHandlerTests.cs index cc23b6253e..1d770264ee 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Infrastructure/MvcRouteHandlerTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Infrastructure/MvcRouteHandlerTests.cs @@ -242,13 +242,13 @@ namespace Microsoft.AspNet.Mvc.Infrastructure { optionsAccessor = new TestOptionsManager(); } - +#pragma warning disable 0618 var telemetry = new TelemetryListener("Microsoft.AspNet"); if (telemetryListener != null) { telemetry.SubscribeWithAdapter(telemetryListener); } - +#pragma warning restore 0618 var httpContext = new Mock(); httpContext.Setup(h => h.RequestServices.GetService(typeof(IActionContextAccessor))) .Returns(new ActionContextAccessor()); @@ -262,9 +262,10 @@ namespace Microsoft.AspNet.Mvc.Infrastructure .Returns(new MvcMarkerService()); httpContext.Setup(h => h.RequestServices.GetService(typeof(IOptions))) .Returns(optionsAccessor); +#pragma warning disable 0618 httpContext.Setup(h => h.RequestServices.GetService(typeof(TelemetrySource))) .Returns(telemetry); - +#pragma warning restore 0618 return new RouteContext(httpContext.Object); } } diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/PartialViewResultTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/PartialViewResultTest.cs index 4bd57960fc..ff614e3464 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/PartialViewResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/PartialViewResultTest.cs @@ -105,12 +105,14 @@ namespace Microsoft.AspNet.Mvc private HttpContext GetHttpContext() { var options = new TestOptionsManager(); +#pragma warning disable 0618 var viewExecutor = new PartialViewResultExecutor( options, new TestHttpResponseStreamWriterFactory(), new CompositeViewEngine(options), new TelemetryListener("Microsoft.AspNet"), NullLoggerFactory.Instance); +#pragma warning restore 0618 var services = new ServiceCollection(); services.AddInstance(viewExecutor); diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/PartialViewResultExecutorTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/PartialViewResultExecutorTest.cs index 81bc6aaf7a..f19ae1e77f 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/PartialViewResultExecutorTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/PartialViewResultExecutorTest.cs @@ -71,6 +71,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures Assert.Equal(viewName, viewEngineResult.ViewName); } +#pragma warning disable 0618 [Fact] public void FindView_Notifies_ViewFound() { @@ -141,6 +142,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures Assert.Equal(new string[] { "location/myview" }, listener.ViewNotFound.SearchedLocations); Assert.Equal("myview", listener.ViewNotFound.ViewName); } +#pragma warning restore 0618 [Fact] public async Task ExecuteAsync_UsesContentType_FromPartialViewResult() @@ -200,6 +202,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor()); } +#pragma warning disable 0618 private PartialViewResultExecutor GetViewExecutor(TelemetrySource telemetry = null) { if (telemetry == null) @@ -224,6 +227,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures return viewExecutor; } +#pragma warning restore 0618 } } #endif diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewExecutorTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewExecutorTest.cs index 20476efbd3..0f4efa6fe8 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewExecutorTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewExecutorTest.cs @@ -146,7 +146,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures Assert.Equal(500, context.Response.StatusCode); Assert.Equal("abcd", Encoding.UTF8.GetString(memoryStream.ToArray())); } - +#pragma warning disable 0618 [Fact] public async Task ExecuteAsync_WritesTelemetry() { @@ -190,7 +190,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures Assert.NotNull(adapter.AfterView?.View); Assert.NotNull(adapter.AfterView?.ViewContext); } - +#pragma warning restore 0618 [Fact] public async Task ExecuteAsync_DoesNotWriteToResponse_OnceExceptionIsThrown() { @@ -277,7 +277,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures return view.Object; } - +#pragma warning disable 0618 private ViewExecutor CreateViewExecutor(TelemetryListener listener = null) { if (listener == null) @@ -291,6 +291,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures new Mock(MockBehavior.Strict).Object, listener); } +#pragma warning restore 0618 } } #endif \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewResultExecutorTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewResultExecutorTest.cs index f07aa3676e..7628156025 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewResultExecutorTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewResultExecutorTest.cs @@ -71,6 +71,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures Assert.Equal(viewName, viewEngineResult.ViewName); } +#pragma warning disable 0618 [Fact] public void FindView_Notifies_ViewFound() { @@ -141,6 +142,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures Assert.Equal(new string[] { "location/myview" }, listener.ViewNotFound.SearchedLocations); Assert.Equal("myview", listener.ViewNotFound.ViewName); } +#pragma warning restore 0618 [Fact] public async Task ExecuteAsync_UsesContentType_FromViewResult() @@ -200,6 +202,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor()); } +#pragma warning disable 0618 private ViewResultExecutor GetViewExecutor(TelemetrySource telemetry = null) { if (telemetry == null) @@ -224,6 +227,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures return viewExecutor; } +#pragma warning restore 0618 } } #endif diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewResultTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewResultTest.cs index fb0a3ccb09..3fca82ee03 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewResultTest.cs @@ -105,12 +105,14 @@ namespace Microsoft.AspNet.Mvc private HttpContext GetHttpContext() { var options = new TestOptionsManager(); +#pragma warning disable 0618 var viewExecutor = new ViewResultExecutor( options, new TestHttpResponseStreamWriterFactory(), new CompositeViewEngine(options), new TelemetryListener("Microsoft.AspNet"), NullLoggerFactory.Instance); +#pragma warning restore 0618 var services = new ServiceCollection(); services.AddInstance(viewExecutor);