diff --git a/Mvc.NoFun.sln b/Mvc.NoFun.sln index b72d4d4bf1..ddc884c63c 100644 --- a/Mvc.NoFun.sln +++ b/Mvc.NoFun.sln @@ -28,6 +28,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FAD65E9C-3CF3-4F68-9757-C7358604030B}" ProjectSection(SolutionItems) = preProject global.json = global.json + NuGetPackageVerifier.json = NuGetPackageVerifier.json EndProjectSection EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.WebApiCompatShim", "src\Microsoft.AspNet.Mvc.WebApiCompatShim\Microsoft.AspNet.Mvc.WebApiCompatShim.xproj", "{23D30B8C-04B1-4577-A604-ED27EA1E4A0E}" @@ -42,8 +43,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TagHelperSample.Web", "samp EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TagHelpers.Test", "test\Microsoft.AspNet.Mvc.TagHelpers.Test\Microsoft.AspNet.Mvc.TagHelpers.Test.xproj", "{860119ED-3DB1-424D-8D0A-30132A8A7D96}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.PageExecutionInstrumentation.Interfaces", "src\Microsoft.AspNet.PageExecutionInstrumentation.Interfaces\Microsoft.AspNet.PageExecutionInstrumentation.Interfaces.xproj", "{4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestCommon", "test\Microsoft.AspNet.Mvc.TestCommon\Microsoft.AspNet.Mvc.TestCommon.xproj", "{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.IntegrationTests", "test\Microsoft.AspNet.Mvc.IntegrationTests\Microsoft.AspNet.Mvc.IntegrationTests.xproj", "{864FA09D-1E48-403A-A6C8-4F079D2A30F0}" @@ -244,18 +243,6 @@ Global {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Release|Mixed Platforms.Build.0 = Release|Any CPU {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Release|x86.ActiveCfg = Release|Any CPU {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Release|x86.Build.0 = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|x86.ActiveCfg = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|x86.Build.0 = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|Any CPU.Build.0 = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|x86.ActiveCfg = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|x86.Build.0 = Release|Any CPU {F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|x86.ActiveCfg = Debug|Any CPU @@ -525,7 +512,6 @@ Global {B2347320-308E-4D2B-AEC8-005DFA68B0C9} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {2223120F-D675-40DA-8CD8-11DC14A0B2C7} = {DAAE4C74-D06F-4874-A166-33305D2643CE} {860119ED-3DB1-424D-8D0A-30132A8A7D96} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {F504357E-C2E1-4818-BA5C-9A2EAC25FEE5} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {864FA09D-1E48-403A-A6C8-4F079D2A30F0} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {1154203C-7579-4525-906E-BC55268421C1} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} diff --git a/Mvc.sln b/Mvc.sln index 308001f973..b22ae18a96 100644 --- a/Mvc.sln +++ b/Mvc.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.24711.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}" EndProject @@ -116,8 +116,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ControllersFromServicesWebS EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ControllersFromServicesClassLibrary", "test\WebSites\ControllersFromServicesClassLibrary\ControllersFromServicesClassLibrary.xproj", "{551DC89E-2A13-4CF2-83D7-1ADD802443D5}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.PageExecutionInstrumentation.Interfaces", "src\Microsoft.AspNet.PageExecutionInstrumentation.Interfaces\Microsoft.AspNet.PageExecutionInstrumentation.Interfaces.xproj", "{4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UserClassLibrary", "test\WebSites\UserClassLibrary\UserClassLibrary.xproj", "{C651F432-4EBE-41A6-BAD2-3E07CCBA209C}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ControllerDiscoveryConventionsWebSite", "test\WebSites\ControllerDiscoveryConventionsWebSite\ControllerDiscoveryConventionsWebSite.xproj", "{A19022EF-9BA3-4349-94E4-F48E13E1C8AE}" @@ -720,18 +718,6 @@ Global {551DC89E-2A13-4CF2-83D7-1ADD802443D5}.Release|Mixed Platforms.Build.0 = Release|Any CPU {551DC89E-2A13-4CF2-83D7-1ADD802443D5}.Release|x86.ActiveCfg = Release|Any CPU {551DC89E-2A13-4CF2-83D7-1ADD802443D5}.Release|x86.Build.0 = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|x86.ActiveCfg = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Debug|x86.Build.0 = Debug|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|Any CPU.Build.0 = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|x86.ActiveCfg = Release|Any CPU - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE}.Release|x86.Build.0 = Release|Any CPU {C651F432-4EBE-41A6-BAD2-3E07CCBA209C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C651F432-4EBE-41A6-BAD2-3E07CCBA209C}.Debug|Any CPU.Build.0 = Debug|Any CPU {C651F432-4EBE-41A6-BAD2-3E07CCBA209C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -1159,7 +1145,6 @@ Global {AC9BE567-540E-4C70-90C2-AAF021307A80} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {983741B2-4424-4ED1-9B03-7675A67230C8} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {551DC89E-2A13-4CF2-83D7-1ADD802443D5} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} - {4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {C651F432-4EBE-41A6-BAD2-3E07CCBA209C} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {A19022EF-9BA3-4349-94E4-F48E13E1C8AE} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {B11C99C9-E577-4CA2-AC53-4F20EA71AD34} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} diff --git a/NuGetPackageVerifier.json b/NuGetPackageVerifier.json index d772e03fe9..56143bbd97 100644 --- a/NuGetPackageVerifier.json +++ b/NuGetPackageVerifier.json @@ -22,8 +22,7 @@ "Microsoft.AspNet.Mvc.Razor.Host": { }, "Microsoft.AspNet.Mvc.TagHelpers": { }, "Microsoft.AspNet.Mvc.ViewFeatures": { }, - "Microsoft.AspNet.Mvc.WebApiCompatShim": { }, - "Microsoft.AspNet.PageExecutionInstrumentation.Interfaces": { } + "Microsoft.AspNet.Mvc.WebApiCompatShim": { } } }, "Default": { // Rules to run for packages not listed in any other set. diff --git a/src/Microsoft.AspNet.Mvc.Razor/IRazorPage.cs b/src/Microsoft.AspNet.Mvc.Razor/IRazorPage.cs index 156bedb227..57e57b3166 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/IRazorPage.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/IRazorPage.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using Microsoft.AspNet.Mvc.Rendering; -using Microsoft.AspNet.PageExecutionInstrumentation; namespace Microsoft.AspNet.Mvc.Razor { @@ -45,11 +44,6 @@ namespace Microsoft.AspNet.Mvc.Razor /// string Layout { get; set; } - /// - /// Gets or sets a instance used to instrument the page execution. - /// - IPageExecutionContext PageExecutionContext { get; set; } - /// /// Gets or sets the sections that can be rendered by this page. /// diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs index c745b36943..bde2981b27 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs @@ -16,7 +16,6 @@ using Microsoft.AspNet.Mvc.Infrastructure; using Microsoft.AspNet.Mvc.Razor.Internal; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.ViewFeatures; -using Microsoft.AspNet.PageExecutionInstrumentation; using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.Extensions.DependencyInjection; @@ -77,9 +76,6 @@ namespace Microsoft.AspNet.Mvc.Razor [RazorInject] public HtmlEncoder HtmlEncoder { get; set; } - /// - public IPageExecutionContext PageExecutionContext { get; set; } - /// /// Gets or sets a instance used to instrument the page execution. /// @@ -937,7 +933,6 @@ namespace Microsoft.AspNet.Mvc.Razor { const string BeginContextEvent = "Microsoft.AspNet.Mvc.Razor.BeginInstrumentationContext"; - PageExecutionContext?.BeginContext(position, length, isLiteral); if (DiagnosticSource?.IsEnabled(BeginContextEvent) == true) { DiagnosticSource.Write( @@ -957,7 +952,6 @@ namespace Microsoft.AspNet.Mvc.Razor { const string EndContextEvent = "Microsoft.AspNet.Mvc.Razor.EndInstrumentationContext"; - PageExecutionContext?.EndContext(); if (DiagnosticSource?.IsEnabled(EndContextEvent) == true) { DiagnosticSource.Write( diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs index 388ad77770..6cae8bb1ae 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/RazorTextWriter.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.Razor /// This type is designed to avoid creating large in-memory strings when buffering and supporting the contract that /// expects. /// - public class RazorTextWriter : HtmlTextWriter, IBufferedTextWriter + public class RazorTextWriter : HtmlTextWriter { /// /// Creates a new instance of . @@ -228,8 +228,9 @@ namespace Microsoft.AspNet.Mvc.Razor var targetRazorTextWriter = writer as RazorTextWriter; if (targetRazorTextWriter != null) { - writer = targetRazorTextWriter.IsBuffering ? targetRazorTextWriter.BufferedWriter : - targetRazorTextWriter.UnbufferedWriter; + writer = targetRazorTextWriter.IsBuffering ? + targetRazorTextWriter.BufferedWriter : + targetRazorTextWriter.UnbufferedWriter; } return writer; diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs index b0aafed57b..46f2950740 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/RazorView.cs @@ -3,14 +3,11 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.ViewEngines; -using Microsoft.AspNet.PageExecutionInstrumentation; namespace Microsoft.AspNet.Mvc.Razor { @@ -23,7 +20,6 @@ namespace Microsoft.AspNet.Mvc.Razor private readonly IRazorViewEngine _viewEngine; private readonly IRazorPageActivator _pageActivator; private readonly HtmlEncoder _htmlEncoder; - private IPageExecutionListenerFeature _pageExecutionFeature; /// /// Initializes a new instance of @@ -89,11 +85,6 @@ namespace Microsoft.AspNet.Mvc.Razor /// public IReadOnlyList ViewStartPages { get; } - private bool EnableInstrumentation - { - get { return _pageExecutionFeature != null; } - } - /// public virtual async Task RenderAsync(ViewContext context) { @@ -102,40 +93,22 @@ namespace Microsoft.AspNet.Mvc.Razor throw new ArgumentNullException(nameof(context)); } - _pageExecutionFeature = context.HttpContext.Features.Get(); - var bodyWriter = await RenderPageAsync(RazorPage, context, ViewStartPages); await RenderLayoutAsync(context, bodyWriter); } - private async Task RenderPageAsync( + private async Task RenderPageAsync( IRazorPage page, ViewContext context, IReadOnlyList viewStartPages) { var razorTextWriter = new RazorTextWriter(context.Writer, context.Writer.Encoding, _htmlEncoder); - var writer = (TextWriter)razorTextWriter; - var bufferedWriter = (IBufferedTextWriter)razorTextWriter; - - if (EnableInstrumentation) - { - writer = _pageExecutionFeature.DecorateWriter(razorTextWriter); - bufferedWriter = writer as IBufferedTextWriter; - if (bufferedWriter == null) - { - var message = Resources.FormatInstrumentation_WriterMustBeBufferedTextWriter( - nameof(TextWriter), - _pageExecutionFeature.GetType().FullName, - typeof(IBufferedTextWriter).FullName); - throw new InvalidOperationException(message); - } - } // The writer for the body is passed through the ViewContext, allowing things like HtmlHelpers // and ViewComponents to reference it. var oldWriter = context.Writer; var oldFilePath = context.ExecutingFilePath; - context.Writer = writer; + context.Writer = razorTextWriter; context.ExecutingFilePath = page.Path; try @@ -147,24 +120,19 @@ namespace Microsoft.AspNet.Mvc.Razor } await RenderPageCoreAsync(page, context); - return bufferedWriter; + return razorTextWriter; } finally { context.Writer = oldWriter; context.ExecutingFilePath = oldFilePath; - writer.Dispose(); + razorTextWriter.Dispose(); } } private Task RenderPageCoreAsync(IRazorPage page, ViewContext context) { page.ViewContext = context; - if (EnableInstrumentation) - { - page.PageExecutionContext = _pageExecutionFeature.GetContext(page.Path, context.Writer); - } - _pageActivator.Activate(page, context); return page.ExecuteAsync(); } @@ -201,7 +169,7 @@ namespace Microsoft.AspNet.Mvc.Razor private async Task RenderLayoutAsync( ViewContext context, - IBufferedTextWriter bodyWriter) + RazorTextWriter bodyWriter) { // A layout page can specify another layout page. We'll need to continue // looking for layout pages until they're no longer specified. diff --git a/src/Microsoft.AspNet.Mvc.Razor/project.json b/src/Microsoft.AspNet.Mvc.Razor/project.json index 2024a158b6..0d951debbe 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/project.json +++ b/src/Microsoft.AspNet.Mvc.Razor/project.json @@ -13,7 +13,6 @@ "Microsoft.AspNet.Mvc.Razor.Host": "6.0.0-*", "Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-*", "Microsoft.AspNet.Razor.Runtime.Precompilation": "4.0.0-*", - "Microsoft.AspNet.PageExecutionInstrumentation.Interfaces": "1.0.0-*", "Microsoft.Extensions.HashCodeCombiner.Sources": { "version": "1.0.0-*", "type": "build" diff --git a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/IBufferedTextWriter.cs b/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/IBufferedTextWriter.cs deleted file mode 100644 index be0b32ab7b..0000000000 --- a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/IBufferedTextWriter.cs +++ /dev/null @@ -1,32 +0,0 @@ -// 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.IO; -using System.Threading.Tasks; - -namespace Microsoft.AspNet.Mvc.Razor -{ - /// - /// Specifies the contracts for a that buffers its content. - /// - public interface IBufferedTextWriter - { - /// - /// Gets a flag that determines if content is currently being buffered. - /// - bool IsBuffering { get; } - - /// - /// Copies the buffered content to the . - /// - /// The to copy the contents to. - void CopyTo(TextWriter writer); - - /// - /// Asynchronously copies the buffered content to the . - /// - /// The to copy the contents to. - /// A representing the copy operation. - Task CopyToAsync(TextWriter writer); - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/IPageExecutionContext.cs b/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/IPageExecutionContext.cs deleted file mode 100644 index 9df196152d..0000000000 --- a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/IPageExecutionContext.cs +++ /dev/null @@ -1,25 +0,0 @@ -// 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.PageExecutionInstrumentation -{ - /// - /// Specifies the contracts for a execution context that instruments web page execution. - /// - public interface IPageExecutionContext - { - /// - /// Invoked at the start of a write operation. - /// - /// The absolute character position of the expression or text in the Razor file. - /// The character length of the expression or text in the Razor file. - /// A flag that indicates if the operation is for a literal text and not for a - /// language expression. - void BeginContext(int position, int length, bool isLiteral); - - /// - /// Invoked at the end of a write operation. - /// - void EndContext(); - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/IPageExecutionListenerFeature.cs b/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/IPageExecutionListenerFeature.cs deleted file mode 100644 index 6cf9fe147a..0000000000 --- a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/IPageExecutionListenerFeature.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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.IO; - -namespace Microsoft.AspNet.PageExecutionInstrumentation -{ - /// - /// Specifies the contracts for a HTTP feature that provides the context to instrument a web page. - /// - public interface IPageExecutionListenerFeature - { - /// - /// Decorates the used by web page instances to - /// write the result to. - /// - /// The output for the web page. - /// A that wraps . - TextWriter DecorateWriter(TextWriter writer); - - /// - /// Creates a for the specified . - /// - /// The path of the page. - /// The obtained from . - /// - /// The . - IPageExecutionContext GetContext(string sourceFilePath, TextWriter writer); - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces.xproj b/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces.xproj deleted file mode 100644 index 8311f5fa73..0000000000 --- a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces.xproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 4da2d7c1-a7b6-4c01-b57d-89e6ea4609de - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/Properties/AssemblyInfo.cs deleted file mode 100644 index b2437d9ad6..0000000000 --- a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -// 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.Reflection; -using System.Resources; - -[assembly: AssemblyMetadata("Serviceable", "True")] -[assembly: NeutralResourcesLanguage("en-us")] \ No newline at end of file diff --git a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/project.json b/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/project.json deleted file mode 100644 index b204a52a67..0000000000 --- a/src/Microsoft.AspNet.PageExecutionInstrumentation.Interfaces/project.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "description": "Abstractions for page instrumentation.", - "version": "1.0.0-*", - "repository": { - "type": "git", - "url": "git://github.com/aspnet/mvc" - }, - "compilationOptions": { - "warningsAsErrors": true, - "keyFile": "../../tools/Key.snk" - }, - "frameworks": { - "net451": {}, - "dotnet5.4": { - "dependencies": { - "System.IO": "4.0.11-*", - "System.Resources.ResourceManager": "4.0.1-*" - } - } - } -} diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/RazorPageExecutionInstrumentationWebSite.Home.ViewWithPartial.html b/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/RazorPageExecutionInstrumentationWebSite.Home.ViewWithPartial.html index 061fd827a1..81cbd4fb84 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/RazorPageExecutionInstrumentationWebSite.Home.ViewWithPartial.html +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/RazorPageExecutionInstrumentationWebSite.Home.ViewWithPartial.html @@ -1,27 +1,20 @@ -
-2147483647 -viewstart-content -view-with-partial-content -

partial-content

-

partial-content

-
-

/Views/_ViewStart.cshtml: Non-literal at 96 contains 16 characters.

-

/Views/_ViewStart.cshtml: Literal at 112 contains 2 characters.

-

/Views/Home/ViewWithPartial.cshtml: Literal at 0 contains 27 characters.

-

/Views/Home/ViewWithPartial.cshtml: Non-literal at 28 contains 39 characters.

-

/Views/Home/_PartialView.cshtml: Literal at 31 contains 2 characters.

-

/Views/Home/_PartialView.cshtml: Literal at 33 contains 8 characters.

-

/Views/Home/_PartialView.cshtml: Non-literal at 41 contains 4 characters.

-

/Views/Home/_PartialView.cshtml: Literal at 45 contains 1 characters.

-

/Views/Home/_PartialView.cshtml: Literal at 46 contains 20 characters.

-

/Views/Home/_PartialView.cshtml: Literal at 67 contains 2 characters.

-

/Views/Home/_PartialView.cshtml: Literal at 31 contains 2 characters.

-

/Views/Home/_PartialView.cshtml: Literal at 33 contains 8 characters.

-

/Views/Home/_PartialView.cshtml: Non-literal at 41 contains 4 characters.

-

/Views/Home/_PartialView.cshtml: Literal at 45 contains 1 characters.

-

/Views/Home/_PartialView.cshtml: Literal at 46 contains 20 characters.

-

/Views/_Layout.cshtml: Literal at 82 contains 7 characters.

-

/Views/_Layout.cshtml: Non-literal at 90 contains 12 characters.

-

/Views/_Layout.cshtml: Literal at 102 contains 2 characters.

-

/Views/_Layout.cshtml: Non-literal at 105 contains 12 characters.

-

/Views/_Layout.cshtml: Literal at 117 contains 10 characters.

+/Views/_ViewStart.cshtml: Non-literal at 96 contains 16 characters. +/Views/_ViewStart.cshtml: Literal at 112 contains 2 characters. +/Views/Home/ViewWithPartial.cshtml: Literal at 0 contains 27 characters. +/Views/Home/ViewWithPartial.cshtml: Non-literal at 28 contains 39 characters. +/Views/Home/_PartialView.cshtml: Literal at 31 contains 2 characters. +/Views/Home/_PartialView.cshtml: Literal at 33 contains 8 characters. +/Views/Home/_PartialView.cshtml: Non-literal at 41 contains 4 characters. +/Views/Home/_PartialView.cshtml: Literal at 45 contains 1 characters. +/Views/Home/_PartialView.cshtml: Literal at 46 contains 20 characters. +/Views/Home/ViewWithPartial.cshtml: Literal at 67 contains 2 characters. +/Views/Home/_PartialView.cshtml: Literal at 31 contains 2 characters. +/Views/Home/_PartialView.cshtml: Literal at 33 contains 8 characters. +/Views/Home/_PartialView.cshtml: Non-literal at 41 contains 4 characters. +/Views/Home/_PartialView.cshtml: Literal at 45 contains 1 characters. +/Views/Home/_PartialView.cshtml: Literal at 46 contains 20 characters. +/Views/_Layout.cshtml: Literal at 0 contains 7 characters. +/Views/_Layout.cshtml: Non-literal at 8 contains 12 characters. +/Views/_Layout.cshtml: Literal at 20 contains 2 characters. +/Views/_Layout.cshtml: Non-literal at 23 contains 12 characters. +/Views/_Layout.cshtml: Literal at 35 contains 10 characters. diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs index 20417bb812..c1bde016d8 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs @@ -15,7 +15,6 @@ using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.TestCommon; using Microsoft.AspNet.Mvc.ViewEngines; using Microsoft.AspNet.Mvc.ViewFeatures; -using Microsoft.AspNet.PageExecutionInstrumentation; using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Razor.TagHelpers; using Microsoft.AspNet.Routing; @@ -659,93 +658,6 @@ namespace Microsoft.AspNet.Mvc.Razor Assert.Same(HtmlString.Empty, actual); } - [Fact] - public async Task WriteAttribute_CallsBeginAndEndContext_OnPageExecutionContext() - { - // Arrange - var page = CreatePage(p => - { - p.HtmlEncoder = new HtmlTestEncoder(); - p.BeginWriteAttribute("href", "prefix", 0, "suffix", 34, 2); - p.WriteAttributeValue("prefix", 0, "attr1-value", 8, 14, true); - p.WriteAttributeValue("prefix2", 22, "attr2", 29, 5, false); - p.EndWriteAttribute(); - }); - var context = new Mock(MockBehavior.Strict); - var sequence = new MockSequence(); - context.InSequence(sequence).Setup(f => f.BeginContext(0, 6, true)).Verifiable(); - context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable(); - context.InSequence(sequence).Setup(f => f.BeginContext(0, 6, true)).Verifiable(); - context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable(); - context.InSequence(sequence).Setup(f => f.BeginContext(8, 14, true)).Verifiable(); - context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable(); - context.InSequence(sequence).Setup(f => f.BeginContext(22, 7, true)).Verifiable(); - context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable(); - context.InSequence(sequence).Setup(f => f.BeginContext(29, 5, false)).Verifiable(); - context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable(); - context.InSequence(sequence).Setup(f => f.BeginContext(34, 6, true)).Verifiable(); - context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable(); - page.PageExecutionContext = context.Object; - - // Act - await page.ExecuteAsync(); - - // Assert - context.Verify(); - } - - [Fact] - public async Task WriteAttribute_WithBoolValue_CallsBeginAndEndContext_OnPageExecutionContext() - { - // Arrange - var page = CreatePage(p => - { - p.HtmlEncoder = new HtmlTestEncoder(); - p.BeginWriteAttribute("href", "prefix", 0, "suffix", 10, 1); - p.WriteAttributeValue("", 6, "true", 6, 4, false); - p.EndWriteAttribute(); - }); - var context = new Mock(MockBehavior.Strict); - var sequence = new MockSequence(); - context.InSequence(sequence).Setup(f => f.BeginContext(0, 6, true)).Verifiable(); - context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable(); - context.InSequence(sequence).Setup(f => f.BeginContext(6, 4, false)).Verifiable(); - context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable(); - context.InSequence(sequence).Setup(f => f.BeginContext(10, 6, true)).Verifiable(); - context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable(); - page.PageExecutionContext = context.Object; - - // Act - await page.ExecuteAsync(); - - // Assert - context.Verify(); - } - - [Fact] - public async Task WriteAttribute_CallsBeginAndEndContext_OnPrefixAndSuffixValues() - { - // Arrange - var page = CreatePage(p => - { - p.BeginWriteAttribute("href", "prefix", 0, "tail", 7, 0); - p.EndWriteAttribute(); - }); - var context = new Mock(MockBehavior.Strict); - var sequence = new MockSequence(); - context.InSequence(sequence).Setup(f => f.BeginContext(0, 6, true)).Verifiable(); - context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable(); - context.InSequence(sequence).Setup(f => f.BeginContext(7, 4, true)).Verifiable(); - context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable(); - page.PageExecutionContext = context.Object; - - // Act - await page.ExecuteAsync(); - - // Assert - context.Verify(); - } - [Fact] public async Task WriteAttribute_WritesBeginAndEndEvents_ToDiagnosticSource() { diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewTest.cs index 35520ef053..93e1fa39c0 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewTest.cs @@ -12,7 +12,6 @@ using Microsoft.AspNet.Mvc.Abstractions; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.ViewFeatures; -using Microsoft.AspNet.PageExecutionInstrumentation; using Microsoft.AspNet.Routing; using Microsoft.Extensions.Primitives; using Microsoft.Extensions.WebEncoders.Testing; @@ -54,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.Razor // Assert Assert.NotSame(expected, actual); - Assert.IsAssignableFrom(actual); + Assert.IsType(actual); Assert.Equal("HtmlEncode[[Hello world]]", viewContext.Writer.ToString()); } @@ -1373,163 +1372,6 @@ namespace Microsoft.AspNet.Mvc.Razor Assert.Equal(expected, ex.Message); } - [Fact] - public async Task RenderAsync_UsesPageExecutionFeatureFromRequest_ToWrapWriter() - { - // Arrange - var pageWriter = CreateBufferedWriter(); - var layoutWriter = CreateBufferedWriter(); - - var layoutExecuted = false; - var count = -1; - var feature = new Mock(MockBehavior.Strict); - feature - .Setup(f => f.DecorateWriter(It.IsAny())) - .Returns(() => - { - count++; - if (count == 0) - { - return pageWriter; - } - else if (count == 1) - { - return layoutWriter; - } - throw new Exception(); - }) - .Verifiable(); - - var pageContext = Mock.Of(); - feature - .Setup(f => f.GetContext("/MyPage.cshtml", pageWriter)) - .Returns(pageContext) - .Verifiable(); - - var layoutContext = Mock.Of(); - feature - .Setup(f => f.GetContext("/Layout.cshtml", layoutWriter)) - .Returns(layoutContext) - .Verifiable(); - - var page = new TestableRazorPage(v => - { - v.HtmlEncoder = new HtmlTestEncoder(); - v.Layout = "Layout"; - Assert.Same(pageWriter, v.Output); - Assert.Same(pageContext, v.PageExecutionContext); - }); - page.Path = "/MyPage.cshtml"; - - var layout = new TestableRazorPage(v => - { - v.HtmlEncoder = new HtmlTestEncoder(); - Assert.Same(layoutWriter, v.Output); - Assert.Same(layoutContext, v.PageExecutionContext); - v.RenderBodyPublic(); - - layoutExecuted = true; - }); - layout.Path = "/Layout.cshtml"; - - var viewEngine = new Mock(MockBehavior.Strict); - viewEngine - .Setup(p => p.GetPage("/MyPage.cshtml", "Layout")) - .Returns(new RazorPageResult("Layout", Enumerable.Empty())); - viewEngine - .Setup(p => p.FindPage(It.IsAny(), "Layout")) - .Returns(new RazorPageResult("/Layout.cshtml", layout)); - - var view = new RazorView( - viewEngine.Object, - Mock.Of(), - new IRazorPage[0], - page, - new HtmlTestEncoder()); - var viewContext = CreateViewContext(view); - viewContext.HttpContext.Features.Set(feature.Object); - - // Act - await view.RenderAsync(viewContext); - - // Assert - feature.Verify(); - Assert.True(layoutExecuted); - } - - [Fact] - public async Task RenderAsync_UsesPageExecutionFeatureFromRequest_ToGetExecutionContext() - { - // Arrange - var writer = new StringWriter(); - var executed = false; - var feature = new Mock(MockBehavior.Strict); - - var pageContext = Mock.Of(); - feature.Setup(f => f.GetContext("/MyPartialPage.cshtml", It.IsAny())) - .Returns(pageContext) - .Verifiable(); - - feature.Setup(f => f.DecorateWriter(It.IsAny())) - .Returns((RazorTextWriter r) => r) - .Verifiable(); - - var page = new TestableRazorPage(v => - { - v.HtmlEncoder = new HtmlTestEncoder(); - Assert.IsType(v.Output); - Assert.Same(pageContext, v.PageExecutionContext); - executed = true; - - v.Write("Hello world"); - }); - page.Path = "/MyPartialPage.cshtml"; - - var view = new RazorView( - Mock.Of(), - Mock.Of(), - new IRazorPage[0], - page, - new HtmlTestEncoder()); - var viewContext = CreateViewContext(view); - viewContext.Writer = writer; - viewContext.HttpContext.Features.Set(feature.Object); - - // Act - await view.RenderAsync(viewContext); - - // Assert - feature.Verify(); - Assert.True(executed); - Assert.Equal("HtmlEncode[[Hello world]]", viewContext.Writer.ToString()); - } - - [Fact] - public async Task RenderAsync_DoesNotSetExecutionContextWhenListenerIsNotRegistered() - { - // Arrange - var executed = false; - var page = new TestableRazorPage(v => - { - Assert.Null(v.PageExecutionContext); - executed = true; - }); - - var view = new RazorView( - Mock.Of(), - Mock.Of(), - new IRazorPage[0], - page, - new HtmlTestEncoder()); - var viewContext = CreateViewContext(view); - - // Act - await view.RenderAsync(viewContext); - - // Assert - Assert.True(executed); - } - [Fact] public async Task RenderAsync_CopiesLayoutPropertyFromViewStart() { @@ -1718,15 +1560,6 @@ namespace Microsoft.AspNet.Mvc.Razor Assert.Equal(expected, viewContext.Writer.ToString()); } - private static TextWriter CreateBufferedWriter() - { - var mockWriter = new Mock(); - var bufferedWriter = mockWriter.As(); - bufferedWriter.SetupGet(b => b.IsBuffering) - .Returns(true); - return mockWriter.Object; - } - private static ViewContext CreateViewContext(RazorView view) { var httpContext = new DefaultHttpContext(); diff --git a/test/WebSites/RazorPageExecutionInstrumentationWebSite/IHoldInstrumentationData.cs b/test/WebSites/RazorPageExecutionInstrumentationWebSite/IHoldInstrumentationData.cs deleted file mode 100644 index 67e90f7ce2..0000000000 --- a/test/WebSites/RazorPageExecutionInstrumentationWebSite/IHoldInstrumentationData.cs +++ /dev/null @@ -1,14 +0,0 @@ -// 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; - -namespace RazorPageExecutionInstrumentationWebSite -{ - public interface IHoldInstrumentationData - { - IEnumerable Values { get; } - - void IgnoreFurtherData(); - } -} diff --git a/test/WebSites/RazorPageExecutionInstrumentationWebSite/InstrumentationData.cs b/test/WebSites/RazorPageExecutionInstrumentationWebSite/InstrumentationData.cs deleted file mode 100644 index a3de66fbb5..0000000000 --- a/test/WebSites/RazorPageExecutionInstrumentationWebSite/InstrumentationData.cs +++ /dev/null @@ -1,31 +0,0 @@ -// 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 RazorPageExecutionInstrumentationWebSite -{ - public class InstrumentationData - { - public InstrumentationData(string filePath, int position, int length, bool isLiteral) - { - FilePath = filePath; - Position = position; - Length = length; - IsLiteral = isLiteral; - } - - public string FilePath { get; } - - public int Position { get; } - - public int Length { get; } - - public bool IsLiteral { get; } - - public override string ToString() - { - var literal = IsLiteral ? "Literal" : "Non-literal"; - - return $"{FilePath}: {literal} at {Position} contains {Length} characters."; - } - } -} diff --git a/test/WebSites/RazorPageExecutionInstrumentationWebSite/RazorPageDiagnosticListener.cs b/test/WebSites/RazorPageExecutionInstrumentationWebSite/RazorPageDiagnosticListener.cs new file mode 100644 index 0000000000..b441d09411 --- /dev/null +++ b/test/WebSites/RazorPageExecutionInstrumentationWebSite/RazorPageDiagnosticListener.cs @@ -0,0 +1,29 @@ +// 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.IO; +using Microsoft.AspNet.Http; +using Microsoft.Extensions.DiagnosticAdapter; + +namespace RazorPageExecutionInstrumentationWebSite +{ + public class RazorPageDiagnosticListener + { + public static readonly object WriterKey = new object(); + + [DiagnosticName("Microsoft.AspNet.Mvc.Razor.BeginInstrumentationContext")] + public virtual void OnBeginPageInstrumentationContext( + HttpContext httpContext, + string path, + int position, + int length, + bool isLiteral) + { + var literal = isLiteral ? "Literal" : "Non-literal"; + var text = $"{path}: {literal} at {position} contains {length} characters."; + + var writer = (TextWriter)httpContext.Items[WriterKey]; + writer.WriteLine(text); + } + } +} diff --git a/test/WebSites/RazorPageExecutionInstrumentationWebSite/Startup.cs b/test/WebSites/RazorPageExecutionInstrumentationWebSite/Startup.cs index 8e26a5e9b1..5ef676e8af 100644 --- a/test/WebSites/RazorPageExecutionInstrumentationWebSite/Startup.cs +++ b/test/WebSites/RazorPageExecutionInstrumentationWebSite/Startup.cs @@ -1,13 +1,10 @@ // 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.Threading.Tasks; +using System.Diagnostics; +using System.IO; using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Http; -using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Mvc.Razor.Compilation; -using Microsoft.AspNet.PageExecutionInstrumentation; using Microsoft.Extensions.DependencyInjection; namespace RazorPageExecutionInstrumentationWebSite @@ -22,24 +19,24 @@ namespace RazorPageExecutionInstrumentationWebSite // Add MVC services to the services container. services.AddMvc(); - - // Make instrumentation data available in views. - services.AddScoped(); - services.AddScoped( - provider => provider.GetRequiredService().Holder); } public void Configure(IApplicationBuilder app) { + var listener = new RazorPageDiagnosticListener(); + var diagnosticSource = app.ApplicationServices.GetRequiredService(); + diagnosticSource.SubscribeWithAdapter(listener); + app.UseCultureReplacer(); - // Execute views with instrumentation enabled. - app.Use((HttpContext context, Func next) => + app.Use(async (context, next) => { - var listenerFeature = context.RequestServices.GetRequiredService(); - context.Features.Set(listenerFeature); - - return next(); + using (var writer = new StreamWriter(context.Response.Body)) + { + context.Items[RazorPageDiagnosticListener.WriterKey] = writer; + context.Response.Body = Stream.Null; + await next(); + } }); // Add MVC to the request pipeline diff --git a/test/WebSites/RazorPageExecutionInstrumentationWebSite/TestPageExecutionListenerFeature.cs b/test/WebSites/RazorPageExecutionInstrumentationWebSite/TestPageExecutionListenerFeature.cs deleted file mode 100644 index 4d3d5482f8..0000000000 --- a/test/WebSites/RazorPageExecutionInstrumentationWebSite/TestPageExecutionListenerFeature.cs +++ /dev/null @@ -1,57 +0,0 @@ -// 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.IO; -using Microsoft.AspNet.PageExecutionInstrumentation; - -namespace RazorPageExecutionInstrumentationWebSite -{ - public class TestPageExecutionListenerFeature : IPageExecutionListenerFeature - { - private readonly TestPageExecutionContext _executionContext = new TestPageExecutionContext(); - - public IHoldInstrumentationData Holder => _executionContext; - - public TextWriter DecorateWriter(TextWriter writer) - { - return writer; - } - - public IPageExecutionContext GetContext(string sourceFilePath, TextWriter writer) - { - _executionContext.FilePath = sourceFilePath; - - return _executionContext; - } - - private class TestPageExecutionContext : IHoldInstrumentationData, IPageExecutionContext - { - private readonly List _values = new List(); - private bool _ignoreNewData; - - public string FilePath { get; set; } - - public IEnumerable Values => _values; - - public void IgnoreFurtherData() - { - _ignoreNewData = true; - } - - public void BeginContext(int position, int length, bool isLiteral) - { - if (_ignoreNewData) - { - return; - } - - _values.Add(new InstrumentationData(FilePath, position, length, isLiteral)); - } - - public void EndContext() - { - } - } - } -} \ No newline at end of file diff --git a/test/WebSites/RazorPageExecutionInstrumentationWebSite/Views/_Layout.cshtml b/test/WebSites/RazorPageExecutionInstrumentationWebSite/Views/_Layout.cshtml index 9fd7ce212b..23e469ccc9 100644 --- a/test/WebSites/RazorPageExecutionInstrumentationWebSite/Views/_Layout.cshtml +++ b/test/WebSites/RazorPageExecutionInstrumentationWebSite/Views/_Layout.cshtml @@ -1,12 +1,4 @@ -@inject RazorPageExecutionInstrumentationWebSite.IHoldInstrumentationData Holder -
+
@int.MaxValue @RenderBody()
-@{ - Holder.IgnoreFurtherData(); - foreach (var data in Holder.Values) - { -

@data.ToString()

- } -} \ No newline at end of file diff --git a/test/WebSites/RazorPageExecutionInstrumentationWebSite/project.json b/test/WebSites/RazorPageExecutionInstrumentationWebSite/project.json index 14c1cb9408..aef9eb01eb 100644 --- a/test/WebSites/RazorPageExecutionInstrumentationWebSite/project.json +++ b/test/WebSites/RazorPageExecutionInstrumentationWebSite/project.json @@ -1,18 +1,19 @@ { - "commands": { - "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001", - "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5000" - }, - "dependencies": { - "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", - "Microsoft.AspNet.Mvc": "6.0.0-*", - "Microsoft.AspNet.Mvc.TestConfiguration": "1.0.0", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*", - "Microsoft.AspNet.StaticFiles": "1.0.0-*" - }, - "frameworks": { - "dnx451": { }, - "dnxcore50": { } - }, - "webroot": "wwwroot" + "commands": { + "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001", + "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5000" + }, + "dependencies": { + "Microsoft.AspNet.Mvc": "6.0.0-*", + "Microsoft.AspNet.Mvc.TestConfiguration": "1.0.0", + "Microsoft.AspNet.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNet.Server.WebListener": "1.0.0-*", + "Microsoft.AspNet.StaticFiles": "1.0.0-*", + "Microsoft.Extensions.DiagnosticAdapter": "1.0.0-*" + }, + "frameworks": { + "dnx451": { }, + "dnxcore50": { } + }, + "webroot": "wwwroot" }