From 86d045c667da181e6130aa5aca4aef0f067e2446 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 12 May 2017 15:44:49 -0700 Subject: [PATCH] Fix #1305 move instrumentation to MVC --- .../InstrumentationPass.cs} | 5 ++-- .../RazorExtensions.cs | 2 +- .../InstrumentationPassTest.cs} | 27 ++++++++++--------- .../InstrumentationPassIntegrationTest.cs | 6 +++-- .../BasicTest.codegen.cs | 0 .../BasicTest.cshtml | 0 .../BasicTest.ir.txt | 0 .../Langauge}/Intermediate/RazorIRAssert.cs | 0 .../Properties/AssemblyInfo.cs | 9 +++++++ 9 files changed, 31 insertions(+), 18 deletions(-) rename src/{Microsoft.AspNetCore.Razor.Language/DefaultInstrumentationPass.cs => Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs} (96%) rename test/{Microsoft.AspNetCore.Razor.Language.Test/DefaultInstrumentationPassTest.cs => Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs} (92%) rename test/{Microsoft.AspNetCore.Razor.Language.Test => Microsoft.AspNetCore.Mvc.Razor.Extensions.Test}/IntegrationTests/InstrumentationPassIntegrationTest.cs (92%) rename test/{Microsoft.AspNetCore.Razor.Language.Test => Microsoft.AspNetCore.Mvc.Razor.Extensions.Test}/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs (100%) rename test/{Microsoft.AspNetCore.Razor.Language.Test => Microsoft.AspNetCore.Mvc.Razor.Extensions.Test}/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml (100%) rename test/{Microsoft.AspNetCore.Razor.Language.Test => Microsoft.AspNetCore.Mvc.Razor.Extensions.Test}/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt (100%) rename test/{Microsoft.AspNetCore.Razor.Language.Test => Microsoft.AspNetCore.Razor.Test.Common/Langauge}/Intermediate/RazorIRAssert.cs (100%) create mode 100644 test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultInstrumentationPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs similarity index 96% rename from src/Microsoft.AspNetCore.Razor.Language/DefaultInstrumentationPass.cs rename to src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs index 730075b312..46cf7197bc 100644 --- a/src/Microsoft.AspNetCore.Razor.Language/DefaultInstrumentationPass.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/InstrumentationPass.cs @@ -3,11 +3,12 @@ using System.Collections.Generic; using System.Globalization; +using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; -namespace Microsoft.AspNetCore.Razor.Language +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { - public class DefaultInstrumentationPass : RazorIRPassBase, IRazorIROptimizationPass + public class InstrumentationPass : RazorIRPassBase, IRazorIROptimizationPass { public override int Order => DefaultFeatureOrder; diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs index 03bea5e656..548206a42b 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorExtensions.cs @@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions if (!builder.DesignTime) { - builder.Features.Add(new DefaultInstrumentationPass()); + builder.Features.Add(new InstrumentationPass()); } } } diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultInstrumentationPassTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs similarity index 92% rename from test/Microsoft.AspNetCore.Razor.Language.Test/DefaultInstrumentationPassTest.cs rename to test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs index 025afbabc1..4c7948f884 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/DefaultInstrumentationPassTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/InstrumentationPassTest.cs @@ -1,13 +1,14 @@ // 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.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; using Xunit; using static Microsoft.AspNetCore.Razor.Language.Intermediate.RazorIRAssert; -namespace Microsoft.AspNetCore.Razor.Language +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions { - public class DefaultInstrumentationPassTest + public class InstrumentationPassTest { [Fact] public void InstrumentationPass_InstrumentsHtml() @@ -28,7 +29,7 @@ namespace Microsoft.AspNetCore.Razor.Language var irDocument = (DocumentIRNode)builder.Build(); - var pass = new DefaultInstrumentationPass(); + var pass = new InstrumentationPass(); // Act pass.ExecuteCore(TestRazorCodeDocument.CreateEmpty(), irDocument); @@ -37,7 +38,7 @@ namespace Microsoft.AspNetCore.Razor.Language Children( irDocument, n => BeginInstrumentation("1, 1, true", n), - n => Html("Hi", n), + n => RazorIRAssert.Html("Hi", n), n => EndInstrumentation(n)); } @@ -56,7 +57,7 @@ namespace Microsoft.AspNetCore.Razor.Language var irDocument = (DocumentIRNode)builder.Build(); - var pass = new DefaultInstrumentationPass(); + var pass = new InstrumentationPass(); // Act pass.ExecuteCore(TestRazorCodeDocument.CreateEmpty(), irDocument); @@ -64,7 +65,7 @@ namespace Microsoft.AspNetCore.Razor.Language // Assert Children( irDocument, - n => Html("Hi", n)); + n => RazorIRAssert.Html("Hi", n)); } [Fact] @@ -84,7 +85,7 @@ namespace Microsoft.AspNetCore.Razor.Language var irDocument = (DocumentIRNode)builder.Build(); - var pass = new DefaultInstrumentationPass(); + var pass = new InstrumentationPass(); // Act pass.ExecuteCore(TestRazorCodeDocument.CreateEmpty(), irDocument); @@ -111,7 +112,7 @@ namespace Microsoft.AspNetCore.Razor.Language var irDocument = (DocumentIRNode)builder.Build(); - var pass = new DefaultInstrumentationPass(); + var pass = new InstrumentationPass(); // Act pass.ExecuteCore(TestRazorCodeDocument.CreateEmpty(), irDocument); @@ -147,7 +148,7 @@ namespace Microsoft.AspNetCore.Razor.Language var irDocument = (DocumentIRNode)builder.Build(); - var pass = new DefaultInstrumentationPass(); + var pass = new InstrumentationPass(); // Act pass.ExecuteCore(TestRazorCodeDocument.CreateEmpty(), irDocument); @@ -195,7 +196,7 @@ namespace Microsoft.AspNetCore.Razor.Language var irDocument = (DocumentIRNode)builder.Build(); - var pass = new DefaultInstrumentationPass(); + var pass = new InstrumentationPass(); // Act pass.ExecuteCore(TestRazorCodeDocument.CreateEmpty(), irDocument); @@ -232,7 +233,7 @@ namespace Microsoft.AspNetCore.Razor.Language var irDocument = (DocumentIRNode)builder.Build(); - var pass = new DefaultInstrumentationPass(); + var pass = new InstrumentationPass(); // Act pass.ExecuteCore(TestRazorCodeDocument.CreateEmpty(), irDocument); @@ -262,7 +263,7 @@ namespace Microsoft.AspNetCore.Razor.Language var irDocument = (DocumentIRNode)builder.Build(); - var pass = new DefaultInstrumentationPass(); + var pass = new InstrumentationPass(); // Act pass.ExecuteCore(TestRazorCodeDocument.CreateEmpty(), irDocument); @@ -293,7 +294,7 @@ namespace Microsoft.AspNetCore.Razor.Language var irDocument = (DocumentIRNode)builder.Build(); - var pass = new DefaultInstrumentationPass(); + var pass = new InstrumentationPass(); // Act pass.ExecuteCore(TestRazorCodeDocument.CreateEmpty(), irDocument); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/InstrumentationPassIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/IntegrationTests/InstrumentationPassIntegrationTest.cs similarity index 92% rename from test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/InstrumentationPassIntegrationTest.cs rename to test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/IntegrationTests/InstrumentationPassIntegrationTest.cs index 5c6605caa3..2c9425c8a3 100644 --- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/InstrumentationPassIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/IntegrationTests/InstrumentationPassIntegrationTest.cs @@ -3,9 +3,11 @@ using System; using System.Collections.Generic; +using Microsoft.AspNetCore.Razor.Language; +using Microsoft.AspNetCore.Razor.Language.IntegrationTests; using Xunit; -namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests +namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.IntegrationTests { public class InstrumentationPassIntegrationTest : IntegrationTestBase { @@ -43,7 +45,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests var engine = RazorEngine.Create(b => { b.AddTagHelpers(descriptors); - b.Features.Add(new DefaultInstrumentationPass()); + b.Features.Add(new InstrumentationPass()); }); var document = CreateCodeDocument(); diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs rename to test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.codegen.cs diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml rename to test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.cshtml diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt rename to test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/TestFiles/IntegrationTests/InstrumentationPassIntegrationTest/BasicTest.ir.txt diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/RazorIRAssert.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Langauge/Intermediate/RazorIRAssert.cs similarity index 100% rename from test/Microsoft.AspNetCore.Razor.Language.Test/Intermediate/RazorIRAssert.cs rename to test/Microsoft.AspNetCore.Razor.Test.Common/Langauge/Intermediate/RazorIRAssert.cs diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..dd401143f5 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// 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.Runtime.CompilerServices; +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Language.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]