Suppress [Obsolete] warnings from DiagnosticSource

This commit is contained in:
Ryan Nowak 2015-10-08 12:47:08 -07:00
parent 91cb6281e4
commit 9342cb0ab7
14 changed files with 68 additions and 10 deletions

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
private readonly ControllerActionDescriptor _descriptor; private readonly ControllerActionDescriptor _descriptor;
private readonly IControllerFactory _controllerFactory; private readonly IControllerFactory _controllerFactory;
private readonly IControllerActionArgumentBinder _argumentBinder; private readonly IControllerActionArgumentBinder _argumentBinder;
#pragma warning disable 0618
public ControllerActionInvoker( public ControllerActionInvoker(
ActionContext actionContext, ActionContext actionContext,
IReadOnlyList<IFilterProvider> filterProviders, IReadOnlyList<IFilterProvider> filterProviders,
@ -129,6 +129,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
"descriptor"); "descriptor");
} }
} }
#pragma warning disable 0618
protected override object CreateInstance() protected override object CreateInstance()
{ {

View File

@ -18,6 +18,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
{ {
public class ControllerActionInvokerProvider : IActionInvokerProvider public class ControllerActionInvokerProvider : IActionInvokerProvider
{ {
#pragma warning disable 0618
private readonly IControllerActionArgumentBinder _argumentBinder; private readonly IControllerActionArgumentBinder _argumentBinder;
private readonly IControllerFactory _controllerFactory; private readonly IControllerFactory _controllerFactory;
private readonly IFilterProvider[] _filterProviders; private readonly IFilterProvider[] _filterProviders;
@ -53,6 +54,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
_logger = loggerFactory.CreateLogger<ControllerActionInvoker>(); _logger = loggerFactory.CreateLogger<ControllerActionInvoker>();
_telemetry = telemetry; _telemetry = telemetry;
} }
#pragma warning restore 0618
public int Order public int Order
{ {

View File

@ -31,7 +31,9 @@ namespace Microsoft.AspNet.Mvc.Controllers
private readonly IReadOnlyList<IValueProviderFactory> _valueProviderFactories; private readonly IReadOnlyList<IValueProviderFactory> _valueProviderFactories;
private readonly IActionBindingContextAccessor _actionBindingContextAccessor; private readonly IActionBindingContextAccessor _actionBindingContextAccessor;
private readonly ILogger _logger; private readonly ILogger _logger;
#pragma warning disable 0618
private readonly TelemetrySource _telemetry; private readonly TelemetrySource _telemetry;
#pragma warning restore 0618
private readonly int _maxModelValidationErrors; private readonly int _maxModelValidationErrors;
private IFilterMetadata[] _filters; private IFilterMetadata[] _filters;
@ -61,6 +63,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
private const string ResultFilterShortCircuitLogMessage = private const string ResultFilterShortCircuitLogMessage =
"Request was short circuited at result filter '{ResultFilter}'."; "Request was short circuited at result filter '{ResultFilter}'.";
#pragma warning disable 0618
public FilterActionInvoker( public FilterActionInvoker(
ActionContext actionContext, ActionContext actionContext,
IReadOnlyList<IFilterProvider> filterProviders, IReadOnlyList<IFilterProvider> filterProviders,
@ -137,6 +140,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
_telemetry = telemetry; _telemetry = telemetry;
_maxModelValidationErrors = maxModelValidationErrors; _maxModelValidationErrors = maxModelValidationErrors;
} }
#pragma warning restore 0618
protected ActionContext ActionContext { get; private set; } protected ActionContext ActionContext { get; private set; }
@ -652,6 +656,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
try try
{ {
#pragma warning disable 0618
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionMethod")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionMethod"))
{ {
_telemetry.WriteTelemetry( _telemetry.WriteTelemetry(
@ -663,11 +668,13 @@ namespace Microsoft.AspNet.Mvc.Controllers
controller = _actionExecutingContext.Controller controller = _actionExecutingContext.Controller
}); });
} }
#pragma warning restore 0618
result = await InvokeActionAsync(_actionExecutingContext); result = await InvokeActionAsync(_actionExecutingContext);
} }
finally finally
{ {
#pragma warning disable 0618
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionMethod")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionMethod"))
{ {
_telemetry.WriteTelemetry( _telemetry.WriteTelemetry(
@ -680,6 +687,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
result = result result = result
}); });
} }
#pragma warning restore 0618
} }
_actionExecutedContext = new ActionExecutedContext( _actionExecutedContext = new ActionExecutedContext(
@ -827,12 +835,14 @@ namespace Microsoft.AspNet.Mvc.Controllers
private async Task InvokeResultAsync(IActionResult result) private async Task InvokeResultAsync(IActionResult result)
{ {
#pragma warning disable 0618
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionResult")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionResult"))
{ {
_telemetry.WriteTelemetry( _telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.BeforeActionResult", "Microsoft.AspNet.Mvc.BeforeActionResult",
new { actionContext = ActionContext, result = result }); new { actionContext = ActionContext, result = result });
} }
#pragma warning restore 0618
try try
{ {
@ -840,12 +850,14 @@ namespace Microsoft.AspNet.Mvc.Controllers
} }
finally finally
{ {
#pragma warning disable 0618
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionResult")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionResult"))
{ {
_telemetry.WriteTelemetry( _telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.AfterActionResult", "Microsoft.AspNet.Mvc.AfterActionResult",
new { actionContext = ActionContext, result = result }); new { actionContext = ActionContext, result = result });
} }
#pragma warning restore 0618
} }
} }

