diff --git a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerTypeProvider.cs b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerTypeProvider.cs index 8480c49a5a..0f4a6ae111 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DefaultControllerTypeProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/DefaultControllerTypeProvider.cs @@ -5,9 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -using Microsoft.AspNet.Mvc.Logging; using Microsoft.Framework.Internal; -using Microsoft.Framework.Logging; namespace Microsoft.AspNet.Mvc { @@ -27,7 +25,6 @@ namespace Microsoft.AspNet.Mvc /// /// that provides assemblies to look for /// controllers in. - /// The . public DefaultControllerTypeProvider(IAssemblyProvider assemblyProvider) { _assemblyProvider = assemblyProvider; diff --git a/src/Microsoft.AspNet.Mvc.Core/Logging/LoggerExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Logging/LoggerExtensions.cs deleted file mode 100644 index 3471bdc78b..0000000000 --- a/src/Microsoft.AspNet.Mvc.Core/Logging/LoggerExtensions.cs +++ /dev/null @@ -1,21 +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 Microsoft.Framework.Internal; -using Microsoft.Framework.Logging; - -namespace Microsoft.AspNet.Mvc.Logging -{ - internal static class LoggerExtensions - { - public static void WriteValues([NotNull] this ILogger logger, object values) - { - logger.Log( - logLevel: LogLevel.Verbose, - eventId: 0, - state: values, - exception: null, - formatter: LogFormatter.Formatter); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/Logging/StringBuilderHelpers.cs b/src/Microsoft.AspNet.Mvc.Core/Logging/StringBuilderHelpers.cs deleted file mode 100644 index 725ef8a63e..0000000000 --- a/src/Microsoft.AspNet.Mvc.Core/Logging/StringBuilderHelpers.cs +++ /dev/null @@ -1,55 +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; -using System.Collections.Generic; -using System.Text; - -namespace Microsoft.AspNet.Mvc.Logging -{ - internal static class StringBuilderHelpers - { - public static void Append( - StringBuilder builder, - IEnumerable items, - Func itemFormatter = null) - { - if (items == null) - { - return; - } - - foreach (var item in items) - { - builder.Append(Environment.NewLine); - builder.Append("\t\t"); - - if (itemFormatter == null) - { - builder.Append(item != null ? item.ToString() : "null"); - } - else - { - builder.Append(item != null ? itemFormatter(item) : "null"); - } - } - } - - public static void Append(StringBuilder builder, IDictionary dict) - { - if (dict == null) - { - return; - } - - foreach (var kvp in dict) - { - builder.Append(Environment.NewLine); - builder.Append("\t\t"); - builder.Append(kvp.Key != null ? kvp.Key.ToString() : "null"); - builder.Append(" : "); - builder.Append(kvp.Value != null ? kvp.Value.ToString() : "null"); - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs index cbd1a70fdf..b6ee8e94e9 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/DefaultActionSelectorTests.cs @@ -17,6 +17,7 @@ using Microsoft.AspNet.Mvc.Routing; using Microsoft.AspNet.Routing; using Microsoft.Framework.Internal; using Microsoft.Framework.Logging; +using Microsoft.Framework.Logging.Testing; using Moq; using Xunit; @@ -29,7 +30,7 @@ namespace Microsoft.AspNet.Mvc { // Arrange var sink = new TestSink(); - var loggerFactory = new TestLoggerFactory(sink); + var loggerFactory = new TestLoggerFactory(sink, enabled: true); var actions = new ActionDescriptor[] { diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/BeginScopeContext.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Logging/BeginScopeContext.cs deleted file mode 100644 index 4c69db10b8..0000000000 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/BeginScopeContext.cs +++ /dev/null @@ -1,12 +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. - -namespace Microsoft.AspNet.Mvc -{ - public class BeginScopeContext - { - public object Scope { get; set; } - - public string LoggerName { get; set; } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/NullDisposable.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Logging/NullDisposable.cs deleted file mode 100644 index 7d2e1ef73a..0000000000 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/NullDisposable.cs +++ /dev/null @@ -1,17 +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; - -namespace Microsoft.AspNet.Mvc -{ - public class NullDisposable : IDisposable - { - public static NullDisposable Instance = new NullDisposable(); - - public void Dispose() - { - // intentionally does nothing - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/NullLogger.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Logging/NullLogger.cs deleted file mode 100644 index f6a304d3e7..0000000000 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/NullLogger.cs +++ /dev/null @@ -1,27 +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; -using Microsoft.Framework.Logging; - -namespace Microsoft.AspNet.Mvc -{ - public class NullLogger : ILogger - { - public static NullLogger Instance = new NullLogger(); - - public IDisposable BeginScopeImpl(object state) - { - return NullDisposable.Instance; - } - - public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) - { - } - - public bool IsEnabled(LogLevel logLevel) - { - return false; - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/NullLoggerFactory.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Logging/NullLoggerFactory.cs deleted file mode 100644 index 162988f1e1..0000000000 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/NullLoggerFactory.cs +++ /dev/null @@ -1,24 +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 Microsoft.Framework.Logging; - -namespace Microsoft.AspNet.Mvc -{ - public class NullLoggerFactory : ILoggerFactory - { - public static NullLoggerFactory Instance = new NullLoggerFactory(); - - public LogLevel MinimumLevel { get; set; } - - public ILogger CreateLogger(string name) - { - return NullLogger.Instance; - } - - public void AddProvider(ILoggerProvider provider) - { - - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/PropertiesAssert.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Logging/PropertiesAssert.cs deleted file mode 100644 index 851883accd..0000000000 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/PropertiesAssert.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Linq; -using Xunit; - -namespace Microsoft.AspNet.Mvc.Logging -{ - public static class PropertiesAssert - { - /// - /// Given two types, compares their properties and asserts true if they have the same property names. - /// - /// The original type to compare against. - /// The shadow type whose properties will be compared against the original. - /// Properties that exist in the original type but not the shadow. - /// Properties that are in the shadow type but not in the original. - public static void PropertiesAreTheSame(Type original, Type shadow, string[] exclude = null, string[] include = null) - { - var originalProperties = original.GetProperties().Where(p => !exclude?.Contains(p.Name) ?? true) - .Select(p => p.Name); - if (include != null) - { - originalProperties = originalProperties.Concat(include.ToList()); - } - originalProperties = originalProperties.OrderBy(n => n); - - // Message is a property on all ILoggerStructures - var shadowProperties = shadow.GetProperties().Where(p => !string.Equals("Message", p.Name)) - .Select(p => p.Name).OrderBy(n => n); - - Assert.True(originalProperties.SequenceEqual(shadowProperties)); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/TestLogger.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Logging/TestLogger.cs deleted file mode 100644 index 3984aa308f..0000000000 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/TestLogger.cs +++ /dev/null @@ -1,55 +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; -using Microsoft.Framework.Logging; - -namespace Microsoft.AspNet.Mvc -{ - public class TestLogger : ILogger - { - private object _scope; - private TestSink _sink; - private string _name; - - public TestLogger(string name, TestSink sink) - { - _sink = sink; - _name = name; - } - - public string Name { get; set; } - - public IDisposable BeginScopeImpl(object state) - { - _scope = state; - - _sink.Begin(new BeginScopeContext() - { - LoggerName = _name, - Scope = state, - }); - - return NullDisposable.Instance; - } - - public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) - { - _sink.Write(new WriteContext() - { - LogLevel = logLevel, - EventId = eventId, - State = state, - Exception = exception, - Formatter = formatter, - LoggerName = _name, - Scope = _scope - }); - } - - public bool IsEnabled(LogLevel logLevel) - { - return true; - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/TestLoggerFactory.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Logging/TestLoggerFactory.cs deleted file mode 100644 index 6a237a9038..0000000000 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/TestLoggerFactory.cs +++ /dev/null @@ -1,29 +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 Microsoft.Framework.Logging; - -namespace Microsoft.AspNet.Mvc -{ - public class TestLoggerFactory : ILoggerFactory - { - private TestSink _sink; - - public TestLoggerFactory(TestSink sink) - { - _sink = sink; - } - - public LogLevel MinimumLevel { get; set; } - - public ILogger CreateLogger(string name) - { - return new TestLogger(name, _sink); - } - - public void AddProvider(ILoggerProvider provider) - { - - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/TestSink.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Logging/TestSink.cs deleted file mode 100644 index 93fd55b7e7..0000000000 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/TestSink.cs +++ /dev/null @@ -1,56 +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; -using System.Collections.Generic; - -namespace Microsoft.AspNet.Mvc -{ - public class TestSink - { - public TestSink( - Func writeEnabled = null, - Func beginEnabled = null) - { - WriteEnabled = writeEnabled; - BeginEnabled = beginEnabled; - - Scopes = new List(); - Writes = new List(); - } - - public Func WriteEnabled { get; set; } - - public Func BeginEnabled { get; set; } - - public List Scopes { get; set; } - - public List Writes { get; set; } - - public void Write(WriteContext context) - { - if (WriteEnabled == null || WriteEnabled(context)) - { - Writes.Add(context); - } - } - - public void Begin(BeginScopeContext context) - { - if (BeginEnabled == null || BeginEnabled(context)) - { - Scopes.Add(context); - } - } - - public static bool EnableWithTypeName(WriteContext context) - { - return context.LoggerName.Equals(typeof(T).FullName); - } - - public static bool EnableWithTypeName(BeginScopeContext context) - { - return context.LoggerName.Equals(typeof(T).FullName); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/WriteContext.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Logging/WriteContext.cs deleted file mode 100644 index 354a0340b2..0000000000 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Logging/WriteContext.cs +++ /dev/null @@ -1,25 +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; -using Microsoft.Framework.Logging; - -namespace Microsoft.AspNet.Mvc -{ - public class WriteContext - { - public LogLevel LogLevel { get; set; } - - public int EventId { get; set; } - - public object State { get; set; } - - public Exception Exception { get; set; } - - public Func Formatter { get; set; } - - public object Scope { get; set; } - - public string LoggerName { get; set; } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/MvcRouteHandlerTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/MvcRouteHandlerTests.cs index eea8c825ea..e1cbff1005 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/MvcRouteHandlerTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/MvcRouteHandlerTests.cs @@ -5,10 +5,9 @@ using System; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Internal; -using Microsoft.AspNet.Mvc.Logging; using Microsoft.AspNet.Routing; -using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; +using Microsoft.Framework.Logging.Testing; using Microsoft.Framework.OptionsModel; using Moq; using Xunit; @@ -22,7 +21,7 @@ namespace Microsoft.AspNet.Mvc { // Arrange var sink = new TestSink(); - var loggerFactory = new TestLoggerFactory(sink); + var loggerFactory = new TestLoggerFactory(sink, enabled: true); var displayName = "A.B.C"; var actionDescriptor = new Mock(); actionDescriptor.SetupGet(ad => ad.DisplayName) @@ -46,7 +45,7 @@ namespace Microsoft.AspNet.Mvc { // Arrange var sink = new TestSink(); - var loggerFactory = new TestLoggerFactory(sink); + var loggerFactory = new TestLoggerFactory(sink, enabled: true); var mockActionSelector = new Mock(); mockActionSelector.Setup(a => a.SelectAsync(It.IsAny())) diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/RemoteAttributeTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/RemoteAttributeTest.cs index 6117032608..e7a0d81689 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/RemoteAttributeTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/RemoteAttributeTest.cs @@ -9,6 +9,7 @@ using Microsoft.AspNet.Mvc.ModelBinding.Validation; using Microsoft.AspNet.Routing; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; +using Microsoft.Framework.Logging.Testing; using Microsoft.Framework.OptionsModel; using Moq; using Xunit; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs index 064baa94eb..560d132e3e 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs @@ -9,6 +9,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Core; using Microsoft.AspNet.Routing; using Microsoft.Framework.Logging; +using Microsoft.Framework.Logging.Testing; using Moq; using Xunit; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs index 97c6933d8a..984a7110ba 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http.Core; using Microsoft.AspNet.Routing; using Microsoft.Framework.Logging; +using Microsoft.Framework.Logging.Testing; using Microsoft.Framework.OptionsModel; using Moq; using Xunit; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/InnerAttributeRouteTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/InnerAttributeRouteTest.cs index 574a964b46..cfe6f70af6 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/InnerAttributeRouteTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/InnerAttributeRouteTest.cs @@ -6,10 +6,10 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Http; -using Microsoft.AspNet.Mvc.Logging; using Microsoft.AspNet.Routing; using Microsoft.AspNet.Routing.Template; using Microsoft.Framework.Logging; +using Microsoft.Framework.Logging.Testing; using Microsoft.Framework.OptionsModel; using Moq; using Xunit; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/UrlHelperTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/UrlHelperTest.cs index 333f512f1f..9a830868cc 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/UrlHelperTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/UrlHelperTest.cs @@ -10,6 +10,7 @@ using Microsoft.AspNet.Mvc.Internal; using Microsoft.AspNet.Routing; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; +using Microsoft.Framework.Logging.Testing; using Microsoft.Framework.OptionsModel; using Moq; using Xunit; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/project.json b/test/Microsoft.AspNet.Mvc.Core.Test/project.json index 18c9d594b7..4cc46e2ded 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Core.Test/project.json @@ -7,6 +7,7 @@ "Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" }, "Microsoft.AspNet.Mvc.Xml": "6.0.0-*", "Microsoft.AspNet.Testing": "1.0.0-*", + "Microsoft.Framework.Logging.Testing": "1.0.0-*", "Moq": "4.2.1312.1622", "xunit.runner.aspnet": "2.0.0-aspnet-*" },