From 465b4ce0df0ae92928b8ff2e4673f829cbbaa982 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Sun, 6 Sep 2015 20:23:05 -0700 Subject: [PATCH] Use TelemetrySource --- Mvc.NoFun.sln | 17 ++++- Mvc.sln | 15 ++++ .../Actions/ControllerActionInvoker.cs | 6 +- .../ControllerActionInvokerProvider.cs | 10 +-- .../Actions/FilterActionInvoker.cs | 24 +++---- .../Actions/MvcRouteHandler.cs | 16 ++--- .../MvcCoreServiceCollectionExtensions.cs | 17 ++++- src/Microsoft.AspNet.Mvc.Core/project.json | 68 ++++++++++++------- .../ActionResults/ViewResult.cs | 15 ++-- .../Actions/ControllerActionInvokerTest.cs | 10 +-- .../Actions/MvcRouteHandlerTests.cs | 23 +++---- .../project.json | 51 +++++++------- .../IProxyActionContext.cs | 2 +- .../IProxyActionDescriptor.cs | 2 +- .../IProxyActionResult.cs | 2 +- .../IProxyHttpContext.cs | 2 +- .../IProxyRouteData.cs | 2 +- .../IProxyView.cs | 2 +- ...et.Mvc.TestTelemetryListener.Sources.xproj | 19 ++++++ .../TestTelemetryListener.cs} | 14 ++-- .../project.json | 12 ++++ .../ActionResults/ViewResultTest.cs | 29 +++++--- .../project.json | 48 +++++++------ 23 files changed, 258 insertions(+), 148 deletions(-) rename test/{Microsoft.AspNet.Mvc.TestCommon/Notification => Microsoft.AspNet.Mvc.TestTelemetryListener.Sources}/IProxyActionContext.cs (80%) rename test/{Microsoft.AspNet.Mvc.TestCommon/Notification => Microsoft.AspNet.Mvc.TestTelemetryListener.Sources}/IProxyActionDescriptor.cs (80%) rename test/{Microsoft.AspNet.Mvc.TestCommon/Notification => Microsoft.AspNet.Mvc.TestTelemetryListener.Sources}/IProxyActionResult.cs (80%) rename test/{Microsoft.AspNet.Mvc.TestCommon/Notification => Microsoft.AspNet.Mvc.TestTelemetryListener.Sources}/IProxyHttpContext.cs (80%) rename test/{Microsoft.AspNet.Mvc.TestCommon/Notification => Microsoft.AspNet.Mvc.TestTelemetryListener.Sources}/IProxyRouteData.cs (88%) rename test/{Microsoft.AspNet.Mvc.TestCommon/Notification => Microsoft.AspNet.Mvc.TestTelemetryListener.Sources}/IProxyView.cs (79%) create mode 100644 test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources.xproj rename test/{Microsoft.AspNet.Mvc.TestCommon/Notification/TestNotificationListener.cs => Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/TestTelemetryListener.cs} (89%) create mode 100644 test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/project.json diff --git a/Mvc.NoFun.sln b/Mvc.NoFun.sln index 4a5467b699..958a6bff24 100644 --- a/Mvc.NoFun.sln +++ b/Mvc.NoFun.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23017.0 +VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}" EndProject @@ -88,6 +88,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Locali EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Localization.Test", "test\Microsoft.AspNet.Mvc.Localization.Test\Microsoft.AspNet.Mvc.Localization.Test.xproj", "{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestTelemetryListener.Sources", "test\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources.xproj", "{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -518,6 +520,18 @@ Global {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|Mixed Platforms.Build.0 = Release|Any CPU {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.ActiveCfg = Release|Any CPU {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.Build.0 = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|x86.ActiveCfg = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|x86.Build.0 = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Any CPU.Build.0 = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.ActiveCfg = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -560,5 +574,6 @@ Global {827DBBCB-F3A9-4BAD-8262-4BD43E28EB3B} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {50893B10-5735-4F35-9995-F81DA3F0189E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {8FC726B5-E766-44E0-8B38-1313B6D8D9A7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} EndGlobalSection EndGlobal diff --git a/Mvc.sln b/Mvc.sln index 152c44c231..754710375a 100644 --- a/Mvc.sln +++ b/Mvc.sln @@ -186,6 +186,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Locali EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Localization.Test", "test\Microsoft.AspNet.Mvc.Localization.Test\Microsoft.AspNet.Mvc.Localization.Test.xproj", "{8FC726B5-E766-44E0-8B38-1313B6D8D9A7}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestTelemetryListener.Sources", "test\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources\Microsoft.AspNet.Mvc.TestTelemetryListener.Sources.xproj", "{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1140,6 +1142,18 @@ Global {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|Mixed Platforms.Build.0 = Release|Any CPU {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.ActiveCfg = Release|Any CPU {8FC726B5-E766-44E0-8B38-1313B6D8D9A7}.Release|x86.Build.0 = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|x86.ActiveCfg = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Debug|x86.Build.0 = Debug|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Any CPU.Build.0 = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.ActiveCfg = Release|Any CPU + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1231,5 +1245,6 @@ Global {60873DFA-97B9-419E-BAA3-940FC9B07085} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {50893B10-5735-4F35-9995-F81DA3F0189E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {8FC726B5-E766-44E0-8B38-1313B6D8D9A7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} + {9879B5D5-2325-4A81-B4DF-F279FE8FEEB4} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNet.Mvc.Core/Actions/ControllerActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/Actions/ControllerActionInvoker.cs index 33021589cd..a612946f20 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Actions/ControllerActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Actions/ControllerActionInvoker.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.Tracing; using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNet.Mvc.ActionResults; @@ -14,7 +15,6 @@ using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding.Validation; using Microsoft.Framework.Internal; using Microsoft.Framework.Logging; -using Microsoft.Framework.Notification; namespace Microsoft.AspNet.Mvc.Actions { @@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc.Actions [NotNull] IReadOnlyList valueProviderFactories, [NotNull] IActionBindingContextAccessor actionBindingContextAccessor, [NotNull] ILogger logger, - [NotNull] INotifier notifier, + [NotNull] TelemetrySource telemetry, int maxModelValidationErrors) : base( actionContext, @@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.Actions valueProviderFactories, actionBindingContextAccessor, logger, - notifier, + telemetry, maxModelValidationErrors) { _descriptor = descriptor; diff --git a/src/Microsoft.AspNet.Mvc.Core/Actions/ControllerActionInvokerProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Actions/ControllerActionInvokerProvider.cs index 1f315dd3e8..23d69e8a16 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Actions/ControllerActionInvokerProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Actions/ControllerActionInvokerProvider.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using System.Diagnostics.Tracing; using System.Linq; using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Mvc.Formatters; @@ -9,7 +10,6 @@ using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding.Validation; using Microsoft.Framework.Internal; using Microsoft.Framework.Logging; -using Microsoft.Framework.Notification; using Microsoft.Framework.OptionsModel; namespace Microsoft.AspNet.Mvc.Actions @@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.Actions private readonly IActionBindingContextAccessor _actionBindingContextAccessor; private readonly int _maxModelValidationErrors; private readonly ILogger _logger; - private readonly INotifier _notifier; + private readonly TelemetrySource _telemetry; public ControllerActionInvokerProvider( IControllerFactory controllerFactory, @@ -36,7 +36,7 @@ namespace Microsoft.AspNet.Mvc.Actions IOptions optionsAccessor, IActionBindingContextAccessor actionBindingContextAccessor, ILoggerFactory loggerFactory, - INotifier notifier) + TelemetrySource telemetry) { _controllerFactory = controllerFactory; _filterProviders = filterProviders.OrderBy(item => item.Order).ToArray(); @@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.Actions _actionBindingContextAccessor = actionBindingContextAccessor; _maxModelValidationErrors = optionsAccessor.Value.MaxModelValidationErrors; _logger = loggerFactory.CreateLogger(); - _notifier = notifier; + _telemetry = telemetry; } public int Order @@ -77,7 +77,7 @@ namespace Microsoft.AspNet.Mvc.Actions _valueProviderFactories, _actionBindingContextAccessor, _logger, - _notifier, + _telemetry, _maxModelValidationErrors); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Actions/FilterActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/Actions/FilterActionInvoker.cs index ffc54dc4d7..bfc7f2ca0d 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Actions/FilterActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Actions/FilterActionInvoker.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.Tracing; using System.Linq; using System.Runtime.ExceptionServices; using System.Threading.Tasks; @@ -16,7 +17,6 @@ using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding.Validation; using Microsoft.Framework.Internal; using Microsoft.Framework.Logging; -using Microsoft.Framework.Notification; namespace Microsoft.AspNet.Mvc.Actions { @@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.Actions private readonly IReadOnlyList _valueProviderFactories; private readonly IActionBindingContextAccessor _actionBindingContextAccessor; private readonly ILogger _logger; - private readonly INotifier _notifier; + private readonly TelemetrySource _telemetry; private readonly int _maxModelValidationErrors; private IFilterMetadata[] _filters; @@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Mvc.Actions [NotNull] IReadOnlyList valueProviderFactories, [NotNull] IActionBindingContextAccessor actionBindingContextAccessor, [NotNull] ILogger logger, - [NotNull] INotifier notifier, + [NotNull] TelemetrySource telemetry, int maxModelValidationErrors) { ActionContext = actionContext; @@ -83,7 +83,7 @@ namespace Microsoft.AspNet.Mvc.Actions _valueProviderFactories = valueProviderFactories; _actionBindingContextAccessor = actionBindingContextAccessor; _logger = logger; - _notifier = notifier; + _telemetry = telemetry; _maxModelValidationErrors = maxModelValidationErrors; } @@ -571,9 +571,9 @@ namespace Microsoft.AspNet.Mvc.Actions try { - if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.BeforeActionMethod")) + if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionMethod")) { - _notifier.Notify( + _telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.BeforeActionMethod", new { actionContext = ActionContext, arguments = _actionExecutingContext.ActionArguments }); } @@ -582,9 +582,9 @@ namespace Microsoft.AspNet.Mvc.Actions } finally { - if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.AfterActionMethod")) + if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionMethod")) { - _notifier.Notify( + _telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.AfterActionMethod", new { actionContext = ActionContext, result }); } @@ -735,9 +735,9 @@ namespace Microsoft.AspNet.Mvc.Actions private async Task InvokeResultAsync(IActionResult result) { - if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.BeforeActionResult")) + if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeActionResult")) { - _notifier.Notify( + _telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.BeforeActionResult", new { actionContext = ActionContext, result }); } @@ -748,9 +748,9 @@ namespace Microsoft.AspNet.Mvc.Actions } finally { - if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.AfterActionResult")) + if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterActionResult")) { - _notifier.Notify( + _telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.AfterActionResult", new { actionContext = ActionContext, result }); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Actions/MvcRouteHandler.cs b/src/Microsoft.AspNet.Mvc.Core/Actions/MvcRouteHandler.cs index a5186ebe14..971ff42d67 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Actions/MvcRouteHandler.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Actions/MvcRouteHandler.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics.Tracing; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Core; @@ -10,7 +11,6 @@ using Microsoft.AspNet.Routing; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Internal; using Microsoft.Framework.Logging; -using Microsoft.Framework.Notification; namespace Microsoft.AspNet.Mvc.Actions { @@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc.Actions private IActionInvokerFactory _actionInvokerFactory; private IActionSelector _actionSelector; private ILogger _logger; - private INotifier _notifier; + private TelemetrySource _telemetry; public VirtualPathData GetVirtualPath([NotNull] VirtualPathContext context) { @@ -70,9 +70,9 @@ namespace Microsoft.AspNet.Mvc.Actions { context.RouteData = newRouteData; - if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.BeforeAction")) + if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.BeforeAction")) { - _notifier.Notify( + _telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.BeforeAction", new { actionDescriptor, httpContext = context.HttpContext, routeData = context.RouteData}); } @@ -87,9 +87,9 @@ namespace Microsoft.AspNet.Mvc.Actions } finally { - if (_notifier.ShouldNotify("Microsoft.AspNet.Mvc.AfterAction")) + if (_telemetry.IsEnabled("Microsoft.AspNet.Mvc.AfterAction")) { - _notifier.Notify( + _telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.AfterAction", new { actionDescriptor, httpContext = context.HttpContext }); } @@ -140,9 +140,9 @@ namespace Microsoft.AspNet.Mvc.Actions _logger = factory.CreateLogger(); } - if (_notifier == null) + if (_telemetry == null) { - _notifier = context.RequestServices.GetRequiredService(); + _telemetry = context.RequestServices.GetRequiredService(); } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs index 62e3c6dae4..56d69ae6e0 100644 --- a/src/Microsoft.AspNet.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics.Tracing; +using System.Linq; using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.ActionConstraints; using Microsoft.AspNet.Mvc.Actions; @@ -64,7 +66,7 @@ namespace Microsoft.Framework.DependencyInjection services.TryAddEnumerable( ServiceDescriptor.Transient()); services.TryAddSingleton(); - + // // Action Selection // @@ -132,7 +134,18 @@ namespace Microsoft.Framework.DependencyInjection { services.AddOptions(); services.AddRouting(); - services.AddNotifier(); + + // Registered as a Source for us, and as a Listener for consumers. + if (!services.Any(s => s.ServiceType == typeof(TelemetrySource))) + { + var source = new TelemetryListener("Microsoft.AspNet"); + services.AddInstance(source); + + if (!services.Any(s => s.ServiceType == typeof(TelemetryListener))) + { + services.AddInstance(source); + } + } } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/project.json b/src/Microsoft.AspNet.Mvc.Core/project.json index 553822de15..05629aa374 100644 --- a/src/Microsoft.AspNet.Mvc.Core/project.json +++ b/src/Microsoft.AspNet.Mvc.Core/project.json @@ -1,30 +1,48 @@ { - "description": "The core runtime components of ASP.NET MVC.", - "version": "6.0.0-*", - "repository": { - "type": "git", - "url": "git://github.com/aspnet/mvc" + "description": "The core runtime components of ASP.NET MVC.", + "version": "6.0.0-*", + "repository": { + "type": "git", + "url": "git://github.com/aspnet/mvc" + }, + "compilationOptions": { + "warningsAsErrors": true + }, + "dependencies": { + "Microsoft.AspNet.Authorization": "1.0.0-*", + "Microsoft.AspNet.FileProviders.Abstractions": "1.0.0-*", + "Microsoft.AspNet.Hosting.Abstractions": "1.0.0-*", + "Microsoft.AspNet.Mvc.Abstractions": "6.0.0-*", + "Microsoft.Dnx.Runtime.Abstractions": "1.0.0-*", + "Microsoft.Framework.ClosedGenericMatcher.Sources": { + "version": "1.0.0-*", + "type": "build" }, - "compilationOptions": { - "warningsAsErrors": true + "Microsoft.Framework.Logging.Abstractions": "1.0.0-*", + "Microsoft.Framework.NotNullAttribute.Sources": { + "version": "1.0.0-*", + "type": "build" }, - "dependencies": { - "Microsoft.AspNet.Authorization": "1.0.0-*", - "Microsoft.AspNet.FileProviders.Abstractions": "1.0.0-*", - "Microsoft.AspNet.Hosting.Abstractions": "1.0.0-*", - "Microsoft.AspNet.Mvc.Abstractions": "6.0.0-*", - "Microsoft.Dnx.Runtime.Abstractions": "1.0.0-*", - "Microsoft.Framework.ClosedGenericMatcher.Sources": { "version": "1.0.0-*", "type": "build" }, - "Microsoft.Framework.Logging.Abstractions": "1.0.0-*", - "Microsoft.Framework.Notification": "1.0.0-*", - "Microsoft.Framework.NotNullAttribute.Sources": { "version": "1.0.0-*", "type": "build" }, - "Microsoft.Framework.PropertyActivator.Sources": { "version": "1.0.0-*", "type": "build" }, - "Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" }, - "Microsoft.Framework.SecurityHelper.Sources": { "version": "1.0.0-*", "type": "build" } - + "Microsoft.Framework.PropertyActivator.Sources": { + "version": "1.0.0-*", + "type": "build" }, - "frameworks": { - "dnx451": { }, - "dnxcore50": { } - } + "Microsoft.Framework.PropertyHelper.Sources": { + "version": "1.0.0-*", + "type": "build" + }, + "Microsoft.Framework.SecurityHelper.Sources": { + "version": "1.0.0-*", + "type": "build" + }, + "System.Diagnostics.Tracing.Telemetry": "4.0.0-beta-*" + }, + "frameworks": { + "dnx451": { + "frameworkAssemblies": { + "System.Runtime": "" + } + }, + "dnxcore50": { } + } } diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ActionResults/ViewResult.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ActionResults/ViewResult.cs index da95914a3b..0bdbe4fedf 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ActionResults/ViewResult.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ActionResults/ViewResult.cs @@ -9,8 +9,7 @@ using Microsoft.Framework.Internal; using Microsoft.Framework.Logging; using Microsoft.Net.Http.Headers; using Microsoft.Framework.OptionsModel; -using Microsoft.Framework.Notification; -using Microsoft.AspNet.Mvc.Actions; +using System.Diagnostics.Tracing; namespace Microsoft.AspNet.Mvc.ActionResults { @@ -28,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.ActionResults /// Gets or sets the name of the view to render. /// /// - /// When null, defaults to . + /// When null, defaults to . /// public string ViewName { get; set; } @@ -61,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.ActionResults var viewEngine = ViewEngine ?? services.GetRequiredService(); var logger = services.GetRequiredService>(); - var notifier = services.GetRequiredService(); + var telemetry = services.GetRequiredService(); var options = services.GetRequiredService>(); @@ -69,9 +68,9 @@ namespace Microsoft.AspNet.Mvc.ActionResults var viewEngineResult = viewEngine.FindView(context, viewName); if(!viewEngineResult.Success) { - if (notifier.ShouldNotify("Microsoft.AspNet.Mvc.ViewResultViewNotFound")) + if (telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewResultViewNotFound")) { - notifier.Notify( + telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.ViewResultViewNotFound", new { @@ -89,9 +88,9 @@ namespace Microsoft.AspNet.Mvc.ActionResults } var view = viewEngineResult.EnsureSuccessful().View; - if (notifier.ShouldNotify("Microsoft.AspNet.Mvc.ViewResultViewFound")) + if (telemetry.IsEnabled("Microsoft.AspNet.Mvc.ViewResultViewFound")) { - notifier.Notify( + telemetry.WriteTelemetry( "Microsoft.AspNet.Mvc.ViewResultViewFound", new { actionContext = context, result = this, viewName, view = view }); } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Actions/ControllerActionInvokerTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Actions/ControllerActionInvokerTest.cs index 3e2a838cf1..dd846836a1 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Actions/ControllerActionInvokerTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Actions/ControllerActionInvokerTest.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics.Tracing; using System.IO; using System.Linq; using System.Reflection; @@ -20,7 +21,6 @@ using Microsoft.AspNet.Testing; using Microsoft.Framework.Internal; using Microsoft.Framework.Logging; using Microsoft.Framework.Logging.Testing; -using Microsoft.Framework.Notification; using Microsoft.Framework.OptionsModel; using Microsoft.Net.Http.Headers; using Moq; @@ -2046,7 +2046,7 @@ namespace Microsoft.AspNet.Mvc.Actions new IValueProviderFactory[0], new ActionBindingContextAccessor(), new NullLoggerFactory().CreateLogger(), - new Notifier(new ProxyNotifierMethodAdapter()), + new TelemetryListener("Microsoft.AspNet"), maxAllowedErrorsInModelState); return invoker; @@ -2107,7 +2107,7 @@ namespace Microsoft.AspNet.Mvc.Actions new IValueProviderFactory[0], new ActionBindingContextAccessor(), new NullLoggerFactory().CreateLogger(), - new Notifier(new ProxyNotifierMethodAdapter()), + new TelemetryListener("Microsoft.AspNet"), 200); // Act @@ -2208,7 +2208,7 @@ namespace Microsoft.AspNet.Mvc.Actions IReadOnlyList valueProviderFactories, IActionBindingContextAccessor actionBindingContext, ILogger logger, - INotifier notifier, + TelemetrySource telemetry, int maxAllowedErrorsInModelState) : base( actionContext, @@ -2223,7 +2223,7 @@ namespace Microsoft.AspNet.Mvc.Actions valueProviderFactories, actionBindingContext, logger, - notifier, + telemetry, maxAllowedErrorsInModelState) { ControllerFactory = controllerFactory; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Actions/MvcRouteHandlerTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Actions/MvcRouteHandlerTests.cs index 6f9782faac..5524c82667 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Actions/MvcRouteHandlerTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Actions/MvcRouteHandlerTests.cs @@ -2,14 +2,13 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics.Tracing; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.Internal; -using Microsoft.AspNet.Mvc.TestCommon.Notification; using Microsoft.AspNet.Routing; using Microsoft.Framework.Logging; using Microsoft.Framework.Logging.Testing; -using Microsoft.Framework.Notification; using Microsoft.Framework.OptionsModel; using Moq; using Xunit; @@ -158,9 +157,9 @@ namespace Microsoft.AspNet.Mvc.Actions public async Task RouteAsync_Notifies_ActionSelected() { // Arrange - var listener = new TestNotificationListener(); + var listener = new TestTelemetryListener(); - var context = CreateRouteContext(notificationListener: listener); + var context = CreateRouteContext(telemetryListener: listener); context.RouteData.Values.Add("tag", "value"); var handler = new MvcRouteHandler(); @@ -183,9 +182,9 @@ namespace Microsoft.AspNet.Mvc.Actions public async Task RouteAsync_Notifies_ActionInvoked() { // Arrange - var listener = new TestNotificationListener(); + var listener = new TestTelemetryListener(); - var context = CreateRouteContext(notificationListener: listener); + var context = CreateRouteContext(telemetryListener: listener); var handler = new MvcRouteHandler(); @@ -203,7 +202,7 @@ namespace Microsoft.AspNet.Mvc.Actions IActionInvokerFactory invokerFactory = null, ILoggerFactory loggerFactory = null, IOptions optionsAccessor = null, - object notificationListener = null) + object telemetryListener = null) { if (actionDescriptor == null) { @@ -243,10 +242,10 @@ namespace Microsoft.AspNet.Mvc.Actions optionsAccessor = new TestOptionsManager(); } - var notifier = new Notifier(new ProxyNotifierMethodAdapter()); - if (notificationListener != null) + var telemetry = new TelemetryListener("Microsoft.AspNet"); + if (telemetryListener != null) { - notifier.EnlistTarget(notificationListener); + telemetry.SubscribeWithAdapter(telemetryListener); } var httpContext = new Mock(); @@ -262,8 +261,8 @@ namespace Microsoft.AspNet.Mvc.Actions .Returns(new MvcMarkerService()); httpContext.Setup(h => h.RequestServices.GetService(typeof(IOptions))) .Returns(optionsAccessor); - httpContext.Setup(h => h.RequestServices.GetService(typeof(INotifier))) - .Returns(notifier); + httpContext.Setup(h => h.RequestServices.GetService(typeof(TelemetrySource))) + .Returns(telemetry); return new RouteContext(httpContext.Object); } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/project.json b/test/Microsoft.AspNet.Mvc.Core.Test/project.json index f237b89e5c..516fd5e5e8 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Core.Test/project.json @@ -1,28 +1,33 @@ { - "compilationOptions": { - "warningsAsErrors": true + "compilationOptions": { + "warningsAsErrors": true + }, + "dependencies": { + "Microsoft.AspNet.Http": "1.0.0-*", + "Microsoft.AspNet.Mvc": "6.0.0-*", + "Microsoft.AspNet.Mvc.TestCommon": { + "version": "6.0.0-*", + "type": "build" }, - "dependencies": { - "Microsoft.AspNet.Http": "1.0.0-*", - "Microsoft.AspNet.Mvc": "6.0.0-*", - "Microsoft.AspNet.Mvc.TestCommon": { - "version": "6.0.0-*", - "type": "build" - }, - "Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*", - "Microsoft.AspNet.Testing": "1.0.0-*", - "Microsoft.Framework.DependencyInjection": "1.0.0-*", - "Microsoft.Framework.Logging.Testing": "1.0.0-*", - "Microsoft.Framework.WebEncoders.Testing": "1.0.0-*", - "Moq": "4.2.1312.1622", - "xunit.runner.aspnet": "2.0.0-aspnet-*" + "Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*", + "Microsoft.AspNet.Mvc.TestTelemetryListener.Sources": { + "version": "6.0.0-*", + "type": "build" }, - "commands": { - "test": "xunit.runner.aspnet" - }, - "frameworks": { - "dnx451": { - "compilationOptions": { "define": ["MOCK_SUPPORT"] } - } + "Microsoft.AspNet.Testing": "1.0.0-*", + "Microsoft.Framework.DependencyInjection": "1.0.0-*", + "Microsoft.Framework.Logging.Testing": "1.0.0-*", + "Microsoft.Framework.TelemetryAdapter": "1.0.0-*", + "Microsoft.Framework.WebEncoders.Testing": "1.0.0-*", + "Moq": "4.2.1312.1622", + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, + "commands": { + "test": "xunit.runner.aspnet" + }, + "frameworks": { + "dnx451": { + "compilationOptions": { "define": [ "MOCK_SUPPORT" ] } } + } } diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyActionContext.cs b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyActionContext.cs similarity index 80% rename from test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyActionContext.cs rename to test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyActionContext.cs index 43ff07a224..5d5aab524f 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyActionContext.cs +++ b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyActionContext.cs @@ -1,7 +1,7 @@ // 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. -namespace Microsoft.AspNet.Mvc.TestCommon.Notification +namespace Microsoft.AspNet.Mvc { public interface IProxyActionContext { diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyActionDescriptor.cs b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyActionDescriptor.cs similarity index 80% rename from test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyActionDescriptor.cs rename to test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyActionDescriptor.cs index 093a8c4faf..eae1edff2f 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyActionDescriptor.cs +++ b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyActionDescriptor.cs @@ -1,7 +1,7 @@ // 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. -namespace Microsoft.AspNet.Mvc.TestCommon.Notification +namespace Microsoft.AspNet.Mvc { public interface IProxyActionDescriptor { diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyActionResult.cs b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyActionResult.cs similarity index 80% rename from test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyActionResult.cs rename to test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyActionResult.cs index ba950170d6..4c93860d9d 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyActionResult.cs +++ b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyActionResult.cs @@ -1,7 +1,7 @@ // 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. -namespace Microsoft.AspNet.Mvc.TestCommon.Notification +namespace Microsoft.AspNet.Mvc { public interface IProxyActionResult { diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyHttpContext.cs b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyHttpContext.cs similarity index 80% rename from test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyHttpContext.cs rename to test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyHttpContext.cs index d2b1ba6ab9..7001fd0d99 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyHttpContext.cs +++ b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyHttpContext.cs @@ -1,7 +1,7 @@ // 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. -namespace Microsoft.AspNet.Mvc.TestCommon.Notification +namespace Microsoft.AspNet.Mvc { public interface IProxyHttpContext { diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyRouteData.cs b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyRouteData.cs similarity index 88% rename from test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyRouteData.cs rename to test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyRouteData.cs index 07062d4a31..bd1edd2ce4 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyRouteData.cs +++ b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyRouteData.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; -namespace Microsoft.AspNet.Mvc.TestCommon.Notification +namespace Microsoft.AspNet.Mvc { public interface IProxyRouteData { diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyView.cs b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyView.cs similarity index 79% rename from test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyView.cs rename to test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyView.cs index dbd20f325a..cb036a09a0 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/IProxyView.cs +++ b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/IProxyView.cs @@ -1,7 +1,7 @@ // 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. -namespace Microsoft.AspNet.Mvc.TestCommon.Notification +namespace Microsoft.AspNet.Mvc { public interface IProxyView { diff --git a/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources.xproj b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources.xproj new file mode 100644 index 0000000000..61e335c36f --- /dev/null +++ b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources.xproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 9879b5d5-2325-4a81-b4df-f279fe8feeb4 + Microsoft.AspNet.Mvc.TestTelemetryListener.Sources + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + + 2.0 + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/TestNotificationListener.cs b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/TestTelemetryListener.cs similarity index 89% rename from test/Microsoft.AspNet.Mvc.TestCommon/Notification/TestNotificationListener.cs rename to test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/TestTelemetryListener.cs index 27f6db58c9..232278ccf5 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/Notification/TestNotificationListener.cs +++ b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/TestTelemetryListener.cs @@ -2,11 +2,11 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; -using Microsoft.Framework.Notification; +using Microsoft.Framework.TelemetryAdapter; -namespace Microsoft.AspNet.Mvc.TestCommon.Notification +namespace Microsoft.AspNet.Mvc { - public class TestNotificationListener + public class TestTelemetryListener { public class OnBeforeActionEventData { @@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.TestCommon.Notification public OnBeforeActionEventData BeforeAction { get; set; } - [NotificationName("Microsoft.AspNet.Mvc.BeforeAction")] + [TelemetryName("Microsoft.AspNet.Mvc.BeforeAction")] public virtual void OnBeforeAction( IProxyHttpContext httpContext, IProxyRouteData routeData, @@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Mvc.TestCommon.Notification public OnAfterActionEventData AfterAction { get; set; } - [NotificationName("Microsoft.AspNet.Mvc.AfterAction")] + [TelemetryName("Microsoft.AspNet.Mvc.AfterAction")] public virtual void OnAfterAction( IProxyHttpContext httpContext, IProxyActionDescriptor actionDescriptor) @@ -61,7 +61,7 @@ namespace Microsoft.AspNet.Mvc.TestCommon.Notification public OnViewResultViewFoundEventData ViewResultViewFound { get; set; } - [NotificationName("Microsoft.AspNet.Mvc.ViewResultViewFound")] + [TelemetryName("Microsoft.AspNet.Mvc.ViewResultViewFound")] public virtual void OnViewResultViewFound( IProxyActionContext actionContext, IProxyActionResult result, @@ -87,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.TestCommon.Notification public OnViewResultViewNotFoundEventData ViewResultViewNotFound { get; set; } - [NotificationName("Microsoft.AspNet.Mvc.ViewResultViewNotFound")] + [TelemetryName("Microsoft.AspNet.Mvc.ViewResultViewNotFound")] public virtual void OnViewResultViewNotFound( IProxyActionContext actionContext, IProxyActionResult result, diff --git a/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/project.json b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/project.json new file mode 100644 index 0000000000..06391bc602 --- /dev/null +++ b/test/Microsoft.AspNet.Mvc.TestTelemetryListener.Sources/project.json @@ -0,0 +1,12 @@ +{ + "version": "6.0.0-*", + "shared": "**/*.cs", + "frameworks": { + "dnx451": { }, + "dnxcore50": { + "dependencies": { + "System.Runtime": "4.0.21-beta-*" + } + } + } +} diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ActionResults/ViewResultTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ActionResults/ViewResultTest.cs index dfb3bb424d..066b17af74 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ActionResults/ViewResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ActionResults/ViewResultTest.cs @@ -2,17 +2,16 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Diagnostics.Tracing; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.Actions; using Microsoft.AspNet.Mvc.Rendering; -using Microsoft.AspNet.Mvc.TestCommon.Notification; using Microsoft.AspNet.Routing; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; -using Microsoft.Framework.Notification; using Microsoft.Framework.OptionsModel; using Microsoft.Net.Http.Headers; using Moq; @@ -207,8 +206,14 @@ namespace Microsoft.AspNet.Mvc.ActionResults .Verifiable(); var serviceProvider = new Mock(); - serviceProvider.Setup(s => s.GetService(typeof(INotifier))) - .Returns(new Notifier(new ProxyNotifierMethodAdapter())); + + var telemetry = new TelemetryListener("Microsoft.AspNet"); + serviceProvider + .Setup(s => s.GetService(typeof(TelemetrySource))) + .Returns(telemetry); + serviceProvider + .Setup(s => s.GetService(typeof(TelemetryListener))) + .Returns(telemetry); serviceProvider.Setup(p => p.GetService(typeof(ICompositeViewEngine))) .Returns(viewEngine.Object); serviceProvider.Setup(p => p.GetService(typeof(ILogger))) @@ -242,8 +247,8 @@ namespace Microsoft.AspNet.Mvc.ActionResults var httpContext = GetHttpContext(); var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor()); - var listener = new TestNotificationListener(); - httpContext.RequestServices.GetRequiredService().EnlistTarget(listener); + var listener = new TestTelemetryListener(); + httpContext.RequestServices.GetRequiredService().SubscribeWithAdapter(listener); var viewEngine = new Mock(); var view = Mock.Of(); @@ -276,8 +281,8 @@ namespace Microsoft.AspNet.Mvc.ActionResults var httpContext = GetHttpContext(); var context = new ActionContext(httpContext, new RouteData(), new ActionDescriptor()); - var listener = new TestNotificationListener(); - httpContext.RequestServices.GetRequiredService().EnlistTarget(listener); + var listener = new TestTelemetryListener(); + httpContext.RequestServices.GetRequiredService().SubscribeWithAdapter(listener); var viewEngine = new Mock(); var view = Mock.Of(); @@ -316,9 +321,11 @@ namespace Microsoft.AspNet.Mvc.ActionResults serviceProvider.Setup(s => s.GetService(typeof(IOptions))) .Returns(optionsAccessor.Object); - serviceProvider.Setup(s => s.GetService(typeof(INotifier))) - .Returns(new Notifier(new ProxyNotifierMethodAdapter())); - + var telemetry = new TelemetryListener("Microsoft.AspNet"); + serviceProvider.Setup(s => s.GetService(typeof(TelemetryListener))) + .Returns(telemetry); + serviceProvider.Setup(s => s.GetService(typeof(TelemetrySource))) + .Returns(telemetry); var httpContext = new DefaultHttpContext(); httpContext.RequestServices = serviceProvider.Object; diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json index c8c70973b1..c25a1c9398 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json @@ -1,25 +1,33 @@ { - "compilationOptions": { - "warningsAsErrors": true + "compilationOptions": { + "warningsAsErrors": true + }, + "dependencies": { + "Microsoft.AspNet.Http": "1.0.0-*", + "Microsoft.AspNet.Mvc": "6.0.0-*", + "Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*", + "Microsoft.AspNet.Mvc.TestCommon": { + "version": "6.0.0-*", + "type": "build" }, - "dependencies": { - "Microsoft.AspNet.Http": "1.0.0-*", - "Microsoft.AspNet.Mvc": "6.0.0-*", - "Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*", - "Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" }, - "Microsoft.AspNet.Testing": "1.0.0-*", - "Microsoft.Framework.DependencyInjection": "1.0.0-*", - "Microsoft.Framework.Logging.Testing": "1.0.0-*", - "Microsoft.Framework.WebEncoders.Testing": "1.0.0-*", - "Moq": "4.2.1312.1622", - "xunit.runner.aspnet": "2.0.0-aspnet-*" + "Microsoft.AspNet.Mvc.TestTelemetryListener.Sources": { + "version": "6.0.0-*", + "type": "build" }, - "commands": { - "test": "xunit.runner.aspnet" - }, - "frameworks": { - "dnx451": { - "compilationOptions": { "define": ["MOCK_SUPPORT"] } - } + "Microsoft.AspNet.Testing": "1.0.0-*", + "Microsoft.Framework.DependencyInjection": "1.0.0-*", + "Microsoft.Framework.Logging.Testing": "1.0.0-*", + "Microsoft.Framework.TelemetryAdapter": "1.0.0-*", + "Microsoft.Framework.WebEncoders.Testing": "1.0.0-*", + "Moq": "4.2.1312.1622", + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, + "commands": { + "test": "xunit.runner.aspnet" + }, + "frameworks": { + "dnx451": { + "compilationOptions": { "define": [ "MOCK_SUPPORT" ] } } + } }