View File

@ -20,7 +20,9 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
private IActionInvokerFactory _actionInvokerFactory; private IActionInvokerFactory _actionInvokerFactory;
private IActionSelector _actionSelector; private IActionSelector _actionSelector;
private ILogger _logger; private ILogger _logger;
#pragma warning disable 0618
private TelemetrySource _telemetry; private TelemetrySource _telemetry;
#pragma warning restore 0618
public VirtualPathData GetVirtualPath(VirtualPathContext context) public VirtualPathData GetVirtualPath(VirtualPathContext context)
{ {
@ -80,12 +82,14 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
{ {
context.RouteData = newRouteData; context.RouteData = newRouteData;
#pragma warning disable 0618
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeAction")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeAction"))
{ {
_telemetry.WriteTelemetry( _telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.BeforeAction", "Microsoft.AspNet.Mvc.BeforeAction",
new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData }); new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData });
} }
#pragma warning restore 0618
using (_logger.BeginScope("ActionId: {ActionId}", actionDescriptor.Id)) using (_logger.BeginScope("ActionId: {ActionId}", actionDescriptor.Id))
{ {
@ -97,12 +101,14 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
} }
finally finally
{ {
#pragma warning disable 0618
if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterAction")) if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterAction"))
{ {
_telemetry.WriteTelemetry( _telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.AfterAction", "Microsoft.AspNet.Mvc.AfterAction",
new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData }); new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData });
} }
#pragma warning restore 0618
if (!context.IsHandled) if (!context.IsHandled)
{ {
@ -150,10 +156,12 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
_logger = factory.CreateLogger<MvcRouteHandler>(); _logger = factory.CreateLogger<MvcRouteHandler>();
} }
#pragma warning disable 0618
if (_telemetry == null) if (_telemetry == null)
{ {
_telemetry = context.RequestServices.GetRequiredService<TelemetrySource>(); _telemetry = context.RequestServices.GetRequiredService<TelemetrySource>();
} }
#pragma warning restore 0618
} }
} }
} }

View File

