From c5f771d96d77be8b7bb70e41feeb6d0bac13f7e5 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 3 May 2017 14:33:55 -0700 Subject: [PATCH] Use factory pattern for caching in ControllerActionInvoker --- .../ControllerActivatorProvider.cs | 91 +++++++ .../Controllers/ControllerFactoryProvider.cs | 120 +++++++++ .../IControllerActivatorProvider.cs | 27 +++ .../Controllers/IControllerFactoryProvider.cs | 27 +++ .../MvcCoreServiceCollectionExtensions.cs | 3 + .../Internal/ControllerActionInvoker.cs | 114 ++------- .../Internal/ControllerActionInvokerCache.cs | 72 +++--- .../ControllerActionInvokerCacheEntry.cs | 36 +++ .../ControllerActionInvokerProvider.cs | 27 +-- .../Internal/ControllerBinderDelegate.cs | 13 + .../ControllerBinderDelegateProvider.cs | 163 +++++++++++++ .../DefaultControllerPropertyActivator.cs | 51 +++- ...=> IControllerPropertyActivatorFactory.cs} | 5 + .../Internal/NormalizedRouteValue.cs | 2 +- .../Internal/ResourceInvoker.cs | 4 +- .../Internal/ViewEnginePath.cs | 2 +- .../Microsoft.AspNetCore.Mvc.Core.csproj | 2 +- .../ModelBinding/ParameterBinder.cs | 58 ++++- .../UrlHelperExtensions.cs | 2 +- .../RazorViewEngine.cs | 3 +- .../Internal/PageActionInvoker.cs | 1 - ...taDictionaryControllerPropertyActivator.cs | 40 ++- .../ControllerActivatorProviderTest.cs | 157 ++++++++++++ .../ControllerFactoryProviderTest.cs | 163 +++++++++++++ .../ControllerActionInvokerCacheTest.cs | 37 ++- .../Internal/ControllerActionInvokerTest.cs | 149 ++++++------ ...> ControllerBinderDelegateProviderTest.cs} | 146 ++++++----- .../Internal/MiddlewareFilterTest.cs | 36 ++- .../out.host.17-05-12_14-46-19_16053_4.txt | 227 ++++++++++++++++++ .../out.txt | 172 +++++++++++++ 30 files changed, 1608 insertions(+), 342 deletions(-) create mode 100644 src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerActivatorProvider.cs create mode 100644 src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerFactoryProvider.cs create mode 100644 src/Microsoft.AspNetCore.Mvc.Core/Controllers/IControllerActivatorProvider.cs create mode 100644 src/Microsoft.AspNetCore.Mvc.Core/Controllers/IControllerFactoryProvider.cs create mode 100644 src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerCacheEntry.cs create mode 100644 src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerBinderDelegate.cs create mode 100644 src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerBinderDelegateProvider.cs rename src/Microsoft.AspNetCore.Mvc.Core/Internal/{IControllerPropertyActivator.cs => IControllerPropertyActivatorFactory.cs} (67%) create mode 100644 test/Microsoft.AspNetCore.Mvc.Core.Test/Controllers/ControllerActivatorProviderTest.cs create mode 100644 test/Microsoft.AspNetCore.Mvc.Core.Test/Controllers/ControllerFactoryProviderTest.cs rename test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/{ControllerActionInvokerParameterBindingTest.cs => ControllerBinderDelegateProviderTest.cs} (89%) create mode 100644 test/Microsoft.AspNetCore.Mvc.Core.Test/out.host.17-05-12_14-46-19_16053_4.txt create mode 100644 test/Microsoft.AspNetCore.Mvc.Core.Test/out.txt diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerActivatorProvider.cs b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerActivatorProvider.cs new file mode 100644 index 0000000000..854605f451 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerActivatorProvider.cs @@ -0,0 +1,91 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Reflection; +using Microsoft.AspNetCore.Mvc.Core; +using Microsoft.Extensions.DependencyInjection; + +namespace Microsoft.AspNetCore.Mvc.Controllers +{ + /// + /// Provides methods to create an MVC controller. + /// + public class ControllerActivatorProvider : IControllerActivatorProvider + { + private static readonly Func _createFactory = (type) => ActivatorUtilities.CreateFactory(type, Type.EmptyTypes); + private static readonly Action _dispose = Dispose; + private readonly Func _controllerActivatorCreate; + private readonly Action _controllerActivatorRelease; + + public ControllerActivatorProvider(IControllerActivator controllerActivator) + { + if (controllerActivator == null) + { + throw new ArgumentNullException(nameof(controllerActivator)); + } + + // Compat: Delegate to controllerActivator if it's not the default implementation. + if (controllerActivator.GetType() != typeof(DefaultControllerActivator)) + { + _controllerActivatorCreate = controllerActivator.Create; + _controllerActivatorRelease = controllerActivator.Release; + } + } + + public Func CreateActivator(ControllerActionDescriptor descriptor) + { + if (descriptor == null) + { + throw new ArgumentNullException(nameof(descriptor)); + } + + var controllerType = descriptor.ControllerTypeInfo?.AsType(); + if (controllerType == null) + { + throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull( + nameof(descriptor.ControllerTypeInfo), + nameof(descriptor)), + nameof(descriptor)); + } + + if (_controllerActivatorCreate != null) + { + return _controllerActivatorCreate; + } + + var typeActivator = ActivatorUtilities.CreateFactory(controllerType, Type.EmptyTypes); + return controllerContext => typeActivator(controllerContext.HttpContext.RequestServices, arguments: null); + } + + public Action CreateReleaser(ControllerActionDescriptor descriptor) + { + if (descriptor == null) + { + throw new ArgumentNullException(nameof(descriptor)); + } + + if (_controllerActivatorRelease != null) + { + return _controllerActivatorRelease; + } + + if (typeof(IDisposable).GetTypeInfo().IsAssignableFrom(descriptor.ControllerTypeInfo)) + { + return _dispose; + } + + return null; + } + + private static void Dispose(ControllerContext context, object controller) + { + if (controller == null) + { + throw new ArgumentNullException(nameof(controller)); + } + + ((IDisposable)controller).Dispose(); + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerFactoryProvider.cs b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerFactoryProvider.cs new file mode 100644 index 0000000000..e11ad85096 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/ControllerFactoryProvider.cs @@ -0,0 +1,120 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Core; +using Microsoft.AspNetCore.Mvc.Internal; + +namespace Microsoft.AspNetCore.Mvc.Controllers +{ + public class ControllerFactoryProvider : IControllerFactoryProvider + { + private readonly IControllerActivatorProvider _activatorProvider; + private readonly Func _factoryCreateController; + private readonly Action _factoryReleaseController; + private readonly IControllerPropertyActivator[] _propertyActivators; + + public ControllerFactoryProvider( + IControllerActivatorProvider activatorProvider, + IControllerFactory controllerFactory, + IEnumerable propertyActivators) + { + if (activatorProvider == null) + { + throw new ArgumentNullException(nameof(activatorProvider)); + } + + if (controllerFactory == null) + { + throw new ArgumentNullException(nameof(controllerFactory)); + } + + _activatorProvider = activatorProvider; + + // Compat: Delegate to the IControllerFactory if it's not the default implementation. + if (controllerFactory.GetType() != typeof(DefaultControllerFactory)) + { + _factoryCreateController = controllerFactory.CreateController; + _factoryReleaseController = controllerFactory.ReleaseController; + } + + _propertyActivators = propertyActivators.ToArray(); + } + + public Func CreateControllerFactory(ControllerActionDescriptor descriptor) + { + if (descriptor == null) + { + throw new ArgumentNullException(nameof(descriptor)); + } + + var controllerType = descriptor.ControllerTypeInfo?.AsType(); + if (controllerType == null) + { + throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull( + nameof(descriptor.ControllerTypeInfo), + nameof(descriptor)), + nameof(descriptor)); + } + + if (_factoryCreateController != null) + { + return _factoryCreateController; + } + + var controllerActivator = _activatorProvider.CreateActivator(descriptor); + var propertyActivators = GetPropertiesToActivate(descriptor); + object CreateController(ControllerContext controllerContext) + { + var controller = controllerActivator(controllerContext); + for (var i = 0; i < propertyActivators.Length; i++) + { + var propertyActivator = propertyActivators[i]; + propertyActivator(controllerContext, controller); + } + + return controller; + } + + return CreateController; + } + + public Action CreateControllerReleaser(ControllerActionDescriptor descriptor) + { + if (descriptor == null) + { + throw new ArgumentNullException(nameof(descriptor)); + } + + var controllerType = descriptor.ControllerTypeInfo?.AsType(); + if (controllerType == null) + { + throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull( + nameof(descriptor.ControllerTypeInfo), + nameof(descriptor)), + nameof(descriptor)); + } + + if (_factoryReleaseController != null) + { + return _factoryReleaseController; + } + + return _activatorProvider.CreateReleaser(descriptor); + } + + private Action[] GetPropertiesToActivate(ControllerActionDescriptor actionDescriptor) + { + var propertyActivators = new Action[_propertyActivators.Length]; + for (var i = 0; i < _propertyActivators.Length; i++) + { + var activatorProvider = _propertyActivators[i]; + propertyActivators[i] = activatorProvider.GetActivatorDelegate(actionDescriptor); + } + + return propertyActivators; + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Controllers/IControllerActivatorProvider.cs b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/IControllerActivatorProvider.cs new file mode 100644 index 0000000000..0ff5d2b134 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/IControllerActivatorProvider.cs @@ -0,0 +1,27 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNetCore.Mvc.Controllers +{ + /// + /// Provides methods to create a MVC controller. + /// + public interface IControllerActivatorProvider + { + /// + /// Creates a that creates a controller. + /// + /// The . + /// The delegate used to activate the controller. + Func CreateActivator(ControllerActionDescriptor descriptor); + + /// + /// Creates an that releases a controller. + /// + /// The . + /// The delegate used to dispose the activated controller. + Action CreateReleaser(ControllerActionDescriptor descriptor); + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Controllers/IControllerFactoryProvider.cs b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/IControllerFactoryProvider.cs new file mode 100644 index 0000000000..4483047d56 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Core/Controllers/IControllerFactoryProvider.cs @@ -0,0 +1,27 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNetCore.Mvc.Controllers +{ + /// + /// Provides methods to create and release a controller. + /// + public interface IControllerFactoryProvider + { + /// + /// Creates a factory for producing controllers for the specified . + /// + /// The . + /// The controller factory. + Func CreateControllerFactory(ControllerActionDescriptor descriptor); + + /// + /// Releases a controller. + /// + /// The . + /// The delegate used to release the created controller. + Action CreateControllerReleaser(ControllerActionDescriptor descriptor); + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs index d41bb4590e..7e31ac14b1 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs @@ -157,6 +157,9 @@ namespace Microsoft.Extensions.DependencyInjection // Will be cached by the DefaultControllerFactory services.TryAddTransient(); + + services.TryAddSingleton(); + services.TryAddSingleton(); services.TryAddEnumerable( ServiceDescriptor.Transient()); diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs index 4a10775919..8c6b91df0a 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvoker.cs @@ -7,11 +7,8 @@ using System.Diagnostics; using System.Runtime.ExceptionServices; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Core; -using Microsoft.AspNetCore.Mvc.Core.Internal; using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; @@ -19,12 +16,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal { public class ControllerActionInvoker : ResourceInvoker, IActionInvoker { - private readonly IControllerFactory _controllerFactory; - private readonly ParameterBinder _parameterBinder; - private readonly IModelMetadataProvider _modelMetadataProvider; - + private readonly ControllerActionInvokerCacheEntry _cacheEntry; private readonly ControllerContext _controllerContext; - private readonly ObjectMethodExecutor _executor; private object _controller; private Dictionary _arguments; @@ -38,44 +31,27 @@ namespace Microsoft.AspNetCore.Mvc.Internal private ResultExecutedContext _resultExecutedContext; internal ControllerActionInvoker( - IControllerFactory controllerFactory, - ParameterBinder parameterBinder, - IModelMetadataProvider modelMetadataProvider, ILogger logger, DiagnosticSource diagnosticSource, ControllerContext controllerContext, - IFilterMetadata[] filters, - ObjectMethodExecutor objectMethodExecutor) + ControllerActionInvokerCacheEntry cacheEntry, + IFilterMetadata[] filters) : base(diagnosticSource, logger, controllerContext, filters, controllerContext.ValueProviderFactories) { - - if (controllerFactory == null) + if (cacheEntry == null) { - throw new ArgumentNullException(nameof(controllerFactory)); + throw new ArgumentNullException(nameof(cacheEntry)); } - if (parameterBinder == null) - { - throw new ArgumentNullException(nameof(parameterBinder)); - } - - if (objectMethodExecutor == null) - { - throw new ArgumentNullException(nameof(objectMethodExecutor)); - } - - _controllerFactory = controllerFactory; - _parameterBinder = parameterBinder; - _modelMetadataProvider = modelMetadataProvider; + _cacheEntry = cacheEntry; _controllerContext = controllerContext; - _executor = objectMethodExecutor; } protected override void ReleaseResources() { - if (_controller != null) + if (_controller != null && _cacheEntry.ControllerReleaser != null) { - _controllerFactory.ReleaseController(_controllerContext, _controller); + _cacheEntry.ControllerReleaser(_controllerContext, _controller); } } @@ -293,7 +269,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal _cursor.Reset(); - _controller = _controllerFactory.CreateController(controllerContext); + _controller = _cacheEntry.ControllerFactory(controllerContext); _arguments = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -757,7 +733,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal private async Task InvokeActionMethodAsync() { var controllerContext = _controllerContext; - var executor = _executor; + var executor = _cacheEntry.ActionMethodExecutor; var controller = _controller; var arguments = _arguments; var orderedArguments = PrepareArguments(arguments, executor); @@ -799,24 +775,24 @@ namespace Microsoft.AspNetCore.Mvc.Internal Resources.FormatActionResult_ActionReturnValueCannotBeNull(typeof(IActionResult))); } } - else if (IsResultIActionResult(_executor)) + else if (IsResultIActionResult(executor)) { - if (_executor.IsMethodAsync) + if (executor.IsMethodAsync) { // Async method returning awaitable-of-IActionResult (e.g., Task) // We have to use ExecuteAsync because we don't know the awaitable's type at compile time. - result = (IActionResult)await _executor.ExecuteAsync(controller, orderedArguments); + result = (IActionResult)await executor.ExecuteAsync(controller, orderedArguments); } else { // Sync method returning IActionResult (e.g., ViewResult) - result = (IActionResult)_executor.Execute(controller, orderedArguments); + result = (IActionResult)executor.Execute(controller, orderedArguments); } if (result == null) { throw new InvalidOperationException( - Resources.FormatActionResult_ActionReturnValueCannotBeNull(_executor.AsyncResultType ?? returnType)); + Resources.FormatActionResult_ActionReturnValueCannotBeNull(executor.AsyncResultType ?? returnType)); } } else if (!executor.IsMethodAsync) @@ -1004,63 +980,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal return TaskCache.CompletedTask; } - return BindArgumentsCoreAsync(_parameterBinder, _modelMetadataProvider, _controllerContext, _controller, _arguments); - } - - // Intentionally static internal for unit testing - internal static async Task BindArgumentsCoreAsync( - ParameterBinder parameterBinder, - IModelMetadataProvider modelMetadataProvider, - ControllerContext controllerContext, - object controller, - Dictionary arguments) - { - var valueProvider = await CompositeValueProvider.CreateAsync(controllerContext); - - var parameters = controllerContext.ActionDescriptor.Parameters; - for (var i = 0; i < parameters.Count; i++) - { - var parameter = parameters[i]; - - var result = await parameterBinder.BindModelAsync(controllerContext, valueProvider, parameter); - if (result.IsModelSet) - { - arguments[parameter.Name] = result.Model; - } - } - - var propertyDescriptors = controllerContext.ActionDescriptor.BoundProperties; - if (propertyDescriptors.Count == 0) - { - // Perf: Early exit to avoid PropertyHelper lookup in the (common) case where we have no - // bound properties. - return; - } - - var controllerType = controller.GetType(); - ModelMetadata controllerMetadata = null; - for (var i = 0; i < propertyDescriptors.Count; i++) - { - var property = propertyDescriptors[i]; - - var result = await parameterBinder.BindModelAsync(controllerContext, valueProvider, property); - if (result.IsModelSet) - { - if (controllerMetadata == null) - { - controllerMetadata = modelMetadataProvider.GetMetadataForType(controllerType); - } - var propertyMetadata = controllerMetadata.Properties[property.Name] ?? - modelMetadataProvider.GetMetadataForProperty(controllerType, property.Name); - if (propertyMetadata != null) - { - PropertyValueSetter.SetValue( - propertyMetadata, - controller, - result.Model); - } - } - } + Debug.Assert(_cacheEntry.ControllerBinderDelegate != null); + return _cacheEntry.ControllerBinderDelegate(_controllerContext, _controller, _arguments); } private static object[] PrepareArguments( @@ -1090,7 +1011,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal return arguments; } - private enum Scope { Resource, diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerCache.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerCache.cs index 2df496ad83..073f4b6897 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerCache.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerCache.cs @@ -5,8 +5,10 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Mvc.Abstractions; +using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Infrastructure; +using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Mvc.Internal @@ -14,16 +16,28 @@ namespace Microsoft.AspNetCore.Mvc.Internal public class ControllerActionInvokerCache { private readonly IActionDescriptorCollectionProvider _collectionProvider; + private readonly ParameterBinder _parameterBinder; + private readonly IModelBinderFactory _modelBinderFactory; + private readonly IModelMetadataProvider _modelMetadataProvider; private readonly IFilterProvider[] _filterProviders; + private readonly IControllerFactoryProvider _controllerFactoryProvider; private volatile InnerCache _currentCache; public ControllerActionInvokerCache( IActionDescriptorCollectionProvider collectionProvider, - IEnumerable filterProviders) + ParameterBinder parameterBinder, + IModelBinderFactory modelBinderFactory, + IModelMetadataProvider modelMetadataProvider, + IEnumerable filterProviders, + IControllerFactoryProvider factoryProvider) { _collectionProvider = collectionProvider; + _parameterBinder = parameterBinder; + _modelBinderFactory = modelBinderFactory; + _modelMetadataProvider = modelMetadataProvider; _filterProviders = filterProviders.OrderBy(item => item.Order).ToArray(); + _controllerFactoryProvider = factoryProvider; } private InnerCache CurrentCache @@ -43,14 +57,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal } } - public ControllerActionInvokerState GetState(ControllerContext controllerContext) + public (ControllerActionInvokerCacheEntry cacheEntry, IFilterMetadata[] filters) GetCachedResult(ControllerContext controllerContext) { var cache = CurrentCache; var actionDescriptor = controllerContext.ActionDescriptor; IFilterMetadata[] filters; - Entry cacheEntry; - if (!cache.Entries.TryGetValue(actionDescriptor, out cacheEntry)) + if (!cache.Entries.TryGetValue(actionDescriptor, out var cacheEntry)) { var filterFactoryResult = FilterFactory.GetAllFilters(_filterProviders, controllerContext); filters = filterFactoryResult.Filters; @@ -63,16 +76,29 @@ namespace Microsoft.AspNetCore.Mvc.Internal actionDescriptor.ControllerTypeInfo, parameterDefaultValues); - cacheEntry = new Entry(filterFactoryResult.CacheableFilters, executor); + var controllerFactory = _controllerFactoryProvider.CreateControllerFactory(actionDescriptor); + var controllerReleaser = _controllerFactoryProvider.CreateControllerReleaser(actionDescriptor); + var propertyBinderFactory = ControllerBinderDelegateProvider.CreateBinderDelegate( + _parameterBinder, + _modelBinderFactory, + _modelMetadataProvider, + actionDescriptor); + + cacheEntry = new ControllerActionInvokerCacheEntry( + filterFactoryResult.CacheableFilters, + controllerFactory, + controllerReleaser, + propertyBinderFactory, + executor); cacheEntry = cache.Entries.GetOrAdd(actionDescriptor, cacheEntry); } else { // Filter instances from statically defined filter descriptors + from filter providers - filters = FilterFactory.CreateUncachedFilters(_filterProviders, controllerContext, cacheEntry.FilterItems); + filters = FilterFactory.CreateUncachedFilters(_filterProviders, controllerContext, cacheEntry.CachedFilters); } - return new ControllerActionInvokerState(filters, cacheEntry.ActionMethodExecutor); + return (cacheEntry, filters); } private class InnerCache @@ -82,38 +108,10 @@ namespace Microsoft.AspNetCore.Mvc.Internal Version = version; } - public ConcurrentDictionary Entries { get; } = - new ConcurrentDictionary(); + public ConcurrentDictionary Entries { get; } = + new ConcurrentDictionary(); public int Version { get; } } - - private struct Entry - { - public Entry(FilterItem[] items, ObjectMethodExecutor executor) - { - FilterItems = items; - ActionMethodExecutor = executor; - } - - public FilterItem[] FilterItems { get; } - - public ObjectMethodExecutor ActionMethodExecutor { get; } - } - - public struct ControllerActionInvokerState - { - internal ControllerActionInvokerState( - IFilterMetadata[] filters, - ObjectMethodExecutor actionMethodExecutor) - { - Filters = filters; - ActionMethodExecutor = actionMethodExecutor; - } - - public IFilterMetadata[] Filters { get; } - - internal ObjectMethodExecutor ActionMethodExecutor { get; } - } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerCacheEntry.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerCacheEntry.cs new file mode 100644 index 0000000000..cd8404518a --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerCacheEntry.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.Internal; + +namespace Microsoft.AspNetCore.Mvc.Internal +{ + public class ControllerActionInvokerCacheEntry + { + internal ControllerActionInvokerCacheEntry( + FilterItem[] cachedFilters, + Func controllerFactory, + Action controllerReleaser, + ControllerBinderDelegate controllerBinderDelegate, + ObjectMethodExecutor actionMethodExecutor) + { + ControllerFactory = controllerFactory; + ControllerReleaser = controllerReleaser; + ControllerBinderDelegate = controllerBinderDelegate; + CachedFilters = cachedFilters; + ActionMethodExecutor = actionMethodExecutor; + } + + public FilterItem[] CachedFilters { get; } + + public Func ControllerFactory { get; } + + public Action ControllerReleaser { get; } + + public ControllerBinderDelegate ControllerBinderDelegate { get; } + + internal ObjectMethodExecutor ActionMethodExecutor { get; } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerProvider.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerProvider.cs index 2466dd6413..eb24102154 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerProvider.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerActionInvokerProvider.cs @@ -15,38 +15,26 @@ namespace Microsoft.AspNetCore.Mvc.Internal { public class ControllerActionInvokerProvider : IActionInvokerProvider { - private readonly IControllerFactory _controllerFactory; private readonly ControllerActionInvokerCache _controllerActionInvokerCache; - private readonly ParameterBinder _parameterBinder; - private readonly IModelMetadataProvider _modelMetadataProvider; private readonly IReadOnlyList _valueProviderFactories; private readonly int _maxModelValidationErrors; private readonly ILogger _logger; private readonly DiagnosticSource _diagnosticSource; public ControllerActionInvokerProvider( - IControllerFactory controllerFactory, ControllerActionInvokerCache controllerActionInvokerCache, - ParameterBinder parameterBinder, - IModelMetadataProvider modelMetadataProvider, IOptions optionsAccessor, ILoggerFactory loggerFactory, DiagnosticSource diagnosticSource) { - _controllerFactory = controllerFactory; _controllerActionInvokerCache = controllerActionInvokerCache; - _parameterBinder = parameterBinder; - _modelMetadataProvider = modelMetadataProvider; _valueProviderFactories = optionsAccessor.Value.ValueProviderFactories.ToArray(); _maxModelValidationErrors = optionsAccessor.Value.MaxModelValidationErrors; _logger = loggerFactory.CreateLogger(); _diagnosticSource = diagnosticSource; } - public int Order - { - get { return -1000; } - } + public int Order => -1000; /// public void OnProvidersExecuting(ActionInvokerProviderContext context) @@ -56,26 +44,21 @@ namespace Microsoft.AspNetCore.Mvc.Internal throw new ArgumentNullException(nameof(context)); } - var actionDescriptor = context.ActionContext.ActionDescriptor as ControllerActionDescriptor; - - if (actionDescriptor != null) + if (context.ActionContext.ActionDescriptor is ControllerActionDescriptor actionDescriptor) { var controllerContext = new ControllerContext(context.ActionContext); // PERF: These are rarely going to be changed, so let's go copy-on-write. controllerContext.ValueProviderFactories = new CopyOnWriteList(_valueProviderFactories); controllerContext.ModelState.MaxAllowedErrors = _maxModelValidationErrors; - var cacheState = _controllerActionInvokerCache.GetState(controllerContext); + var cacheResult = _controllerActionInvokerCache.GetCachedResult(controllerContext); var invoker = new ControllerActionInvoker( - _controllerFactory, - _parameterBinder, - _modelMetadataProvider, _logger, _diagnosticSource, controllerContext, - cacheState.Filters, - cacheState.ActionMethodExecutor); + cacheResult.cacheEntry, + cacheResult.filters); context.Result = invoker; } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerBinderDelegate.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerBinderDelegate.cs new file mode 100644 index 0000000000..6a986160f0 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerBinderDelegate.cs @@ -0,0 +1,13 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Microsoft.AspNetCore.Mvc.Internal +{ + public delegate Task ControllerBinderDelegate( + ControllerContext controllerContext, + object controller, + Dictionary arguments); +} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerBinderDelegateProvider.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerBinderDelegateProvider.cs new file mode 100644 index 0000000000..16bfca522b --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ControllerBinderDelegateProvider.cs @@ -0,0 +1,163 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Microsoft.AspNetCore.Mvc.Internal +{ + public static class ControllerBinderDelegateProvider + { + public static ControllerBinderDelegate CreateBinderDelegate( + ParameterBinder parameterBinder, + IModelBinderFactory modelBinderFactory, + IModelMetadataProvider modelMetadataProvider, + ControllerActionDescriptor actionDescriptor) + { + if (parameterBinder == null) + { + throw new ArgumentNullException(nameof(parameterBinder)); + } + + if (modelMetadataProvider == null) + { + throw new ArgumentNullException(nameof(modelMetadataProvider)); + } + + if (actionDescriptor == null) + { + throw new ArgumentNullException(nameof(actionDescriptor)); + } + + var parameterBindingInfo = GetParameterBindingInfo(modelBinderFactory, modelMetadataProvider, actionDescriptor); + var propertyBindingInfo = GetPropertyBindingInfo(modelBinderFactory, modelMetadataProvider, actionDescriptor); + + if (parameterBindingInfo == null && propertyBindingInfo == null) + { + return null; + } + + return Bind; + + async Task Bind(ControllerContext controllerContext, object controller, Dictionary arguments) + { + var valueProvider = await CompositeValueProvider.CreateAsync(controllerContext); + var parameters = actionDescriptor.Parameters; + + for (var i = 0; i < parameters.Count; i++) + { + var parameter = parameters[i]; + var bindingInfo = parameterBindingInfo[i]; + + var result = await parameterBinder.BindModelAsync( + controllerContext, + bindingInfo.ModelBinder, + valueProvider, + parameter, + bindingInfo.ModelMetadata, + value: null); + + if (result.IsModelSet) + { + arguments[parameter.Name] = result.Model; + } + } + + var properties = actionDescriptor.BoundProperties; + for (var i = 0; i < properties.Count; i++) + { + var property = properties[i]; + var bindingInfo = propertyBindingInfo[i]; + + var result = await parameterBinder.BindModelAsync( + controllerContext, + bindingInfo.ModelBinder, + valueProvider, + property, + bindingInfo.ModelMetadata, + value: null); + + if (result.IsModelSet) + { + PropertyValueSetter.SetValue(bindingInfo.ModelMetadata, controller, result.Model); + } + } + } + } + + private static BindingInfo[] GetParameterBindingInfo( + IModelBinderFactory modelBinderFactory, + IModelMetadataProvider modelMetadataProvider, + ControllerActionDescriptor actionDescriptor) + { + var parameters = actionDescriptor.Parameters; + if (parameters.Count == 0) + { + return null; + } + + var parameterBindingInfo = new BindingInfo[parameters.Count]; + for (var i = 0; i < parameters.Count; i++) + { + var parameter = parameters[i]; + var metadata = modelMetadataProvider.GetMetadataForType(parameter.ParameterType); + var binder = modelBinderFactory.CreateBinder(new ModelBinderFactoryContext + { + BindingInfo = parameter.BindingInfo, + Metadata = metadata, + CacheToken = parameter, + }); + + parameterBindingInfo[i] = new BindingInfo(binder, metadata); + } + + return parameterBindingInfo; + } + + private static BindingInfo[] GetPropertyBindingInfo( + IModelBinderFactory modelBinderFactory, + IModelMetadataProvider modelMetadataProvider, + ControllerActionDescriptor actionDescriptor) + { + var properties = actionDescriptor.BoundProperties; + if (properties.Count == 0) + { + return null; + } + + var propertyBindingInfo = new BindingInfo[properties.Count]; + var controllerType = actionDescriptor.ControllerTypeInfo.AsType(); + for (var i = 0; i < properties.Count; i++) + { + var property = properties[i]; + var metadata = modelMetadataProvider.GetMetadataForProperty(controllerType, property.Name); + var binder = modelBinderFactory.CreateBinder(new ModelBinderFactoryContext + { + BindingInfo = property.BindingInfo, + Metadata = metadata, + CacheToken = property, + }); + + propertyBindingInfo[i] = new BindingInfo(binder, metadata); + } + + return propertyBindingInfo; + } + + private struct BindingInfo + { + public BindingInfo(IModelBinder modelBinder, ModelMetadata modelMetadata) + { + ModelBinder = modelBinder; + ModelMetadata = modelMetadata; + } + + public IModelBinder ModelBinder { get; } + + public ModelMetadata ModelMetadata { get; } + } + } +} diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/DefaultControllerPropertyActivator.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/DefaultControllerPropertyActivator.cs index 366eb6e789..857a4b23cb 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/DefaultControllerPropertyActivator.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/DefaultControllerPropertyActivator.cs @@ -5,24 +5,28 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Threading; using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.Core; using Microsoft.Extensions.Internal; namespace Microsoft.AspNetCore.Mvc.Internal { public class DefaultControllerPropertyActivator : IControllerPropertyActivator { - private readonly ConcurrentDictionary[]> _activateActions; - private readonly Func[]> _getPropertiesToActivate; - - public DefaultControllerPropertyActivator() - { - _activateActions = new ConcurrentDictionary[]>(); - _getPropertiesToActivate = GetPropertiesToActivate; - } + private static readonly Func[]> _getPropertiesToActivate = + GetPropertiesToActivate; + private object _initializeLock = new object(); + private bool _initialized; + private ConcurrentDictionary[]> _activateActions; public void Activate(ControllerContext context, object controller) { + LazyInitializer.EnsureInitialized( + ref _activateActions, + ref _initialized, + ref _initializeLock); + var controllerType = controller.GetType(); var propertiesToActivate = _activateActions.GetOrAdd( controllerType, @@ -35,7 +39,36 @@ namespace Microsoft.AspNetCore.Mvc.Internal } } - private PropertyActivator[] GetPropertiesToActivate(Type type) + public Action GetActivatorDelegate(ControllerActionDescriptor actionDescriptor) + { + if (actionDescriptor == null) + { + throw new ArgumentNullException(nameof(actionDescriptor)); + } + + var controllerType = actionDescriptor.ControllerTypeInfo?.AsType(); + if (controllerType == null) + { + throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull( + nameof(actionDescriptor.ControllerTypeInfo), + nameof(actionDescriptor)), + nameof(actionDescriptor)); + } + + var propertiesToActivate = GetPropertiesToActivate(controllerType); + void Activate(ControllerContext controllerContext, object controller) + { + for (var i = 0; i < propertiesToActivate.Length; i++) + { + var activateInfo = propertiesToActivate[i]; + activateInfo.Activate(controller, controllerContext); + } + } + + return Activate; + } + + private static PropertyActivator[] GetPropertiesToActivate(Type type) { IEnumerable> activators; activators = PropertyActivator.GetPropertiesToActivate( diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/IControllerPropertyActivator.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/IControllerPropertyActivatorFactory.cs similarity index 67% rename from src/Microsoft.AspNetCore.Mvc.Core/Internal/IControllerPropertyActivator.cs rename to src/Microsoft.AspNetCore.Mvc.Core/Internal/IControllerPropertyActivatorFactory.cs index d48144940a..441dee9898 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/IControllerPropertyActivator.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/IControllerPropertyActivatorFactory.cs @@ -1,10 +1,15 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; +using Microsoft.AspNetCore.Mvc.Controllers; + namespace Microsoft.AspNetCore.Mvc.Internal { public interface IControllerPropertyActivator { void Activate(ControllerContext context, object controller); + + Action GetActivatorDelegate(ControllerActionDescriptor actionDescriptor); } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/NormalizedRouteValue.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/NormalizedRouteValue.cs index 6aeee5f9d9..2da629c22e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/NormalizedRouteValue.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/NormalizedRouteValue.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.AspNetCore.Mvc.Core.Internal +namespace Microsoft.AspNetCore.Mvc.Internal { public static class NormalizedRouteValue { diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResourceInvoker.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResourceInvoker.cs index 34dcbb4f91..0e95b14971 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResourceInvoker.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ResourceInvoker.cs @@ -6,12 +6,12 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.ExceptionServices; using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Core; using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.Extensions.Logging; -namespace Microsoft.AspNetCore.Mvc.Core.Internal +namespace Microsoft.AspNetCore.Mvc.Internal { public abstract class ResourceInvoker { diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ViewEnginePath.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ViewEnginePath.cs index 18f69cbec6..a77cd5882a 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/ViewEnginePath.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/ViewEnginePath.cs @@ -7,7 +7,7 @@ using System.Diagnostics; using System.Text; using Microsoft.Extensions.Primitives; -namespace Microsoft.AspNetCore.Mvc.Core.Internal +namespace Microsoft.AspNetCore.Mvc.Internal { public static class ViewEnginePath { diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Microsoft.AspNetCore.Mvc.Core.csproj b/src/Microsoft.AspNetCore.Mvc.Core/Microsoft.AspNetCore.Mvc.Core.csproj index 058082e23f..19783101eb 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Microsoft.AspNetCore.Mvc.Core.csproj +++ b/src/Microsoft.AspNetCore.Mvc.Core/Microsoft.AspNetCore.Mvc.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/ParameterBinder.cs b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/ParameterBinder.cs index 58e6315b09..96b33be59e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/ParameterBinder.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/ParameterBinder.cs @@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding /// The /// The initial model value. /// The result of model binding. - public virtual async Task BindModelAsync( + public virtual Task BindModelAsync( ActionContext actionContext, IValueProvider valueProvider, ParameterDescriptor parameter, @@ -93,13 +93,65 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding } var metadata = _modelMetadataProvider.GetMetadataForType(parameter.ParameterType); - var binder = _modelBinderFactory.CreateBinder(new ModelBinderFactoryContext() + var binder = _modelBinderFactory.CreateBinder(new ModelBinderFactoryContext { BindingInfo = parameter.BindingInfo, Metadata = metadata, CacheToken = parameter, }); + return BindModelAsync( + actionContext, + binder, + valueProvider, + parameter, + metadata, + value); + } + + /// + /// Binds a model specified by using as the initial value. + /// + /// The . + /// The . + /// The . + /// The + /// The . + /// The initial model value. + /// The result of model binding. + public virtual async Task BindModelAsync( + ActionContext actionContext, + IModelBinder modelBinder, + IValueProvider valueProvider, + ParameterDescriptor parameter, + ModelMetadata metadata, + object value) + { + if (actionContext == null) + { + throw new ArgumentNullException(nameof(actionContext)); + } + + if (modelBinder == null) + { + throw new ArgumentNullException(nameof(modelBinder)); + } + + if (valueProvider == null) + { + throw new ArgumentNullException(nameof(valueProvider)); + } + + if (parameter == null) + { + throw new ArgumentNullException(nameof(parameter)); + } + + if (metadata == null) + { + throw new ArgumentNullException(nameof(metadata)); + } + var modelBindingContext = DefaultModelBindingContext.CreateBindingContext( actionContext, valueProvider, @@ -125,7 +177,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding modelBindingContext.ModelName = string.Empty; } - await binder.BindModelAsync(modelBindingContext); + await modelBinder.BindModelAsync(modelBindingContext); var modelBindingResult = modelBindingContext.Result; if (modelBindingResult.IsModelSet) diff --git a/src/Microsoft.AspNetCore.Mvc.Core/UrlHelperExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/UrlHelperExtensions.cs index d7835c28a3..93720a5826 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/UrlHelperExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/UrlHelperExtensions.cs @@ -4,7 +4,7 @@ using System; using System.Diagnostics; using Microsoft.AspNetCore.Mvc.Core; -using Microsoft.AspNetCore.Mvc.Core.Internal; +using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.Routing; using Microsoft.AspNetCore.Routing; diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs b/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs index 264f71dc6d..3770d86d49 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs @@ -6,9 +6,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; -using System.Text; using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Mvc.Core.Internal; +using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.Razor.Internal; using Microsoft.AspNetCore.Mvc.ViewEngines; using Microsoft.AspNetCore.Razor.Language; diff --git a/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/PageActionInvoker.cs b/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/PageActionInvoker.cs index 272a49d5a3..b9443fa298 100644 --- a/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/PageActionInvoker.cs +++ b/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/PageActionInvoker.cs @@ -8,7 +8,6 @@ using System.Reflection; using System.Runtime.ExceptionServices; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.Core.Internal; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ModelBinding; diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewDataDictionaryControllerPropertyActivator.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewDataDictionaryControllerPropertyActivator.cs index 82e9545da6..352c4aba5b 100644 --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewDataDictionaryControllerPropertyActivator.cs +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewFeatures/ViewDataDictionaryControllerPropertyActivator.cs @@ -3,6 +3,8 @@ using System; using System.Collections.Concurrent; +using System.Threading; +using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.Extensions.Internal; @@ -11,20 +13,25 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures { public class ViewDataDictionaryControllerPropertyActivator : IControllerPropertyActivator { - private readonly IModelMetadataProvider _modelMetadataProvider; - private readonly ConcurrentDictionary[]> _activateActions; private readonly Func[]> _getPropertiesToActivate; + private readonly IModelMetadataProvider _modelMetadataProvider; + private ConcurrentDictionary[]> _activateActions; + private bool _initialized; + private object _initializeLock = new object(); public ViewDataDictionaryControllerPropertyActivator(IModelMetadataProvider modelMetadataProvider) { _modelMetadataProvider = modelMetadataProvider; - - _activateActions = new ConcurrentDictionary[]>(); _getPropertiesToActivate = GetPropertiesToActivate; } public void Activate(ControllerContext actionContext, object controller) { + LazyInitializer.EnsureInitialized( + ref _activateActions, + ref _initialized, + ref _initializeLock); + var controllerType = controller.GetType(); var propertiesToActivate = _activateActions.GetOrAdd( controllerType, @@ -37,6 +44,31 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures } } + public Action GetActivatorDelegate(ControllerActionDescriptor actionDescriptor) + { + var controllerType = actionDescriptor.ControllerTypeInfo?.AsType(); + if (controllerType == null) + { + throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull( + nameof(actionDescriptor.ControllerTypeInfo), + nameof(actionDescriptor)), + nameof(actionDescriptor)); + } + + var propertiesToActivate = GetPropertiesToActivate(controllerType); + + void Activate(ControllerContext controllerContext, object controller) + { + for (var i = 0; i < propertiesToActivate.Length; i++) + { + var activateInfo = propertiesToActivate[i]; + activateInfo.Activate(controller, controllerContext); + } + } + + return Activate; + } + private PropertyActivator[] GetPropertiesToActivate(Type type) { var activators = PropertyActivator.GetPropertiesToActivate( diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Controllers/ControllerActivatorProviderTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Controllers/ControllerActivatorProviderTest.cs new file mode 100644 index 0000000000..0f224078b2 --- /dev/null +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Controllers/ControllerActivatorProviderTest.cs @@ -0,0 +1,157 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Reflection; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc.Internal; +using Microsoft.Extensions.DependencyInjection; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Controllers +{ + public class ControllerActivatorProviderTest + { + [Fact] + public void CreateActivator_InvokesIControllerActivator_IfItIsNotDefaultControllerActivator() + { + // Arrange + var expected = new object(); + var activator = new Mock(); + activator.Setup(a => a.Create(It.IsAny())) + .Returns(expected) + .Verifiable(); + var activatorProvider = new ControllerActivatorProvider(activator.Object); + var descriptor = new ControllerActionDescriptor + { + ControllerTypeInfo = typeof(object).GetTypeInfo(), + }; + + // Act + var activatorDelegate = activatorProvider.CreateActivator(descriptor); + var result = activatorDelegate(new ControllerContext()); + + // Assert + Assert.Same(expected, result); + activator.Verify(); + } + + [Fact] + public void CreateActivator_ActivatesControllerInstance() + { + // Arrange + var expected = new TestService(); + var activator = new DefaultControllerActivator(Mock.Of()); + var activatorProvider = new ControllerActivatorProvider(activator); + var descriptor = new ControllerActionDescriptor + { + ControllerTypeInfo = typeof(TestController).GetTypeInfo(), + }; + var serviceProvider = new ServiceCollection() + .AddSingleton(expected) + .BuildServiceProvider(); + var context = new ControllerContext + { + HttpContext = new DefaultHttpContext + { + RequestServices = serviceProvider, + }, + }; + + // Act + var activatorDelegate = activatorProvider.CreateActivator(descriptor); + var result = activatorDelegate(context); + + // Assert + var actual = Assert.IsType(result); + Assert.Same(expected, actual.TestService); + } + + [Fact] + public void CreateReleaser_InvokesIControllerActivator_IfItIsNotDefaultControllerActivator() + { + // Arrange + var expected = new object(); + var activator = new Mock(); + activator.Setup(a => a.Release(It.IsAny(), expected)) + .Verifiable(); + var activatorProvider = new ControllerActivatorProvider(activator.Object); + var descriptor = new ControllerActionDescriptor + { + ControllerTypeInfo = typeof(object).GetTypeInfo(), + }; + + // Act + var releaseDelegate = activatorProvider.CreateReleaser(descriptor); + releaseDelegate(new ControllerContext(), expected); + + // Assert + activator.Verify(); + } + + [Fact] + public void CreateReleaser_ReturnsNullIfControllerIsNotDisposable() + { + // Arrange + var activator = new DefaultControllerActivator(Mock.Of()); + var activatorProvider = new ControllerActivatorProvider(activator); + var descriptor = new ControllerActionDescriptor + { + ControllerTypeInfo = typeof(TestController).GetTypeInfo(), + }; + + // Act + var releaseDelegate = activatorProvider.CreateReleaser(descriptor); + + // Assert + Assert.Null(releaseDelegate); + } + + [Fact] + public void CreateReleaser_ReturnsDelegateThatDisposesInstance() + { + // Arrange + var activator = new DefaultControllerActivator(Mock.Of()); + var activatorProvider = new ControllerActivatorProvider(activator); + var descriptor = new ControllerActionDescriptor + { + ControllerTypeInfo = typeof(DisposableController).GetTypeInfo(), + }; + var controller = new DisposableController(); + + // Act + var releaseDelegate = activatorProvider.CreateReleaser(descriptor); + + // Assert + Assert.NotNull(releaseDelegate); + releaseDelegate(new ControllerContext(), controller); + Assert.True(controller.Disposed); + } + + private class TestController + { + public TestController(TestService testService) + { + TestService = testService; + } + + public TestService TestService { get; } + } + + private class DisposableController : IDisposable + { + public bool Disposed { get; private set; } + + public void Dispose() + { + Disposed = true; + } + } + + private class TestService + { + + } + } +} diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Controllers/ControllerFactoryProviderTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Controllers/ControllerFactoryProviderTest.cs new file mode 100644 index 0000000000..00f4492239 --- /dev/null +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Controllers/ControllerFactoryProviderTest.cs @@ -0,0 +1,163 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Reflection; +using Microsoft.AspNetCore.Mvc.Internal; +using Moq; +using Xunit; + +namespace Microsoft.AspNetCore.Mvc.Controllers +{ + public class ControllerFactoryProviderTest + { + [Fact] + public void CreateControllerFactory_InvokesIControllerFactory_IfItIsNotDefaultControllerFactory() + { + // Arrange + var expected = new object(); + var factory = new Mock(); + factory.Setup(f => f.CreateController(It.IsAny())) + .Returns(expected) + .Verifiable(); + var provider = new ControllerFactoryProvider( + Mock.Of(), + factory.Object, + Enumerable.Empty()); + var descriptor = new ControllerActionDescriptor + { + ControllerTypeInfo = typeof(object).GetTypeInfo(), + }; + + // Act + var factoryResult = provider.CreateControllerFactory(descriptor); + var result = factoryResult(new ControllerContext()); + + // Assert + Assert.Same(result, expected); + factory.Verify(); + } + + [Fact] + public void CreateControllerReleaser_InvokesIControllerFactory_IfItIsNotDefaultControllerFactory() + { + // Arrange + var controller = new object(); + var factory = new Mock(); + factory.Setup(f => f.ReleaseController(It.IsAny(), controller)) + .Verifiable(); + var provider = new ControllerFactoryProvider( + Mock.Of(), + factory.Object, + Enumerable.Empty()); + var descriptor = new ControllerActionDescriptor + { + ControllerTypeInfo = typeof(object).GetTypeInfo(), + }; + + // Act + var releaser = provider.CreateControllerReleaser(descriptor); + releaser(new ControllerContext(), controller); + + // Assert + factory.Verify(); + } + + [Fact] + public void CreateControllerReleaser_UsesControllerActivatorAndPropertyActivator() + { + // Arrange + var expectedProperty1 = new object(); + var expectedProperty2 = new object(); + var expectedController = new TestController(); + var factory = new DefaultControllerFactory( + Mock.Of(), + Enumerable.Empty()); + var activatorProvider = new Mock(); + activatorProvider.Setup(p => p.CreateActivator(It.IsAny())) + .Returns(_ => expectedController) + .Verifiable(); + + var propertyActivator1 = new Mock(); + propertyActivator1.Setup(p => p.GetActivatorDelegate(It.IsAny())) + .Returns((context, controllerObject) => + { + ((TestController)controllerObject).ActivatedValue1 = expectedProperty1; + }) + .Verifiable(); + + var propertyActivator2 = new Mock(); + propertyActivator2.Setup(p => p.GetActivatorDelegate(It.IsAny())) + .Returns((context, controllerObject) => + { + ((TestController)controllerObject).ActivatedValue2 = expectedProperty2; + }) + .Verifiable(); + + var propertyActivators = new[] + { + propertyActivator1.Object, + propertyActivator2.Object, + }; + var provider = new ControllerFactoryProvider( + activatorProvider.Object, + factory, + propertyActivators); + var descriptor = new ControllerActionDescriptor + { + ControllerTypeInfo = typeof(TestController).GetTypeInfo(), + }; + + // Act + var factoryDelegate = provider.CreateControllerFactory(descriptor); + var controller = factoryDelegate(new ControllerContext()); + + // Assert + var actual = Assert.IsType(controller); + Assert.Same(expectedController, actual); + Assert.Same(expectedProperty1, actual.ActivatedValue1); + Assert.Same(expectedProperty2, actual.ActivatedValue2); + activatorProvider.Verify(); + propertyActivator1.Verify(); + propertyActivator2.Verify(); + } + + [Fact] + public void CreateControllerReleaser_ReturnsReleaser() + { + // Arrange + var controller = new object(); + var factory = new DefaultControllerFactory( + Mock.Of(), + Enumerable.Empty()); + Action expected = (_, __) => { }; + var activatorProvider = new Mock(); + activatorProvider.Setup(p => p.CreateReleaser(It.IsAny())) + .Returns(expected) + .Verifiable(); + var provider = new ControllerFactoryProvider( + activatorProvider.Object, + factory, + Enumerable.Empty()); + var descriptor = new ControllerActionDescriptor + { + ControllerTypeInfo = typeof(object).GetTypeInfo(), + }; + + // Act + var actual = provider.CreateControllerReleaser(descriptor); + + // Assert + Assert.Same(expected, actual); + activatorProvider.Verify(); + } + + private class TestController + { + public object ActivatedValue1 { get; set; } + + public object ActivatedValue2 { get; set; } + } + } +} diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionInvokerCacheTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionInvokerCacheTest.cs index 9c9f99fd78..7a0bdf5295 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionInvokerCacheTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionInvokerCacheTest.cs @@ -1,12 +1,17 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Generic; using System.Reflection; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Infrastructure; +using Microsoft.AspNetCore.Mvc.ModelBinding; +using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; using Microsoft.AspNetCore.Routing; +using Moq; using Xunit; namespace Microsoft.AspNetCore.Mvc.Internal @@ -27,15 +32,15 @@ namespace Microsoft.AspNetCore.Mvc.Internal new[] { new DefaultFilterProvider() }); // Act - var cacheEntry1 = controllerActionInvokerCache.GetState(controllerContext); - var cacheEntry2 = controllerActionInvokerCache.GetState(controllerContext); + var cacheEntry1 = controllerActionInvokerCache.GetCachedResult(controllerContext); + var cacheEntry2 = controllerActionInvokerCache.GetCachedResult(controllerContext); // Assert - Assert.Equal(cacheEntry1.Filters, cacheEntry2.Filters); + Assert.Equal(cacheEntry1.filters, cacheEntry2.filters); } [Fact] - public void GetControllerActionMethodExecutor_CachesActionMethodExecutor() + public void GetControllerActionMethodExecutor_CachesEntry() { // Arrange var filter = new TestFilter(); @@ -48,11 +53,11 @@ namespace Microsoft.AspNetCore.Mvc.Internal new[] { new DefaultFilterProvider() }); // Act - var cacheEntry1 = controllerActionInvokerCache.GetState(controllerContext); - var cacheEntry2 = controllerActionInvokerCache.GetState(controllerContext); + var cacheEntry1 = controllerActionInvokerCache.GetCachedResult(controllerContext); + var cacheEntry2 = controllerActionInvokerCache.GetCachedResult(controllerContext); // Assert - Assert.Same(cacheEntry1.ActionMethodExecutor, cacheEntry2.ActionMethodExecutor); + Assert.Same(cacheEntry1.cacheEntry, cacheEntry2.cacheEntry); } private class TestFilter : IFilterMetadata @@ -92,7 +97,19 @@ namespace Microsoft.AspNetCore.Mvc.Internal { var descriptorProvider = new CustomActionDescriptorCollectionProvider( new[] { controllerContext.ActionDescriptor }); - return new ControllerActionInvokerCache(descriptorProvider, filterProviders); + var modelMetadataProvider = TestModelMetadataProvider.CreateDefaultProvider(); + var modelBinderFactory = TestModelBinderFactory.CreateDefault(); + + return new ControllerActionInvokerCache( + descriptorProvider, + new ParameterBinder( + modelMetadataProvider, + modelBinderFactory, + Mock.Of()), + modelBinderFactory, + modelMetadataProvider, + filterProviders, + Mock.Of()); } private static ControllerContext CreateControllerContext(FilterDescriptor[] filterDescriptors) @@ -101,7 +118,9 @@ namespace Microsoft.AspNetCore.Mvc.Internal { FilterDescriptors = filterDescriptors, MethodInfo = typeof(TestController).GetMethod(nameof(TestController.Index)), - ControllerTypeInfo = typeof(TestController).GetTypeInfo() + ControllerTypeInfo = typeof(TestController).GetTypeInfo(), + Parameters = new List(), + BoundProperties = new List(), }; var actionContext = new ActionContext(new DefaultHttpContext(), new RouteData(), actionDescriptor); diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionInvokerTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionInvokerTest.cs index eb48e60791..351ee0ea6b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionInvokerTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionInvokerTest.cs @@ -6,7 +6,6 @@ using System.Buffers; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; -using System.Globalization; using System.IO; using System.Linq; using System.Reflection; @@ -630,7 +629,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal // Assert challenge.Verify(r => r.ExecuteResultAsync(It.IsAny()), Times.Once()); filter1.Verify(f => f.OnAuthorization(It.IsAny()), Times.Once()); - Assert.False(invoker.ControllerFactory.CreateCalled); + Assert.False(invoker.ControllerState.CreateCalled); } [Fact] @@ -674,7 +673,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal f => f.OnAuthorizationAsync(It.IsAny()), Times.Once()); - Assert.False(invoker.ControllerFactory.CreateCalled); + Assert.False(invoker.ControllerState.CreateCalled); } [Fact] @@ -2106,7 +2105,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal expected.Verify(r => r.ExecuteResultAsync(It.IsAny()), Times.Once()); Assert.Same(expected.Object, context.Result); Assert.True(context.Canceled); - Assert.False(invoker.ControllerFactory.CreateCalled); + Assert.False(invoker.ControllerState.CreateCalled); } [Fact] @@ -2156,7 +2155,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal // Assert Assert.Null(context.Result); Assert.True(context.Canceled); - Assert.False(invoker.ControllerFactory.CreateCalled); + Assert.False(invoker.ControllerState.CreateCalled); } [Fact] @@ -2209,7 +2208,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal expected.Verify(r => r.ExecuteResultAsync(It.IsAny()), Times.Once()); Assert.Same(expected.Object, context.Result); Assert.True(context.Canceled); - Assert.False(invoker.ControllerFactory.CreateCalled); + Assert.False(invoker.ControllerState.CreateCalled); } [Fact] @@ -2272,7 +2271,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal f => f.OnResourceExecutionAsync(It.IsAny(), It.IsAny()), Times.Never()); - Assert.False(invoker.ControllerFactory.CreateCalled); + Assert.False(invoker.ControllerState.CreateCalled); } [Fact] @@ -2298,7 +2297,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal await invoker.InvokeAsync(); // Assert - var controllerContext = invoker.ControllerFactory.ControllerContext; + var controllerContext = invoker.ControllerState.ControllerContext; Assert.NotNull(controllerContext); Assert.Equal(2, controllerContext.ValueProviderFactories.Count); Assert.Same(valueProviderFactory1, controllerContext.ValueProviderFactories[0]); @@ -2329,7 +2328,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal await invoker.InvokeAsync(); // Assert - var controllerContext = invoker.ControllerFactory.ControllerContext; + var controllerContext = invoker.ControllerState.ControllerContext; Assert.NotNull(controllerContext); Assert.Equal(1, controllerContext.ValueProviderFactories.Count); Assert.Same(valueProviderFactory2, controllerContext.ValueProviderFactories[0]); @@ -2910,35 +2909,29 @@ namespace Microsoft.AspNetCore.Mvc.Internal var actionContext = new ActionContext(context.Object, new RouteData(), actionDescriptor); - var controllerFactory = new Mock(); - controllerFactory.Setup(c => c.CreateController(It.IsAny())) - .Returns(new TestController()); - - var metadataProvider = new EmptyModelMetadataProvider(); - - var parameterBinder = new ParameterBinder( - metadataProvider, - TestModelBinderFactory.CreateDefault(metadataProvider), - new DefaultObjectValidator(metadataProvider, new IModelValidatorProvider[0])); - var controllerContext = new ControllerContext(actionContext) { ValueProviderFactories = new IValueProviderFactory[0] }; controllerContext.ModelState.MaxAllowedErrors = 200; + var objectMethodExecutor = ObjectMethodExecutor.Create( + actionDescriptor.MethodInfo, + actionDescriptor.ControllerTypeInfo, + ParameterDefaultValues.GetParameterDefaultValues(actionDescriptor.MethodInfo)); + + var cacheEntry = new ControllerActionInvokerCacheEntry( + new FilterItem[0], + _ => new TestController(), + (_, __) => { }, + (_, __, ___) => Task.CompletedTask, + actionMethodExecutor: objectMethodExecutor); var invoker = new ControllerActionInvoker( - controllerFactory.Object, - parameterBinder, - metadataProvider, new NullLoggerFactory().CreateLogger(), new DiagnosticListener("Microsoft.AspNetCore"), controllerContext, - new IFilterMetadata[0], - ObjectMethodExecutor.Create( - actionDescriptor.MethodInfo, - actionDescriptor.ControllerTypeInfo, - ParameterDefaultValues.GetParameterDefaultValues(actionDescriptor.MethodInfo))); + cacheEntry, + new IFilterMetadata[0]); // Act await invoker.InvokeAsync(); @@ -2972,7 +2965,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal var invoker = CreateInvoker( new[] { filter }, actionDescriptor, - parameterBinder: null, controller: null, logger: logger); @@ -3015,7 +3007,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal var invoker = CreateInvoker( new[] { filter }, actionDescriptor, - parameterBinder: null, controller: null, diagnosticListener: listener, routeData: routeData); @@ -3055,7 +3046,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal var invoker = CreateInvoker( new[] { filter }, actionDescriptor, - parameterBinder: null, controller: null, diagnosticListener: listener); @@ -3145,8 +3135,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal } actionDescriptor.ControllerTypeInfo = typeof(ControllerActionInvokerTest).GetTypeInfo(); - return CreateInvoker( - filters, actionDescriptor, null, null, maxAllowedErrorsInModelState, valueProviderFactories); + return CreateInvoker(filters, actionDescriptor, null, maxAllowedErrorsInModelState, valueProviderFactories); } private TestControllerActionInvoker CreateInvoker( @@ -3173,18 +3162,17 @@ namespace Microsoft.AspNetCore.Mvc.Internal }); } - var parameterBinder = new TestParameterBinder(arguments); - - return CreateInvoker(filters, actionDescriptor, _controller, parameterBinder, maxAllowedErrorsInModelState); + var testControllerState = new TestControllerState(actionDescriptor, _controller, arguments); + return CreateInvoker(filters, actionDescriptor, _controller, maxAllowedErrorsInModelState, testControllerState: testControllerState); } private TestControllerActionInvoker CreateInvoker( IFilterMetadata[] filters, ControllerActionDescriptor actionDescriptor, object controller, - ParameterBinder parameterBinder = null, int maxAllowedErrorsInModelState = 200, List valueProviderFactories = null, + TestControllerState testControllerState = null, RouteData routeData = null, ILogger logger = null, object diagnosticListener = null) @@ -3222,6 +3210,11 @@ namespace Microsoft.AspNetCore.Mvc.Internal options.OutputFormatters.Add(formatter.Object); + if (testControllerState == null) + { + testControllerState = new TestControllerState(actionDescriptor, controller ?? this); + } + if (routeData == null) { routeData = new RouteData(); @@ -3232,11 +3225,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal routeData: routeData, actionDescriptor: actionDescriptor); - if (parameterBinder == null) - { - parameterBinder = new TestParameterBinder(new Dictionary()); - } - if (valueProviderFactories == null) { valueProviderFactories = new List(); @@ -3255,9 +3243,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal var invoker = new TestControllerActionInvoker( filters, - new MockControllerFactory(controller ?? this), - parameterBinder, - TestModelMetadataProvider.CreateDefaultProvider(), + testControllerState, logger, diagnosticSource, actionContext, @@ -3443,13 +3429,45 @@ namespace Microsoft.AspNetCore.Mvc.Internal } } - private class MockControllerFactory : IControllerFactory + private class TestControllerState { - private object _controller; + private readonly ControllerActionDescriptor _descriptor; + private readonly object _controller; - public MockControllerFactory(object controller) + public TestControllerState( + ControllerActionDescriptor descriptor, + object controller) + : this(descriptor, controller, new Dictionary()) { + } + + public TestControllerState( + ControllerActionDescriptor descriptor, + object controller, + IDictionary actionArguments) + { + _descriptor = descriptor; _controller = controller; + + var objectMethodExecutor = ObjectMethodExecutor.Create( + _descriptor.MethodInfo, + _descriptor.ControllerTypeInfo, + ParameterDefaultValues.GetParameterDefaultValues(_descriptor.MethodInfo)); + + CacheEntry = new ControllerActionInvokerCacheEntry( + new FilterItem[0], + CreateController, + ReleaseController, + (_, __, args) => + { + foreach (var item in actionArguments) + { + args[item.Key] = item.Value; + } + + return Task.CompletedTask; + }, + objectMethodExecutor); } public bool CreateCalled { get; private set; } @@ -3458,6 +3476,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal public ControllerContext ControllerContext { get; private set; } + public ControllerActionInvokerCacheEntry CacheEntry { get; } + public object CreateController(ControllerContext context) { ControllerContext = context; @@ -3485,43 +3505,30 @@ namespace Microsoft.AspNetCore.Mvc.Internal { public TestControllerActionInvoker( IFilterMetadata[] filters, - MockControllerFactory controllerFactory, - ParameterBinder parameterBinder, - IModelMetadataProvider modelMetadataProvider, + TestControllerState testControllerState, ILogger logger, DiagnosticSource diagnosticSource, ActionContext actionContext, IReadOnlyList valueProviderFactories, int maxAllowedErrorsInModelState) : base( - controllerFactory, - parameterBinder, - modelMetadataProvider, logger, diagnosticSource, CreatControllerContext(actionContext, valueProviderFactories, maxAllowedErrorsInModelState), - filters, - CreateExecutor((ControllerActionDescriptor)actionContext.ActionDescriptor)) + testControllerState.CacheEntry, + filters) { - ControllerFactory = controllerFactory; + ControllerState = testControllerState; } - public MockControllerFactory ControllerFactory { get; } + public TestControllerState ControllerState { get; } public async override Task InvokeAsync() { await base.InvokeAsync(); // Make sure that the controller was disposed in every test that creates ones. - ControllerFactory.Verify(); - } - - private static ObjectMethodExecutor CreateExecutor(ControllerActionDescriptor actionDescriptor) - { - return ObjectMethodExecutor.Create( - actionDescriptor.MethodInfo, - actionDescriptor.ControllerTypeInfo, - ParameterDefaultValues.GetParameterDefaultValues(actionDescriptor.MethodInfo)); + ControllerState.Verify(); } private static ControllerContext CreatControllerContext( @@ -3539,6 +3546,14 @@ namespace Microsoft.AspNetCore.Mvc.Internal } } + private static ObjectMethodExecutor CreateExecutor(ControllerActionDescriptor actionDescriptor) + { + return ObjectMethodExecutor.Create( + actionDescriptor.MethodInfo, + actionDescriptor.ControllerTypeInfo, + ParameterDefaultValues.GetParameterDefaultValues(actionDescriptor.MethodInfo)); + } + private class MockAuthorizationFilter : IAuthorizationFilter { int _expectedMaxAllowedErrors; diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionInvokerParameterBindingTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerBinderDelegateProviderTest.cs similarity index 89% rename from test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionInvokerParameterBindingTest.cs rename to test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerBinderDelegateProviderTest.cs index a569ca721e..434fdef05e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerActionInvokerParameterBindingTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/ControllerBinderDelegateProviderTest.cs @@ -9,7 +9,9 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.Formatters; using Microsoft.AspNetCore.Mvc.ModelBinding; +using Microsoft.AspNetCore.Mvc.ModelBinding.Binders; using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; using Microsoft.AspNetCore.Routing; using Moq; @@ -17,7 +19,7 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.Internal { - public class ControllerActionInvokerParameterBindingTest + public class ControllerBinderDelegateProviderTest { [Fact] public async Task BindActionArgumentsAsync_DoesNotAddActionArguments_IfBinderReturnsNull() @@ -44,12 +46,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal var arguments = new Dictionary(StringComparer.Ordinal); // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert Assert.Empty(arguments); @@ -80,12 +83,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal var arguments = new Dictionary(StringComparer.Ordinal); // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert Assert.Empty(arguments); @@ -125,12 +129,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal var arguments = new Dictionary(StringComparer.Ordinal); // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert Assert.Equal(1, arguments.Count); @@ -166,12 +171,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal var arguments = new Dictionary(StringComparer.Ordinal); // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert mockValidator @@ -218,12 +224,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal var parameterBinder = GetParameterBinder(factory, mockValidator.Object); // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert mockValidator @@ -263,12 +270,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal var parameterBinder = GetParameterBinder(factory, mockValidator.Object); // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert mockValidator @@ -314,12 +322,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal var parameterBinder = GetParameterBinder(factory, mockValidator.Object); // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert mockValidator @@ -353,12 +362,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert Assert.Equal("Hello", controller.StringProperty); @@ -388,12 +398,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal var parameterBinder = GetParameterBinder(factory); // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert Assert.Equal(expected, controller.CollectionProperty); @@ -429,12 +440,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal controller.NonNullableProperty = -1; // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert Assert.Equal(-1, controller.NonNullableProperty); @@ -466,12 +478,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal controller.NullableProperty = -1; // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert Assert.Null(controller.NullableProperty); @@ -543,12 +556,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal var parameterBinder = GetParameterBinder(factory); // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert Assert.Equal(expectedValue, propertyAccessor(controller)); @@ -622,12 +636,13 @@ namespace Microsoft.AspNetCore.Mvc.Internal var parameterBinder = GetParameterBinder(factory); // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - controllerContext, - controller, - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, controller, arguments); // Assert Assert.Equal(new string[] { "goodbye" }, controller.ArrayProperty); // Skipped @@ -708,17 +723,20 @@ namespace Microsoft.AspNetCore.Mvc.Internal Parameters = parameters }; var modelMetadataProvider = new EmptyModelMetadataProvider(); - + var modelBinderProvider = new BodyModelBinderProvider(new[] { Mock.Of() }, Mock.Of()); + var factory = TestModelBinderFactory.CreateDefault(modelBinderProvider); var parameterBinder = new Mock( new EmptyModelMetadataProvider(), - TestModelBinderFactory.CreateDefault(), + factory, CreateMockValidator()); parameterBinder.Setup(p => p.BindModelAsync( It.IsAny(), + It.IsAny(), It.IsAny(), It.IsAny(), + It.IsAny(), null)) - .Returns((ActionContext context, IValueProvider valueProvider, ParameterDescriptor descriptor, object v) => + .Returns((ActionContext context, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor descriptor, ModelMetadata metadata, object v) => { ModelBindingResult result; if (descriptor.Name == "accountId") @@ -741,26 +759,26 @@ namespace Microsoft.AspNetCore.Mvc.Internal return Task.FromResult(result); }); - var testContext = new ControllerContext + var controllerContext = new ControllerContext { ActionDescriptor = actionDescriptor, }; var arguments = new Dictionary(StringComparer.Ordinal); - var modelState = testContext.ModelState; + var modelState = controllerContext.ModelState; // Act - await ControllerActionInvoker.BindArgumentsCoreAsync( + var binderDelegate = ControllerBinderDelegateProvider.CreateBinderDelegate( parameterBinder.Object, + factory, TestModelMetadataProvider.CreateDefaultProvider(), - testContext, - new TestController(), - arguments); + actionDescriptor); + + await binderDelegate(controllerContext, new TestController(), arguments); // Assert Assert.True(modelState.IsValid); - object value; - Assert.True(arguments.TryGetValue("accountId", out value)); + Assert.True(arguments.TryGetValue("accountId", out var value)); var accountId = Assert.IsType(value); Assert.Equal(10, accountId); Assert.True(arguments.TryGetValue("transferInfo", out value)); diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/MiddlewareFilterTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/MiddlewareFilterTest.cs index 77d0cc47d0..0455f79937 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/MiddlewareFilterTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/MiddlewareFilterTest.cs @@ -14,7 +14,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; using Microsoft.AspNetCore.Routing; @@ -284,8 +283,6 @@ namespace Microsoft.AspNetCore.Mvc.Internal var invoker = new TestControllerActionInvoker( filters, new MockControllerFactory(controller ?? this), - new TestParameterBinder(actionParameters: null), - TestModelMetadataProvider.CreateDefaultProvider(), new NullLoggerFactory().CreateLogger(), diagnosticSource, actionContext, @@ -342,7 +339,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal return services; } - private class MockControllerFactory : IControllerFactory + private class MockControllerFactory { private object _controller; @@ -380,37 +377,22 @@ namespace Microsoft.AspNetCore.Mvc.Internal } } - private static ControllerActionInvokerCache CreateFilterCache(IFilterProvider[] filterProviders = null) - { - var descriptorProvider = new ActionDescriptorCollectionProvider( - Enumerable.Empty(), - Enumerable.Empty()); - return new ControllerActionInvokerCache( - descriptorProvider, - filterProviders.AsEnumerable() ?? new List()); - } - private class TestControllerActionInvoker : ControllerActionInvoker { public TestControllerActionInvoker( IFilterMetadata[] filters, MockControllerFactory controllerFactory, - ParameterBinder parameterBinder, - IModelMetadataProvider modelMetadataProvider, ILogger logger, DiagnosticSource diagnosticSource, ActionContext actionContext, IReadOnlyList valueProviderFactories, int maxAllowedErrorsInModelState) : base( - controllerFactory, - parameterBinder, - modelMetadataProvider, logger, diagnosticSource, CreatControllerContext(actionContext, valueProviderFactories, maxAllowedErrorsInModelState), - filters, - CreateExecutor((ControllerActionDescriptor)actionContext.ActionDescriptor)) + CreateCacheEntry((ControllerActionDescriptor)actionContext.ActionDescriptor, controllerFactory), + filters) { ControllerFactory = controllerFactory; } @@ -443,6 +425,18 @@ namespace Microsoft.AspNetCore.Mvc.Internal return controllerContext; } + + private static ControllerActionInvokerCacheEntry CreateCacheEntry( + ControllerActionDescriptor actionDescriptor, + MockControllerFactory controllerFactory) + { + return new ControllerActionInvokerCacheEntry( + new FilterItem[0], + controllerFactory.CreateController, + controllerFactory.ReleaseController, + null, + CreateExecutor(actionDescriptor)); + } } private class TestParameterBinder : ParameterBinder diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/out.host.17-05-12_14-46-19_16053_4.txt b/test/Microsoft.AspNetCore.Mvc.Core.Test/out.host.17-05-12_14-46-19_16053_4.txt new file mode 100644 index 0000000000..4f35562480 --- /dev/null +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/out.host.17-05-12_14-46-19_16053_4.txt @@ -0,0 +1,227 @@ +TpTrace Information: 0 : 7340, 2, 2017/05/12, 14:46:19.552, 2296211289945, testhost.dll, DefaultEngineInvoker: Monitoring parent process with id: '17636' +TpTrace Information: 0 : 7340, 2, 2017/05/12, 14:46:19.582, 2296211362311, testhost.dll, DefaultEngineInvoker: Initialize communication on port number: '64746' +TpTrace Information: 0 : 7340, 2, 2017/05/12, 14:46:19.589, 2296211382526, testhost.dll, Trying to connect to server on port : 64746 +TpTrace Information: 0 : 7340, 6, 2017/05/12, 14:46:19.619, 2296211471935, testhost.dll, Connected to the server successfully +TpTrace Information: 0 : 7340, 2, 2017/05/12, 14:46:19.770, 2296211912888, testhost.dll, DefaultEngineInvoker: Start Request Processing. +TpTrace Information: 0 : 7340, 5, 2017/05/12, 14:46:19.786, 2296211961678, testhost.dll, Discovery Session Initialize. +TpTrace Information: 0 : 7340, 5, 2017/05/12, 14:46:19.791, 2296211974612, testhost.dll, Execution started. +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.800, 2296212001963, testhost.dll, TestPluginCache: Updating loadOnlyWellKnownExtensions from False to False. +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.803, 2296212012328, testhost.dll, TestPluginCache: Using directories for assembly resolution 'D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\bin\Debug\netcoreapp2.0'. +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.804, 2296212013228, testhost.dll, TestPluginCache: Updated the available extensions to 'D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\bin\Debug\netcoreapp2.0\xunit.runner.visualstudio.dotnetcore.testadapter.dll'. +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.806, 2296212018539, testhost.dll, TestExecutorService: Loading the extensions +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.824, 2296212071700, testhost.dll, TestPluginCache: Discovering the extensions using extension path. +TpTrace Error: 0 : 7340, 8, 2017/05/12, 14:46:19.825, 2296212074849, testhost.dll, Default extensions folder does not exist +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:19.834, 2296212101249, testhost.dll, AssemblyResolver: xunit.runner.visualstudio.dotnetcore.testadapter: Resolving assembly. +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:19.836, 2296212108511, testhost.dll, AssemblyResolver: xunit.runner.visualstudio.dotnetcore.testadapter: Resolved assembly. +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:19.838, 2296212114315, testhost.dll, AssemblyResolver: xunit.runner.utility.netstandard15: Resolving assembly. +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:19.839, 2296212117237, testhost.dll, AssemblyResolver: xunit.runner.utility.netstandard15: Resolved assembly. +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.849, 2296212144749, testhost.dll, TestPluginCache: Discovered the extensions using extension path 'D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\bin\Debug\netcoreapp2.0\xunit.runner.visualstudio.dotnetcore.testadapter.dll'. +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.851, 2296212152310, testhost.dll, TestPluginCache: Discoverers are 'Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner, xunit.runner.visualstudio.dotnetcore.testadapter, Version=2.2.0.1274, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c'. +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.851, 2296212152804, testhost.dll, TestPluginCache: Executors are 'executor://xunit/VsTestRunner2'. +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.852, 2296212153071, testhost.dll, TestPluginCache: Setting providers are ''. +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.852, 2296212153245, testhost.dll, TestPluginCache: Loggers are ''. +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:19.863, 2296212185977, testhost.dll, TestPluginManager.CreateTestExtension: Attempting to load test extension: Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.863, 2296212186881, testhost.dll, TestDiscoveryManager: LoadExtensions: Created discoverer Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.863, 2296212187141, testhost.dll, TestExecutorService: Loaded the discoverers +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:19.873, 2296212215633, testhost.dll, TestPluginManager.CreateTestExtension: Attempting to load test extension: Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.873, 2296212216190, testhost.dll, TestExecutorExtensionManager: Loading executor Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.873, 2296212216371, testhost.dll, TestExecutorService: Loaded the executors +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.878, 2296212230115, testhost.dll, TestExecutorService: Loaded the settings providers +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:19.878, 2296212230432, testhost.dll, TestExecutorService: Loaded the extensions +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:19.911, 2296212325983, testhost.dll, AssemblyResolver: Microsoft.VisualStudio.TestPlatform.Common.resources: Resolving assembly. +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:19.912, 2296212329124, testhost.dll, AssemblyResolver: Microsoft.VisualStudio.TestPlatform.Common.resources: Resolving assembly. +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:19.938, 2296212406954, testhost.dll, TestDiscoveryManager: Discovering tests from sources D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\bin\Debug\netcoreapp2.0\Microsoft.AspNetCore.Mvc.Core.Test.dll +TpTrace Verbose: 0 : 7340, 8, 2017/05/12, 14:46:19.948, 2296212435838, testhost.dll, BaseRunTests.RunTestInternalWithExecutors: Running tests for executor://xunit/VsTestRunner2 +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:21.567, 2296217179825, testhost.dll, AssemblyResolver: xunit.runner.reporters.netstandard15: Resolving assembly. +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:21.568, 2296217181466, testhost.dll, AssemblyResolver: xunit.runner.reporters.netstandard15: Resolved assembly. +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:21.569, 2296217185540, testhost.dll, AssemblyResolver: xunit.runner.utility.netstandard15: Resolving assembly. +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:21.569, 2296217185750, testhost.dll, AssemblyResolver: xunit.runner.utility.netstandard15: Resolved from cache. +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:21.688, 2296217531986, testhost.dll, [xUnit.net 00:00:01.7330337] Discovering: Microsoft.AspNetCore.Mvc.Core.Test +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:24.892, 2296226920961, testhost.dll, [xUnit.net 00:00:04.9399399] Discovered: Microsoft.AspNetCore.Mvc.Core.Test +TpTrace Information: 0 : 7340, 8, 2017/05/12, 14:46:26.011, 2296230196922, testhost.dll, [xUnit.net 00:00:06.0581478] Starting: Microsoft.AspNetCore.Mvc.Core.Test +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.133, 2296230555033, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.169, 2296230660092, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.235, 2296230853307, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.261, 2296230930194, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.261, 2296230930969, testhost.dll, InProgressTests is null +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.267, 2296230948461, testhost.dll, AssemblyResolver: Microsoft.VisualStudio.TestPlatform.ObjectModel.resources: Resolving assembly. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.268, 2296230950524, testhost.dll, AssemblyResolver: Microsoft.VisualStudio.TestPlatform.ObjectModel.resources: Resolving assembly. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.269, 2296230954276, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.Constructor_InitializesActionName(actionName: null) Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.269, 2296230955003, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.269, 2296230955651, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.DefaultModelMetadataBindingDetailsProviderTest.CreateBindingDetails_BindingBehaviorLeftAlone_ForAttributeOnPropertyType(initialValue: False) Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.270, 2296230956600, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProviderTest.DefaultFilterProvider_UsesFilter_WhenItsNotIFilterFactory Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.270, 2296230958000, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.297, 2296231035076, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.297, 2296231036058, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.297, 2296231036327, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.DefaultModelMetadataBindingDetailsProviderTest.CreateBindingDetails_FindsBindNever_OnContainerClass Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.297, 2296231036648, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.297, 2296231037278, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.298, 2296231037803, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.298, 2296231038351, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.298, 2296231038850, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.298, 2296231039367, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.298, 2296231039898, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.298, 2296231040407, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.299, 2296231040941, testhost.dll, InProgressTests is null +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.299, 2296231041249, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.317, 2296231093622, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.317, 2296231094370, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.317, 2296231094684, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.DefaultModelMetadataBindingDetailsProviderTest.CreateBindingDetails_FindsBindNever_OnProperty Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.317, 2296231094970, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.317, 2296231095534, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.317, 2296231096109, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.318, 2296231096590, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.318, 2296231097119, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.318, 2296231097674, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.318, 2296231098292, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.318, 2296231098860, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.319, 2296231099371, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.319, 2296231099693, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.319, 2296231099904, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.HttpStatusCodeResultTests.HttpStatusCodeResult_ExecuteResultSetsResponseStatusCode Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.319, 2296231100078, testhost.dll, Sending test run statistics +TpTrace Information: 0 : 7340, 15, 2017/05/12, 14:46:26.320, 2296231103948, testhost.dll, AssemblyResolver: Moq.resources: Resolving assembly. +TpTrace Information: 0 : 7340, 15, 2017/05/12, 14:46:26.321, 2296231105746, testhost.dll, AssemblyResolver: Moq.resources: Resolving assembly. +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.336, 2296231150616, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.336, 2296231151249, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.336, 2296231151627, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.336, 2296231151887, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.AuthorizationApplicationModelProviderTest.OnProvidersExecuting_DefaultPolicyProvider_NoAuthorizationData_NoFilterCreated Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.337, 2296231152151, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.337, 2296231152653, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.337, 2296231153361, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.337, 2296231154267, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.DefaultValues Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.338, 2296231155289, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.364, 2296231232490, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.364, 2296231233502, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.364, 2296231233763, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.AuthorizationApplicationModelProviderTest.BuildActionModels_BaseAuthorizeFiltersAreStillValidWhenOverriden Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.365, 2296231234018, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.365, 2296231234496, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ReferenceEqualityComparerTest.GetHashCode_DoesNotThrowForNull Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.365, 2296231235011, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.IsRequired_ReturnsFalse_ForNullableTypes(modelType: typeof(int?)) Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.365, 2296231236582, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.386, 2296231296645, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.386, 2296231297345, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.386, 2296231297586, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ReferenceEqualityComparerTest.Equals_NullEqualsNull Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.386, 2296231298024, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.387, 2296231298477, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.387, 2296231298994, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.AuthorizationApplicationModelProviderTest.CreateControllerModelAndActionModel_AllowAnonymousAttributeAddsAllowAnonymousFilter Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.387, 2296231300245, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_SelectDefaultFormatter_OnAllMediaRangeAcceptHeaderMediaType(acceptHeader: "text/html,application/xhtml+xml,application/xml;q="..., expectedContentType: "application/json; charset=utf-8") Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.387, 2296231300781, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.418, 2296231389989, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.418, 2296231390966, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.418, 2296231391249, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_SelectDefaultFormatter_OnAllMediaRangeAcceptHeaderMediaType(acceptHeader: "*/*", expectedContentType: "application/json; charset=utf-8") Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.418, 2296231391545, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.419, 2296231392686, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProviderTest.DefaultFilterProvider_UsesFilterFactory Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.419, 2296231394117, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.IsReadOnly_ReturnsTrue_ForPrivateSetProperty Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.419, 2296231394412, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.452, 2296231489945, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.452, 2296231490714, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.452, 2296231491331, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.453, 2296231491860, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.453, 2296231492380, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.453, 2296231492876, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.453, 2296231493390, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.453, 2296231493846, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.453, 2296231494319, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.454, 2296231494832, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.454, 2296231495078, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributesTest.GetAttributesForBaseProperty_IncludesMetadataAttributes Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.454, 2296231495345, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.454, 2296231495609, testhost.dll, InProgressTests is null +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.454, 2296231495952, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.475, 2296231559042, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.497, 2296231621740, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.497, 2296231622047, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributesTest.GetAttributesForBasePropertyFromDerivedModel_IncludesMetadataAttributes Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.497, 2296231622299, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.497, 2296231622788, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.498, 2296231625320, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ObjectResult_PerformsContentNegotiation_OnAllMediaRangeAcceptHeaderMediaType(acceptHeader: "text/html,*/*;q=0.8,application/xml;q=0.9", expectedContentType: "application/xml; charset=utf-8") Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.498, 2296231625623, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.519, 2296231686784, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.519, 2296231687393, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.519, 2296231687929, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.520, 2296231688432, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.520, 2296231688899, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.520, 2296231689363, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.520, 2296231689933, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.AuthorizationApplicationModelProviderTest.OnProvidersExecuting_NonDefaultPolicyProvider_HasNoPolicy_HasPolicyProviderAndAuthorizeData Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.520, 2296231690529, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.521, 2296231691077, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.521, 2296231691588, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.521, 2296231692105, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProviderTest.DefaultFilterProvider_UsesFilterFactory_WithIFilterContainer Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.521, 2296231692338, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.555, 2296231791308, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.555, 2296231792089, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.555, 2296231792544, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.ExecuteResultAsync_ThrowsIfActionUrlIsNullOrEmpty(returnValue: "") Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.555, 2296231792931, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_MatchAllContentType_Throws(contentTypes: ["*/*"], invalidContentType: "*/*") Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.556, 2296231793934, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ChallengeResultTest.ChallengeResult_Execute Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.556, 2296231794560, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.578, 2296231858377, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.578, 2296231859156, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.578, 2296231859463, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_MatchAllContentType_Throws(contentTypes: ["*/*", "application/json"], invalidContentType: "*/*") Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.578, 2296231859840, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.578, 2296231860441, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.578, 2296231860942, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilterTest.OnActionExecuting_DoesNotChangeActionResult_IfOtherExceptionsAreFoundOnModelState Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.579, 2296231862973, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.621, 2296231986570, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.622, 2296231987651, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.622, 2296231987981, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilterTest.OnActionExecuting_DoesNotChangeActionResult_IfOtherErrorsAreFoundOnModelState Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.622, 2296231988322, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.622, 2296231988862, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.622, 2296231989078, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.SelectFormatter_WithMultipleProvidedContentTypes_DoesConneg Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.622, 2296231989761, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.SelectFormatter_WithMultipleProvidedContentTypes_DoesConneg Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.623, 2296231990697, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.SelectFormatter_WithMultipleProvidedContentTypes_DoesConneg Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.623, 2296231991261, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.SelectFormatter_WithMultipleProvidedContentTypes_DoesConneg Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.623, 2296231991760, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.SelectFormatter_WithMultipleProvidedContentTypes_DoesConneg Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.623, 2296231992422, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.ExecuteResultAsync_ThrowsIfActionUrlIsNullOrEmpty(returnValue: null) Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.624, 2296231992877, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.643, 2296232050177, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.643, 2296232051058, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.643, 2296232051369, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.SelectFormatter_WithAcceptHeaderAndContentTypes_SetsContentTypeIsServerDefinedWhenExpected Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.644, 2296232051676, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.644, 2296232052232, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ChallengeResultTest.ChallengeResult_ExecuteNoSchemes Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.644, 2296232052867, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.644, 2296232053428, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.Constructor_InitializesControllerName(controllerName: "") Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.645, 2296232054811, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.664, 2296232110598, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.664, 2296232111569, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.664, 2296232111950, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_WithOneProvidedContentType_FromResponseContentType_NoFallback Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.664, 2296232112236, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.664, 2296232112828, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.665, 2296232113829, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.665, 2296232114895, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.665, 2296232115785, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.666, 2296232116417, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.FilterFactoryTest.GetAllFilters_CachesAllFilters Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.666, 2296232117531, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.698, 2296232211061, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.698, 2296232212186, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.699, 2296232212543, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.FilterFactoryTest.GetAllFilters_DoesNotCacheFiltersWithIsReusableFalse Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.699, 2296232212763, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.699, 2296232213589, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_FallsBackOnFormattersInOptions Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.699, 2296232214235, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.699, 2296232214651, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.699, 2296232215146, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderTests.BindModel Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.700, 2296232215639, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.PropertiesProperty_WithDefaultOrder_OrdersPropertyNamesAsProvided Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.700, 2296232216080, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.PropertiesProperty_WithDefaultOrder_OrdersPropertyNamesAsProvided Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.700, 2296232216586, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.718, 2296232270493, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.719, 2296232271820, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.PropertiesProperty_WithDefaultOrder_OrdersPropertyNamesAsProvided Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.719, 2296232272422, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.FilterFactoryTest.GetAllFilters_CachesFilterFromFactory Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.719, 2296232273038, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.PropertiesProperty_WithDefaultOrder_OrdersPropertyNamesAsProvided Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.720, 2296232274788, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderTests.BindModelSetsModelToNullOnNullOrEmptyString(value: "") Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.720, 2296232275103, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.757, 2296232382729, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.757, 2296232383512, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.757, 2296232384187, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.PropertiesSetOnce Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.758, 2296232385513, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProviderTest.DefaultFilterProvider_UsesFilterFactory_WithOrder Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.758, 2296232386667, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.ExecuteResultAsync_SetsStatusCodeAndLocationHeader Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.758, 2296232387109, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.794, 2296232493307, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.795, 2296232494268, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.795, 2296232494585, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.ElementMetadata_ReturnsExpectedMetadata(modelType: typeof(System.Collections.ObjectModel.Collection), elementType: typeof(int)) Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.795, 2296232494872, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.795, 2296232495357, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.797, 2296232501211, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.797, 2296232502098, testhost.dll, InProgressTests is null +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.798, 2296232503780, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderTests.BindModelAddsModelErrorsOnInvalidCharacters Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.798, 2296232504488, testhost.dll, Sending test run statistics +TpTrace Verbose: 0 : 7340, 12, 2017/05/12, 14:46:26.823, 2296232577472, testhost.dll, TestRunCache: OnNewTestResult: Notified the onCacheHit callback. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.831, 2296232600301, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderTests.BindModel_ReturnsWithIsModelSetFalse_WhenValueNotFound Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.831, 2296232601807, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.OnFormatting_NullContext_ThrowsArgumentNullException Passed' in inProgress list. +TpTrace Warning: 0 : 7340, 12, 2017/05/12, 14:46:26.832, 2296232603080, testhost.dll, TestRunCache: No test found corresponding to testResult 'Microsoft.AspNetCore.Mvc.Formatters.TextOutputFormatterTests.SelectResponseCharacterEncoding_SelectsEncoding(acceptCharsetHeaders: "utf-16; q=0.5", supportedEncodings: ["utf-8", "utf-16"], expectedEncoding: "utf-16") Passed' in inProgress list. +TpTrace Information: 0 : 7340, 12, 2017/05/12, 14:46:26.832, 2296232603497, testhost.dll, Sending test run statistics diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/out.txt b/test/Microsoft.AspNetCore.Mvc.Core.Test/out.txt new file mode 100644 index 0000000000..bdb9cee5c9 --- /dev/null +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/out.txt @@ -0,0 +1,172 @@ +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:18.953, 2296209529728, vstest.console.dll, Using .Net Framework version:.NETCoreApp,Version=v2.0 +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:18.998, 2296209653022, vstest.console.dll, TestPluginCache: Discovering the extensions using extension path. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:19.001, 2296209661337, vstest.console.dll, AssemblyResolver: Microsoft.TestPlatform.TestHostRuntimeProvider: Resolving assembly. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:19.003, 2296209666162, vstest.console.dll, AssemblyResolver: Microsoft.TestPlatform.TestHostRuntimeProvider: Resolved assembly. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:19.006, 2296209676477, vstest.console.dll, AssemblyResolver: Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger: Resolving assembly. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:19.008, 2296209680971, vstest.console.dll, AssemblyResolver: Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger: Resolved assembly. +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:19.010, 2296209688504, vstest.console.dll, TestPluginCache: Discovered the extensions using extension path ''. +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:19.011, 2296209689400, vstest.console.dll, TestPluginCache: Discoverers are ''. +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:19.011, 2296209689928, vstest.console.dll, TestPluginCache: Executors are ''. +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:19.011, 2296209690442, vstest.console.dll, TestPluginCache: Setting providers are ''. +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:19.011, 2296209690923, vstest.console.dll, TestPluginCache: Loggers are 'logger://Microsoft/TestPlatform/TrxLogger/v2'. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:19.033, 2296209754849, vstest.console.dll, RunTestsArgumentProcessor:Execute: Test run is starting. +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:19.033, 2296209755453, vstest.console.dll, RunTestsArgumentProcessor:Execute: Queuing Test run. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:19.033, 2296209756222, vstest.console.dll, TestRequestManager.RunTests: run tests started. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:19.086, 2296209908971, vstest.console.dll, TestPluginManager.CreateTestExtension: Attempting to load test extension: Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DefaultTestHostManager +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:19.086, 2296209910233, vstest.console.dll, TestPluginManager.CreateTestExtension: Attempting to load test extension: Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:19.087, 2296209912861, vstest.console.dll, TestEngine: Initializing Parallel Execution as MaxCpuCount is set to: 1 +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:19.096, 2296209940729, vstest.console.dll, TestRunRequest.ExecuteAsync: Creating test run request. +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:19.097, 2296209942353, vstest.console.dll, TestRunRequest.ExecuteAsync: Starting. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:19.097, 2296209943116, vstest.console.dll, TestRunRequest.ExecuteAsync: Starting run with settings:TestRunCriteria: + KeepAlive=False,FrequencyOfRunStatsChangeEvent=10,RunStatsChangeEventTimeout=00:00:01.5000000,TestCaseFilter=,TestExecutorLauncher= + Settingsxml= + + + D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\TestResults + X86 + .NETCoreApp,Version=v2.0 + + + +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:19.097, 2296209943354, vstest.console.dll, TestRunRequest.ExecuteAsync: Wait for the first run request is over. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:19.099, 2296209948803, vstest.console.dll, TestRunRequest.ExecuteAsync: Started. +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:19.099, 2296209949515, vstest.console.dll, TestRunRequest.WaitForCompletion: Waiting with timeout -1. +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:19.099, 2296209949680, vstest.console.dll, ProxyParallelExecutionManager: Triggering test run for next source: D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\bin\Debug\netcoreapp2.0\Microsoft.AspNetCore.Mvc.Core.Test.dll +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:19.100, 2296209951000, vstest.console.dll, ProxyExecutionManager: Test host is non shared. Lazy initialize. +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:19.153, 2296210107110, vstest.console.dll, Listening on port : 64746 +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:19.167, 2296210147124, vstest.console.dll, DotnetTestHostmanager: Full path of dotnet.exe is C:\Users\Pranav\.dotnet\x64\dotnet.exe +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:19.167, 2296210147773, vstest.console.dll, DotnetTestHostmanager: Adding --runtimeconfig "D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\bin\Debug\netcoreapp2.0\Microsoft.AspNetCore.Mvc.Core.Test.runtimeconfig.json" in args +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:19.167, 2296210148038, vstest.console.dll, DotnetTestHostmanager: Adding --depsfile "D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\bin\Debug\netcoreapp2.0\Microsoft.AspNetCore.Mvc.Core.Test.deps.json" in args +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:19.167, 2296210148469, vstest.console.dll, AssemblyResolver: Microsoft.Extensions.DependencyModel: Resolving assembly. +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:19.168, 2296210150826, vstest.console.dll, AssemblyResolver: Microsoft.Extensions.DependencyModel: Resolved assembly. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:19.168, 2296210151668, vstest.console.dll, DotnetTestHostmanager: Reading file D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\bin\Debug\netcoreapp2.0\Microsoft.AspNetCore.Mvc.Core.Test.deps.json to get path of testhost.dll +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:19.220, 2296210304147, vstest.console.dll, DotnetTestHostmanager: Relative path of testhost.dll with respect to package folder is microsoft.testplatform.testhost/15.0.0\lib/netstandard1.5/testhost.dll +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:19.225, 2296210317542, vstest.console.dll, DotnetTestHostmanager: Looking for path microsoft.testplatform.testhost/15.0.0\lib/netstandard1.5/testhost.dll in folder C:\Users\Pranav\.nuget\packages +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:19.225, 2296210318273, vstest.console.dll, DotnetTestHostmanager: Full path of testhost.dll is C:\Users\Pranav\.nuget\packages\microsoft.testplatform.testhost/15.0.0\lib/netstandard1.5/testhost.dll +TpTrace Verbose: 0 : 17636, 5, 2017/05/12, 14:46:19.227, 2296210324293, vstest.console.dll, DotnetTestHostManager: Starting process 'C:\Users\Pranav\.dotnet\x64\dotnet.exe' with command line 'exec --runtimeconfig "D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\bin\Debug\netcoreapp2.0\Microsoft.AspNetCore.Mvc.Core.Test.runtimeconfig.json" --depsfile "D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\bin\Debug\netcoreapp2.0\Microsoft.AspNetCore.Mvc.Core.Test.deps.json" "C:\Users\Pranav\.nuget\packages\microsoft.testplatform.testhost/15.0.0\lib/netstandard1.5/testhost.dll" --port 64746 --parentprocessid 17636 --diag "D:\work\Mvc\test\Microsoft.AspNetCore.Mvc.Core.Test\out.host.17-05-12_14-46-19_16053_4.txt"' +TpTrace Verbose: 0 : 17636, 5, 2017/05/12, 14:46:19.241, 2296210364355, vstest.console.dll, Test Runtime launched with Pid: 7340 +TpTrace Information: 0 : 17636, 6, 2017/05/12, 14:46:19.619, 2296211472265, vstest.console.dll, Accepted Client request and set the flag +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:19.787, 2296211962805, vstest.console.dll, TestRunRequest:SendTestRunMessage: Starting. +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:19.787, 2296211963963, vstest.console.dll, TestRunRequest:SendTestRunMessage: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:21.689, 2296217536188, vstest.console.dll, TestRunRequest:SendTestRunMessage: Starting. +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:21.689, 2296217536624, vstest.console.dll, TestRunRequest:SendTestRunMessage: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:24.893, 2296226922082, vstest.console.dll, TestRunRequest:SendTestRunMessage: Starting. +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:24.893, 2296226922397, vstest.console.dll, TestRunRequest:SendTestRunMessage: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.011, 2296230198328, vstest.console.dll, TestRunRequest:SendTestRunMessage: Starting. +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.011, 2296230198818, vstest.console.dll, TestRunRequest:SendTestRunMessage: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.199, 2296230750425, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.200, 2296230751176, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProviderTest.DefaultFilterProvider_UsesFilter_WhenItsNotIFilterFactory +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.200, 2296230751666, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.277, 2296230978862, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.278, 2296230979323, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_SelectDefaultFormatter_OnAllMediaRangeAcceptHeaderMediaType(acceptHeader: "text/html,application/xhtml+xml,application/xml;q="..., expectedContentType: "application/json; charset=utf-8") +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.278, 2296230979464, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.AuthorizationApplicationModelProviderTest.OnProvidersExecuting_DefaultPolicyProvider_NoAuthorizationData_NoFilterCreated +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.278, 2296230979576, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.MiddlewareFilterTest.UnhandledException_InMiddleware_PropagatesBackToInvoker +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.278, 2296230979676, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.DefaultValues +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.278, 2296230979775, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.HttpStatusCodeResultTests.HttpStatusCodeResult_ExecuteResultSetsResponseStatusCode +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.278, 2296230979916, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.DefaultModelMetadataBindingDetailsProviderTest.CreateBindingDetails_BindingBehaviorLeftAlone_ForAttributeOnPropertyType(initialValue: False) +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.278, 2296230980020, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.Constructor_InitializesActionName(actionName: null) +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.278, 2296230980612, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.305, 2296231058735, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.305, 2296231059242, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.ExecuteResultAsync_ThrowsIfActionUrlIsNullOrEmpty(returnValue: "") +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.305, 2296231059476, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProviderTest.DefaultFilterProvider_UsesFilterFactory +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.305, 2296231059668, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.DefaultModelMetadataBindingDetailsProviderTest.CreateBindingDetails_FindsBindNever_OnContainerClass +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.305, 2296231060066, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.326, 2296231121258, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.326, 2296231121752, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.DefaultModelMetadataBindingDetailsProviderTest.CreateBindingDetails_FindsBindNever_OnProperty +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.326, 2296231122073, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.348, 2296231186087, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.348, 2296231186655, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.372, 2296231255179, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.372, 2296231255669, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.AuthorizationApplicationModelProviderTest.BuildActionModels_BaseAuthorizeFiltersAreStillValidWhenOverriden +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.372, 2296231255874, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ChallengeResultTest.ChallengeResult_Execute +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.372, 2296231256063, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ReferenceEqualityComparerTest.GetHashCode_DoesNotThrowForNull +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.372, 2296231256253, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.IsRequired_ReturnsFalse_ForNullableTypes(modelType: typeof(int?)) +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.372, 2296231256566, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.396, 2296231325482, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.396, 2296231326084, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.AuthorizationApplicationModelProviderTest.CreateControllerModelAndActionModel_AllowAnonymousAttributeAddsAllowAnonymousFilter +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.396, 2296231326311, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.IsReadOnly_ReturnsTrue_ForPrivateSetProperty +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.396, 2296231326430, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ReferenceEqualityComparerTest.Equals_NullEqualsNull +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.396, 2296231326629, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.426, 2296231415383, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.427, 2296231416055, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.AuthorizationApplicationModelProviderTest.OnProvidersExecuting_NonDefaultPolicyProvider_HasNoPolicy_HasPolicyProviderAndAuthorizeData +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.427, 2296231416311, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_SelectDefaultFormatter_OnAllMediaRangeAcceptHeaderMediaType(acceptHeader: "*/*", expectedContentType: "application/json; charset=utf-8") +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.427, 2296231416604, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.463, 2296231521555, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.463, 2296231522109, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProviderTest.DefaultFilterProvider_UsesFilterFactory_WithIFilterContainer +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.463, 2296231522335, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributesTest.GetAttributesForBaseProperty_IncludesMetadataAttributes +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.463, 2296231522541, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ObjectResult_PerformsContentNegotiation_OnAllMediaRangeAcceptHeaderMediaType(acceptHeader: "text/html,*/*;q=0.8,application/xml;q=0.9", expectedContentType: "application/xml; charset=utf-8") +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.463, 2296231522866, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.485, 2296231585808, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.492, 2296231607920, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributesTest.GetAttributesForBasePropertyFromDerivedModel_IncludesMetadataAttributes +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.492, 2296231608328, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.527, 2296231711250, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.528, 2296231711766, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.PropertiesProperty_WithDefaultOrder_OrdersPropertyNamesAsProvided +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.528, 2296231711993, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilterTest.OnActionExecuting_DoesNotChangeActionResult_IfOtherExceptionsAreFoundOnModelState +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.528, 2296231712321, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.564, 2296231817096, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.564, 2296231817584, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_MatchAllContentType_Throws(contentTypes: ["*/*"], invalidContentType: "*/*") +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.564, 2296231817953, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.589, 2296231892418, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.590, 2296231893479, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.DefaultFilterProviderTest.DefaultFilterProvider_UsesFilterFactory_WithOrder +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.590, 2296231893814, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.ExecuteResultAsync_ThrowsIfActionUrlIsNullOrEmpty(returnValue: null) +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.590, 2296231894243, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ChallengeResultTest.ChallengeResult_ExecuteNoSchemes +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.590, 2296231894425, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_MatchAllContentType_Throws(contentTypes: ["*/*", "application/json"], invalidContentType: "*/*") +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.590, 2296231894858, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.630, 2296232012237, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.631, 2296232013343, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.SelectFormatter_WithMultipleProvidedContentTypes_DoesConneg +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.631, 2296232013691, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.UnsupportedContentTypeFilterTest.OnActionExecuting_DoesNotChangeActionResult_IfOtherErrorsAreFoundOnModelState +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.631, 2296232013999, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.656, 2296232088420, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.656, 2296232088979, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.FilterFactoryTest.GetAllFilters_CachesAllFilters +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.656, 2296232089185, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.SelectFormatter_WithAcceptHeaderAndContentTypes_SetsContentTypeIsServerDefinedWhenExpected +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.656, 2296232089350, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.Constructor_InitializesControllerName(controllerName: "") +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.657, 2296232089678, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.682, 2296232163655, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.682, 2296232164239, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_WithOneProvidedContentType_FromResponseContentType_NoFallback +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.682, 2296232164464, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.ExecuteResultAsync_SetsStatusCodeAndLocationHeader +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.682, 2296232164658, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderTests.BindModel +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.682, 2296232165031, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.708, 2296232239915, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.708, 2296232240592, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.FilterFactoryTest.GetAllFilters_DoesNotCacheFiltersWithIsReusableFalse +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.708, 2296232240876, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutorTest.ExecuteAsync_FallsBackOnFormattersInOptions +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.708, 2296232241276, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.753, 2296232373613, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.754, 2296232375335, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderTests.BindModelSetsModelToNullOnNullOrEmptyString(value: "") +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.754, 2296232375640, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.FilterFactoryTest.GetAllFilters_CachesFilterFromFactory +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.771, 2296232424687, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.787, 2296232470786, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.787, 2296232471351, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerTest.InvokeAction_InvokesAsyncResourceFilter_ThrowsUnhandledException +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.787, 2296232471500, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.PropertiesSetOnce +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.787, 2296232471707, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.805, 2296232525812, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.806, 2296232526306, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderTests.BindModelAddsModelErrorsOnInvalidCharacters +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.806, 2296232526580, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataTest.ElementMetadata_ReturnsExpectedMetadata(modelType: typeof(System.Collections.ObjectModel.Collection), elementType: typeof(int)) +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.806, 2296232526774, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.AcceptedAtActionResultTests.OnFormatting_NullContext_ThrowsArgumentNullException +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.806, 2296232527070, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.828, 2296232592590, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Starting. +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.828, 2296232593107, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.Formatters.TextOutputFormatterTests.SelectResponseCharacterEncoding_SelectsEncoding(acceptCharsetHeaders: "utf-16; q=0.5", supportedEncodings: ["utf-8", "utf-16"], expectedEncoding: "utf-16") +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:26.829, 2296232593386, vstest.console.dll, InProgress is Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ByteArrayModelBinderTests.BindModel_ReturnsWithIsModelSetFalse_WhenValueNotFound +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:26.829, 2296232593644, vstest.console.dll, TestRunRequest:SendTestRunStatsChange: Completed. +TpTrace Error: 0 : 17636, 11, 2017/05/12, 14:46:27.899, 2296235728284, vstest.console.dll, SocketCommunicationManager ReceiveMessage: failed to receive message System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host + at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) + --- End of inner exception stack trace --- + at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) + at System.IO.BinaryReader.ReadString() + at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.SocketCommunicationManager.TryReceiveRawMessage(CancellationToken cancellationToken) +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:27.900, 2296235731675, vstest.console.dll, AssemblyResolver: Microsoft.TestPlatform.CommunicationUtilities.resources: Resolving assembly. +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:27.901, 2296235735262, vstest.console.dll, AssemblyResolver: Microsoft.TestPlatform.CommunicationUtilities.resources: Resolving assembly. +TpTrace Error: 0 : 17636, 4, 2017/05/12, 14:46:27.902, 2296235737773, vstest.console.dll, Unable to receive message from testhost: Unable to communicate with test host process. +TpTrace Error: 0 : 17636, 4, 2017/05/12, 14:46:27.902, 2296235739815, vstest.console.dll, Server: TestExecution: Aborting test run because System.IO.IOException: Unable to communicate with test host process. + at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TestRequestSender.TryReceiveRawMessage() + at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TestRequestSender.ListenAndReportTestResults(ITestRunEventsHandler testRunEventsHandler) +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:27.905, 2296235748028, vstest.console.dll, TestRunRequest:SendTestRunMessage: Starting. +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:27.906, 2296235750849, vstest.console.dll, TestRunRequest:SendTestRunMessage: Completed. +TpTrace Error: 0 : 17636, 4, 2017/05/12, 14:46:27.953, 2296235886970, vstest.console.dll, Connection has been broken: not sending SessionEnd message +TpTrace Error: 0 : 17636, 5, 2017/05/12, 14:46:27.955, 2296235892907, vstest.console.dll, Connection has been broken: not sending SessionEnd message +TpTrace Verbose: 0 : 17636, 4, 2017/05/12, 14:46:27.980, 2296235966449, vstest.console.dll, TestRunRequest:TestRunComplete: Starting. IsAborted:True IsCanceled:False. +TpTrace Information: 0 : 17636, 4, 2017/05/12, 14:46:28.012, 2296236060503, vstest.console.dll, TestRunRequest:TestRunComplete: Completed. +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:28.012, 2296236060856, vstest.console.dll, TestRunRequest.Dispose: Starting. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:28.012, 2296236061195, vstest.console.dll, TestRunRequest.Dispose: Completed. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:28.012, 2296236061382, vstest.console.dll, TestRequestManager.RunTests: run tests completed, sucessful: True. +TpTrace Information: 0 : 17636, 2, 2017/05/12, 14:46:28.012, 2296236061500, vstest.console.dll, RunTestsArgumentProcessor:Execute: Test run is completed. +TpTrace Verbose: 0 : 17636, 2, 2017/05/12, 14:46:28.012, 2296236061645, vstest.console.dll, Executor.Execute: Exiting with exit code of 1