From 20daab2fb59c57f9702fdd1a3656298330e435cf Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Thu, 16 Apr 2015 07:20:45 -0700 Subject: [PATCH] Removed direct dependency on Framework.Logging and instead used Framework.Logging.Interfaces. Fixed breaking code which additionally cleans up start-up logging which we wanted to do. --- .../DefaultControllerModelBuilder.cs | 1 - .../DefaultControllerTypeProvider.cs | 13 +----- .../Logging/AssemblyValues.cs | 41 ------------------- src/Microsoft.AspNet.Mvc.Core/project.json | 2 +- .../MvcServiceCollectionExtensions.cs | 5 +-- .../DefaultControllerTypeProviderTest.cs | 2 +- .../ApiControllerActionDiscoveryTest.cs | 2 +- 7 files changed, 5 insertions(+), 61 deletions(-) delete mode 100644 src/Microsoft.AspNet.Mvc.Core/Logging/AssemblyValues.cs diff --git a/src/Microsoft.AspNet.Mvc.Core/ApplicationModels/DefaultControllerModelBuilder.cs b/src/Microsoft.AspNet.Mvc.Core/ApplicationModels/DefaultControllerModelBuilder.cs index 7d183a5722..fff2f915f9 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ApplicationModels/DefaultControllerModelBuilder.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ApplicationModels/DefaultControllerModelBuilder.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using Microsoft.AspNet.Authorization; -using Microsoft.AspNet.Cors; using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Mvc.Description; using Microsoft.AspNet.Mvc.Filters; diff --git a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerTypeProvider.cs b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerTypeProvider.cs index d93d7657fd..8480c49a5a 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerTypeProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerTypeProvider.cs @@ -21,7 +21,6 @@ namespace Microsoft.AspNet.Mvc private static readonly TypeInfo ControllerTypeInfo = typeof(Controller).GetTypeInfo(); private static readonly TypeInfo ObjectTypeInfo = typeof(object).GetTypeInfo(); private readonly IAssemblyProvider _assemblyProvider; - private readonly ILogger _logger; /// /// Initializes a new instance of . @@ -29,11 +28,9 @@ namespace Microsoft.AspNet.Mvc /// that provides assemblies to look for /// controllers in. /// The . - public DefaultControllerTypeProvider(IAssemblyProvider assemblyProvider, - ILoggerFactory loggerFactory) + public DefaultControllerTypeProvider(IAssemblyProvider assemblyProvider) { _assemblyProvider = assemblyProvider; - _logger = loggerFactory.CreateLogger(); } /// @@ -42,14 +39,6 @@ namespace Microsoft.AspNet.Mvc get { var candidateAssemblies = new HashSet(_assemblyProvider.CandidateAssemblies); - if (_logger.IsEnabled(LogLevel.Verbose)) - { - foreach (var assembly in candidateAssemblies) - { - _logger.LogVerbose(new AssemblyValues(assembly)); - } - } - var types = candidateAssemblies.SelectMany(a => a.DefinedTypes); return types.Where(typeInfo => IsController(typeInfo, candidateAssemblies)); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Logging/AssemblyValues.cs b/src/Microsoft.AspNet.Mvc.Core/Logging/AssemblyValues.cs deleted file mode 100644 index 2dd5ac8a20..0000000000 --- a/src/Microsoft.AspNet.Mvc.Core/Logging/AssemblyValues.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Reflection; -using Microsoft.Framework.Internal; -using Microsoft.Framework.Logging; - -namespace Microsoft.AspNet.Mvc.Logging -{ - /// - /// Logging representation of the state of an . Logged during Assembly discovery in Startup. - /// - public class AssemblyValues : ReflectionBasedLogValues - { - public AssemblyValues([NotNull] Assembly inner) - { - AssemblyName = inner.FullName; -#if DNX451 - Location = inner.Location; -#endif - IsDynamic = inner.IsDynamic; - } - - /// - /// The name of the assembly. See . - /// - public string AssemblyName { get; } - -#if DNX451 - /// - /// The location of the assembly. See . - /// - public string Location { get; } -#endif - - /// - /// Whether or not the assembly is dynamic. See . - /// - public bool IsDynamic { get; } - } -} diff --git a/src/Microsoft.AspNet.Mvc.Core/project.json b/src/Microsoft.AspNet.Mvc.Core/project.json index e1cce4133a..a8c1022e29 100644 --- a/src/Microsoft.AspNet.Mvc.Core/project.json +++ b/src/Microsoft.AspNet.Mvc.Core/project.json @@ -18,7 +18,7 @@ "Microsoft.AspNet.Routing": "1.0.0-*", "Microsoft.Framework.BufferEntryCollection.Internal": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.CopyOnWriteDictionary.Internal": { "version": "1.0.0-*", "type": "build" }, - "Microsoft.Framework.Logging": "1.0.0-*", + "Microsoft.Framework.Logging.Interfaces": "1.0.0-*", "Microsoft.Framework.NotNullAttribute.Internal": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.PropertyActivator.Internal": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.PropertyHelper.Internal": { "version": "1.0.0-*", "type": "build" }, diff --git a/src/Microsoft.AspNet.Mvc/MvcServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Mvc/MvcServiceCollectionExtensions.cs index 4efb58ca18..5111fbcf2c 100644 --- a/src/Microsoft.AspNet.Mvc/MvcServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Mvc/MvcServiceCollectionExtensions.cs @@ -5,11 +5,9 @@ using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Routing; using Microsoft.Framework.Internal; -using Microsoft.Framework.Logging; namespace Microsoft.Framework.DependencyInjection { @@ -76,8 +74,7 @@ namespace Microsoft.Framework.DependencyInjection assemblyProvider.CandidateAssemblies.Add(assembly); } - var loggerFactory = new LoggerFactory(); - var controllerTypeProvider = new DefaultControllerTypeProvider(assemblyProvider, loggerFactory); + var controllerTypeProvider = new DefaultControllerTypeProvider(assemblyProvider); var controllerTypes = controllerTypeProvider.ControllerTypes; return WithControllersAsServices(services, controllerTypes.Select(type => type.AsType())); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/DefaultControllerTypeProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/DefaultControllerTypeProviderTest.cs index 2fdc27db47..aac19c51f7 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/DefaultControllerTypeProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/DefaultControllerTypeProviderTest.cs @@ -222,7 +222,7 @@ namespace Microsoft.AspNet.Mvc private static DefaultControllerTypeProvider GetControllerTypeProvider() { var assemblyProvider = new FixedSetAssemblyProvider(); - return new DefaultControllerTypeProvider(assemblyProvider, NullLoggerFactory.Instance); + return new DefaultControllerTypeProvider(assemblyProvider); } } } diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs index f30dbe6540..c306406778 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs @@ -411,7 +411,7 @@ namespace System.Web.Http private class NamespaceFilteredControllerTypeProvider : DefaultControllerTypeProvider { public NamespaceFilteredControllerTypeProvider(IAssemblyProvider provider) - : base(provider, new LoggerFactory()) + : base(provider) { }