@ -16,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
/// </summary> /// </summary>
public class PartialViewResultExecutor : ViewExecutor public class PartialViewResultExecutor : ViewExecutor
{ {
#pragma warning disable 0618
/// <summary> /// <summary>
/// Creates a new <see cref="PartialViewResultExecutor"/>. /// Creates a new <see cref="PartialViewResultExecutor"/>.
/// </summary> /// </summary>
@ -39,6 +40,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
Logger = loggerFactory.CreateLogger<PartialViewResultExecutor>(); Logger = loggerFactory.CreateLogger<PartialViewResultExecutor>();
} }
#pragma warning restore 0618
/// <summary> /// <summary>
/// Gets the <see cref="ILogger"/>. /// Gets the <see cref="ILogger"/>.
@ -69,6 +71,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
var result = viewEngine.FindPartialView(actionContext, viewName); var result = viewEngine.FindPartialView(actionContext, viewName);
if (result.Success) if (result.Success)
{ {
#pragma warning disable 0618
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewFound")) if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewFound"))
{ {
Telemetry.WriteTelemetry( Telemetry.WriteTelemetry(
@ -82,11 +85,12 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
view = result.View, view = result.View,
}); });
} }
#pragma warning restore 0618
Logger.LogVerbose("The partial view '{PartialViewName}' was found.", viewName); Logger.LogVerbose("The partial view '{PartialViewName}' was found.", viewName);
} }
else else
{ {
#pragma warning disable 0618
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound")) if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound"))
{ {
Telemetry.WriteTelemetry( Telemetry.WriteTelemetry(
@ -100,6 +104,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
searchedLocations = result.SearchedLocations searchedLocations = result.SearchedLocations
}); });
} }
#pragma warning restore 0618
Logger.LogError( Logger.LogError(
"The partial view '{PartialViewName}' was not found. Searched locations: {SearchedViewLocations}", "The partial view '{PartialViewName}' was not found. Searched locations: {SearchedViewLocations}",

View File

@ -26,6 +26,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
Encoding = Encoding.UTF8 Encoding = Encoding.UTF8
}.CopyAsReadOnly(); }.CopyAsReadOnly();
#pragma warning disable 0618
/// <summary> /// <summary>
/// Creates a new <see cref="ViewExecutor"/>. /// Creates a new <see cref="ViewExecutor"/>.
/// </summary> /// </summary>
@ -69,6 +70,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
/// Gets the <see cref="TelemetrySource"/>. /// Gets the <see cref="TelemetrySource"/>.
/// </summary> /// </summary>
protected TelemetrySource Telemetry { get; } protected TelemetrySource Telemetry { get; }
#pragma warning restore 0618
/// <summary> /// <summary>
/// Gets the default <see cref="IViewEngine"/>. /// Gets the default <see cref="IViewEngine"/>.
@ -158,21 +160,25 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
writer, writer,
ViewOptions.HtmlHelperOptions); ViewOptions.HtmlHelperOptions);
#pragma warning disable 0618
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeView")) if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeView"))
{ {
Telemetry.WriteTelemetry( Telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.BeforeView", "Microsoft.AspNet.Mvc.BeforeView",
new { view = view, viewContext = viewContext, }); new { view = view, viewContext = viewContext, });
} }
#pragma warning restore 0618
await view.RenderAsync(viewContext); await view.RenderAsync(viewContext);
#pragma warning disable 0618
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterView")) if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterView"))
{ {
Telemetry.WriteTelemetry( Telemetry.WriteTelemetry(
"Microsoft.AspNet.Mvc.AfterView", "Microsoft.AspNet.Mvc.AfterView",
new { view = view, viewContext = viewContext, }); new { view = view, viewContext = viewContext, });
} }
#pragma warning restore 0618
// Perf: Invoke FlushAsync to ensure any buffered content is asynchronously written to the underlying // 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 // response asynchronously. In the absence of this line, the buffer gets synchronously written to the

View File

