parent
bc49a82d02
commit
1aea6fd5bd
13
Mvc.sln
13
Mvc.sln
|
|
@ -51,8 +51,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TagHelpersWebSite", "test\W
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FilesWebSite", "test\WebSites\FilesWebSite\FilesWebSite.csproj", "{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPageExecutionInstrumentationWebSite", "test\WebSites\RazorPageExecutionInstrumentationWebSite\RazorPageExecutionInstrumentationWebSite.csproj", "{2B2B9876-903C-4065-8D62-2EE832BBA106}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationModelWebSite", "test\WebSites\ApplicationModelWebSite\ApplicationModelWebSite.csproj", "{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.WebApiCompatShim", "src\Microsoft.AspNetCore.Mvc.WebApiCompatShim\Microsoft.AspNetCore.Mvc.WebApiCompatShim.csproj", "{23D30B8C-04B1-4577-A604-ED27EA1E4A0E}"
|
||||
|
|
@ -334,16 +332,6 @@ Global
|
|||
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{2B2B9876-903C-4065-8D62-2EE832BBA106}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
|
|
@ -941,7 +929,6 @@ Global
|
|||
{C6304029-78C8-4604-99BE-2078DCA1DD36} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{6DB9B8D0-80F7-4E70-BBB0-0B4C04D79A47} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{0EF9860B-10D7-452F-B0F4-A405B88BEBB3} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{2B2B9876-903C-4065-8D62-2EE832BBA106} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{23D30B8C-04B1-4577-A604-ED27EA1E4A0E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{B2B7BC91-688E-4C1E-A71F-CE948D958DDF} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@
|
|||
<ProjectReference Include="..\WebSites\FormatterWebSite\FormatterWebSite.csproj" />
|
||||
<ProjectReference Include="..\WebSites\HtmlGenerationWebSite\HtmlGenerationWebSite.csproj" />
|
||||
<ProjectReference Include="..\WebSites\RazorBuildWebSite\RazorBuildWebSite.csproj" />
|
||||
<ProjectReference Include="..\WebSites\RazorPageExecutionInstrumentationWebSite\RazorPageExecutionInstrumentationWebSite.csproj" />
|
||||
<ProjectReference Include="..\WebSites\RazorPagesWebSite\RazorPagesWebSite.csproj" />
|
||||
<ProjectReference Include="..\WebSites\RazorWebSite\RazorWebSite.csproj" />
|
||||
<ProjectReference Include="..\WebSites\RoutingWebSite\RoutingWebSite.csproj" />
|
||||
|
|
|
|||
|
|
@ -1,43 +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.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using RazorPageExecutionInstrumentationWebSite;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
||||
{
|
||||
public class RazorPageExecutionInstrumentationTest : IClassFixture<MvcTestFixture<Startup>>
|
||||
{
|
||||
private static readonly Assembly _resourcesAssembly =
|
||||
typeof(RazorPageExecutionInstrumentationTest).GetTypeInfo().Assembly;
|
||||
|
||||
public RazorPageExecutionInstrumentationTest(MvcTestFixture<Startup> fixture)
|
||||
{
|
||||
Client = fixture.CreateDefaultClient();
|
||||
}
|
||||
|
||||
public HttpClient Client { get; }
|
||||
|
||||
[Fact]
|
||||
public async Task InstrumentedViews_RenderAsExpected()
|
||||
{
|
||||
// Arrange
|
||||
var outputFile = "compiler/resources/RazorPageExecutionInstrumentationWebSite.Home.ViewWithPartial.html";
|
||||
var expectedContent =
|
||||
await ResourceFile.ReadResourceAsync(_resourcesAssembly, outputFile, sourceFile: false);
|
||||
|
||||
// Act
|
||||
var content = await Client.GetStringAsync("http://localhost/Home/ViewWithPartial");
|
||||
|
||||
// Assert
|
||||
#if GENERATE_BASELINES
|
||||
ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, content);
|
||||
#else
|
||||
Assert.Equal(expectedContent, content, ignoreLineEndingDifferences: true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
/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.
|
||||
|
|
@ -1,15 +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 Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace RazorPageExecutionInstrumentationWebSite
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public ActionResult ViewWithPartial()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +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 Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DiagnosticAdapter;
|
||||
|
||||
namespace RazorPageExecutionInstrumentationWebSite
|
||||
{
|
||||
public class RazorPageDiagnosticListener
|
||||
{
|
||||
public static readonly object WriterKey = new object();
|
||||
|
||||
[DiagnosticName("Microsoft.AspNetCore.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>$(StandardTestWebsiteTfms)</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc\Microsoft.AspNetCore.Mvc.csproj" />
|
||||
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="$(MicrosoftAspNetCoreServerIISIntegrationPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(MicrosoftAspNetCoreServerKestrelPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(MicrosoftAspNetCoreStaticFilesPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="$(MicrosoftExtensionsDiagnosticAdapterPackageVersion)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,61 +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.Diagnostics;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace RazorPageExecutionInstrumentationWebSite
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
// Set up application services
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Normalize line endings to avoid changes in instrumentation locations between systems.
|
||||
services.AddTransient<RazorProjectFileSystem, TestRazorProjectFileSystem>();
|
||||
|
||||
// Add MVC services to the services container.
|
||||
services.AddMvc();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
var listener = new RazorPageDiagnosticListener();
|
||||
var diagnosticSource = app.ApplicationServices.GetRequiredService<DiagnosticListener>();
|
||||
diagnosticSource.SubscribeWithAdapter(listener);
|
||||
|
||||
app.Use(async (context, 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
|
||||
app.UseMvcWithDefaultRoute();
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var host = CreateWebHostBuilder(args)
|
||||
.Build();
|
||||
|
||||
host.Run();
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
new WebHostBuilder()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseStartup<Startup>()
|
||||
.UseKestrel()
|
||||
.UseIISIntegration();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,48 +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.Text;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc.Razor.Internal;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace RazorPageExecutionInstrumentationWebSite
|
||||
{
|
||||
public class TestRazorProjectFileSystem : FileProviderRazorProjectFileSystem
|
||||
{
|
||||
public TestRazorProjectFileSystem(IRazorViewEngineFileProviderAccessor fileProviderAccessor, IHostingEnvironment hostingEnvironment)
|
||||
: base(fileProviderAccessor, hostingEnvironment)
|
||||
{
|
||||
}
|
||||
|
||||
public override RazorProjectItem GetItem(string path)
|
||||
{
|
||||
var item = (FileProviderRazorProjectItem)base.GetItem(path);
|
||||
return new TestRazorProjectItem(item);
|
||||
}
|
||||
|
||||
private class TestRazorProjectItem : FileProviderRazorProjectItem
|
||||
{
|
||||
public TestRazorProjectItem(FileProviderRazorProjectItem projectItem)
|
||||
: base(projectItem.FileInfo, projectItem.BasePath, projectItem.FilePath, projectItem.RelativePhysicalPath)
|
||||
{
|
||||
}
|
||||
|
||||
public override Stream Read()
|
||||
{
|
||||
// Normalize line endings to '\r\n' (CRLF). This removes core.autocrlf, core.eol, core.safecrlf, and
|
||||
// .gitattributes from the equation and treats "\r\n" and "\n" as equivalent. Does not handle
|
||||
// some line endings like "\r" but otherwise ensures checksums and line mappings are consistent.
|
||||
string text;
|
||||
using (var streamReader = new StreamReader(base.Read()))
|
||||
{
|
||||
text = streamReader.ReadToEnd().Replace("\r", "").Replace("\n", "\r\n");
|
||||
}
|
||||
|
||||
var bytes = Encoding.UTF8.GetBytes(text);
|
||||
return new MemoryStream(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
view-with-partial-content
|
||||
@await Html.PartialAsync("_PartialView")
|
||||
@{
|
||||
await Html.RenderPartialAsync("_PartialView");
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
@{
|
||||
var cls = "class";
|
||||
}
|
||||
<p class="@cls">partial-content</p>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<div>
|
||||
@int.MaxValue
|
||||
@RenderBody()
|
||||
</div>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
@{
|
||||
Layout = "/Views/_Layout.cshtml";
|
||||
var viewStartMessage = "viewstart-content";
|
||||
}
|
||||
@viewStartMessage
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
RazorPageExecutionInstrumentationWebSite
|
||||
===
|
||||
|
||||
This web site is used for functional testing of page instrumentation.
|
||||
Loading…
Reference in New Issue