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.
This commit is contained in:
Kiran Challa 2015-04-16 07:20:45 -07:00
parent 9eb87d4676
commit 20daab2fb5
7 changed files with 5 additions and 61 deletions

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Cors;
using Microsoft.AspNet.Cors.Core; using Microsoft.AspNet.Cors.Core;
using Microsoft.AspNet.Mvc.Description; using Microsoft.AspNet.Mvc.Description;
using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Mvc.Filters;

View File

@ -21,7 +21,6 @@ namespace Microsoft.AspNet.Mvc
private static readonly TypeInfo ControllerTypeInfo = typeof(Controller).GetTypeInfo(); private static readonly TypeInfo ControllerTypeInfo = typeof(Controller).GetTypeInfo();
private static readonly TypeInfo ObjectTypeInfo = typeof(object).GetTypeInfo(); private static readonly TypeInfo ObjectTypeInfo = typeof(object).GetTypeInfo();
private readonly IAssemblyProvider _assemblyProvider; private readonly IAssemblyProvider _assemblyProvider;
private readonly ILogger _logger;
/// <summary> /// <summary>
/// Initializes a new instance of <see cref="DefaultControllerTypeProvider"/>. /// Initializes a new instance of <see cref="DefaultControllerTypeProvider"/>.
@ -29,11 +28,9 @@ namespace Microsoft.AspNet.Mvc
/// <param name="assemblyProvider"><see cref="IAssemblyProvider"/> that provides assemblies to look for /// <param name="assemblyProvider"><see cref="IAssemblyProvider"/> that provides assemblies to look for
/// controllers in.</param> /// controllers in.</param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
public DefaultControllerTypeProvider(IAssemblyProvider assemblyProvider, public DefaultControllerTypeProvider(IAssemblyProvider assemblyProvider)
ILoggerFactory loggerFactory)
{ {
_assemblyProvider = assemblyProvider; _assemblyProvider = assemblyProvider;
_logger = loggerFactory.CreateLogger<DefaultControllerTypeProvider>();
} }
/// <inheritdoc /> /// <inheritdoc />
@ -42,14 +39,6 @@ namespace Microsoft.AspNet.Mvc
get get
{ {
var candidateAssemblies = new HashSet<Assembly>(_assemblyProvider.CandidateAssemblies); var candidateAssemblies = new HashSet<Assembly>(_assemblyProvider.CandidateAssemblies);
if (_logger.IsEnabled(LogLevel.Verbose))
{
foreach (var assembly in candidateAssemblies)
{
_logger.LogVerbose(new AssemblyValues(assembly));
}
}
var types = candidateAssemblies.SelectMany(a => a.DefinedTypes); var types = candidateAssemblies.SelectMany(a => a.DefinedTypes);
return types.Where(typeInfo => IsController(typeInfo, candidateAssemblies)); return types.Where(typeInfo => IsController(typeInfo, candidateAssemblies));
} }

View File

@ -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
{
/// <summary>
/// Logging representation of the state of an <see cref="Assembly"/>. Logged during Assembly discovery in Startup.
/// </summary>
public class AssemblyValues : ReflectionBasedLogValues
{
public AssemblyValues([NotNull] Assembly inner)
{
AssemblyName = inner.FullName;
#if DNX451
Location = inner.Location;
#endif
IsDynamic = inner.IsDynamic;
}
/// <summary>
/// The name of the assembly. See <see cref="Assembly.FullName"/>.
/// </summary>
public string AssemblyName { get; }
#if DNX451
/// <summary>
/// The location of the assembly. See <see cref="Assembly.Location"/>.
/// </summary>
public string Location { get; }
#endif
/// <summary>
/// Whether or not the assembly is dynamic. See <see cref="Assembly.IsDynamic"/>.
/// </summary>
public bool IsDynamic { get; }
}
}

View File

@ -18,7 +18,7 @@
"Microsoft.AspNet.Routing": "1.0.0-*", "Microsoft.AspNet.Routing": "1.0.0-*",
"Microsoft.Framework.BufferEntryCollection.Internal": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.BufferEntryCollection.Internal": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.CopyOnWriteDictionary.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.NotNullAttribute.Internal": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.PropertyActivator.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" }, "Microsoft.Framework.PropertyHelper.Internal": { "version": "1.0.0-*", "type": "build" },

View File

@ -5,11 +5,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Routing; using Microsoft.AspNet.Routing;
using Microsoft.Framework.Internal; using Microsoft.Framework.Internal;
using Microsoft.Framework.Logging;
namespace Microsoft.Framework.DependencyInjection namespace Microsoft.Framework.DependencyInjection
{ {
@ -76,8 +74,7 @@ namespace Microsoft.Framework.DependencyInjection
assemblyProvider.CandidateAssemblies.Add(assembly); assemblyProvider.CandidateAssemblies.Add(assembly);
} }
var loggerFactory = new LoggerFactory(); var controllerTypeProvider = new DefaultControllerTypeProvider(assemblyProvider);
var controllerTypeProvider = new DefaultControllerTypeProvider(assemblyProvider, loggerFactory);
var controllerTypes = controllerTypeProvider.ControllerTypes; var controllerTypes = controllerTypeProvider.ControllerTypes;
return WithControllersAsServices(services, controllerTypes.Select(type => type.AsType())); return WithControllersAsServices(services, controllerTypes.Select(type => type.AsType()));

View File

@ -222,7 +222,7 @@ namespace Microsoft.AspNet.Mvc
private static DefaultControllerTypeProvider GetControllerTypeProvider() private static DefaultControllerTypeProvider GetControllerTypeProvider()
{ {
var assemblyProvider = new FixedSetAssemblyProvider(); var assemblyProvider = new FixedSetAssemblyProvider();
return new DefaultControllerTypeProvider(assemblyProvider, NullLoggerFactory.Instance); return new DefaultControllerTypeProvider(assemblyProvider);
} }
} }
} }

View File

@ -411,7 +411,7 @@ namespace System.Web.Http
private class NamespaceFilteredControllerTypeProvider : DefaultControllerTypeProvider private class NamespaceFilteredControllerTypeProvider : DefaultControllerTypeProvider
{ {
public NamespaceFilteredControllerTypeProvider(IAssemblyProvider provider) public NamespaceFilteredControllerTypeProvider(IAssemblyProvider provider)
: base(provider, new LoggerFactory()) : base(provider)
{ {
} }