@ -16,6 +16,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
/// </summary> /// </summary>
public class ViewResultExecutor : ViewExecutor public class ViewResultExecutor : ViewExecutor
{ {
#pragma warning disable 0618
/// <summary> /// <summary>
/// Creates a new <see cref="ViewResultExecutor"/>. /// Creates a new <see cref="ViewResultExecutor"/>.
/// </summary> /// </summary>
@ -39,6 +40,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
Logger = loggerFactory.CreateLogger<ViewResultExecutor>(); Logger = loggerFactory.CreateLogger<ViewResultExecutor>();
} }
#pragma warning restore 0618
/// <summary> /// <summary>
/// Gets the <see cref="ILogger"/>. /// Gets the <see cref="ILogger"/>.
@ -69,6 +71,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
var result = viewEngine.FindView(actionContext, viewName); var result = viewEngine.FindView(actionContext, viewName);
if (result.Success) if (result.Success)
{ {
#pragma warning disable 0618
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewFound")) if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewFound"))
{ {
Telemetry.WriteTelemetry( Telemetry.WriteTelemetry(
@ -82,11 +85,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
view = result.View, view = result.View,
}); });
} }
#pragma warning restore 0618
Logger.LogVerbose("The view '{ViewName}' was found.", viewName); Logger.LogVerbose("The view '{ViewName}' was found.", viewName);
} }
else else
{ {
#pragma warning disable 0618
if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound")) if (Telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewNotFound"))
{ {
Telemetry.WriteTelemetry( Telemetry.WriteTelemetry(
@ -100,6 +105,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
searchedLocations = result.SearchedLocations searchedLocations = result.SearchedLocations
}); });
} }
#pragma warning restore 0618
Logger.LogError( Logger.LogError(
"The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}", "The view '{ViewName}' was not found. Searched locations: {SearchedViewLocations}",

View File

@ -2041,7 +2041,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
filterProvider filterProvider
.SetupGet(fp => fp.Order) .SetupGet(fp => fp.Order)
.Returns(-1000); .Returns(-1000);
#pragma warning disable 0618
var invoker = new TestControllerActionInvoker( var invoker = new TestControllerActionInvoker(
actionContext, actionContext,
new[] { filterProvider.Object }, new[] { filterProvider.Object },
@ -2057,7 +2057,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(), new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
new TelemetryListener("Microsoft.AspNet"), new TelemetryListener("Microsoft.AspNet"),
maxAllowedErrorsInModelState); maxAllowedErrorsInModelState);
#pragma warning restore 0618
return invoker; return invoker;
} }
@ -2101,6 +2101,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
.Returns(new TestController()); .Returns(new TestController());
var metadataProvider = new EmptyModelMetadataProvider(); var metadataProvider = new EmptyModelMetadataProvider();
#pragma warning disable 0618
var invoker = new ControllerActionInvoker( var invoker = new ControllerActionInvoker(
actionContext, actionContext,
new List<IFilterProvider>(), new List<IFilterProvider>(),
@ -2118,6 +2119,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(), new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
new TelemetryListener("Microsoft.AspNet"), new TelemetryListener("Microsoft.AspNet"),
200); 200);
#pragma warning restore 0618
// Act // Act
await invoker.InvokeAsync(); await invoker.InvokeAsync();
@ -2204,6 +2206,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
private class TestControllerActionInvoker : ControllerActionInvoker private class TestControllerActionInvoker : ControllerActionInvoker
{ {
#pragma warning disable 0618
public TestControllerActionInvoker( public TestControllerActionInvoker(
ActionContext actionContext, ActionContext actionContext,
IFilterProvider[] filterProvider, IFilterProvider[] filterProvider,
@ -2237,6 +2240,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
{ {
ControllerFactory = controllerFactory; ControllerFactory = controllerFactory;
} }
#pragma warning restore 0618
public MockControllerFactory ControllerFactory { get; } public MockControllerFactory ControllerFactory { get; }

View File

@ -242,13 +242,13 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
{ {
optionsAccessor = new TestOptionsManager<MvcOptions>(); optionsAccessor = new TestOptionsManager<MvcOptions>();
} }
#pragma warning disable 0618
var telemetry = new TelemetryListener("Microsoft.AspNet"); var telemetry = new TelemetryListener("Microsoft.AspNet");
if (telemetryListener != null) if (telemetryListener != null)
{ {
telemetry.SubscribeWithAdapter(telemetryListener); telemetry.SubscribeWithAdapter(telemetryListener);
} }
#pragma warning restore 0618
var httpContext = new Mock<HttpContext>(); var httpContext = new Mock<HttpContext>();
httpContext.Setup(h => h.RequestServices.GetService(typeof(IActionContextAccessor))) httpContext.Setup(h => h.RequestServices.GetService(typeof(IActionContextAccessor)))
.Returns(new ActionContextAccessor()); .Returns(new ActionContextAccessor());
@ -262,9 +262,10 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
.Returns(new MvcMarkerService()); .Returns(new MvcMarkerService());
httpContext.Setup(h => h.RequestServices.GetService(typeof(IOptions<MvcOptions>))) httpContext.Setup(h => h.RequestServices.GetService(typeof(IOptions<MvcOptions>)))
.Returns(optionsAccessor); .Returns(optionsAccessor);
#pragma warning disable 0618
httpContext.Setup(h => h.RequestServices.GetService(typeof(TelemetrySource))) httpContext.Setup(h => h.RequestServices.GetService(typeof(TelemetrySource)))
.Returns(telemetry); .Returns(telemetry);
#pragma warning restore 0618
return new RouteContext(httpContext.Object); return new RouteContext(httpContext.Object);
} }
} }

View File

@ -105,12 +105,14 @@ namespace Microsoft.AspNet.Mvc
private HttpContext GetHttpContext() private HttpContext GetHttpContext()
{ {
var options = new TestOptionsManager<MvcViewOptions>(); var options = new TestOptionsManager<MvcViewOptions>();
#pragma warning disable 0618
var viewExecutor = new PartialViewResultExecutor( var viewExecutor = new PartialViewResultExecutor(
options, options,
new TestHttpResponseStreamWriterFactory(), new TestHttpResponseStreamWriterFactory(),
new CompositeViewEngine(options), new CompositeViewEngine(options),
new TelemetryListener("Microsoft.AspNet"), new TelemetryListener("Microsoft.AspNet"),
NullLoggerFactory.Instance); NullLoggerFactory.Instance);
#pragma warning restore 0618
var services = new ServiceCollection(); var services = new ServiceCollection();
services.AddInstance(viewExecutor); services.AddInstance(viewExecutor);

View File

@ -71,6 +71,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
Assert.Equal(viewName, viewEngineResult.ViewName); Assert.Equal(viewName, viewEngineResult.ViewName);
} }
#pragma warning disable 0618
[Fact] [Fact]
public void FindView_Notifies_ViewFound() 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(new string[] { "location/myview" }, listener.ViewNotFound.SearchedLocations);
Assert.Equal("myview", listener.ViewNotFound.ViewName); Assert.Equal("myview", listener.ViewNotFound.ViewName);
} }
#pragma warning restore 0618
[Fact] [Fact]
public async Task ExecuteAsync_UsesContentType_FromPartialViewResult() public async Task ExecuteAsync_UsesContentType_FromPartialViewResult()
@ -200,6 +202,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor()); return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());
} }
#pragma warning disable 0618
private PartialViewResultExecutor GetViewExecutor(TelemetrySource telemetry = null) private PartialViewResultExecutor GetViewExecutor(TelemetrySource telemetry = null)
{ {
if (telemetry == null) if (telemetry == null)
@ -224,6 +227,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
return viewExecutor; return viewExecutor;
} }
#pragma warning restore 0618
} }
} }
#endif #endif

View File

@ -146,7 +146,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
Assert.Equal(500, context.Response.StatusCode); Assert.Equal(500, context.Response.StatusCode);
Assert.Equal("abcd", Encoding.UTF8.GetString(memoryStream.ToArray())); Assert.Equal("abcd", Encoding.UTF8.GetString(memoryStream.ToArray()));
} }
#pragma warning disable 0618
[Fact] [Fact]
public async Task ExecuteAsync_WritesTelemetry() public async Task ExecuteAsync_WritesTelemetry()
{ {
@ -190,7 +190,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
Assert.NotNull(adapter.AfterView?.View); Assert.NotNull(adapter.AfterView?.View);
Assert.NotNull(adapter.AfterView?.ViewContext); Assert.NotNull(adapter.AfterView?.ViewContext);
} }
#pragma warning restore 0618
[Fact] [Fact]
public async Task ExecuteAsync_DoesNotWriteToResponse_OnceExceptionIsThrown() public async Task ExecuteAsync_DoesNotWriteToResponse_OnceExceptionIsThrown()
{ {
@ -277,7 +277,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
return view.Object; return view.Object;
} }
#pragma warning disable 0618
private ViewExecutor CreateViewExecutor(TelemetryListener listener = null) private ViewExecutor CreateViewExecutor(TelemetryListener listener = null)
{ {
if (listener == null) if (listener == null)
@ -291,6 +291,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
new Mock<ICompositeViewEngine>(MockBehavior.Strict).Object, new Mock<ICompositeViewEngine>(MockBehavior.Strict).Object,
listener); listener);
} }
#pragma warning restore 0618
} }
} }
#endif #endif

View File

@ -71,6 +71,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
Assert.Equal(viewName, viewEngineResult.ViewName); Assert.Equal(viewName, viewEngineResult.ViewName);
} }
#pragma warning disable 0618
[Fact] [Fact]
public void FindView_Notifies_ViewFound() 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(new string[] { "location/myview" }, listener.ViewNotFound.SearchedLocations);
Assert.Equal("myview", listener.ViewNotFound.ViewName); Assert.Equal("myview", listener.ViewNotFound.ViewName);
} }
#pragma warning restore 0618
[Fact] [Fact]
public async Task ExecuteAsync_UsesContentType_FromViewResult() public async Task ExecuteAsync_UsesContentType_FromViewResult()
@ -200,6 +202,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor()); return new ActionContext(new DefaultHttpContext(), new RouteData(), new ActionDescriptor());
} }
#pragma warning disable 0618
private ViewResultExecutor GetViewExecutor(TelemetrySource telemetry = null) private ViewResultExecutor GetViewExecutor(TelemetrySource telemetry = null)
{ {
if (telemetry == null) if (telemetry == null)
@ -224,6 +227,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
return viewExecutor; return viewExecutor;
} }
#pragma warning restore 0618
} }
} }
#endif #endif

View File

@ -105,12 +105,14 @@ namespace Microsoft.AspNet.Mvc
private HttpContext GetHttpContext() private HttpContext GetHttpContext()
{ {
var options = new TestOptionsManager<MvcViewOptions>(); var options = new TestOptionsManager<MvcViewOptions>();
#pragma warning disable 0618
var viewExecutor = new ViewResultExecutor( var viewExecutor = new ViewResultExecutor(
options, options,
new TestHttpResponseStreamWriterFactory(), new TestHttpResponseStreamWriterFactory(),
new CompositeViewEngine(options), new CompositeViewEngine(options),
new TelemetryListener("Microsoft.AspNet"), new TelemetryListener("Microsoft.AspNet"),
NullLoggerFactory.Instance); NullLoggerFactory.Instance);
#pragma warning restore 0618
var services = new ServiceCollection(); var services = new ServiceCollection();
services.AddInstance(viewExecutor); services.AddInstance(viewExecutor);